diff options
| author | Clawd <ai@clawd.bot> | 2026-02-28 07:26:43 -0800 |
|---|---|---|
| committer | Clawd <ai@clawd.bot> | 2026-02-28 07:26:43 -0800 |
| commit | 332e5cec2992fefb302251962a3ceca38437a110 (patch) | |
| tree | 7802469abb929e741ccbecd989828f1baf37145f /src/main/db/index.ts | |
| parent | d2d6fd48d97b876c9a9a424c9d2cc1de5352b144 (diff) | |
Phase 2: Claude integration layer
- Add @anthropic-ai/claude-agent-sdk dependency
- Implement src/main/claude/phases.ts with phase configs (research/plan/implement)
- Implement src/main/claude/index.ts with SDK wrapper
- query() integration with session management
- Session resume support
- Artifact read/write utilities
- Phase advancement logic
Diffstat (limited to 'src/main/db/index.ts')
| -rw-r--r-- | src/main/db/index.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/db/index.ts b/src/main/db/index.ts new file mode 100644 index 0000000..a77cdd4 --- /dev/null +++ b/src/main/db/index.ts | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | import Database from "better-sqlite3"; | ||
| 2 | import { app } from "electron"; | ||
| 3 | import path from "node:path"; | ||
| 4 | import fs from "node:fs"; | ||
| 5 | import { initSchema } from "./schema"; | ||
| 6 | |||
| 7 | let db: Database.Database | null = null; | ||
| 8 | |||
| 9 | export function getDb(): Database.Database { | ||
| 10 | if (db) return db; | ||
| 11 | |||
| 12 | const dbDir = app.getPath("userData"); | ||
| 13 | if (!fs.existsSync(dbDir)) { | ||
| 14 | fs.mkdirSync(dbDir, { recursive: true }); | ||
| 15 | } | ||
| 16 | |||
| 17 | const dbPath = path.join(dbDir, "claude-flow.db"); | ||
| 18 | db = new Database(dbPath); | ||
| 19 | db.pragma("journal_mode = WAL"); | ||
| 20 | db.pragma("foreign_keys = ON"); | ||
| 21 | |||
| 22 | initSchema(db); | ||
| 23 | return db; | ||
| 24 | } | ||
| 25 | |||
| 26 | export function closeDb() { | ||
| 27 | if (db) { | ||
| 28 | db.close(); | ||
| 29 | db = null; | ||
| 30 | } | ||
| 31 | } | ||
