Fantasia sqlite main

From vishiri/fantasia-archive · View interactive version

Fantasia sqlite main is an AI agent skill from the GitHub repository vishiri/fantasia-archive. Designs SQLite usage in Fantasia Archive’s Electron main process: file locations under userData, native better-sqlite3 module constraints, and migrations. Use when editing electron-main database code, schema, or persistence paths.

How to use this skill

Skill file

Fantasia Archive — SQLite in main process

Canonical schema documentation

Schema/IPC changes → update docs same commit (docs-database.mdc).

Current state

Principles

  1. No arbitrary SQL from renderer — narrow validated preload APIs + IPC (fantasia-electron-preload)
  2. Paths: app.getPath('userData'); mkdir before open
  3. Native builds: verify yarn quasar:build:electron after upgrades
  4. Lifecycle: deliberate open/close; no leaked handles on dev reload

Active project DB access (mandatory failsafe)

All active .faproject reads/writes → runWithFaProjectDatabaseForIpcAsync / runWithFaProjectDatabaseSync from faProjectDatabaseEnsureConnected.ts. ESLint restricts direct getFaProjectActiveDatabase imports (fa-project-database-access.mdc).

Project settings refresh contract (renderer)

Unlike App Settings (Pinia seed on open), Project Settings always reads SQLite on open:

  1. Open: getProjectSettings + listWorldsForProjectSettings
  2. Edit: local draft until Save
  3. Save: saveProjectSettings → KV patch + optional saveWorldsSnapshot
  4. Errors: throw → action manager toast
  5. Main: runWithFaProjectDatabaseForIpcAsync only

Extend propagateFaProjectSettingsToAppConsumers when new fields need live UI after save. See projectDB.md Project Settings (renderer ↔ SQLite).

New project-DB IPC → ensure layer + tests under projectManagement/_tests/.

Evolution

Types

Shared types → types/. See types-folder.mdc.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.