@stupidloud/codegraph 0.8.1 → 0.9.9
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.
- package/README.md +319 -152
- package/dist/bin/codegraph.d.ts +4 -0
- package/dist/bin/codegraph.d.ts.map +1 -1
- package/dist/bin/codegraph.js +354 -90
- package/dist/bin/codegraph.js.map +1 -1
- package/dist/bin/node-version-check.d.ts +17 -0
- package/dist/bin/node-version-check.d.ts.map +1 -1
- package/dist/bin/node-version-check.js +37 -0
- package/dist/bin/node-version-check.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -11
- package/dist/config.js.map +1 -1
- package/dist/context/formatter.d.ts.map +1 -1
- package/dist/context/formatter.js +25 -6
- package/dist/context/formatter.js.map +1 -1
- package/dist/context/index.d.ts +22 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +257 -6
- package/dist/context/index.js.map +1 -1
- package/dist/context/markers.d.ts +19 -0
- package/dist/context/markers.d.ts.map +1 -0
- package/dist/context/markers.js +22 -0
- package/dist/context/markers.js.map +1 -0
- package/dist/db/index.d.ts +30 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +75 -25
- package/dist/db/index.js.map +1 -1
- package/dist/db/queries.d.ts +104 -0
- package/dist/db/queries.d.ts.map +1 -1
- package/dist/db/queries.js +328 -31
- package/dist/db/queries.js.map +1 -1
- package/dist/db/sqlite-adapter.d.ts +24 -23
- package/dist/db/sqlite-adapter.d.ts.map +1 -1
- package/dist/db/sqlite-adapter.js +54 -174
- package/dist/db/sqlite-adapter.js.map +1 -1
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +6 -20
- package/dist/directory.js.map +1 -1
- package/dist/extraction/generated-detection.d.ts +30 -0
- package/dist/extraction/generated-detection.d.ts.map +1 -0
- package/dist/extraction/generated-detection.js +80 -0
- package/dist/extraction/generated-detection.js.map +1 -0
- package/dist/extraction/grammars.d.ts +23 -1
- package/dist/extraction/grammars.d.ts.map +1 -1
- package/dist/extraction/grammars.js +107 -3
- package/dist/extraction/grammars.js.map +1 -1
- package/dist/extraction/index.d.ts +22 -14
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +272 -183
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/dist/extraction/languages/c-cpp.js +45 -0
- package/dist/extraction/languages/c-cpp.js.map +1 -1
- package/dist/extraction/languages/csharp.d.ts.map +1 -1
- package/dist/extraction/languages/csharp.js +2 -1
- package/dist/extraction/languages/csharp.js.map +1 -1
- package/dist/extraction/languages/go.d.ts.map +1 -1
- package/dist/extraction/languages/go.js +18 -2
- package/dist/extraction/languages/go.js.map +1 -1
- package/dist/extraction/languages/index.d.ts.map +1 -1
- package/dist/extraction/languages/index.js +6 -0
- package/dist/extraction/languages/index.js.map +1 -1
- package/dist/extraction/languages/java.d.ts.map +1 -1
- package/dist/extraction/languages/java.js +6 -0
- package/dist/extraction/languages/java.js.map +1 -1
- package/dist/extraction/languages/kotlin.d.ts.map +1 -1
- package/dist/extraction/languages/kotlin.js +6 -0
- package/dist/extraction/languages/kotlin.js.map +1 -1
- package/dist/extraction/languages/lua.d.ts +3 -0
- package/dist/extraction/languages/lua.d.ts.map +1 -0
- package/dist/extraction/languages/lua.js +150 -0
- package/dist/extraction/languages/lua.js.map +1 -0
- package/dist/extraction/languages/luau.d.ts +3 -0
- package/dist/extraction/languages/luau.d.ts.map +1 -0
- package/dist/extraction/languages/luau.js +37 -0
- package/dist/extraction/languages/luau.js.map +1 -0
- package/dist/extraction/languages/objc.d.ts +3 -0
- package/dist/extraction/languages/objc.d.ts.map +1 -0
- package/dist/extraction/languages/objc.js +133 -0
- package/dist/extraction/languages/objc.js.map +1 -0
- package/dist/extraction/mybatis-extractor.d.ts +48 -0
- package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
- package/dist/extraction/mybatis-extractor.js +198 -0
- package/dist/extraction/mybatis-extractor.js.map +1 -0
- package/dist/extraction/tree-sitter-types.d.ts +14 -0
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.d.ts +84 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.js +715 -16
- package/dist/extraction/tree-sitter.js.map +1 -1
- package/dist/extraction/vue-extractor.d.ts +15 -0
- package/dist/extraction/vue-extractor.d.ts.map +1 -1
- package/dist/extraction/vue-extractor.js +88 -0
- package/dist/extraction/vue-extractor.js.map +1 -1
- package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
- package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
- package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
- package/dist/extraction/wasm-runtime-flags.js +106 -0
- package/dist/extraction/wasm-runtime-flags.js.map +1 -0
- package/dist/graph/traversal.d.ts.map +1 -1
- package/dist/graph/traversal.js +76 -38
- package/dist/graph/traversal.js.map +1 -1
- package/dist/index.d.ts +77 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +133 -19
- package/dist/index.js.map +1 -1
- package/dist/installer/config-writer.d.ts +7 -8
- package/dist/installer/config-writer.d.ts.map +1 -1
- package/dist/installer/config-writer.js +7 -27
- package/dist/installer/config-writer.js.map +1 -1
- package/dist/installer/index.d.ts +51 -16
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +120 -29
- package/dist/installer/index.js.map +1 -1
- package/dist/installer/instructions-template.d.ts +11 -21
- package/dist/installer/instructions-template.d.ts.map +1 -1
- package/dist/installer/instructions-template.js +12 -56
- package/dist/installer/instructions-template.js.map +1 -1
- package/dist/installer/targets/antigravity.d.ts +57 -0
- package/dist/installer/targets/antigravity.d.ts.map +1 -0
- package/dist/installer/targets/antigravity.js +308 -0
- package/dist/installer/targets/antigravity.js.map +1 -0
- package/dist/installer/targets/claude.d.ts +26 -1
- package/dist/installer/targets/claude.d.ts.map +1 -1
- package/dist/installer/targets/claude.js +118 -40
- package/dist/installer/targets/claude.js.map +1 -1
- package/dist/installer/targets/codex.d.ts.map +1 -1
- package/dist/installer/targets/codex.js +15 -13
- package/dist/installer/targets/codex.js.map +1 -1
- package/dist/installer/targets/cursor.d.ts.map +1 -1
- package/dist/installer/targets/cursor.js +61 -36
- package/dist/installer/targets/cursor.js.map +1 -1
- package/dist/installer/targets/gemini.d.ts +26 -0
- package/dist/installer/targets/gemini.d.ts.map +1 -0
- package/dist/installer/targets/gemini.js +167 -0
- package/dist/installer/targets/gemini.js.map +1 -0
- package/dist/installer/targets/hermes.d.ts +18 -0
- package/dist/installer/targets/hermes.d.ts.map +1 -0
- package/dist/installer/targets/hermes.js +359 -0
- package/dist/installer/targets/hermes.js.map +1 -0
- package/dist/installer/targets/kiro.d.ts +27 -0
- package/dist/installer/targets/kiro.d.ts.map +1 -0
- package/dist/installer/targets/kiro.js +178 -0
- package/dist/installer/targets/kiro.js.map +1 -0
- package/dist/installer/targets/opencode.d.ts.map +1 -1
- package/dist/installer/targets/opencode.js +15 -13
- package/dist/installer/targets/opencode.js.map +1 -1
- package/dist/installer/targets/registry.d.ts.map +1 -1
- package/dist/installer/targets/registry.js +8 -0
- package/dist/installer/targets/registry.js.map +1 -1
- package/dist/installer/targets/shared.d.ts.map +1 -1
- package/dist/installer/targets/shared.js +3 -2
- package/dist/installer/targets/shared.js.map +1 -1
- package/dist/installer/targets/types.d.ts +1 -16
- package/dist/installer/targets/types.d.ts.map +1 -1
- package/dist/mcp/daemon-paths.d.ts +46 -0
- package/dist/mcp/daemon-paths.d.ts.map +1 -0
- package/dist/mcp/daemon-paths.js +125 -0
- package/dist/mcp/daemon-paths.js.map +1 -0
- package/dist/mcp/daemon.d.ts +161 -0
- package/dist/mcp/daemon.d.ts.map +1 -0
- package/dist/mcp/daemon.js +403 -0
- package/dist/mcp/daemon.js.map +1 -0
- package/dist/mcp/engine.d.ts +105 -0
- package/dist/mcp/engine.d.ts.map +1 -0
- package/dist/mcp/engine.js +270 -0
- package/dist/mcp/engine.js.map +1 -0
- package/dist/mcp/index.d.ts +70 -52
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +355 -331
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/proxy.d.ts +81 -0
- package/dist/mcp/proxy.d.ts.map +1 -0
- package/dist/mcp/proxy.js +510 -0
- package/dist/mcp/proxy.js.map +1 -0
- package/dist/mcp/server-instructions.d.ts +1 -1
- package/dist/mcp/server-instructions.d.ts.map +1 -1
- package/dist/mcp/server-instructions.js +21 -21
- package/dist/mcp/session.d.ts +77 -0
- package/dist/mcp/session.d.ts.map +1 -0
- package/dist/mcp/session.js +294 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/tools.d.ts +171 -15
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +1714 -298
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/transport.d.ts +111 -29
- package/dist/mcp/transport.d.ts.map +1 -1
- package/dist/mcp/transport.js +181 -71
- package/dist/mcp/transport.js.map +1 -1
- package/dist/mcp/version.d.ts +19 -0
- package/dist/mcp/version.d.ts.map +1 -0
- package/dist/mcp/version.js +71 -0
- package/dist/mcp/version.js.map +1 -0
- package/dist/resolution/callback-synthesizer.d.ts +10 -0
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
- package/dist/resolution/callback-synthesizer.js +1300 -0
- package/dist/resolution/callback-synthesizer.js.map +1 -0
- package/dist/resolution/frameworks/csharp.d.ts.map +1 -1
- package/dist/resolution/frameworks/csharp.js +36 -8
- package/dist/resolution/frameworks/csharp.js.map +1 -1
- package/dist/resolution/frameworks/drupal.d.ts +51 -0
- package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
- package/dist/resolution/frameworks/drupal.js +367 -0
- package/dist/resolution/frameworks/drupal.js.map +1 -0
- package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
- package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
- package/dist/resolution/frameworks/expo-modules.js +143 -0
- package/dist/resolution/frameworks/expo-modules.js.map +1 -0
- package/dist/resolution/frameworks/express.d.ts.map +1 -1
- package/dist/resolution/frameworks/express.js +102 -19
- package/dist/resolution/frameworks/express.js.map +1 -1
- package/dist/resolution/frameworks/fabric.d.ts +3 -0
- package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
- package/dist/resolution/frameworks/fabric.js +354 -0
- package/dist/resolution/frameworks/fabric.js.map +1 -0
- package/dist/resolution/frameworks/go.d.ts.map +1 -1
- package/dist/resolution/frameworks/go.js +6 -3
- package/dist/resolution/frameworks/go.js.map +1 -1
- package/dist/resolution/frameworks/index.d.ts +6 -0
- package/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/dist/resolution/frameworks/index.js +29 -1
- package/dist/resolution/frameworks/index.js.map +1 -1
- package/dist/resolution/frameworks/java.d.ts.map +1 -1
- package/dist/resolution/frameworks/java.js +339 -12
- package/dist/resolution/frameworks/java.js.map +1 -1
- package/dist/resolution/frameworks/laravel.d.ts.map +1 -1
- package/dist/resolution/frameworks/laravel.js +17 -8
- package/dist/resolution/frameworks/laravel.js.map +1 -1
- package/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
- package/dist/resolution/frameworks/nestjs.js +324 -0
- package/dist/resolution/frameworks/nestjs.js.map +1 -1
- package/dist/resolution/frameworks/play.d.ts +19 -0
- package/dist/resolution/frameworks/play.d.ts.map +1 -0
- package/dist/resolution/frameworks/play.js +111 -0
- package/dist/resolution/frameworks/play.js.map +1 -0
- package/dist/resolution/frameworks/python.d.ts.map +1 -1
- package/dist/resolution/frameworks/python.js +134 -16
- package/dist/resolution/frameworks/python.js.map +1 -1
- package/dist/resolution/frameworks/react-native.d.ts +3 -0
- package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
- package/dist/resolution/frameworks/react-native.js +360 -0
- package/dist/resolution/frameworks/react-native.js.map +1 -0
- package/dist/resolution/frameworks/react.d.ts.map +1 -1
- package/dist/resolution/frameworks/react.js +96 -3
- package/dist/resolution/frameworks/react.js.map +1 -1
- package/dist/resolution/frameworks/ruby.d.ts.map +1 -1
- package/dist/resolution/frameworks/ruby.js +106 -2
- package/dist/resolution/frameworks/ruby.js.map +1 -1
- package/dist/resolution/frameworks/rust.d.ts.map +1 -1
- package/dist/resolution/frameworks/rust.js +102 -5
- package/dist/resolution/frameworks/rust.js.map +1 -1
- package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
- package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
- package/dist/resolution/frameworks/swift-objc.js +252 -0
- package/dist/resolution/frameworks/swift-objc.js.map +1 -0
- package/dist/resolution/frameworks/swift.d.ts.map +1 -1
- package/dist/resolution/frameworks/swift.js +30 -6
- package/dist/resolution/frameworks/swift.js.map +1 -1
- package/dist/resolution/go-module.d.ts +26 -0
- package/dist/resolution/go-module.d.ts.map +1 -0
- package/dist/resolution/go-module.js +78 -0
- package/dist/resolution/go-module.js.map +1 -0
- package/dist/resolution/import-resolver.d.ts +28 -0
- package/dist/resolution/import-resolver.d.ts.map +1 -1
- package/dist/resolution/import-resolver.js +617 -5
- package/dist/resolution/import-resolver.js.map +1 -1
- package/dist/resolution/index.d.ts +11 -0
- package/dist/resolution/index.d.ts.map +1 -1
- package/dist/resolution/index.js +196 -10
- package/dist/resolution/index.js.map +1 -1
- package/dist/resolution/lru-cache.d.ts +24 -0
- package/dist/resolution/lru-cache.d.ts.map +1 -0
- package/dist/resolution/lru-cache.js +62 -0
- package/dist/resolution/lru-cache.js.map +1 -0
- package/dist/resolution/name-matcher.d.ts.map +1 -1
- package/dist/resolution/name-matcher.js +212 -0
- package/dist/resolution/name-matcher.js.map +1 -1
- package/dist/resolution/swift-objc-bridge.d.ts +134 -0
- package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
- package/dist/resolution/swift-objc-bridge.js +256 -0
- package/dist/resolution/swift-objc-bridge.js.map +1 -0
- package/dist/resolution/types.d.ts +44 -0
- package/dist/resolution/types.d.ts.map +1 -1
- package/dist/resolution/workspace-packages.d.ts +48 -0
- package/dist/resolution/workspace-packages.d.ts.map +1 -0
- package/dist/resolution/workspace-packages.js +208 -0
- package/dist/resolution/workspace-packages.js.map +1 -0
- package/dist/search/query-utils.d.ts +18 -0
- package/dist/search/query-utils.d.ts.map +1 -1
- package/dist/search/query-utils.js +30 -0
- package/dist/search/query-utils.js.map +1 -1
- package/dist/sync/git-hooks.d.ts.map +1 -1
- package/dist/sync/git-hooks.js +2 -0
- package/dist/sync/git-hooks.js.map +1 -1
- package/dist/sync/index.d.ts +3 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +8 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/watcher.d.ts +214 -12
- package/dist/sync/watcher.d.ts.map +1 -1
- package/dist/sync/watcher.js +467 -55
- package/dist/sync/watcher.js.map +1 -1
- package/dist/sync/worktree.d.ts +54 -0
- package/dist/sync/worktree.d.ts.map +1 -0
- package/dist/sync/worktree.js +137 -0
- package/dist/sync/worktree.js.map +1 -0
- package/dist/types.d.ts +9 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -1
- package/dist/utils.js +1 -1
- package/package.json +2 -2
- package/scripts/add-lang/bench.sh +60 -0
- package/scripts/add-lang/check-grammar.mjs +75 -0
- package/scripts/add-lang/dump-ast.mjs +103 -0
- package/scripts/add-lang/verify-extraction.mjs +70 -0
- package/scripts/agent-eval/arms-F.sh +21 -0
- package/scripts/agent-eval/arms-matrix.sh +37 -0
- package/scripts/agent-eval/bench-readme.sh +28 -0
- package/scripts/agent-eval/bench-why-repo.sh +22 -0
- package/scripts/agent-eval/block-read-hook.sh +19 -0
- package/scripts/agent-eval/hook-settings.json +15 -0
- package/scripts/agent-eval/itrun.sh +24 -11
- package/scripts/agent-eval/parse-arms.mjs +116 -0
- package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
- package/scripts/agent-eval/probe-context.mjs +21 -0
- package/scripts/agent-eval/probe-explore.mjs +40 -0
- package/scripts/agent-eval/probe-node.mjs +20 -0
- package/scripts/agent-eval/probe-sweep.mjs +119 -0
- package/scripts/agent-eval/probe-trace.mjs +20 -0
- package/scripts/agent-eval/run-arms.sh +56 -0
- package/scripts/agent-eval/seq-matrix.mjs +137 -0
- package/scripts/build-bundle.sh +118 -0
- package/scripts/npm-sdk.js +75 -0
- package/scripts/npm-shim.js +246 -0
- package/scripts/pack-npm.sh +119 -0
- package/scripts/prepare-release.mjs +270 -0
- package/scripts/patch-tree-sitter-dart.js +0 -112
- package/scripts/release.sh +0 -68
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SQLite Adapter
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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.
|
|
6
11
|
*/
|
|
7
12
|
export interface SqliteStatement {
|
|
8
13
|
run(...params: any[]): {
|
|
@@ -11,39 +16,35 @@ export interface SqliteStatement {
|
|
|
11
16
|
};
|
|
12
17
|
get(...params: any[]): any;
|
|
13
18
|
all(...params: any[]): any[];
|
|
19
|
+
/**
|
|
20
|
+
* Lazily yield result rows one at a time instead of materializing the whole
|
|
21
|
+
* set with `all()`. Use for unbounded scans (e.g. every function/method node)
|
|
22
|
+
* so memory stays O(1) in the row count rather than O(rows) — see #610, where
|
|
23
|
+
* `all()`-ing every symbol on a dense project spiked the heap into an OOM.
|
|
24
|
+
*/
|
|
25
|
+
iterate(...params: any[]): IterableIterator<any>;
|
|
14
26
|
}
|
|
15
27
|
export interface SqliteDatabase {
|
|
16
28
|
prepare(sql: string): SqliteStatement;
|
|
17
29
|
exec(sql: string): void;
|
|
18
|
-
pragma(str: string
|
|
30
|
+
pragma(str: string, options?: {
|
|
31
|
+
simple?: boolean;
|
|
32
|
+
}): any;
|
|
19
33
|
transaction<T>(fn: (...args: any[]) => T): (...args: any[]) => T;
|
|
20
34
|
close(): void;
|
|
21
35
|
readonly open: boolean;
|
|
22
36
|
}
|
|
23
|
-
export type SqliteBackend = 'native' | 'wasm';
|
|
24
37
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* stderr banner and the MCP status formatter.
|
|
38
|
+
* The active SQLite backend. Only one now (`node:sqlite`); kept as a named type
|
|
39
|
+
* so `codegraph status` and the per-instance reporting have a stable shape.
|
|
28
40
|
*/
|
|
29
|
-
export
|
|
41
|
+
export type SqliteBackend = 'node-sqlite';
|
|
30
42
|
/**
|
|
31
|
-
*
|
|
32
|
-
* WASM. Replaces a one-line `console.warn` that MCP transports (which
|
|
33
|
-
* take stdout for the protocol) typically swallow, leaving users on a
|
|
34
|
-
* 5-10x slower backend with no signal.
|
|
43
|
+
* Create a database connection backed by `node:sqlite`.
|
|
35
44
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
export declare function buildWasmFallbackBanner(nativeError?: string): string;
|
|
40
|
-
/**
|
|
41
|
-
* Create a database connection. Tries native better-sqlite3 first,
|
|
42
|
-
* falls back to node-sqlite3-wasm. Returns the active backend
|
|
43
|
-
* alongside the db so each `DatabaseConnection` can report its own
|
|
44
|
-
* backend per-instance — MCP can open multiple project DBs in one
|
|
45
|
-
* process (`tools.ts` getCodeGraph cache), so a process-global would
|
|
46
|
-
* race / overwrite.
|
|
45
|
+
* Returns the active backend alongside the db so each `DatabaseConnection` can
|
|
46
|
+
* report it per-instance — MCP can open multiple project DBs in one process, so
|
|
47
|
+
* a process-global would race.
|
|
47
48
|
*/
|
|
48
49
|
export declare function createDatabase(dbPath: string): {
|
|
49
50
|
db: SqliteDatabase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-adapter.d.ts","sourceRoot":"","sources":["../../src/db/sqlite-adapter.ts"],"names":[],"mappings":"AAAA
|
|
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;QAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC7E,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IAC3B,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;IAC7B;;;;;OAKG;IACH,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;CAClD;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;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC;AA2F1C;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,CAY7F"}
|
|
@@ -2,175 +2,77 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* SQLite Adapter
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
7
12
|
*/
|
|
8
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.WASM_FALLBACK_FIX_RECIPE = void 0;
|
|
10
|
-
exports.buildWasmFallbackBanner = buildWasmFallbackBanner;
|
|
11
14
|
exports.createDatabase = createDatabase;
|
|
12
15
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* stderr banner and the MCP status formatter.
|
|
16
|
-
*/
|
|
17
|
-
exports.WASM_FALLBACK_FIX_RECIPE = '`xcode-select --install` (macOS) or `apt install build-essential` (Debian/Ubuntu), ' +
|
|
18
|
-
'then `npm rebuild better-sqlite3`, or `npm install better-sqlite3 --save` to force-include it.';
|
|
19
|
-
/**
|
|
20
|
-
* Multi-line banner shown to stderr when `createDatabase` falls back to
|
|
21
|
-
* WASM. Replaces a one-line `console.warn` that MCP transports (which
|
|
22
|
-
* take stdout for the protocol) typically swallow, leaving users on a
|
|
23
|
-
* 5-10x slower backend with no signal.
|
|
24
|
-
*
|
|
25
|
-
* Exported for unit testing — pinning the recipe content prevents
|
|
26
|
-
* future edits from silently stripping the recovery commands.
|
|
27
|
-
*/
|
|
28
|
-
function buildWasmFallbackBanner(nativeError) {
|
|
29
|
-
const sep = '─'.repeat(72);
|
|
30
|
-
const lines = [
|
|
31
|
-
sep,
|
|
32
|
-
'[CodeGraph] WASM SQLite fallback active (better-sqlite3 unavailable)',
|
|
33
|
-
sep,
|
|
34
|
-
'Indexing and sync will be 5-10x slower than the native backend.',
|
|
35
|
-
'',
|
|
36
|
-
'Fix on macOS:',
|
|
37
|
-
' xcode-select --install # install C build tools',
|
|
38
|
-
' npm rebuild better-sqlite3 # rebuild native binding for current Node',
|
|
39
|
-
'',
|
|
40
|
-
'Fix on Linux:',
|
|
41
|
-
' sudo apt install build-essential python3 make # Debian/Ubuntu',
|
|
42
|
-
' # or: sudo yum groupinstall "Development Tools" # RHEL/Fedora',
|
|
43
|
-
' npm rebuild better-sqlite3',
|
|
44
|
-
'',
|
|
45
|
-
'Or force-include as a hard dependency on any platform:',
|
|
46
|
-
' npm install better-sqlite3 --save',
|
|
47
|
-
'',
|
|
48
|
-
'Verify after fix: `codegraph status` should show `Backend: native`.',
|
|
49
|
-
];
|
|
50
|
-
if (nativeError) {
|
|
51
|
-
lines.push('', `Native load error: ${nativeError}`);
|
|
52
|
-
}
|
|
53
|
-
lines.push(sep);
|
|
54
|
-
return lines.join('\n');
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Translate @named parameters (better-sqlite3 style) to positional ? params
|
|
58
|
-
* for node-sqlite3-wasm, which only supports positional binding.
|
|
59
|
-
*
|
|
60
|
-
* Returns the rewritten SQL and an ordered list of parameter names.
|
|
61
|
-
* If no named params are found, returns null for paramOrder (positional mode).
|
|
62
|
-
*/
|
|
63
|
-
function translateNamedParams(sql) {
|
|
64
|
-
const paramOrder = [];
|
|
65
|
-
const rewritten = sql.replace(/@(\w+)/g, (_match, name) => {
|
|
66
|
-
paramOrder.push(name);
|
|
67
|
-
return '?';
|
|
68
|
-
});
|
|
69
|
-
if (paramOrder.length === 0) {
|
|
70
|
-
return { sql, paramOrder: null };
|
|
71
|
-
}
|
|
72
|
-
return { sql: rewritten, paramOrder };
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Convert better-sqlite3-style params to a positional array for node-sqlite3-wasm.
|
|
76
|
-
*
|
|
77
|
-
* Handles three calling conventions:
|
|
78
|
-
* - Named object: run({ id: '1', name: 'a' }) → positional array via paramOrder
|
|
79
|
-
* - Positional args: run('a', 'b') → ['a', 'b']
|
|
80
|
-
* - No args: run() → undefined
|
|
81
|
-
*/
|
|
82
|
-
function resolveParams(params, paramOrder) {
|
|
83
|
-
if (params.length === 0)
|
|
84
|
-
return undefined;
|
|
85
|
-
// If paramOrder exists and first arg is a plain object, do named→positional translation
|
|
86
|
-
if (paramOrder && params.length === 1 && params[0] !== null && typeof params[0] === 'object' && !Array.isArray(params[0]) && !(params[0] instanceof Buffer) && !(params[0] instanceof Uint8Array)) {
|
|
87
|
-
const obj = params[0];
|
|
88
|
-
return paramOrder.map(name => obj[name]);
|
|
89
|
-
}
|
|
90
|
-
// Positional: single value or already an array
|
|
91
|
-
if (params.length === 1)
|
|
92
|
-
return params[0];
|
|
93
|
-
return params;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Wraps node-sqlite3-wasm to match the better-sqlite3 interface.
|
|
16
|
+
* Wraps Node's built-in `node:sqlite` (`DatabaseSync`) to match the
|
|
17
|
+
* better-sqlite3 interface the rest of the code expects.
|
|
97
18
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* - node-sqlite3-wasm has `isOpen` instead of `open`
|
|
103
|
-
* - node-sqlite3-wasm doesn't have a `pragma()` method
|
|
104
|
-
* - node-sqlite3-wasm doesn't have a `transaction()` method
|
|
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`).
|
|
105
23
|
*/
|
|
106
|
-
class
|
|
24
|
+
class NodeSqliteAdapter {
|
|
107
25
|
_db;
|
|
108
|
-
// Track raw WASM statements so we can finalize them on close.
|
|
109
|
-
// node-sqlite3-wasm won't release its file lock if statements are left open.
|
|
110
|
-
_openStmts = new Set();
|
|
111
26
|
constructor(dbPath) {
|
|
112
27
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
113
|
-
const {
|
|
114
|
-
this._db = new
|
|
28
|
+
const { DatabaseSync } = require('node:sqlite');
|
|
29
|
+
this._db = new DatabaseSync(dbPath);
|
|
115
30
|
}
|
|
116
31
|
get open() {
|
|
117
32
|
return this._db.isOpen;
|
|
118
33
|
}
|
|
119
34
|
prepare(sql) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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);
|
|
123
39
|
return {
|
|
124
40
|
run(...params) {
|
|
125
|
-
const
|
|
126
|
-
const result = resolved !== undefined ? stmt.run(resolved) : stmt.run();
|
|
41
|
+
const r = stmt.run(...params);
|
|
127
42
|
return {
|
|
128
|
-
changes:
|
|
129
|
-
lastInsertRowid:
|
|
43
|
+
changes: Number(r?.changes ?? 0),
|
|
44
|
+
lastInsertRowid: r?.lastInsertRowid ?? 0,
|
|
130
45
|
};
|
|
131
46
|
},
|
|
132
47
|
get(...params) {
|
|
133
|
-
|
|
134
|
-
return resolved !== undefined ? stmt.get(resolved) : stmt.get();
|
|
48
|
+
return stmt.get(...params);
|
|
135
49
|
},
|
|
136
50
|
all(...params) {
|
|
137
|
-
|
|
138
|
-
|
|
51
|
+
return stmt.all(...params);
|
|
52
|
+
},
|
|
53
|
+
iterate(...params) {
|
|
54
|
+
return stmt.iterate(...params);
|
|
139
55
|
},
|
|
140
56
|
};
|
|
141
57
|
}
|
|
142
58
|
exec(sql) {
|
|
143
59
|
this._db.exec(sql);
|
|
144
60
|
}
|
|
145
|
-
pragma(str) {
|
|
61
|
+
pragma(str, options) {
|
|
146
62
|
const trimmed = str.trim();
|
|
147
|
-
// Write pragma
|
|
63
|
+
// Write pragma ("key = value"): node:sqlite is real SQLite, so every pragma
|
|
64
|
+
// (WAL, mmap, synchronous, …) applies as-is.
|
|
148
65
|
if (trimmed.includes('=')) {
|
|
149
|
-
|
|
150
|
-
const key = trimmed.substring(0, eqIdx).trim();
|
|
151
|
-
const value = trimmed.substring(eqIdx + 1).trim();
|
|
152
|
-
// WAL is not supported in WASM SQLite — use DELETE journal mode
|
|
153
|
-
if (key === 'journal_mode' && value.toUpperCase() === 'WAL') {
|
|
154
|
-
this._db.exec('PRAGMA journal_mode = DELETE');
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
// mmap is not available in WASM — silently skip
|
|
158
|
-
if (key === 'mmap_size') {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
// synchronous = NORMAL is unsafe without WAL — use FULL
|
|
162
|
-
if (key === 'synchronous' && value.toUpperCase() === 'NORMAL') {
|
|
163
|
-
this._db.exec('PRAGMA synchronous = FULL');
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
this._db.exec(`PRAGMA ${key} = ${value}`);
|
|
66
|
+
this._db.exec(`PRAGMA ${trimmed}`);
|
|
167
67
|
return;
|
|
168
68
|
}
|
|
169
|
-
// Read pragma:
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
69
|
+
// Read pragma. Default: the row object (e.g. { journal_mode: 'wal' }).
|
|
70
|
+
// `{ simple: true }` returns just the single column value, like better-sqlite3.
|
|
71
|
+
const row = this._db.prepare(`PRAGMA ${trimmed}`).get();
|
|
72
|
+
if (options?.simple) {
|
|
73
|
+
return row && typeof row === 'object' ? Object.values(row)[0] : row;
|
|
74
|
+
}
|
|
75
|
+
return row;
|
|
174
76
|
}
|
|
175
77
|
transaction(fn) {
|
|
176
78
|
return (...args) => {
|
|
@@ -187,51 +89,29 @@ class WasmDatabaseAdapter {
|
|
|
187
89
|
};
|
|
188
90
|
}
|
|
189
91
|
close() {
|
|
190
|
-
//
|
|
191
|
-
//
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
try {
|
|
195
|
-
stmt.finalize();
|
|
196
|
-
}
|
|
197
|
-
catch { /* already finalized */ }
|
|
198
|
-
}
|
|
199
|
-
this._openStmts.clear();
|
|
200
|
-
this._db.close();
|
|
92
|
+
// node:sqlite's DatabaseSync.close() throws if already closed; make it
|
|
93
|
+
// idempotent to match better-sqlite3 (callers may close more than once).
|
|
94
|
+
if (this._db.isOpen)
|
|
95
|
+
this._db.close();
|
|
201
96
|
}
|
|
202
97
|
}
|
|
203
98
|
/**
|
|
204
|
-
* Create a database connection
|
|
205
|
-
*
|
|
206
|
-
* alongside the db so each `DatabaseConnection` can
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* race / overwrite.
|
|
99
|
+
* Create a database connection backed by `node:sqlite`.
|
|
100
|
+
*
|
|
101
|
+
* Returns the active backend alongside the db so each `DatabaseConnection` can
|
|
102
|
+
* report it per-instance — MCP can open multiple project DBs in one process, so
|
|
103
|
+
* a process-global would race.
|
|
210
104
|
*/
|
|
211
105
|
function createDatabase(dbPath) {
|
|
212
|
-
let nativeError;
|
|
213
|
-
let wasmError;
|
|
214
|
-
// Try native better-sqlite3 first
|
|
215
|
-
try {
|
|
216
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
217
|
-
const Database = require('better-sqlite3');
|
|
218
|
-
const db = new Database(dbPath);
|
|
219
|
-
return { db: db, backend: 'native' };
|
|
220
|
-
}
|
|
221
|
-
catch (error) {
|
|
222
|
-
nativeError = error instanceof Error ? error.message : String(error);
|
|
223
|
-
}
|
|
224
|
-
// Fall back to WASM
|
|
225
106
|
try {
|
|
226
|
-
|
|
227
|
-
console.warn(buildWasmFallbackBanner(nativeError));
|
|
228
|
-
return { db, backend: 'wasm' };
|
|
107
|
+
return { db: new NodeSqliteAdapter(dbPath), backend: 'node-sqlite' };
|
|
229
108
|
}
|
|
230
109
|
catch (error) {
|
|
231
|
-
|
|
110
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
111
|
+
throw new Error('Failed to open SQLite via the built-in node:sqlite module.\n' +
|
|
112
|
+
'CodeGraph requires node:sqlite (Node.js 22.5+). Install the self-contained\n' +
|
|
113
|
+
'CodeGraph release (it bundles a compatible Node), or run on Node 22.5+.\n' +
|
|
114
|
+
`Underlying error: ${msg}`);
|
|
232
115
|
}
|
|
233
|
-
throw new Error(`Failed to load any SQLite backend.\n` +
|
|
234
|
-
` Native (better-sqlite3): ${nativeError}\n` +
|
|
235
|
-
` WASM (node-sqlite3-wasm): ${wasmError}`);
|
|
236
116
|
}
|
|
237
117
|
//# sourceMappingURL=sqlite-adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-adapter.js","sourceRoot":"","sources":["../../src/db/sqlite-adapter.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"sqlite-adapter.js","sourceRoot":"","sources":["../../src/db/sqlite-adapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AA8HH,wCAYC;AA5GD;;;;;;;;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,IAAI;QACN,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,GAAW;QACjB,oEAAoE;QACpE,4EAA4E;QA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,GAAG,EAAE,CAC3B,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/directory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,eAAO,MAAM,aAAa,eAAe,CAAC;AAE1C;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAQ1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAmBzE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,eAAO,MAAM,aAAa,eAAe,CAAC;AAE1C;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAQ1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAmBzE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAyBzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAuBzD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CA8BnE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CA+B5D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAYlF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG;IACtD,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CA8BA"}
|
package/dist/directory.js
CHANGED
|
@@ -117,25 +117,11 @@ function createDirectory(projectRoot) {
|
|
|
117
117
|
// Create .gitignore inside .codegraph (if it doesn't exist)
|
|
118
118
|
const gitignorePath = path.join(codegraphDir, '.gitignore');
|
|
119
119
|
if (!fs.existsSync(gitignorePath)) {
|
|
120
|
-
const gitignoreContent = `# CodeGraph data files
|
|
121
|
-
#
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
*.db-wal
|
|
126
|
-
*.db-shm
|
|
127
|
-
|
|
128
|
-
# Local config may contain provider API keys
|
|
129
|
-
config.json
|
|
130
|
-
|
|
131
|
-
# Cache
|
|
132
|
-
cache/
|
|
133
|
-
|
|
134
|
-
# Logs
|
|
135
|
-
*.log
|
|
136
|
-
|
|
137
|
-
# Hook markers
|
|
138
|
-
.dirty
|
|
120
|
+
const gitignoreContent = `# CodeGraph data files — local to each machine, not for committing.
|
|
121
|
+
# Ignore everything in .codegraph/ except this file itself, so transient
|
|
122
|
+
# files (the database, daemon.pid, sockets, logs) never show up in git.
|
|
123
|
+
*
|
|
124
|
+
!.gitignore
|
|
139
125
|
`;
|
|
140
126
|
fs.writeFileSync(gitignorePath, gitignoreContent, 'utf-8');
|
|
141
127
|
}
|
|
@@ -251,7 +237,7 @@ function validateDirectory(projectRoot) {
|
|
|
251
237
|
const gitignorePath = path.join(codegraphDir, '.gitignore');
|
|
252
238
|
if (!fs.existsSync(gitignorePath)) {
|
|
253
239
|
try {
|
|
254
|
-
const gitignoreContent = `# CodeGraph data files
|
|
240
|
+
const gitignoreContent = `# CodeGraph data files — local to each machine, not for committing.\n# Ignore everything in .codegraph/ except this file itself, so transient\n# files (the database, daemon.pid, sockets, logs) never show up in git.\n*\n!.gitignore\n`;
|
|
255
241
|
fs.writeFileSync(gitignorePath, gitignoreContent, 'utf-8');
|
|
256
242
|
}
|
|
257
243
|
catch {
|
package/dist/directory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaH,0CAEC;AAMD,sCAQC;AAWD,4DAmBC;AAMD,
|
|
1
|
+
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaH,0CAEC;AAMD,sCAQC;AAWD,4DAmBC;AAMD,0CAyBC;AAKD,0CAuBC;AAKD,sDA8BC;AAKD,4CA+BC;AAKD,gDAYC;AAKD,8CAiCC;AAlPD,uCAAyB;AACzB,2CAA6B;AAE7B;;GAEG;AACU,QAAA,aAAa,GAAG,YAAY,CAAC;AAE1C;;GAEG;AACH,SAAgB,eAAe,CAAC,WAAmB;IACjD,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,qBAAa,CAAC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,WAAmB;IAC/C,MAAM,YAAY,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAClD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;QAC7E,OAAO,KAAK,CAAC;IACf,CAAC;IACD,qDAAqD;IACrD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EA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,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;QACxD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAClC,CAAC;IAED,qDAAqD;IACrD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAC5D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,0OAA0O,CAAC;YACpQ,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAC7D,CAAC;QAAC,MAAM,CAAC;YACP,kCAAkC;YAClC,MAAM,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated-file detection for symbol-disambiguation down-ranking.
|
|
3
|
+
*
|
|
4
|
+
* When a query like "Send" matches 17 symbols across protobuf scaffolding,
|
|
5
|
+
* test mocks, and the hand-written implementation, the FTS ranker often
|
|
6
|
+
* surfaces the generated stubs first because their names are identical
|
|
7
|
+
* to the implementation's name (validated empirically on cosmos-sdk —
|
|
8
|
+
* see project_go_multi_module_audit memory). Generated stubs frequently
|
|
9
|
+
* have no body to trace from, so the agent ends up reading source anyway.
|
|
10
|
+
*
|
|
11
|
+
* This helper is a pure path-based classifier consulted at disambiguation
|
|
12
|
+
* time (findSymbol / findAllSymbols / codegraph_search formatting), NOT
|
|
13
|
+
* a hard filter — generated nodes are still in the graph and remain
|
|
14
|
+
* reachable; they just rank LAST when there's a real implementation
|
|
15
|
+
* with the same name.
|
|
16
|
+
*
|
|
17
|
+
* Scope: suffix patterns only. Most generated files follow the
|
|
18
|
+
* `<basename>.<tool>.<ext>` convention (`.pb.go`, `_grpc.pb.go`,
|
|
19
|
+
* `.g.dart`, `_pb2.py`), and that covers ~all of what we saw in the
|
|
20
|
+
* Go audit. A future addition would be scanning for the canonical
|
|
21
|
+
* `// Code generated by` header during extraction, for the rare files
|
|
22
|
+
* that defy the suffix convention.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Whether `filePath` looks like a tool-generated source file based on
|
|
26
|
+
* its filename. Path-only — does not read content. The result is a
|
|
27
|
+
* relevance hint for disambiguation, not a hard claim.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isGeneratedFile(filePath: string): boolean;
|
|
30
|
+
//# sourceMappingURL=generated-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-detection.d.ts","sourceRoot":"","sources":["../../src/extraction/generated-detection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAgDH;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generated-file detection for symbol-disambiguation down-ranking.
|
|
4
|
+
*
|
|
5
|
+
* When a query like "Send" matches 17 symbols across protobuf scaffolding,
|
|
6
|
+
* test mocks, and the hand-written implementation, the FTS ranker often
|
|
7
|
+
* surfaces the generated stubs first because their names are identical
|
|
8
|
+
* to the implementation's name (validated empirically on cosmos-sdk —
|
|
9
|
+
* see project_go_multi_module_audit memory). Generated stubs frequently
|
|
10
|
+
* have no body to trace from, so the agent ends up reading source anyway.
|
|
11
|
+
*
|
|
12
|
+
* This helper is a pure path-based classifier consulted at disambiguation
|
|
13
|
+
* time (findSymbol / findAllSymbols / codegraph_search formatting), NOT
|
|
14
|
+
* a hard filter — generated nodes are still in the graph and remain
|
|
15
|
+
* reachable; they just rank LAST when there's a real implementation
|
|
16
|
+
* with the same name.
|
|
17
|
+
*
|
|
18
|
+
* Scope: suffix patterns only. Most generated files follow the
|
|
19
|
+
* `<basename>.<tool>.<ext>` convention (`.pb.go`, `_grpc.pb.go`,
|
|
20
|
+
* `.g.dart`, `_pb2.py`), and that covers ~all of what we saw in the
|
|
21
|
+
* Go audit. A future addition would be scanning for the canonical
|
|
22
|
+
* `// Code generated by` header during extraction, for the rare files
|
|
23
|
+
* that defy the suffix convention.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isGeneratedFile = isGeneratedFile;
|
|
27
|
+
const GENERATED_PATTERNS = [
|
|
28
|
+
// Go — protobuf / gRPC / pulsar
|
|
29
|
+
/\.pb\.go$/,
|
|
30
|
+
/\.pulsar\.go$/,
|
|
31
|
+
/_grpc\.pb\.go$/,
|
|
32
|
+
// Go — mockgen output. Default emits `mock_<src>.go`; many projects
|
|
33
|
+
// (cosmos-sdk uses `expected_*_mocks.go`) rename to `*_mock.go` /
|
|
34
|
+
// `*_mocks.go`. Matching either suffix catches both conventions
|
|
35
|
+
// without false-positive risk on hand-written sources.
|
|
36
|
+
/_mock\.go$/,
|
|
37
|
+
/_mocks\.go$/,
|
|
38
|
+
/^mock_[^/]+\.go$/,
|
|
39
|
+
// TypeScript / JavaScript — common codegen suffixes (Apollo / GraphQL
|
|
40
|
+
// codegen, Prisma, Hasura, ts-proto, gRPC-web, swagger-codegen).
|
|
41
|
+
/\.generated\.[jt]sx?$/,
|
|
42
|
+
/\.gen\.[jt]sx?$/,
|
|
43
|
+
/\.pb\.[jt]s$/,
|
|
44
|
+
/_pb\.[jt]s$/,
|
|
45
|
+
/_grpc_pb\.[jt]s$/,
|
|
46
|
+
// Python — protobuf / gRPC / openapi-codegen
|
|
47
|
+
/_pb2(_grpc)?\.py$/,
|
|
48
|
+
/_pb2\.pyi$/,
|
|
49
|
+
// C++ — protobuf
|
|
50
|
+
/\.pb\.(cc|h)$/,
|
|
51
|
+
// C# — protobuf / gRPC (protoc-gen-csharp puts output under obj/ but
|
|
52
|
+
// many projects also commit *.g.cs and *Grpc.cs siblings)
|
|
53
|
+
/\.g\.cs$/,
|
|
54
|
+
/Grpc\.cs$/,
|
|
55
|
+
// Java — protobuf / gRPC: protoc-gen-java emits `*OuterClass.java`,
|
|
56
|
+
// protoc-gen-grpc-java emits `*Grpc.java`. The XxxImplBase abstract
|
|
57
|
+
// class lives inside Xxx*Grpc.java.
|
|
58
|
+
/OuterClass\.java$/,
|
|
59
|
+
/Grpc\.java$/,
|
|
60
|
+
// Swift — protobuf
|
|
61
|
+
/\.pb\.swift$/,
|
|
62
|
+
// Dart — build_runner / freezed / json_serializable / chopper
|
|
63
|
+
/\.g\.dart$/,
|
|
64
|
+
/\.freezed\.dart$/,
|
|
65
|
+
/\.pb\.dart$/,
|
|
66
|
+
/\.pbgrpc\.dart$/,
|
|
67
|
+
/\.chopper\.dart$/,
|
|
68
|
+
// Rust — common build.rs OUT_DIR outputs are usually outside the source
|
|
69
|
+
// tree, but in-tree generated files often use `*.generated.rs`.
|
|
70
|
+
/\.generated\.rs$/,
|
|
71
|
+
];
|
|
72
|
+
/**
|
|
73
|
+
* Whether `filePath` looks like a tool-generated source file based on
|
|
74
|
+
* its filename. Path-only — does not read content. The result is a
|
|
75
|
+
* relevance hint for disambiguation, not a hard claim.
|
|
76
|
+
*/
|
|
77
|
+
function isGeneratedFile(filePath) {
|
|
78
|
+
return GENERATED_PATTERNS.some((p) => p.test(filePath));
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=generated-detection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-detection.js","sourceRoot":"","sources":["../../src/extraction/generated-detection.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;AAqDH,0CAEC;AArDD,MAAM,kBAAkB,GAA0B;IAChD,gCAAgC;IAChC,WAAW;IACX,eAAe;IACf,gBAAgB;IAChB,oEAAoE;IACpE,kEAAkE;IAClE,gEAAgE;IAChE,uDAAuD;IACvD,YAAY;IACZ,aAAa;IACb,kBAAkB;IAClB,sEAAsE;IACtE,iEAAiE;IACjE,uBAAuB;IACvB,iBAAiB;IACjB,cAAc;IACd,aAAa;IACb,kBAAkB;IAClB,6CAA6C;IAC7C,mBAAmB;IACnB,YAAY;IACZ,iBAAiB;IACjB,eAAe;IACf,qEAAqE;IACrE,0DAA0D;IAC1D,UAAU;IACV,WAAW;IACX,oEAAoE;IACpE,oEAAoE;IACpE,oCAAoC;IACpC,mBAAmB;IACnB,aAAa;IACb,mBAAmB;IACnB,cAAc;IACd,8DAA8D;IAC9D,YAAY;IACZ,kBAAkB;IAClB,aAAa;IACb,iBAAiB;IACjB,kBAAkB;IAClB,wEAAwE;IACxE,gEAAgE;IAChE,kBAAkB;CACnB,CAAC;AAEF;;;;GAIG;AACH,SAAgB,eAAe,CAAC,QAAgB;IAC9C,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -7,11 +7,23 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Parser } from 'web-tree-sitter';
|
|
9
9
|
import { Language } from '../types';
|
|
10
|
-
export type GrammarLanguage = Exclude<Language, 'svelte' | 'vue' | 'liquid' | 'unknown'>;
|
|
10
|
+
export type GrammarLanguage = Exclude<Language, 'svelte' | 'vue' | 'liquid' | 'yaml' | 'twig' | 'xml' | 'properties' | 'unknown'>;
|
|
11
11
|
/**
|
|
12
12
|
* File extension to Language mapping
|
|
13
13
|
*/
|
|
14
14
|
export declare const EXTENSION_MAP: Record<string, Language>;
|
|
15
|
+
/**
|
|
16
|
+
* Whether a file is one CodeGraph can parse, based purely on its extension.
|
|
17
|
+
* This is the single source of truth for "should we index this file" — derived
|
|
18
|
+
* from EXTENSION_MAP so parser support and indexing selection never drift.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isSourceFile(filePath: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Play Framework routes file: the extensionless `conf/routes` (and included
|
|
23
|
+
* `conf/*.routes`). No grammar — route extraction is done by the Play framework
|
|
24
|
+
* resolver, so it's processed through the no-grammar (`yaml`-style) path.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isPlayRoutesFile(filePath: string): boolean;
|
|
15
27
|
/**
|
|
16
28
|
* Initialize the tree-sitter WASM runtime. Must be called before loading grammars.
|
|
17
29
|
* Does NOT load any grammar WASM files — use loadGrammarsForLanguages() for that.
|
|
@@ -51,6 +63,16 @@ export declare function isLanguageSupported(language: Language): boolean;
|
|
|
51
63
|
* Check if a grammar has been loaded and is ready for parsing.
|
|
52
64
|
*/
|
|
53
65
|
export declare function isGrammarLoaded(language: Language): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Languages tracked at the file-record level only: parsing emits zero symbol
|
|
68
|
+
* nodes, but the file is still stored (and framework resolvers may add per-file
|
|
69
|
+
* references later, e.g. Drupal routing yml, Spring `@Value` against
|
|
70
|
+
* application.properties). This is the canonical set behind the no-symbol
|
|
71
|
+
* branch in `tree-sitter.ts`; `xml` is intentionally excluded because its
|
|
72
|
+
* MyBatis extractor emits a file node. Callers use this to count such files as
|
|
73
|
+
* indexed rather than skipped, so it must stay in sync with that branch.
|
|
74
|
+
*/
|
|
75
|
+
export declare function isFileLevelOnlyLanguage(language: Language): boolean;
|
|
54
76
|
/**
|
|
55
77
|
* Get all supported languages (those with grammar definitions).
|
|
56
78
|
*/
|