@kkvcrobatz107/codegraph 0.9.6-pkm.2 → 0.9.6-pkm.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,9 @@
1
1
  /**
2
2
  * SQLite Adapter
3
3
  *
4
- * Thin wrapper over Node's built-in `node:sqlite` (`DatabaseSync`), exposed
5
- * through a small better-sqlite3-shaped interface so the rest of the codebase
6
- * is storage-agnostic.
7
- *
8
- * CodeGraph ships with a bundled Node runtime, so `node:sqlite` (real SQLite,
9
- * with WAL + FTS5) is always available — there is no native build step and no
10
- * wasm fallback. When run from source instead, it requires Node >= 22.5.
4
+ * Uses better-sqlite3 (native, always compiled with FTS5, WAL, mmap).
5
+ * better-sqlite3 ships prebuilt binaries for Node 22 Windows x64 — no
6
+ * compile step needed for the supported platform.
11
7
  */
12
8
  export interface SqliteStatement {
13
9
  run(...params: any[]): {
@@ -27,18 +23,7 @@ export interface SqliteDatabase {
27
23
  close(): void;
28
24
  readonly open: boolean;
29
25
  }
30
- /**
31
- * The active SQLite backend. Only one now (`node:sqlite`); kept as a named type
32
- * so `codegraph status` and the per-instance reporting have a stable shape.
33
- */
34
- export type SqliteBackend = 'node-sqlite';
35
- /**
36
- * Create a database connection backed by `node:sqlite`.
37
- *
38
- * Returns the active backend alongside the db so each `DatabaseConnection` can
39
- * report it per-instance — MCP can open multiple project DBs in one process, so
40
- * a process-global would race.
41
- */
26
+ export type SqliteBackend = 'better-sqlite3';
42
27
  export declare function createDatabase(dbPath: string): {
43
28
  db: SqliteDatabase;
44
29
  backend: SqliteBackend;
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite-adapter.d.ts","sourceRoot":"","sources":["../../src/db/sqlite-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;Q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AC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC;IACtC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,GAAG,CAAC;IACzD,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACjE,KAAK,IAAI,IAAI,CAAC;IACd,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAE7C,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,CAG7F"}
@@ -2,113 +2,19 @@
2
2
  /**
3
3
  * SQLite Adapter
4
4
  *
5
- * Thin wrapper over Node's built-in `node:sqlite` (`DatabaseSync`), exposed
6
- * through a small better-sqlite3-shaped interface so the rest of the codebase
7
- * is storage-agnostic.
8
- *
9
- * CodeGraph ships with a bundled Node runtime, so `node:sqlite` (real SQLite,
10
- * with WAL + FTS5) is always available — there is no native build step and no
11
- * wasm fallback. When run from source instead, it requires Node >= 22.5.
5
+ * Uses better-sqlite3 (native, always compiled with FTS5, WAL, mmap).
6
+ * better-sqlite3 ships prebuilt binaries for Node 22 Windows x64 — no
7
+ * compile step needed for the supported platform.
12
8
  */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
13
12
  Object.defineProperty(exports, "__esModule", { value: true });
14
13
  exports.createDatabase = createDatabase;
15
- /**
16
- * Wraps Node's built-in `node:sqlite` (`DatabaseSync`) to match the
17
- * better-sqlite3 interface the rest of the code expects.
18
- *
19
- * node:sqlite is real SQLite compiled into Node, so it supports WAL, FTS5,
20
- * mmap, and `@named` params natively — the only shims needed are the
21
- * better-sqlite3 conveniences node:sqlite omits: a `.pragma()` helper, a
22
- * `.transaction()` helper, and `open` (node:sqlite exposes `isOpen`).
23
- */
24
- class NodeSqliteAdapter {
25
- _db;
26
- constructor(dbPath) {
27
- // eslint-disable-next-line @typescript-eslint/no-require-imports
28
- const { DatabaseSync } = require('node:sqlite');
29
- this._db = new DatabaseSync(dbPath);
30
- }
31
- get open() {
32
- return this._db.isOpen;
33
- }
34
- prepare(sql) {
35
- // node:sqlite matches better-sqlite3's calling convention (variadic
36
- // positional args, or a single object for @named params), so params forward
37
- // through unchanged.
38
- const stmt = this._db.prepare(sql);
39
- return {
40
- run(...params) {
41
- const r = stmt.run(...params);
42
- return {
43
- changes: Number(r?.changes ?? 0),
44
- lastInsertRowid: r?.lastInsertRowid ?? 0,
45
- };
46
- },
47
- get(...params) {
48
- return stmt.get(...params);
49
- },
50
- all(...params) {
51
- return stmt.all(...params);
52
- },
53
- };
54
- }
55
- exec(sql) {
56
- this._db.exec(sql);
57
- }
58
- pragma(str, options) {
59
- const trimmed = str.trim();
60
- // Write pragma ("key = value"): node:sqlite is real SQLite, so every pragma
61
- // (WAL, mmap, synchronous, …) applies as-is.
62
- if (trimmed.includes('=')) {
63
- this._db.exec(`PRAGMA ${trimmed}`);
64
- return;
65
- }
66
- // Read pragma. Default: the row object (e.g. { journal_mode: 'wal' }).
67
- // `{ simple: true }` returns just the single column value, like better-sqlite3.
68
- const row = this._db.prepare(`PRAGMA ${trimmed}`).get();
69
- if (options?.simple) {
70
- return row && typeof row === 'object' ? Object.values(row)[0] : row;
71
- }
72
- return row;
73
- }
74
- transaction(fn) {
75
- return (...args) => {
76
- this._db.exec('BEGIN');
77
- try {
78
- const result = fn(...args);
79
- this._db.exec('COMMIT');
80
- return result;
81
- }
82
- catch (error) {
83
- this._db.exec('ROLLBACK');
84
- throw error;
85
- }
86
- };
87
- }
88
- close() {
89
- // node:sqlite's DatabaseSync.close() throws if already closed; make it
90
- // idempotent to match better-sqlite3 (callers may close more than once).
91
- if (this._db.isOpen)
92
- this._db.close();
93
- }
94
- }
95
- /**
96
- * Create a database connection backed by `node:sqlite`.
97
- *
98
- * Returns the active backend alongside the db so each `DatabaseConnection` can
99
- * report it per-instance — MCP can open multiple project DBs in one process, so
100
- * a process-global would race.
101
- */
14
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
15
+ const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
102
16
  function createDatabase(dbPath) {
103
- try {
104
- return { db: new NodeSqliteAdapter(dbPath), backend: 'node-sqlite' };
105
- }
106
- catch (error) {
107
- const msg = error instanceof Error ? error.message : String(error);
108
- throw new Error('Failed to open SQLite via the built-in node:sqlite module.\n' +
109
- 'CodeGraph requires node:sqlite (Node.js 22.5+). Install the self-contained\n' +
110
- 'CodeGraph release (it bundles a compatible Node), or run on Node 22.5+.\n' +
111
- `Underlying error: ${msg}`);
112
- }
17
+ const db = new better_sqlite3_1.default(dbPath);
18
+ return { db: db, backend: 'better-sqlite3' };
113
19
  }
114
20
  //# sourceMappingURL=sqlite-adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite-adapter.js","sourceRoot":"","sources":["../../src/db/sqlite-adapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAoHH,wCAYC;AAzGD;;;;;;;;GAQG;AACH,MAAM,iBAAiB;IACb,GAAG,CAAM;IAEjB,YAAY,MAAc;QACxB,iEAAiE;QACjE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;QAChD,IAAI,CAAC,GAAG,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,IAA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AC3E,qBAAqB,GAAG,EAAE,CAC3B,CAAC;IACJ,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"sqlite-adapter.js","sourceRoot":"","sources":["../../src/db/sqlite-adapter.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAsBH,wCAGC;AAvBD,iEAAiE;AACjE,oEAAsC;AAmBtC,SAAgB,cAAc,CAAC,MAAc;IAC3C,MAAM,EAAE,GAAG,IAAI,wBAAQ,CAAC,MAAM,CAAQ,CAAC;IACvC,OAAO,EAAE,EAAE,EAAE,EAAoB,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AACjE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kkvcrobatz107/codegraph",
3
- "version": "0.9.6-pkm.2",
3
+ "version": "0.9.6-pkm.4",
4
4
  "description": "AgentPKM fork of @colbymchenry/codegraph — output path patched to knowledge/codegraph/ (upstream: https://github.com/colbymchenry/codegraph, MIT).",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,6 +32,7 @@
32
32
  "author": "",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
+ "better-sqlite3": "^11.9.0",
35
36
  "@clack/prompts": "^1.3.0",
36
37
  "chokidar": "^4.0.3",
37
38
  "commander": "^14.0.2",