@saluzi/codegraph 0.1.0 → 0.2.1
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/LICENSE +21 -0
- package/README.md +885 -0
- package/dist/bin/codegraph.d.ts +2 -1
- package/dist/bin/codegraph.d.ts.map +1 -0
- package/dist/bin/codegraph.js +2248 -0
- package/dist/bin/codegraph.js.map +1 -0
- package/dist/bin/command-supervision.d.ts +49 -0
- package/dist/bin/command-supervision.d.ts.map +1 -0
- package/dist/bin/command-supervision.js +95 -0
- package/dist/bin/command-supervision.js.map +1 -0
- package/dist/bin/fatal-handler.d.ts +20 -0
- package/dist/bin/fatal-handler.d.ts.map +1 -0
- package/dist/bin/fatal-handler.js +118 -0
- package/dist/bin/fatal-handler.js.map +1 -0
- package/dist/bin/node-version-check.d.ts.map +1 -0
- package/dist/bin/node-version-check.js +79 -0
- package/dist/bin/node-version-check.js.map +1 -0
- package/dist/bin/uninstall.d.ts.map +1 -0
- package/dist/bin/uninstall.js +36 -0
- package/dist/bin/uninstall.js.map +1 -0
- package/dist/context/formatter.d.ts +6 -9
- package/dist/context/formatter.d.ts.map +1 -0
- package/dist/context/formatter.js +25 -6
- package/dist/context/formatter.js.map +1 -0
- package/dist/context/index.d.ts +102 -100
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +252 -6
- package/dist/context/index.js.map +1 -0
- 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 +185 -85
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +257 -14
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrations.d.ts +15 -18
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +82 -1
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/queries.d.ts +503 -281
- package/dist/db/queries.d.ts.map +1 -0
- package/dist/db/queries.js +644 -107
- package/dist/db/queries.js.map +1 -0
- package/dist/db/schema.sql +69 -26
- package/dist/db/sqlite-adapter.d.ts +26 -22
- package/dist/db/sqlite-adapter.d.ts.map +1 -0
- package/dist/db/sqlite-adapter.js +11 -35
- package/dist/db/sqlite-adapter.js.map +1 -0
- package/dist/db/wal-valve.d.ts +106 -0
- package/dist/db/wal-valve.d.ts.map +1 -0
- package/dist/db/wal-valve.js +208 -0
- package/dist/db/wal-valve.js.map +1 -0
- package/dist/directory.d.ts +140 -19
- package/dist/directory.d.ts.map +1 -0
- package/dist/directory.js +568 -35
- package/dist/directory.js.map +1 -0
- package/dist/errors.d.ts +32 -45
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js.map +1 -0
- package/dist/extraction/astro-extractor.d.ts +79 -0
- package/dist/extraction/astro-extractor.d.ts.map +1 -0
- package/dist/extraction/astro-extractor.js +320 -0
- package/dist/extraction/astro-extractor.js.map +1 -0
- package/dist/extraction/cfml-extractor.d.ts +107 -0
- package/dist/extraction/cfml-extractor.d.ts.map +1 -0
- package/dist/extraction/cfml-extractor.js +494 -0
- package/dist/extraction/cfml-extractor.js.map +1 -0
- package/dist/extraction/dfm-extractor.d.ts +17 -17
- package/dist/extraction/dfm-extractor.d.ts.map +1 -0
- package/dist/extraction/dfm-extractor.js.map +1 -0
- package/dist/extraction/extraction-version.d.ts +25 -0
- package/dist/extraction/extraction-version.d.ts.map +1 -0
- package/dist/extraction/extraction-version.js +28 -0
- package/dist/extraction/extraction-version.js.map +1 -0
- package/dist/extraction/function-ref.d.ts +118 -0
- package/dist/extraction/function-ref.d.ts.map +1 -0
- package/dist/extraction/function-ref.js +727 -0
- package/dist/extraction/function-ref.js.map +1 -0
- 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 +83 -0
- package/dist/extraction/generated-detection.js.map +1 -0
- package/dist/extraction/grammars.d.ts +74 -30
- package/dist/extraction/grammars.d.ts.map +1 -0
- package/dist/extraction/grammars.js +289 -15
- package/dist/extraction/grammars.js.map +1 -0
- package/dist/extraction/index.d.ts +193 -109
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/index.js +1485 -362
- package/dist/extraction/index.js.map +1 -0
- package/dist/extraction/languages/arkts.d.ts +3 -0
- package/dist/extraction/languages/arkts.d.ts.map +1 -0
- package/dist/extraction/languages/arkts.js +127 -0
- package/dist/extraction/languages/arkts.js.map +1 -0
- package/dist/extraction/languages/c-cpp.d.ts +110 -4
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
- package/dist/extraction/languages/c-cpp.js +713 -2
- package/dist/extraction/languages/c-cpp.js.map +1 -0
- package/dist/extraction/languages/cfquery.d.ts +12 -0
- package/dist/extraction/languages/cfquery.d.ts.map +1 -0
- package/dist/extraction/languages/cfquery.js +28 -0
- package/dist/extraction/languages/cfquery.js.map +1 -0
- package/dist/extraction/languages/cfscript.d.ts +3 -0
- package/dist/extraction/languages/cfscript.d.ts.map +1 -0
- package/dist/extraction/languages/cfscript.js +73 -0
- package/dist/extraction/languages/cfscript.js.map +1 -0
- package/dist/extraction/languages/cobol.d.ts +33 -0
- package/dist/extraction/languages/cobol.d.ts.map +1 -0
- package/dist/extraction/languages/cobol.js +499 -0
- package/dist/extraction/languages/cobol.js.map +1 -0
- package/dist/extraction/languages/csharp.d.ts +25 -3
- package/dist/extraction/languages/csharp.d.ts.map +1 -0
- package/dist/extraction/languages/csharp.js +106 -3
- package/dist/extraction/languages/csharp.js.map +1 -0
- package/dist/extraction/languages/dart.d.ts +3 -3
- package/dist/extraction/languages/dart.d.ts.map +1 -0
- package/dist/extraction/languages/dart.js +183 -1
- package/dist/extraction/languages/dart.js.map +1 -0
- package/dist/extraction/languages/erlang.d.ts +3 -0
- package/dist/extraction/languages/erlang.d.ts.map +1 -0
- package/dist/extraction/languages/erlang.js +350 -0
- package/dist/extraction/languages/erlang.js.map +1 -0
- package/dist/extraction/languages/go.d.ts +3 -3
- package/dist/extraction/languages/go.d.ts.map +1 -0
- package/dist/extraction/languages/go.js +55 -2
- package/dist/extraction/languages/go.js.map +1 -0
- package/dist/extraction/languages/index.d.ts +4 -4
- package/dist/extraction/languages/index.d.ts.map +1 -0
- package/dist/extraction/languages/index.js +22 -0
- package/dist/extraction/languages/index.js.map +1 -0
- package/dist/extraction/languages/java.d.ts +3 -3
- package/dist/extraction/languages/java.d.ts.map +1 -0
- package/dist/extraction/languages/java.js +252 -1
- package/dist/extraction/languages/java.js.map +1 -0
- package/dist/extraction/languages/javascript.d.ts +3 -3
- package/dist/extraction/languages/javascript.d.ts.map +1 -0
- package/dist/extraction/languages/javascript.js +16 -0
- package/dist/extraction/languages/javascript.js.map +1 -0
- package/dist/extraction/languages/kotlin.d.ts +3 -3
- package/dist/extraction/languages/kotlin.d.ts.map +1 -0
- package/dist/extraction/languages/kotlin.js +126 -0
- package/dist/extraction/languages/kotlin.js.map +1 -0
- package/dist/extraction/languages/lua.d.ts +3 -3
- package/dist/extraction/languages/lua.d.ts.map +1 -0
- package/dist/extraction/languages/lua.js.map +1 -0
- package/dist/extraction/languages/luau.d.ts +3 -3
- package/dist/extraction/languages/luau.d.ts.map +1 -0
- package/dist/extraction/languages/luau.js.map +1 -0
- package/dist/extraction/languages/nix.d.ts +3 -0
- package/dist/extraction/languages/nix.d.ts.map +1 -0
- package/dist/extraction/languages/nix.js +294 -0
- package/dist/extraction/languages/nix.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 +175 -0
- package/dist/extraction/languages/objc.js.map +1 -0
- package/dist/extraction/languages/pascal.d.ts +3 -3
- package/dist/extraction/languages/pascal.d.ts.map +1 -0
- package/dist/extraction/languages/pascal.js +11 -0
- package/dist/extraction/languages/pascal.js.map +1 -0
- package/dist/extraction/languages/php.d.ts +3 -3
- package/dist/extraction/languages/php.d.ts.map +1 -0
- package/dist/extraction/languages/php.js +90 -1
- package/dist/extraction/languages/php.js.map +1 -0
- package/dist/extraction/languages/python.d.ts +3 -3
- package/dist/extraction/languages/python.d.ts.map +1 -0
- package/dist/extraction/languages/python.js.map +1 -0
- package/dist/extraction/languages/r.d.ts +3 -0
- package/dist/extraction/languages/r.d.ts.map +1 -0
- package/dist/extraction/languages/r.js +314 -0
- package/dist/extraction/languages/r.js.map +1 -0
- package/dist/extraction/languages/ruby.d.ts +3 -3
- package/dist/extraction/languages/ruby.d.ts.map +1 -0
- package/dist/extraction/languages/ruby.js +35 -0
- package/dist/extraction/languages/ruby.js.map +1 -0
- package/dist/extraction/languages/rust.d.ts +3 -3
- package/dist/extraction/languages/rust.d.ts.map +1 -0
- package/dist/extraction/languages/rust.js +35 -2
- package/dist/extraction/languages/rust.js.map +1 -0
- package/dist/extraction/languages/scala.d.ts +3 -3
- package/dist/extraction/languages/scala.d.ts.map +1 -0
- package/dist/extraction/languages/scala.js +80 -10
- package/dist/extraction/languages/scala.js.map +1 -0
- package/dist/extraction/languages/solidity.d.ts +3 -0
- package/dist/extraction/languages/solidity.d.ts.map +1 -0
- package/dist/extraction/languages/solidity.js +293 -0
- package/dist/extraction/languages/solidity.js.map +1 -0
- package/dist/extraction/languages/swift.d.ts +3 -3
- package/dist/extraction/languages/swift.d.ts.map +1 -0
- package/dist/extraction/languages/swift.js +61 -0
- package/dist/extraction/languages/swift.js.map +1 -0
- package/dist/extraction/languages/terraform.d.ts +3 -0
- package/dist/extraction/languages/terraform.d.ts.map +1 -0
- package/dist/extraction/languages/terraform.js +641 -0
- package/dist/extraction/languages/terraform.js.map +1 -0
- package/dist/extraction/languages/typescript.d.ts +16 -3
- package/dist/extraction/languages/typescript.d.ts.map +1 -0
- package/dist/extraction/languages/typescript.js +38 -0
- package/dist/extraction/languages/typescript.js.map +1 -0
- package/dist/extraction/languages/vbnet.d.ts +11 -0
- package/dist/extraction/languages/vbnet.d.ts.map +1 -0
- package/dist/extraction/languages/vbnet.js +141 -0
- package/dist/extraction/languages/vbnet.js.map +1 -0
- package/dist/extraction/liquid-extractor.d.ts +48 -41
- package/dist/extraction/liquid-extractor.d.ts.map +1 -0
- package/dist/extraction/liquid-extractor.js +53 -9
- package/dist/extraction/liquid-extractor.js.map +1 -0
- package/dist/extraction/mybatis-extractor.d.ts +68 -0
- package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
- package/dist/extraction/mybatis-extractor.js +300 -0
- package/dist/extraction/mybatis-extractor.js.map +1 -0
- package/dist/extraction/parse-pool.d.ts +152 -0
- package/dist/extraction/parse-pool.d.ts.map +1 -0
- package/dist/extraction/parse-pool.js +387 -0
- package/dist/extraction/parse-pool.js.map +1 -0
- package/dist/extraction/parse-worker.d.ts +2 -2
- package/dist/extraction/parse-worker.d.ts.map +1 -0
- package/dist/extraction/parse-worker.js +13 -3
- package/dist/extraction/parse-worker.js.map +1 -0
- package/dist/extraction/razor-extractor.d.ts +42 -0
- package/dist/extraction/razor-extractor.d.ts.map +1 -0
- package/dist/extraction/razor-extractor.js +285 -0
- package/dist/extraction/razor-extractor.js.map +1 -0
- package/dist/extraction/svelte-extractor.d.ts +42 -42
- package/dist/extraction/svelte-extractor.d.ts.map +1 -0
- package/dist/extraction/svelte-extractor.js +6 -3
- package/dist/extraction/svelte-extractor.js.map +1 -0
- package/dist/extraction/tree-sitter-helpers.d.ts +7 -18
- package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
- package/dist/extraction/tree-sitter-helpers.js +60 -10
- package/dist/extraction/tree-sitter-helpers.js.map +1 -0
- package/dist/extraction/tree-sitter-types.d.ts +224 -157
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
- package/dist/extraction/tree-sitter-types.js.map +1 -0
- package/dist/extraction/tree-sitter.d.ts +689 -221
- package/dist/extraction/tree-sitter.d.ts.map +1 -0
- package/dist/extraction/tree-sitter.js +4193 -117
- package/dist/extraction/tree-sitter.js.map +1 -0
- package/dist/extraction/vue-extractor.d.ts +40 -25
- package/dist/extraction/vue-extractor.d.ts.map +1 -0
- package/dist/extraction/vue-extractor.js +94 -3
- package/dist/extraction/vue-extractor.js.map +1 -0
- package/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
- package/dist/extraction/wasm-runtime-flags.d.ts +6 -14
- package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
- package/dist/extraction/wasm-runtime-flags.js +1 -0
- package/dist/extraction/wasm-runtime-flags.js.map +1 -0
- package/dist/graph/index.d.ts +3 -3
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/queries.d.ts +96 -99
- package/dist/graph/queries.d.ts.map +1 -0
- package/dist/graph/queries.js +13 -40
- package/dist/graph/queries.js.map +1 -0
- package/dist/graph/traversal.d.ts +117 -127
- package/dist/graph/traversal.d.ts.map +1 -0
- package/dist/graph/traversal.js +92 -21
- package/dist/graph/traversal.js.map +1 -0
- package/dist/index.d.ts +615 -481
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +709 -18
- package/dist/index.js.map +1 -0
- package/dist/installer/config-writer.d.ts +13 -14
- package/dist/installer/config-writer.d.ts.map +1 -0
- package/dist/installer/config-writer.js +91 -0
- package/dist/installer/config-writer.js.map +1 -0
- package/dist/installer/index.d.ts +84 -82
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +619 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/installer/instructions-template.d.ts +35 -24
- package/dist/installer/instructions-template.d.ts.map +1 -0
- package/dist/installer/instructions-template.js +53 -0
- package/dist/installer/instructions-template.js.map +1 -0
- 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 +34 -27
- package/dist/installer/targets/claude.d.ts.map +1 -0
- package/dist/installer/targets/claude.js +454 -0
- package/dist/installer/targets/claude.js.map +1 -0
- package/dist/installer/targets/codex.d.ts +3 -3
- package/dist/installer/targets/codex.d.ts.map +1 -0
- package/dist/installer/targets/codex.js +185 -0
- package/dist/installer/targets/codex.js.map +1 -0
- package/dist/installer/targets/cursor.d.ts +3 -3
- package/dist/installer/targets/cursor.d.ts.map +1 -0
- package/dist/installer/targets/cursor.js +254 -0
- package/dist/installer/targets/cursor.js.map +1 -0
- 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 +165 -0
- package/dist/installer/targets/gemini.js.map +1 -0
- package/dist/installer/targets/hermes.d.ts +3 -3
- 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 +12 -4
- package/dist/installer/targets/opencode.d.ts.map +1 -0
- package/dist/installer/targets/opencode.js +288 -0
- package/dist/installer/targets/opencode.js.map +1 -0
- package/dist/installer/targets/registry.d.ts +9 -12
- package/dist/installer/targets/registry.d.ts.map +1 -0
- package/dist/installer/targets/registry.js +91 -0
- package/dist/installer/targets/registry.js.map +1 -0
- package/dist/installer/targets/shared.d.ts +38 -29
- package/dist/installer/targets/shared.d.ts.map +1 -0
- package/dist/installer/targets/shared.js +264 -0
- package/dist/installer/targets/shared.js.map +1 -0
- package/dist/installer/targets/toml.d.ts +11 -23
- package/dist/installer/targets/toml.d.ts.map +1 -0
- package/dist/installer/targets/toml.js +147 -0
- package/dist/installer/targets/toml.js.map +1 -0
- package/dist/installer/targets/types.d.ts +62 -76
- package/dist/installer/targets/types.d.ts.map +1 -0
- package/dist/installer/targets/types.js +16 -0
- package/dist/installer/targets/types.js.map +1 -0
- package/dist/mcp/daemon-manager.d.ts +42 -0
- package/dist/mcp/daemon-manager.d.ts.map +1 -0
- package/dist/mcp/daemon-manager.js +129 -0
- package/dist/mcp/daemon-manager.js.map +1 -0
- package/dist/mcp/daemon-paths.d.ts +73 -0
- package/dist/mcp/daemon-paths.d.ts.map +1 -0
- package/dist/mcp/daemon-paths.js +165 -0
- package/dist/mcp/daemon-paths.js.map +1 -0
- package/dist/mcp/daemon-registry.d.ts +47 -0
- package/dist/mcp/daemon-registry.d.ts.map +1 -0
- package/dist/mcp/daemon-registry.js +233 -0
- package/dist/mcp/daemon-registry.js.map +1 -0
- package/dist/mcp/daemon.d.ts +290 -0
- package/dist/mcp/daemon.d.ts.map +1 -0
- package/dist/mcp/daemon.js +862 -0
- package/dist/mcp/daemon.js.map +1 -0
- package/dist/mcp/dynamic-boundaries.d.ts +41 -0
- package/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
- package/dist/mcp/dynamic-boundaries.js +360 -0
- package/dist/mcp/dynamic-boundaries.js.map +1 -0
- package/dist/mcp/early-ppid.d.ts +26 -0
- package/dist/mcp/early-ppid.d.ts.map +1 -0
- package/dist/mcp/early-ppid.js +29 -0
- package/dist/mcp/early-ppid.js.map +1 -0
- package/dist/mcp/engine.d.ts +122 -0
- package/dist/mcp/engine.d.ts.map +1 -0
- package/dist/mcp/engine.js +350 -0
- package/dist/mcp/engine.js.map +1 -0
- package/dist/mcp/index.d.ts +89 -74
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +506 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/liveness-watchdog.d.ts +35 -0
- package/dist/mcp/liveness-watchdog.d.ts.map +1 -0
- package/dist/mcp/liveness-watchdog.js +267 -0
- package/dist/mcp/liveness-watchdog.js.map +1 -0
- package/dist/mcp/ppid-watchdog.d.ts +62 -0
- package/dist/mcp/ppid-watchdog.d.ts.map +1 -0
- package/dist/mcp/ppid-watchdog.js +64 -0
- package/dist/mcp/ppid-watchdog.js.map +1 -0
- package/dist/mcp/proxy.d.ts +87 -0
- package/dist/mcp/proxy.d.ts.map +1 -0
- package/dist/mcp/proxy.js +667 -0
- package/dist/mcp/proxy.js.map +1 -0
- package/dist/mcp/query-pool.d.ts +108 -0
- package/dist/mcp/query-pool.d.ts.map +1 -0
- package/dist/mcp/query-pool.js +315 -0
- package/dist/mcp/query-pool.js.map +1 -0
- package/dist/mcp/query-worker.d.ts +24 -0
- package/dist/mcp/query-worker.d.ts.map +1 -0
- package/dist/mcp/query-worker.js +87 -0
- package/dist/mcp/query-worker.js.map +1 -0
- package/dist/mcp/server-instructions.d.ts +22 -8
- package/dist/mcp/server-instructions.d.ts.map +1 -0
- package/dist/mcp/server-instructions.js +106 -0
- package/dist/mcp/server-instructions.js.map +1 -0
- package/dist/mcp/session.d.ts +93 -0
- package/dist/mcp/session.d.ts.map +1 -0
- package/dist/mcp/session.js +357 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/startup-handshake.d.ts +44 -0
- package/dist/mcp/startup-handshake.d.ts.map +1 -0
- package/dist/mcp/startup-handshake.js +73 -0
- package/dist/mcp/startup-handshake.js.map +1 -0
- package/dist/mcp/stdin-teardown.d.ts +27 -0
- package/dist/mcp/stdin-teardown.d.ts.map +1 -0
- package/dist/mcp/stdin-teardown.js +49 -0
- package/dist/mcp/stdin-teardown.js.map +1 -0
- package/dist/mcp/tools.d.ts +557 -213
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +4477 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/transport.d.ts +158 -87
- package/dist/mcp/transport.d.ts.map +1 -0
- package/dist/mcp/transport.js +377 -0
- package/dist/mcp/transport.js.map +1 -0
- 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/project-config.d.ts +94 -0
- package/dist/project-config.d.ts.map +1 -0
- package/dist/project-config.js +374 -0
- package/dist/project-config.js.map +1 -0
- package/dist/resolution/c-fnptr-synthesizer.d.ts +6 -0
- package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
- package/dist/resolution/c-fnptr-synthesizer.js +1062 -0
- package/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
- package/dist/resolution/callback-synthesizer.d.ts +15 -0
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
- package/dist/resolution/callback-synthesizer.js +3938 -0
- package/dist/resolution/callback-synthesizer.js.map +1 -0
- package/dist/resolution/cooperative-yield.d.ts +32 -0
- package/dist/resolution/cooperative-yield.d.ts.map +1 -0
- package/dist/resolution/cooperative-yield.js +42 -0
- package/dist/resolution/cooperative-yield.js.map +1 -0
- package/dist/resolution/frameworks/astro.d.ts +9 -0
- package/dist/resolution/frameworks/astro.d.ts.map +1 -0
- package/dist/resolution/frameworks/astro.js +169 -0
- package/dist/resolution/frameworks/astro.js.map +1 -0
- package/dist/resolution/frameworks/cargo-workspace.d.ts +3 -5
- package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
- package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
- package/dist/resolution/frameworks/cics.d.ts +20 -0
- package/dist/resolution/frameworks/cics.d.ts.map +1 -0
- package/dist/resolution/frameworks/cics.js +90 -0
- package/dist/resolution/frameworks/cics.js.map +1 -0
- package/dist/resolution/frameworks/csharp.d.ts +3 -3
- package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
- package/dist/resolution/frameworks/csharp.js +36 -8
- package/dist/resolution/frameworks/csharp.js.map +1 -0
- package/dist/resolution/frameworks/drupal.d.ts +3 -3
- package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
- package/dist/resolution/frameworks/drupal.js +44 -12
- 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 +148 -0
- package/dist/resolution/frameworks/expo-modules.js.map +1 -0
- package/dist/resolution/frameworks/express.d.ts +3 -3
- package/dist/resolution/frameworks/express.d.ts.map +1 -0
- package/dist/resolution/frameworks/express.js +102 -19
- package/dist/resolution/frameworks/express.js.map +1 -0
- 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 +3 -3
- package/dist/resolution/frameworks/go.d.ts.map +1 -0
- package/dist/resolution/frameworks/go.js +6 -3
- package/dist/resolution/frameworks/go.js.map +1 -0
- package/dist/resolution/frameworks/goframe.d.ts +41 -0
- package/dist/resolution/frameworks/goframe.d.ts.map +1 -0
- package/dist/resolution/frameworks/goframe.js +112 -0
- package/dist/resolution/frameworks/goframe.js.map +1 -0
- package/dist/resolution/frameworks/index.d.ts +29 -31
- package/dist/resolution/frameworks/index.d.ts.map +1 -0
- package/dist/resolution/frameworks/index.js +39 -1
- package/dist/resolution/frameworks/index.js.map +1 -0
- package/dist/resolution/frameworks/java.d.ts +3 -3
- package/dist/resolution/frameworks/java.d.ts.map +1 -0
- package/dist/resolution/frameworks/java.js +352 -12
- package/dist/resolution/frameworks/java.js.map +1 -0
- package/dist/resolution/frameworks/laravel.d.ts +4 -4
- package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
- package/dist/resolution/frameworks/laravel.js +17 -8
- package/dist/resolution/frameworks/laravel.js.map +1 -0
- package/dist/resolution/frameworks/nestjs.d.ts +3 -3
- package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
- package/dist/resolution/frameworks/nestjs.js +324 -0
- package/dist/resolution/frameworks/nestjs.js.map +1 -0
- 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 +5 -5
- package/dist/resolution/frameworks/python.d.ts.map +1 -0
- package/dist/resolution/frameworks/python.js +138 -16
- package/dist/resolution/frameworks/python.js.map +1 -0
- 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 +410 -0
- package/dist/resolution/frameworks/react-native.js.map +1 -0
- package/dist/resolution/frameworks/react.d.ts +3 -3
- package/dist/resolution/frameworks/react.d.ts.map +1 -0
- package/dist/resolution/frameworks/react.js +122 -60
- package/dist/resolution/frameworks/react.js.map +1 -0
- package/dist/resolution/frameworks/ruby.d.ts +3 -3
- package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
- package/dist/resolution/frameworks/ruby.js +106 -2
- package/dist/resolution/frameworks/ruby.js.map +1 -0
- package/dist/resolution/frameworks/rust.d.ts +3 -3
- package/dist/resolution/frameworks/rust.d.ts.map +1 -0
- package/dist/resolution/frameworks/rust.js +102 -5
- package/dist/resolution/frameworks/rust.js.map +1 -0
- package/dist/resolution/frameworks/svelte.d.ts +3 -3
- package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
- package/dist/resolution/frameworks/svelte.js +5 -1
- package/dist/resolution/frameworks/svelte.js.map +1 -0
- 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 +5 -5
- package/dist/resolution/frameworks/swift.d.ts.map +1 -0
- package/dist/resolution/frameworks/swift.js +30 -6
- package/dist/resolution/frameworks/swift.js.map +1 -0
- package/dist/resolution/frameworks/terraform.d.ts +38 -0
- package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
- package/dist/resolution/frameworks/terraform.js +277 -0
- package/dist/resolution/frameworks/terraform.js.map +1 -0
- package/dist/resolution/frameworks/vue.d.ts +3 -3
- package/dist/resolution/frameworks/vue.d.ts.map +1 -0
- package/dist/resolution/frameworks/vue.js +24 -27
- package/dist/resolution/frameworks/vue.js.map +1 -0
- 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/goframe-synthesizer.d.ts +29 -0
- package/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
- package/dist/resolution/goframe-synthesizer.js +163 -0
- package/dist/resolution/goframe-synthesizer.js.map +1 -0
- package/dist/resolution/import-resolver.d.ts +53 -29
- package/dist/resolution/import-resolver.d.ts.map +1 -0
- package/dist/resolution/import-resolver.js +1319 -8
- package/dist/resolution/import-resolver.js.map +1 -0
- package/dist/resolution/index.d.ts +243 -103
- package/dist/resolution/index.d.ts.map +1 -0
- package/dist/resolution/index.js +1055 -53
- package/dist/resolution/index.js.map +1 -0
- package/dist/resolution/lru-cache.d.ts +9 -9
- package/dist/resolution/lru-cache.d.ts.map +1 -0
- package/dist/resolution/lru-cache.js.map +1 -0
- package/dist/resolution/name-matcher.d.ts +91 -29
- package/dist/resolution/name-matcher.d.ts.map +1 -0
- package/dist/resolution/name-matcher.js +1478 -32
- package/dist/resolution/name-matcher.js.map +1 -0
- package/dist/resolution/path-aliases.d.ts +23 -27
- package/dist/resolution/path-aliases.d.ts.map +1 -0
- package/dist/resolution/path-aliases.js.map +1 -0
- package/dist/resolution/strip-comments.d.ts +3 -16
- package/dist/resolution/strip-comments.d.ts.map +1 -0
- package/dist/resolution/strip-comments.js +51 -0
- package/dist/resolution/strip-comments.js.map +1 -0
- 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 +217 -136
- package/dist/resolution/types.d.ts.map +1 -0
- package/dist/resolution/types.js.map +1 -0
- package/dist/resolution/workspace-packages.d.ts +58 -0
- package/dist/resolution/workspace-packages.d.ts.map +1 -0
- package/dist/resolution/workspace-packages.js +346 -0
- package/dist/resolution/workspace-packages.js.map +1 -0
- package/dist/search/identifier-segments.d.ts +60 -0
- package/dist/search/identifier-segments.d.ts.map +1 -0
- package/dist/search/identifier-segments.js +176 -0
- package/dist/search/identifier-segments.js.map +1 -0
- package/dist/search/query-parser.d.ts +14 -18
- package/dist/search/query-parser.d.ts.map +1 -0
- package/dist/search/query-parser.js.map +1 -0
- package/dist/search/query-utils.d.ts +45 -17
- package/dist/search/query-utils.d.ts.map +1 -0
- package/dist/search/query-utils.js +113 -47
- package/dist/search/query-utils.js.map +1 -0
- package/dist/sync/git-hooks.d.ts +13 -22
- package/dist/sync/git-hooks.d.ts.map +1 -0
- package/dist/sync/git-hooks.js +4 -0
- package/dist/sync/git-hooks.js.map +1 -0
- package/dist/sync/index.d.ts +6 -12
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +8 -1
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/watch-policy.d.ts +8 -11
- package/dist/sync/watch-policy.d.ts.map +1 -0
- package/dist/sync/watch-policy.js.map +1 -0
- package/dist/sync/watcher.d.ts +335 -63
- package/dist/sync/watcher.d.ts.map +1 -0
- package/dist/sync/watcher.js +709 -53
- package/dist/sync/watcher.js.map +1 -0
- package/dist/sync/worktree.d.ts +63 -0
- package/dist/sync/worktree.d.ts.map +1 -0
- package/dist/sync/worktree.js +182 -0
- package/dist/sync/worktree.js.map +1 -0
- package/dist/telemetry/index.d.ts +143 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +541 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/types.d.ts +308 -326
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/glyphs.d.ts +20 -20
- package/dist/ui/glyphs.d.ts.map +1 -0
- package/dist/ui/glyphs.js +78 -0
- package/dist/ui/glyphs.js.map +1 -0
- package/dist/ui/shimmer-progress.d.ts +7 -7
- package/dist/ui/shimmer-progress.d.ts.map +1 -0
- package/dist/ui/shimmer-progress.js +90 -0
- package/dist/ui/shimmer-progress.js.map +1 -0
- package/dist/ui/shimmer-worker.d.ts +2 -2
- package/dist/ui/shimmer-worker.d.ts.map +1 -0
- package/dist/ui/shimmer-worker.js +118 -0
- package/dist/ui/shimmer-worker.js.map +1 -0
- package/dist/ui/types.d.ts +14 -17
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui/types.js +3 -0
- package/dist/ui/types.js.map +1 -0
- package/dist/upgrade/index.d.ts +164 -0
- package/dist/upgrade/index.d.ts.map +1 -0
- package/dist/upgrade/index.js +646 -0
- package/dist/upgrade/index.js.map +1 -0
- package/dist/upgrade/remove-binary.d.ts +87 -0
- package/dist/upgrade/remove-binary.d.ts.map +1 -0
- package/dist/upgrade/remove-binary.js +289 -0
- package/dist/upgrade/remove-binary.js.map +1 -0
- package/dist/upgrade/update-check.d.ts +92 -0
- package/dist/upgrade/update-check.d.ts.map +1 -0
- package/dist/upgrade/update-check.js +258 -0
- package/dist/upgrade/update-check.js.map +1 -0
- package/dist/utils.d.ts +116 -123
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +83 -49
- package/dist/utils.js.map +1 -0
- package/package.json +42 -10
- 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/ab-adoption.sh +91 -0
- package/scripts/agent-eval/ab-hook.sh +86 -0
- package/scripts/agent-eval/ab-impl.sh +78 -0
- package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -0
- package/scripts/agent-eval/ab-sufficiency.sh +78 -0
- package/scripts/agent-eval/arms-F.sh +21 -0
- package/scripts/agent-eval/arms-matrix.sh +37 -0
- package/scripts/agent-eval/audit.sh +68 -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 +120 -0
- package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
- package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
- package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
- package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
- package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
- package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
- package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
- package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
- package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
- package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
- package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
- package/scripts/agent-eval/offload-eval-setup.sh +24 -0
- package/scripts/agent-eval/offload-eval-styles.sh +72 -0
- package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
- package/scripts/agent-eval/offload-eval.md +76 -0
- package/scripts/agent-eval/parse-arms.mjs +116 -0
- package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
- package/scripts/agent-eval/parse-run.mjs +45 -0
- package/scripts/agent-eval/parse-session.mjs +93 -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/redirect-read-hook.sh +38 -0
- package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
- package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
- package/scripts/agent-eval/run-agent.sh +34 -0
- package/scripts/agent-eval/run-all.sh +75 -0
- package/scripts/agent-eval/run-arms.sh +56 -0
- package/scripts/agent-eval/seq-matrix.mjs +137 -0
- package/scripts/build-bundle.sh +123 -0
- package/scripts/extract-release-notes.mjs +130 -0
- package/scripts/local-install.sh +41 -0
- package/scripts/npm-sdk.js +75 -0
- package/scripts/npm-shim.js +275 -0
- package/scripts/pack-npm.sh +119 -0
- package/scripts/prepare-release.mjs +270 -0
- package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
- package/dist/installer/claude-md-template.d.ts +0 -19
package/dist/index.js
CHANGED
|
@@ -42,9 +42,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
42
42
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
43
43
|
};
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.CodeGraph = exports.MCPServer = exports.FileWatcher = exports.MemoryMonitor = exports.throttle = exports.debounce = exports.processInBatches = exports.FileLock = exports.Mutex = exports.defaultLogger = exports.silentLogger = exports.getLogger = exports.setLogger = exports.ConfigError = exports.VectorError = exports.SearchError = exports.DatabaseError = exports.ParseError = exports.FileError = exports.CodeGraphError = exports.loadAllGrammars = exports.loadGrammarsForLanguages = exports.initGrammars = exports.getSupportedLanguages = exports.isGrammarLoaded = exports.isLanguageSupported = exports.detectLanguage = exports.CODEGRAPH_DIR = exports.findNearestCodeGraphRoot = exports.isInitialized = exports.getCodeGraphDir = exports.getDatabasePath = void 0;
|
|
45
|
+
exports.CodeGraph = exports.MCPServer = exports.LockUnavailableError = exports.FileWatcher = exports.MemoryMonitor = exports.throttle = exports.debounce = exports.processInBatches = exports.FileLock = exports.Mutex = exports.defaultLogger = exports.silentLogger = exports.getLogger = exports.setLogger = exports.ConfigError = exports.VectorError = exports.SearchError = exports.DatabaseError = exports.ParseError = exports.FileError = exports.CodeGraphError = exports.loadAllGrammars = exports.loadGrammarsForLanguages = exports.initGrammars = exports.getSupportedLanguages = exports.isGrammarLoaded = exports.isLanguageSupported = exports.detectLanguage = exports.CODEGRAPH_DIR = exports.findNearestCodeGraphRoot = exports.isInitialized = exports.getCodeGraphDir = exports.QueryBuilder = exports.DatabaseConnection = exports.getDatabasePath = void 0;
|
|
46
46
|
const path = __importStar(require("path"));
|
|
47
47
|
const db_1 = require("./db");
|
|
48
|
+
const wal_valve_1 = require("./db/wal-valve");
|
|
48
49
|
const queries_1 = require("./db/queries");
|
|
49
50
|
const directory_1 = require("./directory");
|
|
50
51
|
const extraction_1 = require("./extraction");
|
|
@@ -53,15 +54,28 @@ const graph_1 = require("./graph");
|
|
|
53
54
|
const context_1 = require("./context");
|
|
54
55
|
const utils_1 = require("./utils");
|
|
55
56
|
const sync_1 = require("./sync");
|
|
57
|
+
const extraction_version_1 = require("./extraction/extraction-version");
|
|
58
|
+
const directory_2 = require("./directory");
|
|
59
|
+
const query_utils_1 = require("./search/query-utils");
|
|
60
|
+
const version_1 = require("./mcp/version");
|
|
61
|
+
const identifier_segments_1 = require("./search/identifier-segments");
|
|
62
|
+
const cooperative_yield_1 = require("./resolution/cooperative-yield");
|
|
56
63
|
// Re-export types for consumers
|
|
57
64
|
__exportStar(require("./types"), exports);
|
|
65
|
+
// Storage building blocks for embedded/SDK consumers that drive the graph
|
|
66
|
+
// directly (open a DB, run prepared queries) rather than through the CodeGraph
|
|
67
|
+
// facade. Exposed from the package entry so they no longer require deep imports
|
|
68
|
+
// into dist/ (issue #354).
|
|
58
69
|
var db_2 = require("./db");
|
|
59
70
|
Object.defineProperty(exports, "getDatabasePath", { enumerable: true, get: function () { return db_2.getDatabasePath; } });
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
Object.defineProperty(exports, "
|
|
63
|
-
|
|
64
|
-
Object.defineProperty(exports, "
|
|
71
|
+
Object.defineProperty(exports, "DatabaseConnection", { enumerable: true, get: function () { return db_2.DatabaseConnection; } });
|
|
72
|
+
var queries_2 = require("./db/queries");
|
|
73
|
+
Object.defineProperty(exports, "QueryBuilder", { enumerable: true, get: function () { return queries_2.QueryBuilder; } });
|
|
74
|
+
var directory_3 = require("./directory");
|
|
75
|
+
Object.defineProperty(exports, "getCodeGraphDir", { enumerable: true, get: function () { return directory_3.getCodeGraphDir; } });
|
|
76
|
+
Object.defineProperty(exports, "isInitialized", { enumerable: true, get: function () { return directory_3.isInitialized; } });
|
|
77
|
+
Object.defineProperty(exports, "findNearestCodeGraphRoot", { enumerable: true, get: function () { return directory_3.findNearestCodeGraphRoot; } });
|
|
78
|
+
Object.defineProperty(exports, "CODEGRAPH_DIR", { enumerable: true, get: function () { return directory_3.CODEGRAPH_DIR; } });
|
|
65
79
|
var extraction_2 = require("./extraction");
|
|
66
80
|
Object.defineProperty(exports, "detectLanguage", { enumerable: true, get: function () { return extraction_2.detectLanguage; } });
|
|
67
81
|
Object.defineProperty(exports, "isLanguageSupported", { enumerable: true, get: function () { return extraction_2.isLanguageSupported; } });
|
|
@@ -91,6 +105,9 @@ Object.defineProperty(exports, "throttle", { enumerable: true, get: function ()
|
|
|
91
105
|
Object.defineProperty(exports, "MemoryMonitor", { enumerable: true, get: function () { return utils_2.MemoryMonitor; } });
|
|
92
106
|
var sync_2 = require("./sync");
|
|
93
107
|
Object.defineProperty(exports, "FileWatcher", { enumerable: true, get: function () { return sync_2.FileWatcher; } });
|
|
108
|
+
Object.defineProperty(exports, "LockUnavailableError", { enumerable: true, get: function () { return sync_2.LockUnavailableError; } });
|
|
109
|
+
var mcp_1 = require("./mcp");
|
|
110
|
+
Object.defineProperty(exports, "MCPServer", { enumerable: true, get: function () { return mcp_1.MCPServer; } });
|
|
94
111
|
/**
|
|
95
112
|
* Main CodeGraph class
|
|
96
113
|
*
|
|
@@ -100,6 +117,9 @@ class CodeGraph {
|
|
|
100
117
|
db;
|
|
101
118
|
queries;
|
|
102
119
|
projectRoot;
|
|
120
|
+
// Assigned via wireLayers() from the constructor (and again on reopen) — the
|
|
121
|
+
// `!` tells TS these are definitely set even though the assignment is one
|
|
122
|
+
// method call away from the constructor body.
|
|
103
123
|
orchestrator;
|
|
104
124
|
resolver;
|
|
105
125
|
graphManager;
|
|
@@ -115,12 +135,63 @@ class CodeGraph {
|
|
|
115
135
|
this.db = db;
|
|
116
136
|
this.queries = queries;
|
|
117
137
|
this.projectRoot = projectRoot;
|
|
118
|
-
this.fileLock = new utils_1.FileLock(path.join(
|
|
119
|
-
this.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
this.fileLock = new utils_1.FileLock(path.join((0, directory_2.getCodeGraphDir)(projectRoot), 'codegraph.lock'));
|
|
139
|
+
this.wireLayers();
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* (Re)build the query/extraction/graph layers over the current `this.queries`
|
|
143
|
+
* (which wraps `this.db`). Factored out of the constructor so `reopenIfReplaced`
|
|
144
|
+
* can rebuild them against a fresh connection without duplicating the wiring.
|
|
145
|
+
* The path-based `fileLock` is independent of the DB handle, so it stays put.
|
|
146
|
+
*/
|
|
147
|
+
wireLayers() {
|
|
148
|
+
// Down-weight the project name as a query term in search ranking — it names
|
|
149
|
+
// the whole repo, not a symbol, so it has no discriminative value (#720).
|
|
150
|
+
try {
|
|
151
|
+
this.queries.setProjectNameTokens((0, query_utils_1.deriveProjectNameTokens)(this.projectRoot));
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
// Best-effort: ranking still works without it.
|
|
155
|
+
}
|
|
156
|
+
this.orchestrator = new extraction_1.ExtractionOrchestrator(this.projectRoot, this.queries);
|
|
157
|
+
this.resolver = (0, resolution_1.createResolver)(this.projectRoot, this.queries);
|
|
158
|
+
this.graphManager = new graph_1.GraphQueryManager(this.queries);
|
|
159
|
+
this.traverser = new graph_1.GraphTraverser(this.queries);
|
|
160
|
+
this.contextBuilder = (0, context_1.createContextBuilder)(this.projectRoot, this.queries, this.traverser);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Heal a stale database handle in place. If `.codegraph/` was removed and
|
|
164
|
+
* recreated at the SAME path while this instance held the DB open — a git
|
|
165
|
+
* worktree removed and re-added, or `rm -rf .codegraph` + `codegraph init` —
|
|
166
|
+
* our open fd points at the now-unlinked inode and can never see the new
|
|
167
|
+
* index, so every query returns the pre-removal snapshot until the process
|
|
168
|
+
* restarts (#925). When that's detected, open the live file at the same path,
|
|
169
|
+
* rebuild the query layers, and swap them IN PLACE, so every holder of this
|
|
170
|
+
* instance (the MCP daemon's default project, cached projectPath connections)
|
|
171
|
+
* heals without a restart. Returns true iff it reopened.
|
|
172
|
+
*
|
|
173
|
+
* POSIX-only in practice: `isReplacedOnDisk` never fires on Windows (an open
|
|
174
|
+
* file can't be unlinked there, and st_ino is unreliable).
|
|
175
|
+
*/
|
|
176
|
+
reopenIfReplaced() {
|
|
177
|
+
if (!this.db.isReplacedOnDisk())
|
|
178
|
+
return false;
|
|
179
|
+
const dbPath = this.db.getPath();
|
|
180
|
+
// Open the live file FIRST — if that throws (e.g. mid-recreate), the old
|
|
181
|
+
// handle stays in place and the caller retries on the next query, rather
|
|
182
|
+
// than leaving this instance with no connection at all.
|
|
183
|
+
const fresh = db_1.DatabaseConnection.open(dbPath);
|
|
184
|
+
const stale = this.db;
|
|
185
|
+
this.db = fresh;
|
|
186
|
+
this.queries = new queries_1.QueryBuilder(fresh.getDb());
|
|
187
|
+
this.wireLayers();
|
|
188
|
+
// Releasing the dead handle also frees the leaked db/-wal/-shm fds that were
|
|
189
|
+
// pinning the unlinked inode (#925).
|
|
190
|
+
try {
|
|
191
|
+
stale.close();
|
|
192
|
+
}
|
|
193
|
+
catch { /* the old inode is gone; closing just frees fds */ }
|
|
194
|
+
return true;
|
|
124
195
|
}
|
|
125
196
|
// ===========================================================================
|
|
126
197
|
// Lifecycle Methods
|
|
@@ -201,6 +272,48 @@ class CodeGraph {
|
|
|
201
272
|
}
|
|
202
273
|
return instance;
|
|
203
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Rebuild the project's database from scratch and return a fresh, empty
|
|
277
|
+
* instance — the "same result as a fresh init" semantics that `codegraph
|
|
278
|
+
* index` documents.
|
|
279
|
+
*
|
|
280
|
+
* Unlike `open()` followed by `clear()`, this DISCARDS the existing
|
|
281
|
+
* `.codegraph/codegraph.db` (and its `-wal`/`-shm` sidecars) before
|
|
282
|
+
* re-initializing, instead of opening the old database and DELETE-ing every
|
|
283
|
+
* row. On a large or pre-fix poisoned index — e.g. an old graph that scanned
|
|
284
|
+
* an ignored gitlink corpus (#1065) into ~1.6M nodes with a multi-GB WAL —
|
|
285
|
+
* the per-row `nodes_fts` delete-trigger churn blocks the main thread long
|
|
286
|
+
* enough to trip the #850 liveness watchdog before indexing even starts, so a
|
|
287
|
+
* full re-index could never recover the bad state (#1067). Discarding the
|
|
288
|
+
* files is O(1) regardless of size, reclaims the disk, and sidesteps opening
|
|
289
|
+
* (and running migrations against) the poisoned database entirely.
|
|
290
|
+
*/
|
|
291
|
+
static async recreate(projectRoot) {
|
|
292
|
+
await (0, extraction_1.initGrammars)();
|
|
293
|
+
const resolvedRoot = path.resolve(projectRoot);
|
|
294
|
+
// Check if initialized — recreate REBUILDS an existing project; it is not a
|
|
295
|
+
// first-time `init`.
|
|
296
|
+
if (!(0, directory_1.isInitialized)(resolvedRoot)) {
|
|
297
|
+
throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`);
|
|
298
|
+
}
|
|
299
|
+
const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
|
|
300
|
+
try {
|
|
301
|
+
(0, db_1.removeDatabaseFiles)(dbPath);
|
|
302
|
+
}
|
|
303
|
+
catch (err) {
|
|
304
|
+
// POSIX unlinks an open file fine; this fires mainly on Windows when a
|
|
305
|
+
// live daemon/MCP server still holds the database. Turn the raw EBUSY into
|
|
306
|
+
// an actionable instruction instead of a generic failure.
|
|
307
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
308
|
+
throw new Error(`Could not rebuild the index — the database file is in use (${reason}). ` +
|
|
309
|
+
`Stop any running CodeGraph MCP server/daemon for this project and retry, ` +
|
|
310
|
+
`or remove the ${(0, directory_2.getCodeGraphDir)(resolvedRoot)} directory and run "codegraph init".`);
|
|
311
|
+
}
|
|
312
|
+
// Re-create an empty, freshly-schema'd database at the same path.
|
|
313
|
+
const db = db_1.DatabaseConnection.initialize(dbPath);
|
|
314
|
+
const queries = new queries_1.QueryBuilder(db.getDb());
|
|
315
|
+
return new CodeGraph(db, queries, resolvedRoot);
|
|
316
|
+
}
|
|
204
317
|
/**
|
|
205
318
|
* Open synchronously (without sync)
|
|
206
319
|
*/
|
|
@@ -258,8 +371,62 @@ class CodeGraph {
|
|
|
258
371
|
catch {
|
|
259
372
|
return { success: false, filesIndexed: 0, filesSkipped: 0, filesErrored: 0, nodesCreated: 0, edgesCreated: 0, errors: [{ message: 'Could not acquire file lock - another process may be indexing', severity: 'error' }], durationMs: 0 };
|
|
260
373
|
}
|
|
374
|
+
// Defer WAL auto-checkpointing for the whole bulk run (#1231): the
|
|
375
|
+
// default 1000-page interval re-writes hot pages into the main DB file
|
|
376
|
+
// over and over — ~95% of all disk I/O during a bulk index, and a
|
|
377
|
+
// 19+min → 45s difference on HDD-class storage. The valve bounds WAL
|
|
378
|
+
// growth by backfilling PASSIVEly on a worker thread (never blocking
|
|
379
|
+
// the writer or the #850 watchdog heartbeat); runMaintenance below does
|
|
380
|
+
// the final fold-up before the interval is restored in the finally.
|
|
381
|
+
// Kill switch: CODEGRAPH_NO_WAL_DEFER=1. Non-WAL journal modes (some
|
|
382
|
+
// network filesystems) have no WAL to defer — skip.
|
|
383
|
+
const deferWal = process.env.CODEGRAPH_NO_WAL_DEFER !== '1' && this.db.getJournalMode() === 'wal';
|
|
384
|
+
let walValve = null;
|
|
385
|
+
let priorAutocheckpoint = 1000;
|
|
386
|
+
if (deferWal) {
|
|
387
|
+
priorAutocheckpoint = this.db.getWalAutocheckpoint();
|
|
388
|
+
this.db.setWalAutocheckpoint(0);
|
|
389
|
+
walValve = new wal_valve_1.WalCheckpointValve(this.db, undefined, undefined, options.verbose ? (m) => console.log(`[wal-valve] ${m}`) : undefined);
|
|
390
|
+
walValve.start();
|
|
391
|
+
}
|
|
261
392
|
try {
|
|
262
|
-
const
|
|
393
|
+
const before = this.queries.getNodeAndEdgeCount();
|
|
394
|
+
// Mark the index as in-flight BEFORE any writes: a run killed
|
|
395
|
+
// mid-index (OOM, SIGKILL, the #850 liveness watchdog) leaves this
|
|
396
|
+
// marker behind, so `codegraph status` can tell a truncated index
|
|
397
|
+
// from a completed one instead of silently serving partial results.
|
|
398
|
+
try {
|
|
399
|
+
this.queries.setMetadata('index_state', 'indexing');
|
|
400
|
+
}
|
|
401
|
+
catch { /* metadata is advisory */ }
|
|
402
|
+
// Segment vocabulary starts empty and is repopulated by the node write
|
|
403
|
+
// path as every file (re-)indexes below — so a full index is also the
|
|
404
|
+
// orphan-cleanup pass for names deleted since the last one.
|
|
405
|
+
try {
|
|
406
|
+
this.queries.clearNameSegmentVocab();
|
|
407
|
+
}
|
|
408
|
+
catch { /* vocab is advisory — never fail an index over it */ }
|
|
409
|
+
const result = await this.orchestrator.indexAll(options.onProgress, options.signal, options.verbose, walValve ? () => walValve.backpressure() : undefined);
|
|
410
|
+
// Fold the parse phase's WAL BEFORE the first post-parse reads
|
|
411
|
+
// (resolver re-init and resolution both read on the main thread):
|
|
412
|
+
// paging a bulk-write-sized WAL there is what blew the #850
|
|
413
|
+
// watchdog's 60s window in the #1231 repro. Off-thread + awaited,
|
|
414
|
+
// so the event loop keeps turning.
|
|
415
|
+
if (walValve)
|
|
416
|
+
await walValve.foldNow();
|
|
417
|
+
// Re-detect frameworks now that the index is populated. The resolver
|
|
418
|
+
// is constructed with createResolver() before any files exist, so
|
|
419
|
+
// framework resolvers whose detect() consults the indexed file list
|
|
420
|
+
// (e.g. UIKit/SwiftUI scanning for imports, swift-objc-bridge looking
|
|
421
|
+
// for both Swift and ObjC files) all return false on that initial pass
|
|
422
|
+
// and silently drop themselves. Re-initializing here gives them a
|
|
423
|
+
// chance to see the actual project before resolution runs.
|
|
424
|
+
if (result.success && result.filesIndexed > 0) {
|
|
425
|
+
this.resolver.initialize();
|
|
426
|
+
// Cross-file finalization (e.g. NestJS RouterModule prefixes). Runs
|
|
427
|
+
// before resolution so updated names show up in subsequent reads.
|
|
428
|
+
this.resolver.runPostExtract();
|
|
429
|
+
}
|
|
263
430
|
// Resolve references to create call/import/extends edges
|
|
264
431
|
if (result.success && result.filesIndexed > 0) {
|
|
265
432
|
// Get count without loading all refs into memory
|
|
@@ -276,15 +443,112 @@ class CodeGraph {
|
|
|
276
443
|
total,
|
|
277
444
|
});
|
|
278
445
|
});
|
|
446
|
+
// Second pass: chained calls whose method lives on a supertype the
|
|
447
|
+
// receiver conforms to (protocol-extension / inherited / default-
|
|
448
|
+
// interface). Needs the implements/extends edges the main pass just
|
|
449
|
+
// built, so it runs after resolution (#750).
|
|
450
|
+
const tChained = Date.now();
|
|
451
|
+
await this.resolver.resolveChainedCallsViaConformance();
|
|
452
|
+
if (process.env.CODEGRAPH_SYNTH_TIMINGS)
|
|
453
|
+
console.error(`[synth-timing] chainedConformance: ${Date.now() - tChained}ms`);
|
|
454
|
+
// Same lifecycle for `this.<member>` callback registrations whose
|
|
455
|
+
// member is inherited from a supertype (#808).
|
|
456
|
+
const tDeferred = Date.now();
|
|
457
|
+
await this.resolver.resolveDeferredThisMemberRefs();
|
|
458
|
+
if (process.env.CODEGRAPH_SYNTH_TIMINGS)
|
|
459
|
+
console.error(`[synth-timing] deferredThisMember: ${Date.now() - tDeferred}ms`);
|
|
279
460
|
}
|
|
280
461
|
// Refresh planner stats + checkpoint the WAL after bulk writes.
|
|
281
|
-
//
|
|
462
|
+
// Off-thread (worker connection): on a multi-GB index this is minutes
|
|
463
|
+
// of IO, and inline it starved the #850 watchdog AFTER a fully
|
|
464
|
+
// successful index. Never load-bearing for correctness.
|
|
465
|
+
if (result.success && result.filesIndexed > 0) {
|
|
466
|
+
const tMaint = Date.now();
|
|
467
|
+
// Quiesce the valve first so its in-flight checkpoint and the
|
|
468
|
+
// maintenance checkpoint don't contend for the checkpointer lock
|
|
469
|
+
// (the loser would silently no-op and leave the WAL unfolded).
|
|
470
|
+
if (walValve) {
|
|
471
|
+
walValve.stop();
|
|
472
|
+
await walValve.drain();
|
|
473
|
+
}
|
|
474
|
+
await this.db.runMaintenance();
|
|
475
|
+
if (process.env.CODEGRAPH_SYNTH_TIMINGS)
|
|
476
|
+
console.error(`[phase-timing] maintenance: ${Date.now() - tMaint}ms`);
|
|
477
|
+
}
|
|
478
|
+
// The orchestrator only sees extraction-phase counts; resolution and
|
|
479
|
+
// synthesizer edges (often >50% of the graph on JVM repos) come later.
|
|
480
|
+
// Recompute against the DB so the CLI summary reports the true totals.
|
|
282
481
|
if (result.success && result.filesIndexed > 0) {
|
|
283
|
-
|
|
482
|
+
const tCount = Date.now();
|
|
483
|
+
const after = this.queries.getNodeAndEdgeCount();
|
|
484
|
+
if (process.env.CODEGRAPH_SYNTH_TIMINGS)
|
|
485
|
+
console.error(`[phase-timing] count-recompute: ${Date.now() - tCount}ms`);
|
|
486
|
+
result.nodesCreated = after.nodes - before.nodes;
|
|
487
|
+
result.edgesCreated = after.edges - before.edges;
|
|
488
|
+
}
|
|
489
|
+
// Stamp the index with the engine that built it, so `codegraph status`
|
|
490
|
+
// and `codegraph upgrade` can recommend a re-index when the running
|
|
491
|
+
// engine produces richer extraction than the one on disk. Only on a
|
|
492
|
+
// real full index — a sync touches a subset, so it must NOT advance the
|
|
493
|
+
// extraction stamp (the bulk would still be stale). See extraction-version.ts.
|
|
494
|
+
if (result.success && result.filesIndexed > 0) {
|
|
495
|
+
try {
|
|
496
|
+
this.queries.setMetadata('indexed_with_version', version_1.CodeGraphPackageVersion);
|
|
497
|
+
this.queries.setMetadata('indexed_with_extraction_version', String(extraction_version_1.EXTRACTION_VERSION));
|
|
498
|
+
}
|
|
499
|
+
catch { /* metadata is advisory — never fail an index over it */ }
|
|
500
|
+
}
|
|
501
|
+
// Reconcile the scan's ground truth against what the pipeline
|
|
502
|
+
// accounted for. A shortfall means files were silently dropped
|
|
503
|
+
// (observed in the wild: a run under heavy load came up 37 files
|
|
504
|
+
// short with no error) — record it and tell the user, don't let the
|
|
505
|
+
// index pass as complete.
|
|
506
|
+
try {
|
|
507
|
+
if (!result.success) {
|
|
508
|
+
this.queries.setMetadata('index_state', 'failed');
|
|
509
|
+
}
|
|
510
|
+
else {
|
|
511
|
+
const accounted = result.filesIndexed + result.filesSkipped + result.filesErrored;
|
|
512
|
+
const discovered = result.filesDiscovered;
|
|
513
|
+
const shortfall = discovered !== undefined ? discovered - accounted : 0;
|
|
514
|
+
if (discovered !== undefined && shortfall > 0) {
|
|
515
|
+
this.queries.setMetadata('index_state', 'partial');
|
|
516
|
+
this.queries.setMetadata('index_files_discovered', String(discovered));
|
|
517
|
+
this.queries.setMetadata('index_files_accounted', String(accounted));
|
|
518
|
+
result.errors.push({
|
|
519
|
+
message: `Index is missing ${shortfall} of ${discovered} discovered files (indexed ${result.filesIndexed}, skipped ${result.filesSkipped}, errored ${result.filesErrored}). The index is PARTIAL — re-run \`codegraph index\`.`,
|
|
520
|
+
severity: 'warning',
|
|
521
|
+
code: 'index_partial',
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
this.queries.setMetadata('index_state', 'complete');
|
|
526
|
+
if (discovered !== undefined) {
|
|
527
|
+
this.queries.setMetadata('index_files_discovered', String(discovered));
|
|
528
|
+
this.queries.setMetadata('index_files_accounted', String(accounted));
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
284
532
|
}
|
|
533
|
+
catch { /* metadata is advisory — never fail an index over it */ }
|
|
285
534
|
return result;
|
|
286
535
|
}
|
|
287
536
|
finally {
|
|
537
|
+
// Restore the auto-checkpoint interval AFTER the fold-up above so the
|
|
538
|
+
// next ordinary write doesn't inherit a giant inline checkpoint. On
|
|
539
|
+
// the error path the WAL may still be large; correctness is unchanged
|
|
540
|
+
// (SQLite replays the WAL on the next open) and the follow-up write
|
|
541
|
+
// that folds it is the known cost of a failed run.
|
|
542
|
+
if (walValve) {
|
|
543
|
+
walValve.stop();
|
|
544
|
+
await walValve.drain();
|
|
545
|
+
}
|
|
546
|
+
if (deferWal) {
|
|
547
|
+
try {
|
|
548
|
+
this.db.setWalAutocheckpoint(priorAutocheckpoint);
|
|
549
|
+
}
|
|
550
|
+
catch { /* connection may be closing */ }
|
|
551
|
+
}
|
|
288
552
|
this.fileLock.release();
|
|
289
553
|
}
|
|
290
554
|
});
|
|
@@ -324,12 +588,45 @@ class CodeGraph {
|
|
|
324
588
|
return { filesChecked: 0, filesAdded: 0, filesModified: 0, filesRemoved: 0, nodesUpdated: 0, durationMs: 0 };
|
|
325
589
|
}
|
|
326
590
|
try {
|
|
591
|
+
// Captured BEFORE the sync runs: the sync's own incremental writes
|
|
592
|
+
// populate vocab rows for the files it touches, so an end-of-sync
|
|
593
|
+
// emptiness check would see "non-empty" and skip the backfill forever,
|
|
594
|
+
// leaving every unchanged file's names unsegmented.
|
|
595
|
+
const vocabWasEmpty = (() => {
|
|
596
|
+
try {
|
|
597
|
+
return this.queries.isNameSegmentVocabEmpty();
|
|
598
|
+
}
|
|
599
|
+
catch {
|
|
600
|
+
return false;
|
|
601
|
+
}
|
|
602
|
+
})();
|
|
327
603
|
const result = await this.orchestrator.sync(options.onProgress);
|
|
328
|
-
//
|
|
604
|
+
// Cross-file finalization (e.g. NestJS RouterModule prefixes). Run on
|
|
605
|
+
// every sync that touched files so edits to `app.module.ts` propagate
|
|
606
|
+
// to controllers in unchanged files. The pass is idempotent and cheap
|
|
607
|
+
// (regex over *.module.ts only).
|
|
329
608
|
if (result.filesAdded > 0 || result.filesModified > 0) {
|
|
609
|
+
this.resolver.runPostExtract();
|
|
610
|
+
}
|
|
611
|
+
else if (result.filesRemoved > 0) {
|
|
612
|
+
// A pure-removal sync still resolves refs below — the deletion path
|
|
613
|
+
// resurrects the removed file's incoming edges as pending refs
|
|
614
|
+
// (#1240 removal case) and the orphan sweep consumes them. In a
|
|
615
|
+
// long-lived process (daemon) the resolver's name caches were
|
|
616
|
+
// warmed against the pre-removal graph; drop them so resolution
|
|
617
|
+
// sees the post-removal state. (runPostExtract above clears caches
|
|
618
|
+
// itself, so the changed-files branch is already covered.)
|
|
619
|
+
this.resolver.clearCaches();
|
|
620
|
+
}
|
|
621
|
+
// Resolve references if files were updated
|
|
622
|
+
const filesChanged = result.filesAdded > 0 || result.filesModified > 0;
|
|
623
|
+
if (filesChanged) {
|
|
330
624
|
if (result.changedFilePaths) {
|
|
331
625
|
// Scope resolution to changed files (git fast path — bounded set)
|
|
626
|
+
const tRefLoad = Date.now();
|
|
332
627
|
const unresolvedRefs = this.queries.getUnresolvedReferencesByFiles(result.changedFilePaths);
|
|
628
|
+
if (process.env.CODEGRAPH_SYNTH_TIMINGS)
|
|
629
|
+
console.error(`[phase-timing] sync-ref-load: ${Date.now() - tRefLoad}ms (${unresolvedRefs.length} refs)`);
|
|
333
630
|
options.onProgress?.({
|
|
334
631
|
phase: 'resolving',
|
|
335
632
|
current: 0,
|
|
@@ -342,6 +639,32 @@ class CodeGraph {
|
|
|
342
639
|
total,
|
|
343
640
|
});
|
|
344
641
|
});
|
|
642
|
+
// Retry previously-failed refs the changed files may now satisfy
|
|
643
|
+
// (#1240). Scoped resolution above only re-resolves refs FROM the
|
|
644
|
+
// changed files — but when a changed file gains an export/symbol,
|
|
645
|
+
// refs in UNCHANGED files that failed against the old graph can
|
|
646
|
+
// now resolve, and nothing else ever revisits them (their rows
|
|
647
|
+
// were parked as status='failed' by an earlier completed pass).
|
|
648
|
+
// Look them up by the symbol names the changed files now carry
|
|
649
|
+
// and re-resolve just that set. On a sync where no failed ref
|
|
650
|
+
// matches, this is one indexed lookup.
|
|
651
|
+
const tRetry = Date.now();
|
|
652
|
+
const retryable = this.queries.getRetryableFailedReferences(this.queries.getNodeNamesByFiles(result.changedFilePaths));
|
|
653
|
+
if (retryable.length > 0) {
|
|
654
|
+
options.onProgress?.({
|
|
655
|
+
phase: 'resolving',
|
|
656
|
+
current: 0,
|
|
657
|
+
total: retryable.length,
|
|
658
|
+
});
|
|
659
|
+
await this.resolver.resolveAndPersistListYielding(retryable);
|
|
660
|
+
options.onProgress?.({
|
|
661
|
+
phase: 'resolving',
|
|
662
|
+
current: retryable.length,
|
|
663
|
+
total: retryable.length,
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
if (process.env.CODEGRAPH_SYNTH_TIMINGS)
|
|
667
|
+
console.error(`[phase-timing] sync-failed-ref-retry: ${Date.now() - tRetry}ms (${retryable.length} refs)`);
|
|
345
668
|
}
|
|
346
669
|
else {
|
|
347
670
|
// No git info — use batched resolution to avoid OOM
|
|
@@ -360,10 +683,60 @@ class CodeGraph {
|
|
|
360
683
|
});
|
|
361
684
|
}
|
|
362
685
|
}
|
|
686
|
+
// Orphan sweep (#1187). A resolution pass that dies mid-run — the #850
|
|
687
|
+
// daemon liveness watchdog's SIGKILL (#1122), Ctrl-C, a crash — leaves
|
|
688
|
+
// the refs it never reached in unresolved_refs, and the git-scoped fast
|
|
689
|
+
// path above never revisits them (it reads only the changed files'
|
|
690
|
+
// rows). Those files' call edges were then missing PERMANENTLY, with
|
|
691
|
+
// nothing to see except a too-small blast radius, until a full
|
|
692
|
+
// re-index. A completed pass takes every row it processed out of the
|
|
693
|
+
// PENDING set (resolved rows are deleted, unresolvable ones parked as
|
|
694
|
+
// status='failed' for the #1240 retry above), so any pending row now
|
|
695
|
+
// is such an orphan — or a row from an older engine's scoped pass.
|
|
696
|
+
// Grind them down with the batched resolver; this also makes a bare
|
|
697
|
+
// `codegraph sync` the recovery command for a wedged index. On a
|
|
698
|
+
// healthy index this is one COUNT query.
|
|
699
|
+
const orphanCount = this.queries.getUnresolvedReferencesCount();
|
|
700
|
+
if (orphanCount > 0) {
|
|
701
|
+
options.onProgress?.({
|
|
702
|
+
phase: 'resolving',
|
|
703
|
+
current: 0,
|
|
704
|
+
total: orphanCount,
|
|
705
|
+
});
|
|
706
|
+
await this.resolveReferencesBatched((current, total) => {
|
|
707
|
+
options.onProgress?.({
|
|
708
|
+
phase: 'resolving',
|
|
709
|
+
current,
|
|
710
|
+
total,
|
|
711
|
+
});
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
if (filesChanged || orphanCount > 0) {
|
|
715
|
+
// Second pass: chained calls whose method lives on a supertype the
|
|
716
|
+
// receiver conforms to (protocol-extension / inherited). Needs the
|
|
717
|
+
// implements/extends edges built above (#750).
|
|
718
|
+
await this.resolver.resolveChainedCallsViaConformance();
|
|
719
|
+
// Same lifecycle for `this.<member>` callback registrations whose
|
|
720
|
+
// member is inherited from a supertype (#808).
|
|
721
|
+
await this.resolver.resolveDeferredThisMemberRefs();
|
|
722
|
+
}
|
|
363
723
|
// Refresh planner stats + checkpoint the WAL after bulk writes.
|
|
364
|
-
|
|
365
|
-
|
|
724
|
+
// Off-thread — see indexAll's call site.
|
|
725
|
+
if (filesChanged || result.filesRemoved > 0 || orphanCount > 0) {
|
|
726
|
+
await this.db.runMaintenance();
|
|
366
727
|
}
|
|
728
|
+
// Heal the segment vocabulary on indexes built before the table
|
|
729
|
+
// existed (upgrade path): incremental writes above only cover changed
|
|
730
|
+
// files, so a vocab that was empty when this sync STARTED means the
|
|
731
|
+
// bulk was never segmented — backfill it (INSERT OR IGNORE, so the
|
|
732
|
+
// rows the sync just wrote are fine). Batched + yielding — sync can
|
|
733
|
+
// run on the daemon's liveness-watchdog thread (#850/#1091).
|
|
734
|
+
try {
|
|
735
|
+
if (vocabWasEmpty && this.queries.getNodeAndEdgeCount().nodes > 0) {
|
|
736
|
+
await this.rebuildNameSegmentVocab();
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
catch { /* vocab is advisory — never fail a sync over it */ }
|
|
367
740
|
return result;
|
|
368
741
|
}
|
|
369
742
|
finally {
|
|
@@ -394,6 +767,14 @@ class CodeGraph {
|
|
|
394
767
|
return true;
|
|
395
768
|
this.watcher = new sync_1.FileWatcher(this.projectRoot, async () => {
|
|
396
769
|
const result = await this.sync();
|
|
770
|
+
// sync() returns this exact zero-shape iff it failed to acquire the
|
|
771
|
+
// file lock (a real empty sync always has filesChecked > 0 because
|
|
772
|
+
// scanDirectory ran). Surface that to the watcher as a typed error
|
|
773
|
+
// so it keeps pendingFiles + reschedules instead of clearing them
|
|
774
|
+
// (#449).
|
|
775
|
+
if (result.filesChecked === 0 && result.durationMs === 0) {
|
|
776
|
+
throw new sync_1.LockUnavailableError();
|
|
777
|
+
}
|
|
397
778
|
const filesChanged = result.filesAdded + result.filesModified + result.filesRemoved;
|
|
398
779
|
return { filesChanged, durationMs: result.durationMs };
|
|
399
780
|
}, options);
|
|
@@ -414,12 +795,98 @@ class CodeGraph {
|
|
|
414
795
|
isWatching() {
|
|
415
796
|
return this.watcher?.isActive() ?? false;
|
|
416
797
|
}
|
|
798
|
+
/**
|
|
799
|
+
* True once live watching has permanently degraded (OS watch-resource
|
|
800
|
+
* exhaustion, or a write lock held past the retry budget) and auto-sync is
|
|
801
|
+
* disabled until the next {@link watch} call. Distinct from `!isWatching()`:
|
|
802
|
+
* a stopped/never-started watcher is inactive but NOT degraded. MCP tools use
|
|
803
|
+
* this to surface a whole-index "results may be stale" notice, since
|
|
804
|
+
* `getPendingFiles()` goes empty once watching stops (#876).
|
|
805
|
+
*/
|
|
806
|
+
isWatcherDegraded() {
|
|
807
|
+
return this.watcher?.isDegraded() ?? false;
|
|
808
|
+
}
|
|
809
|
+
/** The reason live watching degraded, or null if it is healthy (#876). */
|
|
810
|
+
getWatcherDegradedReason() {
|
|
811
|
+
return this.watcher?.getDegradedReason() ?? null;
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Files seen by the file watcher since the last successful sync —
|
|
815
|
+
* the per-file "stale" signal MCP tools attach to responses so an agent
|
|
816
|
+
* can fall back to {@link Read} for just the affected file without
|
|
817
|
+
* waiting for a debounced sync to complete (issue #403).
|
|
818
|
+
*
|
|
819
|
+
* Returns an empty list when the watcher isn't active, or no events have
|
|
820
|
+
* arrived. Each entry includes `firstSeenMs` and `lastSeenMs` (wall-clock
|
|
821
|
+
* `Date.now()` values) so callers can render "edited Nms ago", plus an
|
|
822
|
+
* `indexing` flag indicating whether the in-flight sync (if any) will
|
|
823
|
+
* absorb that file.
|
|
824
|
+
*/
|
|
825
|
+
getPendingFiles() {
|
|
826
|
+
return this.watcher?.getPendingFiles() ?? [];
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Resolves once the file watcher has installed its watch set. Useful for
|
|
830
|
+
* tests that need a deterministic boundary before asserting on
|
|
831
|
+
* `getPendingFiles()`. Resolves immediately when no watcher is active.
|
|
832
|
+
*/
|
|
833
|
+
waitUntilWatcherReady(timeoutMs) {
|
|
834
|
+
return this.watcher ? this.watcher.waitUntilReady(timeoutMs) : Promise.resolve();
|
|
835
|
+
}
|
|
417
836
|
/**
|
|
418
837
|
* Get files that have changed since last index
|
|
419
838
|
*/
|
|
420
839
|
getChangedFiles() {
|
|
421
840
|
return this.orchestrator.getChangedFiles();
|
|
422
841
|
}
|
|
842
|
+
/**
|
|
843
|
+
* Most recent index timestamp (ms since epoch) across all tracked files, or
|
|
844
|
+
* null when nothing is indexed yet. Lets library consumers check index
|
|
845
|
+
* freshness without shelling out to `codegraph status --json`. (#329)
|
|
846
|
+
*/
|
|
847
|
+
getLastIndexedAt() {
|
|
848
|
+
return this.queries.getLastIndexedAt();
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Completeness of the last full index run. `'complete'` is the only good
|
|
852
|
+
* state. `'indexing'` after the fact means a run was killed mid-index (OOM,
|
|
853
|
+
* SIGKILL, liveness watchdog) and the on-disk index is truncated;
|
|
854
|
+
* `'partial'` means the run finished but silently dropped files
|
|
855
|
+
* (discovered > indexed+skipped+errored); `'failed'` means it reported
|
|
856
|
+
* failure. `null` = index predates this marker. Surfaced by
|
|
857
|
+
* `codegraph status`.
|
|
858
|
+
*/
|
|
859
|
+
getIndexState() {
|
|
860
|
+
const raw = this.queries.getMetadata('index_state');
|
|
861
|
+
return raw === 'indexing' || raw === 'complete' || raw === 'partial' || raw === 'failed'
|
|
862
|
+
? raw
|
|
863
|
+
: null;
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* Which engine built the current index: the package version + extraction
|
|
867
|
+
* version stamped at the last full `indexAll`. Either field is null for an
|
|
868
|
+
* index built before stamping existed (treated as stale). See
|
|
869
|
+
* `extraction-version.ts` and `isIndexStale()`.
|
|
870
|
+
*/
|
|
871
|
+
getIndexBuildInfo() {
|
|
872
|
+
const version = this.queries.getMetadata('indexed_with_version');
|
|
873
|
+
const ev = this.queries.getMetadata('indexed_with_extraction_version');
|
|
874
|
+
const parsed = ev != null ? parseInt(ev, 10) : NaN;
|
|
875
|
+
return { version, extractionVersion: Number.isFinite(parsed) ? parsed : null };
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* True when the on-disk index was built by an engine whose extraction is
|
|
879
|
+
* older than the one now running — i.e. a re-index would add data a migration
|
|
880
|
+
* can't backfill. False when there's no index yet (nothing to refresh) or the
|
|
881
|
+
* stamp is current. This is the signal behind `codegraph status`'s re-index
|
|
882
|
+
* hint and `codegraph upgrade`'s reminder.
|
|
883
|
+
*/
|
|
884
|
+
isIndexStale() {
|
|
885
|
+
if (this.queries.getLastIndexedAt() == null)
|
|
886
|
+
return false;
|
|
887
|
+
const { extractionVersion } = this.getIndexBuildInfo();
|
|
888
|
+
return extractionVersion == null || extractionVersion < extraction_version_1.EXTRACTION_VERSION;
|
|
889
|
+
}
|
|
423
890
|
/**
|
|
424
891
|
* Extract nodes and edges from source code (without storing)
|
|
425
892
|
*/
|
|
@@ -450,6 +917,16 @@ class CodeGraph {
|
|
|
450
917
|
async resolveReferencesBatched(onProgress) {
|
|
451
918
|
return this.resolver.resolveAndPersistBatched(onProgress);
|
|
452
919
|
}
|
|
920
|
+
/**
|
|
921
|
+
* References extracted but never attempted by a resolution pass. Zero on a
|
|
922
|
+
* healthy index — a completed pass consumes every pending row (resolving it
|
|
923
|
+
* or parking it as failed, #1240). Non-zero at rest means a pass was
|
|
924
|
+
* interrupted mid-run (killed indexer, crash — #1187), so some files' call
|
|
925
|
+
* edges are missing; the next `sync` sweeps them.
|
|
926
|
+
*/
|
|
927
|
+
getPendingReferenceCount() {
|
|
928
|
+
return this.queries.getUnresolvedReferencesCount();
|
|
929
|
+
}
|
|
453
930
|
/**
|
|
454
931
|
* Get detected frameworks in the project
|
|
455
932
|
*/
|
|
@@ -511,12 +988,226 @@ class CodeGraph {
|
|
|
511
988
|
getNodesByKind(kind) {
|
|
512
989
|
return this.queries.getNodesByKind(kind);
|
|
513
990
|
}
|
|
991
|
+
/**
|
|
992
|
+
* Get ALL nodes with an exact name (direct index lookup, not FTS-ranked/capped).
|
|
993
|
+
* Used to enumerate every overload of a heavily-overloaded name so the specific
|
|
994
|
+
* definition the caller wants is never dropped below a search cut.
|
|
995
|
+
*/
|
|
996
|
+
getNodesByName(name) {
|
|
997
|
+
return this.queries.getNodesByName(name);
|
|
998
|
+
}
|
|
999
|
+
/** Nodes whose name starts with `prefix` (index range scan, capped). */
|
|
1000
|
+
getNodesByNamePrefix(prefix, limit = 20) {
|
|
1001
|
+
return this.queries.getNodesByNamePrefix(prefix, limit);
|
|
1002
|
+
}
|
|
514
1003
|
/**
|
|
515
1004
|
* Search nodes by text
|
|
516
1005
|
*/
|
|
517
1006
|
searchNodes(query, options) {
|
|
518
1007
|
return this.queries.searchNodes(query, options);
|
|
519
1008
|
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Graph-derived prompt matching for the front-load hook's MEDIUM tier:
|
|
1011
|
+
* which indexed symbols do these prose words name? "state machine des
|
|
1012
|
+
* commandes" → `OrderStateMachine`, in any human language whose technical
|
|
1013
|
+
* nouns are Latin script — no keyword list involved.
|
|
1014
|
+
*
|
|
1015
|
+
* Precision comes from the repo's own naming statistics, not vocabulary:
|
|
1016
|
+
* - CO-OCCURRENCE: ≥2 words that are segments of the SAME name ("state" +
|
|
1017
|
+
* "machine" → OrderStateMachine) is strong evidence and always qualifies.
|
|
1018
|
+
* - RARITY: a single matched word qualifies only when its segment is
|
|
1019
|
+
* discriminative here (≤ {@link SEGMENT_RARITY_CEILING} distinct names) —
|
|
1020
|
+
* "checkout" in a shop backend yes, "state" in a react app no.
|
|
1021
|
+
* Every candidate is re-verified against `nodes` before being returned
|
|
1022
|
+
* (vocab rows are proposals; deletions leave orphans by design), so a
|
|
1023
|
+
* returned symbol is guaranteed to exist right now.
|
|
1024
|
+
*/
|
|
1025
|
+
getSegmentMatches(words, limit = 6) {
|
|
1026
|
+
if (words.length === 0)
|
|
1027
|
+
return [];
|
|
1028
|
+
// Variant → original word (plural folding), for coverage accounting.
|
|
1029
|
+
const variantToWord = new Map();
|
|
1030
|
+
for (const word of words) {
|
|
1031
|
+
for (const variant of (0, identifier_segments_1.segmentLookupVariants)(word)) {
|
|
1032
|
+
if (!variantToWord.has(variant))
|
|
1033
|
+
variantToWord.set(variant, word);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
const variants = [...variantToWord.keys()];
|
|
1037
|
+
// Tier A: co-occurrence. The SQL folds variants back to their original
|
|
1038
|
+
// word (#1146), so minWords=2 means two distinct PROMPT WORDS — a name
|
|
1039
|
+
// matching both `service` and `services` can't tie with (or crowd past
|
|
1040
|
+
// the LIMIT) a genuine two-word match. The JS re-check below recomputes
|
|
1041
|
+
// the fold from live segments as the honesty layer.
|
|
1042
|
+
const variantPairs = [...variantToWord.entries()].map(([segment, word]) => ({ segment, word }));
|
|
1043
|
+
const candidates = [];
|
|
1044
|
+
for (const hit of this.queries.getSegmentCoOccurrence(variantPairs, 2, 24)) {
|
|
1045
|
+
const matched = this.wordsMatchingName(hit.name, variantToWord);
|
|
1046
|
+
if (matched.size >= 2)
|
|
1047
|
+
candidates.push({ name: hit.name, matchedWords: matched });
|
|
1048
|
+
}
|
|
1049
|
+
// Tier B: single rare word. Only when co-occurrence found nothing — a
|
|
1050
|
+
// co-occurring name is categorically stronger evidence — and under
|
|
1051
|
+
// stricter rules, because one word is thin: the word must be ≥5 chars
|
|
1052
|
+
// (measured FPs: "this", "typo"); the segment must appear in AT LEAST TWO
|
|
1053
|
+
// names (a concept the codebase is about clusters across names —
|
|
1054
|
+
// CheckoutService/CheckoutController — while a prose coincidence is a
|
|
1055
|
+
// singleton: measured FP "deploy to PRODUCTION" → the one name
|
|
1056
|
+
// matchesNonProductionDir); and the candidate name must have ≥2 segments
|
|
1057
|
+
// (a bare common verb matching a bare function name — "write" → `write` —
|
|
1058
|
+
// is prose coincidence, not the user naming a symbol).
|
|
1059
|
+
if (candidates.length === 0) {
|
|
1060
|
+
const singleWordVariants = variants.filter((v) => variantToWord.get(v).length >= 5);
|
|
1061
|
+
const counts = this.queries.getSegmentNameCounts(singleWordVariants);
|
|
1062
|
+
const rare = [...counts.entries()]
|
|
1063
|
+
.filter(([, n]) => n >= 2 && n <= CodeGraph.SEGMENT_RARITY_CEILING)
|
|
1064
|
+
.sort((a, b) => a[1] - b[1])
|
|
1065
|
+
.slice(0, 2);
|
|
1066
|
+
for (const [variant] of rare) {
|
|
1067
|
+
const word = variantToWord.get(variant);
|
|
1068
|
+
for (const name of this.queries.getNamesForSegment(variant, 12)) {
|
|
1069
|
+
if ((0, identifier_segments_1.splitIdentifierSegments)(name).length < 2)
|
|
1070
|
+
continue;
|
|
1071
|
+
candidates.push({ name, matchedWords: new Set([word]) });
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
// Verify against nodes (the honesty gate) and pick a representative
|
|
1076
|
+
// definition per name. A name whose only nodes are file/import kind has
|
|
1077
|
+
// no real definition to point at — surfacing the import statement instead
|
|
1078
|
+
// reads as a matched symbol but isn't one (#1144) — so it's skipped, the
|
|
1079
|
+
// same way an orphaned vocab row is. (Import names no longer enter the
|
|
1080
|
+
// vocab at write time, but rows written before that exclusion persist
|
|
1081
|
+
// until the next full index.)
|
|
1082
|
+
const out = [];
|
|
1083
|
+
const seen = new Set();
|
|
1084
|
+
candidates.sort((a, b) => b.matchedWords.size - a.matchedWords.size || a.name.length - b.name.length);
|
|
1085
|
+
for (const candidate of candidates) {
|
|
1086
|
+
if (out.length >= limit)
|
|
1087
|
+
break;
|
|
1088
|
+
if (seen.has(candidate.name))
|
|
1089
|
+
continue;
|
|
1090
|
+
seen.add(candidate.name);
|
|
1091
|
+
const nodes = this.queries.getNodesByName(candidate.name);
|
|
1092
|
+
if (nodes.length === 0)
|
|
1093
|
+
continue; // orphaned vocab row — name no longer exists
|
|
1094
|
+
const rep = nodes.find((n) => n.kind !== 'file' && n.kind !== 'import');
|
|
1095
|
+
if (!rep)
|
|
1096
|
+
continue; // no real definition — don't surface an import/file as one
|
|
1097
|
+
out.push({
|
|
1098
|
+
name: candidate.name,
|
|
1099
|
+
kind: rep.kind,
|
|
1100
|
+
filePath: rep.filePath,
|
|
1101
|
+
startLine: rep.startLine ?? 0,
|
|
1102
|
+
matchedWords: [...candidate.matchedWords].sort(),
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
return out;
|
|
1106
|
+
}
|
|
1107
|
+
/** A single word ("state") can match hundreds of names in a big repo — that
|
|
1108
|
+
* is noise, not signal. Ceiling for the single-word tier; co-occurrence is
|
|
1109
|
+
* exempt because two words on one name is already discriminative. */
|
|
1110
|
+
static SEGMENT_RARITY_CEILING = 25;
|
|
1111
|
+
/** Which of the prompt's original words match `name`'s segments (via
|
|
1112
|
+
* variants). Segments are recomputed in JS — a name-keyed vocab lookup
|
|
1113
|
+
* would scan the (segment, name) primary key. */
|
|
1114
|
+
wordsMatchingName(name, variantToWord) {
|
|
1115
|
+
const segments = new Set((0, identifier_segments_1.splitIdentifierSegments)(name));
|
|
1116
|
+
const matched = new Set();
|
|
1117
|
+
for (const [variant, word] of variantToWord) {
|
|
1118
|
+
if (segments.has(variant))
|
|
1119
|
+
matched.add(word);
|
|
1120
|
+
}
|
|
1121
|
+
return matched;
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* One-shot upgrade heal for callers that open the graph WITHOUT syncing —
|
|
1125
|
+
* concretely the prompt hook, whose MEDIUM tier reads the segment
|
|
1126
|
+
* vocabulary: a database migrated from before the vocab table existed
|
|
1127
|
+
* starts with it empty, and the only other backfill lives inside `sync()`,
|
|
1128
|
+
* which such callers never run (#1142). Returns true when the vocab is
|
|
1129
|
+
* usable (already populated — the overwhelmingly common one-SELECT case —
|
|
1130
|
+
* or healed here); false when it isn't (empty graph, or another process
|
|
1131
|
+
* holds the index lock — that process's own sync heals it).
|
|
1132
|
+
*/
|
|
1133
|
+
async healSegmentVocabIfEmpty() {
|
|
1134
|
+
const empty = (() => {
|
|
1135
|
+
try {
|
|
1136
|
+
return this.queries.isNameSegmentVocabEmpty();
|
|
1137
|
+
}
|
|
1138
|
+
catch {
|
|
1139
|
+
return false;
|
|
1140
|
+
}
|
|
1141
|
+
})();
|
|
1142
|
+
if (!empty)
|
|
1143
|
+
return true;
|
|
1144
|
+
if (this.queries.getNodeAndEdgeCount().nodes === 0)
|
|
1145
|
+
return false;
|
|
1146
|
+
return this.indexMutex.withLock(async () => {
|
|
1147
|
+
try {
|
|
1148
|
+
this.fileLock.acquire();
|
|
1149
|
+
}
|
|
1150
|
+
catch {
|
|
1151
|
+
return false; // an index/sync is running — it backfills the vocab itself
|
|
1152
|
+
}
|
|
1153
|
+
try {
|
|
1154
|
+
if (!this.queries.isNameSegmentVocabEmpty())
|
|
1155
|
+
return true; // raced: healed meanwhile
|
|
1156
|
+
await this.rebuildNameSegmentVocab();
|
|
1157
|
+
return true;
|
|
1158
|
+
}
|
|
1159
|
+
finally {
|
|
1160
|
+
this.fileLock.release();
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
/**
|
|
1165
|
+
* Rebuild the segment vocabulary from the current graph, batched and
|
|
1166
|
+
* yielding — the upgrade-heal path for indexes built before the vocab table
|
|
1167
|
+
* existed. Runs inside the index mutex/lock (sync and
|
|
1168
|
+
* healSegmentVocabIfEmpty hold them).
|
|
1169
|
+
*/
|
|
1170
|
+
async rebuildNameSegmentVocab() {
|
|
1171
|
+
const maybeYield = (0, cooperative_yield_1.createYielder)();
|
|
1172
|
+
const BATCH = 2000;
|
|
1173
|
+
for (let offset = 0;; offset += BATCH) {
|
|
1174
|
+
const names = this.queries.getDistinctNodeNames(BATCH, offset);
|
|
1175
|
+
if (names.length === 0)
|
|
1176
|
+
break;
|
|
1177
|
+
this.queries.insertNameSegmentsBatch(names);
|
|
1178
|
+
await maybeYield();
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Normalized project-name tokens (go.mod / package.json / repo dir) used to
|
|
1183
|
+
* down-weight the non-discriminative project name in search ranking (#720).
|
|
1184
|
+
* Exposed so explore can exclude it from the PascalCase type-disambiguation
|
|
1185
|
+
* bias, which would otherwise pull overloaded tokens toward whichever stack
|
|
1186
|
+
* embeds the project name.
|
|
1187
|
+
*/
|
|
1188
|
+
getProjectNameTokens() {
|
|
1189
|
+
return this.queries.getProjectNameTokens();
|
|
1190
|
+
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Find the project's "primary route file" — the file with the densest
|
|
1193
|
+
* concentration of framework-emitted `route` nodes (≥3 routes, ≥30%
|
|
1194
|
+
* of all non-test routes). Used to inline the routing config in
|
|
1195
|
+
* `codegraph_explore` responses on small realworld template repos
|
|
1196
|
+
* (rails-realworld, laravel-realworld, drupal-admintoolbar, …) where
|
|
1197
|
+
* Glob+Read of `routes.rb`/`urls.py`/etc. otherwise beats codegraph.
|
|
1198
|
+
*/
|
|
1199
|
+
getTopRouteFile() {
|
|
1200
|
+
return this.queries.getTopRouteFile();
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Build a URL → handler routing manifest from the index. Each entry
|
|
1204
|
+
* pairs a route node (URL + method) with its handler function/method
|
|
1205
|
+
* via the `references` edge that framework resolvers emit. Returns
|
|
1206
|
+
* null when fewer than 3 valid (non-test) routes exist.
|
|
1207
|
+
*/
|
|
1208
|
+
getRoutingManifest(limit) {
|
|
1209
|
+
return this.queries.getRoutingManifest(limit);
|
|
1210
|
+
}
|
|
520
1211
|
// ===========================================================================
|
|
521
1212
|
// Edge Operations
|
|
522
1213
|
// ===========================================================================
|