@bharanidev/bhgraph-win32-arm64 1.0.0
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/bin/bhgraph.cmd +1 -0
- package/lib/dist/bin/bhgraph.d.ts +26 -0
- package/lib/dist/bin/bhgraph.d.ts.map +1 -0
- package/lib/dist/bin/bhgraph.js +2207 -0
- package/lib/dist/bin/bhgraph.js.map +1 -0
- package/lib/dist/bin/command-supervision.d.ts +12 -0
- package/lib/dist/bin/command-supervision.d.ts.map +1 -0
- package/lib/dist/bin/command-supervision.js +89 -0
- package/lib/dist/bin/command-supervision.js.map +1 -0
- package/lib/dist/bin/fatal-handler.d.ts +20 -0
- package/lib/dist/bin/fatal-handler.d.ts.map +1 -0
- package/lib/dist/bin/fatal-handler.js +118 -0
- package/lib/dist/bin/fatal-handler.js.map +1 -0
- package/lib/dist/bin/node-version-check.d.ts +37 -0
- package/lib/dist/bin/node-version-check.d.ts.map +1 -0
- package/lib/dist/bin/node-version-check.js +79 -0
- package/lib/dist/bin/node-version-check.js.map +1 -0
- package/lib/dist/bin/uninstall.d.ts +14 -0
- package/lib/dist/bin/uninstall.d.ts.map +1 -0
- package/lib/dist/bin/uninstall.js +36 -0
- package/lib/dist/bin/uninstall.js.map +1 -0
- package/lib/dist/context/formatter.d.ts +30 -0
- package/lib/dist/context/formatter.d.ts.map +1 -0
- package/lib/dist/context/formatter.js +263 -0
- package/lib/dist/context/formatter.js.map +1 -0
- package/lib/dist/context/index.d.ts +119 -0
- package/lib/dist/context/index.d.ts.map +1 -0
- package/lib/dist/context/index.js +1296 -0
- package/lib/dist/context/index.js.map +1 -0
- package/lib/dist/context/markers.d.ts +19 -0
- package/lib/dist/context/markers.d.ts.map +1 -0
- package/lib/dist/context/markers.js +22 -0
- package/lib/dist/context/markers.js.map +1 -0
- package/lib/dist/db/index.d.ts +142 -0
- package/lib/dist/db/index.d.ts.map +1 -0
- package/lib/dist/db/index.js +335 -0
- package/lib/dist/db/index.js.map +1 -0
- package/lib/dist/db/migrations.d.ts +44 -0
- package/lib/dist/db/migrations.d.ts.map +1 -0
- package/lib/dist/db/migrations.js +182 -0
- package/lib/dist/db/migrations.js.map +1 -0
- package/lib/dist/db/queries.d.ts +452 -0
- package/lib/dist/db/queries.d.ts.map +1 -0
- package/lib/dist/db/queries.js +1740 -0
- package/lib/dist/db/queries.js.map +1 -0
- package/lib/dist/db/schema.sql +182 -0
- package/lib/dist/db/sqlite-adapter.d.ts +53 -0
- package/lib/dist/db/sqlite-adapter.d.ts.map +1 -0
- package/lib/dist/db/sqlite-adapter.js +117 -0
- package/lib/dist/db/sqlite-adapter.js.map +1 -0
- package/lib/dist/directory.d.ts +183 -0
- package/lib/dist/directory.d.ts.map +1 -0
- package/lib/dist/directory.js +797 -0
- package/lib/dist/directory.js.map +1 -0
- package/lib/dist/errors.d.ts +136 -0
- package/lib/dist/errors.d.ts.map +1 -0
- package/lib/dist/errors.js +219 -0
- package/lib/dist/errors.js.map +1 -0
- package/lib/dist/extraction/astro-extractor.d.ts +79 -0
- package/lib/dist/extraction/astro-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/astro-extractor.js +320 -0
- package/lib/dist/extraction/astro-extractor.js.map +1 -0
- package/lib/dist/extraction/cfml-extractor.d.ts +107 -0
- package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/cfml-extractor.js +494 -0
- package/lib/dist/extraction/cfml-extractor.js.map +1 -0
- package/lib/dist/extraction/dfm-extractor.d.ts +31 -0
- package/lib/dist/extraction/dfm-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/dfm-extractor.js +151 -0
- package/lib/dist/extraction/dfm-extractor.js.map +1 -0
- package/lib/dist/extraction/extraction-version.d.ts +25 -0
- package/lib/dist/extraction/extraction-version.d.ts.map +1 -0
- package/lib/dist/extraction/extraction-version.js +28 -0
- package/lib/dist/extraction/extraction-version.js.map +1 -0
- package/lib/dist/extraction/function-ref.d.ts +118 -0
- package/lib/dist/extraction/function-ref.d.ts.map +1 -0
- package/lib/dist/extraction/function-ref.js +727 -0
- package/lib/dist/extraction/function-ref.js.map +1 -0
- package/lib/dist/extraction/generated-detection.d.ts +30 -0
- package/lib/dist/extraction/generated-detection.d.ts.map +1 -0
- package/lib/dist/extraction/generated-detection.js +83 -0
- package/lib/dist/extraction/generated-detection.js.map +1 -0
- package/lib/dist/extraction/grammars.d.ts +123 -0
- package/lib/dist/extraction/grammars.d.ts.map +1 -0
- package/lib/dist/extraction/grammars.js +589 -0
- package/lib/dist/extraction/grammars.js.map +1 -0
- package/lib/dist/extraction/index.d.ts +232 -0
- package/lib/dist/extraction/index.d.ts.map +1 -0
- package/lib/dist/extraction/index.js +2269 -0
- package/lib/dist/extraction/index.js.map +1 -0
- package/lib/dist/extraction/languages/arkts.d.ts +3 -0
- package/lib/dist/extraction/languages/arkts.d.ts.map +1 -0
- package/lib/dist/extraction/languages/arkts.js +127 -0
- package/lib/dist/extraction/languages/arkts.js.map +1 -0
- package/lib/dist/extraction/languages/c-cpp.d.ts +110 -0
- package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -0
- package/lib/dist/extraction/languages/c-cpp.js +837 -0
- package/lib/dist/extraction/languages/c-cpp.js.map +1 -0
- package/lib/dist/extraction/languages/cfquery.d.ts +12 -0
- package/lib/dist/extraction/languages/cfquery.d.ts.map +1 -0
- package/lib/dist/extraction/languages/cfquery.js +28 -0
- package/lib/dist/extraction/languages/cfquery.js.map +1 -0
- package/lib/dist/extraction/languages/cfscript.d.ts +3 -0
- package/lib/dist/extraction/languages/cfscript.d.ts.map +1 -0
- package/lib/dist/extraction/languages/cfscript.js +73 -0
- package/lib/dist/extraction/languages/cfscript.js.map +1 -0
- package/lib/dist/extraction/languages/cobol.d.ts +33 -0
- package/lib/dist/extraction/languages/cobol.d.ts.map +1 -0
- package/lib/dist/extraction/languages/cobol.js +499 -0
- package/lib/dist/extraction/languages/cobol.js.map +1 -0
- package/lib/dist/extraction/languages/csharp.d.ts +25 -0
- package/lib/dist/extraction/languages/csharp.d.ts.map +1 -0
- package/lib/dist/extraction/languages/csharp.js +175 -0
- package/lib/dist/extraction/languages/csharp.js.map +1 -0
- package/lib/dist/extraction/languages/dart.d.ts +3 -0
- package/lib/dist/extraction/languages/dart.d.ts.map +1 -0
- package/lib/dist/extraction/languages/dart.js +374 -0
- package/lib/dist/extraction/languages/dart.js.map +1 -0
- package/lib/dist/extraction/languages/erlang.d.ts +3 -0
- package/lib/dist/extraction/languages/erlang.d.ts.map +1 -0
- package/lib/dist/extraction/languages/erlang.js +350 -0
- package/lib/dist/extraction/languages/erlang.js.map +1 -0
- package/lib/dist/extraction/languages/go.d.ts +3 -0
- package/lib/dist/extraction/languages/go.d.ts.map +1 -0
- package/lib/dist/extraction/languages/go.js +111 -0
- package/lib/dist/extraction/languages/go.js.map +1 -0
- package/lib/dist/extraction/languages/index.d.ts +10 -0
- package/lib/dist/extraction/languages/index.d.ts.map +1 -0
- package/lib/dist/extraction/languages/index.js +71 -0
- package/lib/dist/extraction/languages/index.js.map +1 -0
- package/lib/dist/extraction/languages/java.d.ts +3 -0
- package/lib/dist/extraction/languages/java.d.ts.map +1 -0
- package/lib/dist/extraction/languages/java.js +315 -0
- package/lib/dist/extraction/languages/java.js.map +1 -0
- package/lib/dist/extraction/languages/javascript.d.ts +3 -0
- package/lib/dist/extraction/languages/javascript.d.ts.map +1 -0
- package/lib/dist/extraction/languages/javascript.js +106 -0
- package/lib/dist/extraction/languages/javascript.js.map +1 -0
- package/lib/dist/extraction/languages/kotlin.d.ts +3 -0
- package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -0
- package/lib/dist/extraction/languages/kotlin.js +379 -0
- package/lib/dist/extraction/languages/kotlin.js.map +1 -0
- package/lib/dist/extraction/languages/lua.d.ts +3 -0
- package/lib/dist/extraction/languages/lua.d.ts.map +1 -0
- package/lib/dist/extraction/languages/lua.js +150 -0
- package/lib/dist/extraction/languages/lua.js.map +1 -0
- package/lib/dist/extraction/languages/luau.d.ts +3 -0
- package/lib/dist/extraction/languages/luau.d.ts.map +1 -0
- package/lib/dist/extraction/languages/luau.js +37 -0
- package/lib/dist/extraction/languages/luau.js.map +1 -0
- package/lib/dist/extraction/languages/nix.d.ts +3 -0
- package/lib/dist/extraction/languages/nix.d.ts.map +1 -0
- package/lib/dist/extraction/languages/nix.js +294 -0
- package/lib/dist/extraction/languages/nix.js.map +1 -0
- package/lib/dist/extraction/languages/objc.d.ts +3 -0
- package/lib/dist/extraction/languages/objc.d.ts.map +1 -0
- package/lib/dist/extraction/languages/objc.js +175 -0
- package/lib/dist/extraction/languages/objc.js.map +1 -0
- package/lib/dist/extraction/languages/pascal.d.ts +3 -0
- package/lib/dist/extraction/languages/pascal.d.ts.map +1 -0
- package/lib/dist/extraction/languages/pascal.js +77 -0
- package/lib/dist/extraction/languages/pascal.js.map +1 -0
- package/lib/dist/extraction/languages/php.d.ts +3 -0
- package/lib/dist/extraction/languages/php.d.ts.map +1 -0
- package/lib/dist/extraction/languages/php.js +196 -0
- package/lib/dist/extraction/languages/php.js.map +1 -0
- package/lib/dist/extraction/languages/python.d.ts +3 -0
- package/lib/dist/extraction/languages/python.d.ts.map +1 -0
- package/lib/dist/extraction/languages/python.js +56 -0
- package/lib/dist/extraction/languages/python.js.map +1 -0
- package/lib/dist/extraction/languages/r.d.ts +3 -0
- package/lib/dist/extraction/languages/r.d.ts.map +1 -0
- package/lib/dist/extraction/languages/r.js +314 -0
- package/lib/dist/extraction/languages/r.js.map +1 -0
- package/lib/dist/extraction/languages/ruby.d.ts +3 -0
- package/lib/dist/extraction/languages/ruby.d.ts.map +1 -0
- package/lib/dist/extraction/languages/ruby.js +149 -0
- package/lib/dist/extraction/languages/ruby.js.map +1 -0
- package/lib/dist/extraction/languages/rust.d.ts +3 -0
- package/lib/dist/extraction/languages/rust.d.ts.map +1 -0
- package/lib/dist/extraction/languages/rust.js +142 -0
- package/lib/dist/extraction/languages/rust.js.map +1 -0
- package/lib/dist/extraction/languages/scala.d.ts +3 -0
- package/lib/dist/extraction/languages/scala.d.ts.map +1 -0
- package/lib/dist/extraction/languages/scala.js +209 -0
- package/lib/dist/extraction/languages/scala.js.map +1 -0
- package/lib/dist/extraction/languages/solidity.d.ts +3 -0
- package/lib/dist/extraction/languages/solidity.d.ts.map +1 -0
- package/lib/dist/extraction/languages/solidity.js +293 -0
- package/lib/dist/extraction/languages/solidity.js.map +1 -0
- package/lib/dist/extraction/languages/swift.d.ts +3 -0
- package/lib/dist/extraction/languages/swift.d.ts.map +1 -0
- package/lib/dist/extraction/languages/swift.js +152 -0
- package/lib/dist/extraction/languages/swift.js.map +1 -0
- package/lib/dist/extraction/languages/terraform.d.ts +3 -0
- package/lib/dist/extraction/languages/terraform.d.ts.map +1 -0
- package/lib/dist/extraction/languages/terraform.js +641 -0
- package/lib/dist/extraction/languages/terraform.js.map +1 -0
- package/lib/dist/extraction/languages/typescript.d.ts +16 -0
- package/lib/dist/extraction/languages/typescript.d.ts.map +1 -0
- package/lib/dist/extraction/languages/typescript.js +167 -0
- package/lib/dist/extraction/languages/typescript.js.map +1 -0
- package/lib/dist/extraction/languages/vbnet.d.ts +11 -0
- package/lib/dist/extraction/languages/vbnet.d.ts.map +1 -0
- package/lib/dist/extraction/languages/vbnet.js +141 -0
- package/lib/dist/extraction/languages/vbnet.js.map +1 -0
- package/lib/dist/extraction/liquid-extractor.d.ts +59 -0
- package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/liquid-extractor.js +357 -0
- package/lib/dist/extraction/liquid-extractor.js.map +1 -0
- package/lib/dist/extraction/mybatis-extractor.d.ts +68 -0
- package/lib/dist/extraction/mybatis-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/mybatis-extractor.js +300 -0
- package/lib/dist/extraction/mybatis-extractor.js.map +1 -0
- package/lib/dist/extraction/parse-pool.d.ts +126 -0
- package/lib/dist/extraction/parse-pool.d.ts.map +1 -0
- package/lib/dist/extraction/parse-pool.js +319 -0
- package/lib/dist/extraction/parse-pool.js.map +1 -0
- package/lib/dist/extraction/parse-worker.d.ts +8 -0
- package/lib/dist/extraction/parse-worker.d.ts.map +1 -0
- package/lib/dist/extraction/parse-worker.js +97 -0
- package/lib/dist/extraction/parse-worker.js.map +1 -0
- package/lib/dist/extraction/razor-extractor.d.ts +42 -0
- package/lib/dist/extraction/razor-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/razor-extractor.js +285 -0
- package/lib/dist/extraction/razor-extractor.js.map +1 -0
- package/lib/dist/extraction/svelte-extractor.d.ts +56 -0
- package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/svelte-extractor.js +275 -0
- package/lib/dist/extraction/svelte-extractor.js.map +1 -0
- package/lib/dist/extraction/tree-sitter-helpers.d.ts +28 -0
- package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
- package/lib/dist/extraction/tree-sitter-helpers.js +153 -0
- package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -0
- package/lib/dist/extraction/tree-sitter-types.d.ts +258 -0
- package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -0
- package/lib/dist/extraction/tree-sitter-types.js +10 -0
- package/lib/dist/extraction/tree-sitter-types.js.map +1 -0
- package/lib/dist/extraction/tree-sitter.d.ts +706 -0
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -0
- package/lib/dist/extraction/tree-sitter.js +6506 -0
- package/lib/dist/extraction/tree-sitter.js.map +1 -0
- package/lib/dist/extraction/vue-extractor.d.ts +51 -0
- package/lib/dist/extraction/vue-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/vue-extractor.js +254 -0
- package/lib/dist/extraction/vue-extractor.js.map +1 -0
- package/lib/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
- package/lib/dist/extraction/wasm-runtime-flags.d.ts +38 -0
- package/lib/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
- package/lib/dist/extraction/wasm-runtime-flags.js +106 -0
- package/lib/dist/extraction/wasm-runtime-flags.js.map +1 -0
- package/lib/dist/graph/index.d.ts +8 -0
- package/lib/dist/graph/index.d.ts.map +1 -0
- package/lib/dist/graph/index.js +13 -0
- package/lib/dist/graph/index.js.map +1 -0
- package/lib/dist/graph/queries.d.ts +106 -0
- package/lib/dist/graph/queries.d.ts.map +1 -0
- package/lib/dist/graph/queries.js +339 -0
- package/lib/dist/graph/queries.js.map +1 -0
- package/lib/dist/graph/traversal.d.ts +127 -0
- package/lib/dist/graph/traversal.d.ts.map +1 -0
- package/lib/dist/graph/traversal.js +599 -0
- package/lib/dist/graph/traversal.js.map +1 -0
- package/lib/dist/index.d.ts +642 -0
- package/lib/dist/index.d.ts.map +1 -0
- package/lib/dist/index.js +1387 -0
- package/lib/dist/index.js.map +1 -0
- package/lib/dist/installer/config-writer.d.ts +28 -0
- package/lib/dist/installer/config-writer.d.ts.map +1 -0
- package/lib/dist/installer/config-writer.js +91 -0
- package/lib/dist/installer/config-writer.js.map +1 -0
- package/lib/dist/installer/index.d.ts +100 -0
- package/lib/dist/installer/index.d.ts.map +1 -0
- package/lib/dist/installer/index.js +526 -0
- package/lib/dist/installer/index.js.map +1 -0
- package/lib/dist/installer/instructions-template.d.ts +41 -0
- package/lib/dist/installer/instructions-template.d.ts.map +1 -0
- package/lib/dist/installer/instructions-template.js +53 -0
- package/lib/dist/installer/instructions-template.js.map +1 -0
- package/lib/dist/installer/targets/antigravity.d.ts +57 -0
- package/lib/dist/installer/targets/antigravity.d.ts.map +1 -0
- package/lib/dist/installer/targets/antigravity.js +308 -0
- package/lib/dist/installer/targets/antigravity.js.map +1 -0
- package/lib/dist/installer/targets/claude.d.ts +62 -0
- package/lib/dist/installer/targets/claude.d.ts.map +1 -0
- package/lib/dist/installer/targets/claude.js +454 -0
- package/lib/dist/installer/targets/claude.js.map +1 -0
- package/lib/dist/installer/targets/codex.d.ts +18 -0
- package/lib/dist/installer/targets/codex.d.ts.map +1 -0
- package/lib/dist/installer/targets/codex.js +185 -0
- package/lib/dist/installer/targets/codex.js.map +1 -0
- package/lib/dist/installer/targets/cursor.d.ts +35 -0
- package/lib/dist/installer/targets/cursor.d.ts.map +1 -0
- package/lib/dist/installer/targets/cursor.js +254 -0
- package/lib/dist/installer/targets/cursor.js.map +1 -0
- package/lib/dist/installer/targets/gemini.d.ts +26 -0
- package/lib/dist/installer/targets/gemini.d.ts.map +1 -0
- package/lib/dist/installer/targets/gemini.js +165 -0
- package/lib/dist/installer/targets/gemini.js.map +1 -0
- package/lib/dist/installer/targets/hermes.d.ts +18 -0
- package/lib/dist/installer/targets/hermes.d.ts.map +1 -0
- package/lib/dist/installer/targets/hermes.js +359 -0
- package/lib/dist/installer/targets/hermes.js.map +1 -0
- package/lib/dist/installer/targets/kiro.d.ts +27 -0
- package/lib/dist/installer/targets/kiro.d.ts.map +1 -0
- package/lib/dist/installer/targets/kiro.js +178 -0
- package/lib/dist/installer/targets/kiro.js.map +1 -0
- package/lib/dist/installer/targets/opencode.d.ts +38 -0
- package/lib/dist/installer/targets/opencode.d.ts.map +1 -0
- package/lib/dist/installer/targets/opencode.js +288 -0
- package/lib/dist/installer/targets/opencode.js.map +1 -0
- package/lib/dist/installer/targets/registry.d.ts +35 -0
- package/lib/dist/installer/targets/registry.d.ts.map +1 -0
- package/lib/dist/installer/targets/registry.js +91 -0
- package/lib/dist/installer/targets/registry.js.map +1 -0
- package/lib/dist/installer/targets/shared.d.ts +101 -0
- package/lib/dist/installer/targets/shared.d.ts.map +1 -0
- package/lib/dist/installer/targets/shared.js +264 -0
- package/lib/dist/installer/targets/shared.js.map +1 -0
- package/lib/dist/installer/targets/toml.d.ts +52 -0
- package/lib/dist/installer/targets/toml.d.ts.map +1 -0
- package/lib/dist/installer/targets/toml.js +147 -0
- package/lib/dist/installer/targets/toml.js.map +1 -0
- package/lib/dist/installer/targets/types.d.ts +108 -0
- package/lib/dist/installer/targets/types.d.ts.map +1 -0
- package/lib/dist/installer/targets/types.js +16 -0
- package/lib/dist/installer/targets/types.js.map +1 -0
- package/lib/dist/mcp/daemon-manager.d.ts +42 -0
- package/lib/dist/mcp/daemon-manager.d.ts.map +1 -0
- package/lib/dist/mcp/daemon-manager.js +129 -0
- package/lib/dist/mcp/daemon-manager.js.map +1 -0
- package/lib/dist/mcp/daemon-paths.d.ts +73 -0
- package/lib/dist/mcp/daemon-paths.d.ts.map +1 -0
- package/lib/dist/mcp/daemon-paths.js +165 -0
- package/lib/dist/mcp/daemon-paths.js.map +1 -0
- package/lib/dist/mcp/daemon-registry.d.ts +47 -0
- package/lib/dist/mcp/daemon-registry.d.ts.map +1 -0
- package/lib/dist/mcp/daemon-registry.js +233 -0
- package/lib/dist/mcp/daemon-registry.js.map +1 -0
- package/lib/dist/mcp/daemon.d.ts +290 -0
- package/lib/dist/mcp/daemon.d.ts.map +1 -0
- package/lib/dist/mcp/daemon.js +840 -0
- package/lib/dist/mcp/daemon.js.map +1 -0
- package/lib/dist/mcp/dynamic-boundaries.d.ts +41 -0
- package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
- package/lib/dist/mcp/dynamic-boundaries.js +360 -0
- package/lib/dist/mcp/dynamic-boundaries.js.map +1 -0
- package/lib/dist/mcp/early-ppid.d.ts +26 -0
- package/lib/dist/mcp/early-ppid.d.ts.map +1 -0
- package/lib/dist/mcp/early-ppid.js +29 -0
- package/lib/dist/mcp/early-ppid.js.map +1 -0
- package/lib/dist/mcp/engine.d.ts +122 -0
- package/lib/dist/mcp/engine.d.ts.map +1 -0
- package/lib/dist/mcp/engine.js +350 -0
- package/lib/dist/mcp/engine.js.map +1 -0
- package/lib/dist/mcp/index.d.ts +113 -0
- package/lib/dist/mcp/index.d.ts.map +1 -0
- package/lib/dist/mcp/index.js +498 -0
- package/lib/dist/mcp/index.js.map +1 -0
- package/lib/dist/mcp/liveness-watchdog.d.ts +18 -0
- package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -0
- package/lib/dist/mcp/liveness-watchdog.js +207 -0
- package/lib/dist/mcp/liveness-watchdog.js.map +1 -0
- package/lib/dist/mcp/ppid-watchdog.d.ts +62 -0
- package/lib/dist/mcp/ppid-watchdog.d.ts.map +1 -0
- package/lib/dist/mcp/ppid-watchdog.js +64 -0
- package/lib/dist/mcp/ppid-watchdog.js.map +1 -0
- package/lib/dist/mcp/proxy.d.ts +87 -0
- package/lib/dist/mcp/proxy.d.ts.map +1 -0
- package/lib/dist/mcp/proxy.js +659 -0
- package/lib/dist/mcp/proxy.js.map +1 -0
- package/lib/dist/mcp/query-pool.d.ts +94 -0
- package/lib/dist/mcp/query-pool.d.ts.map +1 -0
- package/lib/dist/mcp/query-pool.js +297 -0
- package/lib/dist/mcp/query-pool.js.map +1 -0
- package/lib/dist/mcp/query-worker.d.ts +24 -0
- package/lib/dist/mcp/query-worker.d.ts.map +1 -0
- package/lib/dist/mcp/query-worker.js +87 -0
- package/lib/dist/mcp/query-worker.js.map +1 -0
- package/lib/dist/mcp/server-instructions.d.ts +34 -0
- package/lib/dist/mcp/server-instructions.d.ts.map +1 -0
- package/lib/dist/mcp/server-instructions.js +106 -0
- package/lib/dist/mcp/server-instructions.js.map +1 -0
- package/lib/dist/mcp/session.d.ts +79 -0
- package/lib/dist/mcp/session.d.ts.map +1 -0
- package/lib/dist/mcp/session.js +330 -0
- package/lib/dist/mcp/session.js.map +1 -0
- package/lib/dist/mcp/startup-handshake.d.ts +44 -0
- package/lib/dist/mcp/startup-handshake.d.ts.map +1 -0
- package/lib/dist/mcp/startup-handshake.js +73 -0
- package/lib/dist/mcp/startup-handshake.js.map +1 -0
- package/lib/dist/mcp/stdin-teardown.d.ts +27 -0
- package/lib/dist/mcp/stdin-teardown.d.ts.map +1 -0
- package/lib/dist/mcp/stdin-teardown.js +49 -0
- package/lib/dist/mcp/stdin-teardown.js.map +1 -0
- package/lib/dist/mcp/tools.d.ts +613 -0
- package/lib/dist/mcp/tools.d.ts.map +1 -0
- package/lib/dist/mcp/tools.js +4424 -0
- package/lib/dist/mcp/tools.js.map +1 -0
- package/lib/dist/mcp/transport.d.ts +188 -0
- package/lib/dist/mcp/transport.d.ts.map +1 -0
- package/lib/dist/mcp/transport.js +359 -0
- package/lib/dist/mcp/transport.js.map +1 -0
- package/lib/dist/mcp/version.d.ts +19 -0
- package/lib/dist/mcp/version.d.ts.map +1 -0
- package/lib/dist/mcp/version.js +71 -0
- package/lib/dist/mcp/version.js.map +1 -0
- package/lib/dist/project-config.d.ts +94 -0
- package/lib/dist/project-config.d.ts.map +1 -0
- package/lib/dist/project-config.js +374 -0
- package/lib/dist/project-config.js.map +1 -0
- package/lib/dist/resolution/c-fnptr-synthesizer.d.ts +5 -0
- package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/c-fnptr-synthesizer.js +1038 -0
- package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
- package/lib/dist/resolution/callback-synthesizer.d.ts +15 -0
- package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/callback-synthesizer.js +3658 -0
- package/lib/dist/resolution/callback-synthesizer.js.map +1 -0
- package/lib/dist/resolution/cooperative-yield.d.ts +32 -0
- package/lib/dist/resolution/cooperative-yield.d.ts.map +1 -0
- package/lib/dist/resolution/cooperative-yield.js +42 -0
- package/lib/dist/resolution/cooperative-yield.js.map +1 -0
- package/lib/dist/resolution/frameworks/astro.d.ts +9 -0
- package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/astro.js +169 -0
- package/lib/dist/resolution/frameworks/astro.js.map +1 -0
- package/lib/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
- package/lib/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/cargo-workspace.js +225 -0
- package/lib/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
- package/lib/dist/resolution/frameworks/cics.d.ts +20 -0
- package/lib/dist/resolution/frameworks/cics.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/cics.js +90 -0
- package/lib/dist/resolution/frameworks/cics.js.map +1 -0
- package/lib/dist/resolution/frameworks/csharp.d.ts +8 -0
- package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/csharp.js +241 -0
- package/lib/dist/resolution/frameworks/csharp.js.map +1 -0
- package/lib/dist/resolution/frameworks/drupal.d.ts +51 -0
- package/lib/dist/resolution/frameworks/drupal.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/drupal.js +367 -0
- package/lib/dist/resolution/frameworks/drupal.js.map +1 -0
- package/lib/dist/resolution/frameworks/expo-modules.d.ts +3 -0
- package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/expo-modules.js +148 -0
- package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -0
- package/lib/dist/resolution/frameworks/express.d.ts +8 -0
- package/lib/dist/resolution/frameworks/express.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/express.js +308 -0
- package/lib/dist/resolution/frameworks/express.js.map +1 -0
- package/lib/dist/resolution/frameworks/fabric.d.ts +3 -0
- package/lib/dist/resolution/frameworks/fabric.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/fabric.js +354 -0
- package/lib/dist/resolution/frameworks/fabric.js.map +1 -0
- package/lib/dist/resolution/frameworks/go.d.ts +8 -0
- package/lib/dist/resolution/frameworks/go.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/go.js +161 -0
- package/lib/dist/resolution/frameworks/go.js.map +1 -0
- package/lib/dist/resolution/frameworks/goframe.d.ts +41 -0
- package/lib/dist/resolution/frameworks/goframe.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/goframe.js +112 -0
- package/lib/dist/resolution/frameworks/goframe.js.map +1 -0
- package/lib/dist/resolution/frameworks/index.d.ts +50 -0
- package/lib/dist/resolution/frameworks/index.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/index.js +175 -0
- package/lib/dist/resolution/frameworks/index.js.map +1 -0
- package/lib/dist/resolution/frameworks/java.d.ts +8 -0
- package/lib/dist/resolution/frameworks/java.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/java.js +517 -0
- package/lib/dist/resolution/frameworks/java.js.map +1 -0
- package/lib/dist/resolution/frameworks/laravel.d.ts +13 -0
- package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/laravel.js +257 -0
- package/lib/dist/resolution/frameworks/laravel.js.map +1 -0
- package/lib/dist/resolution/frameworks/nestjs.d.ts +26 -0
- package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/nestjs.js +698 -0
- package/lib/dist/resolution/frameworks/nestjs.js.map +1 -0
- package/lib/dist/resolution/frameworks/play.d.ts +19 -0
- package/lib/dist/resolution/frameworks/play.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/play.js +111 -0
- package/lib/dist/resolution/frameworks/play.js.map +1 -0
- package/lib/dist/resolution/frameworks/python.d.ts +10 -0
- package/lib/dist/resolution/frameworks/python.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/python.js +400 -0
- package/lib/dist/resolution/frameworks/python.js.map +1 -0
- package/lib/dist/resolution/frameworks/react-native.d.ts +3 -0
- package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/react-native.js +410 -0
- package/lib/dist/resolution/frameworks/react-native.js.map +1 -0
- package/lib/dist/resolution/frameworks/react.d.ts +8 -0
- package/lib/dist/resolution/frameworks/react.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/react.js +334 -0
- package/lib/dist/resolution/frameworks/react.js.map +1 -0
- package/lib/dist/resolution/frameworks/ruby.d.ts +8 -0
- package/lib/dist/resolution/frameworks/ruby.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/ruby.js +302 -0
- package/lib/dist/resolution/frameworks/ruby.js.map +1 -0
- package/lib/dist/resolution/frameworks/rust.d.ts +8 -0
- package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/rust.js +304 -0
- package/lib/dist/resolution/frameworks/rust.js.map +1 -0
- package/lib/dist/resolution/frameworks/svelte.d.ts +9 -0
- package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/svelte.js +253 -0
- package/lib/dist/resolution/frameworks/svelte.js.map +1 -0
- package/lib/dist/resolution/frameworks/swift-objc.d.ts +37 -0
- package/lib/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/swift-objc.js +252 -0
- package/lib/dist/resolution/frameworks/swift-objc.js.map +1 -0
- package/lib/dist/resolution/frameworks/swift.d.ts +10 -0
- package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/swift.js +400 -0
- package/lib/dist/resolution/frameworks/swift.js.map +1 -0
- package/lib/dist/resolution/frameworks/terraform.d.ts +38 -0
- package/lib/dist/resolution/frameworks/terraform.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/terraform.js +277 -0
- package/lib/dist/resolution/frameworks/terraform.js.map +1 -0
- package/lib/dist/resolution/frameworks/vue.d.ts +9 -0
- package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/vue.js +303 -0
- package/lib/dist/resolution/frameworks/vue.js.map +1 -0
- package/lib/dist/resolution/go-module.d.ts +26 -0
- package/lib/dist/resolution/go-module.d.ts.map +1 -0
- package/lib/dist/resolution/go-module.js +78 -0
- package/lib/dist/resolution/go-module.js.map +1 -0
- package/lib/dist/resolution/goframe-synthesizer.d.ts +28 -0
- package/lib/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/goframe-synthesizer.js +158 -0
- package/lib/dist/resolution/goframe-synthesizer.js.map +1 -0
- package/lib/dist/resolution/import-resolver.d.ts +85 -0
- package/lib/dist/resolution/import-resolver.d.ts.map +1 -0
- package/lib/dist/resolution/import-resolver.js +1974 -0
- package/lib/dist/resolution/import-resolver.js.map +1 -0
- package/lib/dist/resolution/index.d.ts +238 -0
- package/lib/dist/resolution/index.d.ts.map +1 -0
- package/lib/dist/resolution/index.js +1633 -0
- package/lib/dist/resolution/index.js.map +1 -0
- package/lib/dist/resolution/lru-cache.d.ts +24 -0
- package/lib/dist/resolution/lru-cache.d.ts.map +1 -0
- package/lib/dist/resolution/lru-cache.js +62 -0
- package/lib/dist/resolution/lru-cache.js.map +1 -0
- package/lib/dist/resolution/name-matcher.d.ts +112 -0
- package/lib/dist/resolution/name-matcher.d.ts.map +1 -0
- package/lib/dist/resolution/name-matcher.js +1701 -0
- package/lib/dist/resolution/name-matcher.js.map +1 -0
- package/lib/dist/resolution/path-aliases.d.ts +68 -0
- package/lib/dist/resolution/path-aliases.d.ts.map +1 -0
- package/lib/dist/resolution/path-aliases.js +238 -0
- package/lib/dist/resolution/path-aliases.js.map +1 -0
- package/lib/dist/resolution/strip-comments.d.ts +27 -0
- package/lib/dist/resolution/strip-comments.d.ts.map +1 -0
- package/lib/dist/resolution/strip-comments.js +492 -0
- package/lib/dist/resolution/strip-comments.js.map +1 -0
- package/lib/dist/resolution/swift-objc-bridge.d.ts +134 -0
- package/lib/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
- package/lib/dist/resolution/swift-objc-bridge.js +256 -0
- package/lib/dist/resolution/swift-objc-bridge.js.map +1 -0
- package/lib/dist/resolution/types.d.ts +253 -0
- package/lib/dist/resolution/types.d.ts.map +1 -0
- package/lib/dist/resolution/types.js +8 -0
- package/lib/dist/resolution/types.js.map +1 -0
- package/lib/dist/resolution/workspace-packages.d.ts +58 -0
- package/lib/dist/resolution/workspace-packages.d.ts.map +1 -0
- package/lib/dist/resolution/workspace-packages.js +346 -0
- package/lib/dist/resolution/workspace-packages.js.map +1 -0
- package/lib/dist/search/identifier-segments.d.ts +60 -0
- package/lib/dist/search/identifier-segments.d.ts.map +1 -0
- package/lib/dist/search/identifier-segments.js +176 -0
- package/lib/dist/search/identifier-segments.js.map +1 -0
- package/lib/dist/search/query-parser.d.ts +57 -0
- package/lib/dist/search/query-parser.d.ts.map +1 -0
- package/lib/dist/search/query-parser.js +177 -0
- package/lib/dist/search/query-parser.js.map +1 -0
- package/lib/dist/search/query-utils.d.ts +87 -0
- package/lib/dist/search/query-utils.d.ts.map +1 -0
- package/lib/dist/search/query-utils.js +449 -0
- package/lib/dist/search/query-utils.js.map +1 -0
- package/lib/dist/sync/git-hooks.d.ts +45 -0
- package/lib/dist/sync/git-hooks.d.ts.map +1 -0
- package/lib/dist/sync/git-hooks.js +227 -0
- package/lib/dist/sync/git-hooks.js.map +1 -0
- package/lib/dist/sync/index.d.ts +19 -0
- package/lib/dist/sync/index.d.ts.map +1 -0
- package/lib/dist/sync/index.js +35 -0
- package/lib/dist/sync/index.js.map +1 -0
- package/lib/dist/sync/watch-policy.d.ts +48 -0
- package/lib/dist/sync/watch-policy.d.ts.map +1 -0
- package/lib/dist/sync/watch-policy.js +124 -0
- package/lib/dist/sync/watch-policy.js.map +1 -0
- package/lib/dist/sync/watcher.d.ts +355 -0
- package/lib/dist/sync/watcher.d.ts.map +1 -0
- package/lib/dist/sync/watcher.js +848 -0
- package/lib/dist/sync/watcher.js.map +1 -0
- package/lib/dist/sync/worktree.d.ts +63 -0
- package/lib/dist/sync/worktree.d.ts.map +1 -0
- package/lib/dist/sync/worktree.js +182 -0
- package/lib/dist/sync/worktree.js.map +1 -0
- package/lib/dist/telemetry/index.d.ts +143 -0
- package/lib/dist/telemetry/index.d.ts.map +1 -0
- package/lib/dist/telemetry/index.js +541 -0
- package/lib/dist/telemetry/index.js.map +1 -0
- package/lib/dist/types.d.ts +415 -0
- package/lib/dist/types.d.ts.map +1 -0
- package/lib/dist/types.js +91 -0
- package/lib/dist/types.js.map +1 -0
- package/lib/dist/ui/glyphs.d.ts +42 -0
- package/lib/dist/ui/glyphs.d.ts.map +1 -0
- package/lib/dist/ui/glyphs.js +78 -0
- package/lib/dist/ui/glyphs.js.map +1 -0
- package/lib/dist/ui/shimmer-progress.d.ts +11 -0
- package/lib/dist/ui/shimmer-progress.d.ts.map +1 -0
- package/lib/dist/ui/shimmer-progress.js +90 -0
- package/lib/dist/ui/shimmer-progress.js.map +1 -0
- package/lib/dist/ui/shimmer-worker.d.ts +2 -0
- package/lib/dist/ui/shimmer-worker.d.ts.map +1 -0
- package/lib/dist/ui/shimmer-worker.js +118 -0
- package/lib/dist/ui/shimmer-worker.js.map +1 -0
- package/lib/dist/ui/types.d.ts +17 -0
- package/lib/dist/ui/types.d.ts.map +1 -0
- package/lib/dist/ui/types.js +3 -0
- package/lib/dist/ui/types.js.map +1 -0
- package/lib/dist/upgrade/index.d.ts +132 -0
- package/lib/dist/upgrade/index.d.ts.map +1 -0
- package/lib/dist/upgrade/index.js +498 -0
- package/lib/dist/upgrade/index.js.map +1 -0
- package/lib/dist/utils.d.ts +224 -0
- package/lib/dist/utils.d.ts.map +1 -0
- package/lib/dist/utils.js +583 -0
- package/lib/dist/utils.js.map +1 -0
- package/lib/node_modules/.package-lock.json +125 -0
- package/lib/node_modules/@clack/core/CHANGELOG.md +348 -0
- package/lib/node_modules/@clack/core/LICENSE +9 -0
- package/lib/node_modules/@clack/core/README.md +22 -0
- package/lib/node_modules/@clack/core/dist/index.d.mts +363 -0
- package/lib/node_modules/@clack/core/dist/index.mjs +17 -0
- package/lib/node_modules/@clack/core/dist/index.mjs.map +1 -0
- package/lib/node_modules/@clack/core/package.json +63 -0
- package/lib/node_modules/@clack/prompts/CHANGELOG.md +591 -0
- package/lib/node_modules/@clack/prompts/LICENSE +9 -0
- package/lib/node_modules/@clack/prompts/README.md +375 -0
- package/lib/node_modules/@clack/prompts/dist/index.d.mts +396 -0
- package/lib/node_modules/@clack/prompts/dist/index.mjs +144 -0
- package/lib/node_modules/@clack/prompts/dist/index.mjs.map +1 -0
- package/lib/node_modules/@clack/prompts/package.json +68 -0
- package/lib/node_modules/commander/LICENSE +22 -0
- package/lib/node_modules/commander/Readme.md +1176 -0
- package/lib/node_modules/commander/esm.mjs +16 -0
- package/lib/node_modules/commander/index.js +24 -0
- package/lib/node_modules/commander/lib/argument.js +150 -0
- package/lib/node_modules/commander/lib/command.js +2777 -0
- package/lib/node_modules/commander/lib/error.js +39 -0
- package/lib/node_modules/commander/lib/help.js +747 -0
- package/lib/node_modules/commander/lib/option.js +380 -0
- package/lib/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/lib/node_modules/commander/package-support.json +19 -0
- package/lib/node_modules/commander/package.json +82 -0
- package/lib/node_modules/commander/typings/esm.d.mts +3 -0
- package/lib/node_modules/commander/typings/index.d.ts +1113 -0
- package/lib/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
- package/lib/node_modules/fast-string-truncated-width/dist/index.js +111 -0
- package/lib/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
- package/lib/node_modules/fast-string-truncated-width/dist/types.js +2 -0
- package/lib/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
- package/lib/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
- package/lib/node_modules/fast-string-truncated-width/license +21 -0
- package/lib/node_modules/fast-string-truncated-width/package.json +35 -0
- package/lib/node_modules/fast-string-truncated-width/readme.md +59 -0
- package/lib/node_modules/fast-string-width/dist/index.d.ts +4 -0
- package/lib/node_modules/fast-string-width/dist/index.js +14 -0
- package/lib/node_modules/fast-string-width/license +21 -0
- package/lib/node_modules/fast-string-width/package.json +34 -0
- package/lib/node_modules/fast-string-width/readme.md +42 -0
- package/lib/node_modules/fast-wrap-ansi/LICENSE +23 -0
- package/lib/node_modules/fast-wrap-ansi/README.md +26 -0
- package/lib/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
- package/lib/node_modules/fast-wrap-ansi/lib/main.js +219 -0
- package/lib/node_modules/fast-wrap-ansi/lib/main.js.map +1 -0
- package/lib/node_modules/fast-wrap-ansi/package.json +51 -0
- package/lib/node_modules/ignore/LICENSE-MIT +21 -0
- package/lib/node_modules/ignore/README.md +452 -0
- package/lib/node_modules/ignore/index.d.ts +81 -0
- package/lib/node_modules/ignore/index.js +784 -0
- package/lib/node_modules/ignore/legacy.js +681 -0
- package/lib/node_modules/ignore/package.json +87 -0
- package/lib/node_modules/jsonc-parser/CHANGELOG.md +76 -0
- package/lib/node_modules/jsonc-parser/LICENSE.md +21 -0
- package/lib/node_modules/jsonc-parser/README.md +364 -0
- package/lib/node_modules/jsonc-parser/SECURITY.md +41 -0
- package/lib/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
- package/lib/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
- package/lib/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
- package/lib/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
- package/lib/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
- package/lib/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
- package/lib/node_modules/jsonc-parser/lib/esm/main.js +178 -0
- package/lib/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
- package/lib/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
- package/lib/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
- package/lib/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
- package/lib/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
- package/lib/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
- package/lib/node_modules/jsonc-parser/lib/umd/main.js +194 -0
- package/lib/node_modules/jsonc-parser/package.json +37 -0
- package/lib/node_modules/picomatch/LICENSE +21 -0
- package/lib/node_modules/picomatch/README.md +738 -0
- package/lib/node_modules/picomatch/index.js +17 -0
- package/lib/node_modules/picomatch/lib/constants.js +180 -0
- package/lib/node_modules/picomatch/lib/parse.js +1085 -0
- package/lib/node_modules/picomatch/lib/picomatch.js +341 -0
- package/lib/node_modules/picomatch/lib/scan.js +391 -0
- package/lib/node_modules/picomatch/lib/utils.js +72 -0
- package/lib/node_modules/picomatch/package.json +83 -0
- package/lib/node_modules/picomatch/posix.js +3 -0
- package/lib/node_modules/sisteransi/license +21 -0
- package/lib/node_modules/sisteransi/package.json +34 -0
- package/lib/node_modules/sisteransi/readme.md +113 -0
- package/lib/node_modules/sisteransi/src/index.js +58 -0
- package/lib/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
- package/lib/node_modules/tree-sitter-wasms/LICENSE +24 -0
- package/lib/node_modules/tree-sitter-wasms/README.md +23 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-bash.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c_sharp.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-cpp.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-css.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-dart.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elisp.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elixir.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elm.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-embedded_template.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-go.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-html.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-java.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-javascript.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-json.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-kotlin.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-lua.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-objc.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ocaml.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-php.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-python.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ql.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rescript.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ruby.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rust.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-scala.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-solidity.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-swift.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-systemrdl.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tlaplus.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-toml.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tsx.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-typescript.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-vue.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-yaml.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-zig.wasm +0 -0
- package/lib/node_modules/tree-sitter-wasms/package.json +64 -0
- package/lib/node_modules/web-tree-sitter/LICENSE +21 -0
- package/lib/node_modules/web-tree-sitter/README.md +269 -0
- package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs +4558 -0
- package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs.map +7 -0
- package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js +4516 -0
- package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js.map +7 -0
- package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm +0 -0
- package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm.map +31 -0
- package/lib/node_modules/web-tree-sitter/lib/alloc.c +48 -0
- package/lib/node_modules/web-tree-sitter/lib/alloc.h +41 -0
- package/lib/node_modules/web-tree-sitter/lib/array.h +291 -0
- package/lib/node_modules/web-tree-sitter/lib/atomic.h +68 -0
- package/lib/node_modules/web-tree-sitter/lib/clock.h +146 -0
- package/lib/node_modules/web-tree-sitter/lib/error_costs.h +11 -0
- package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.c +523 -0
- package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.h +36 -0
- package/lib/node_modules/web-tree-sitter/lib/host.h +21 -0
- package/lib/node_modules/web-tree-sitter/lib/language.c +293 -0
- package/lib/node_modules/web-tree-sitter/lib/language.h +293 -0
- package/lib/node_modules/web-tree-sitter/lib/length.h +52 -0
- package/lib/node_modules/web-tree-sitter/lib/lexer.c +483 -0
- package/lib/node_modules/web-tree-sitter/lib/lexer.h +54 -0
- package/lib/node_modules/web-tree-sitter/lib/lib.c +12 -0
- package/lib/node_modules/web-tree-sitter/lib/node.c +875 -0
- package/lib/node_modules/web-tree-sitter/lib/parser.c +2297 -0
- package/lib/node_modules/web-tree-sitter/lib/parser.h +286 -0
- package/lib/node_modules/web-tree-sitter/lib/point.h +48 -0
- package/lib/node_modules/web-tree-sitter/lib/query.c +4347 -0
- package/lib/node_modules/web-tree-sitter/lib/reduce_action.h +34 -0
- package/lib/node_modules/web-tree-sitter/lib/reusable_node.h +95 -0
- package/lib/node_modules/web-tree-sitter/lib/stack.c +912 -0
- package/lib/node_modules/web-tree-sitter/lib/stack.h +133 -0
- package/lib/node_modules/web-tree-sitter/lib/subtree.c +1034 -0
- package/lib/node_modules/web-tree-sitter/lib/subtree.h +399 -0
- package/lib/node_modules/web-tree-sitter/lib/tree-sitter.c +987 -0
- package/lib/node_modules/web-tree-sitter/lib/tree-sitter.cjs +2988 -0
- package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm +0 -0
- package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm.map +1 -0
- package/lib/node_modules/web-tree-sitter/lib/tree.c +170 -0
- package/lib/node_modules/web-tree-sitter/lib/tree.h +31 -0
- package/lib/node_modules/web-tree-sitter/lib/tree_cursor.c +716 -0
- package/lib/node_modules/web-tree-sitter/lib/tree_cursor.h +48 -0
- package/lib/node_modules/web-tree-sitter/lib/ts_assert.h +11 -0
- package/lib/node_modules/web-tree-sitter/lib/unicode.h +75 -0
- package/lib/node_modules/web-tree-sitter/lib/wasm_store.c +1937 -0
- package/lib/node_modules/web-tree-sitter/lib/wasm_store.h +31 -0
- package/lib/node_modules/web-tree-sitter/package.json +98 -0
- package/lib/node_modules/web-tree-sitter/src/bindings.ts +26 -0
- package/lib/node_modules/web-tree-sitter/src/constants.ts +133 -0
- package/lib/node_modules/web-tree-sitter/src/index.ts +31 -0
- package/lib/node_modules/web-tree-sitter/src/language.ts +291 -0
- package/lib/node_modules/web-tree-sitter/src/lookahead_iterator.ts +75 -0
- package/lib/node_modules/web-tree-sitter/src/marshal.ts +176 -0
- package/lib/node_modules/web-tree-sitter/src/node.ts +646 -0
- package/lib/node_modules/web-tree-sitter/src/parser.ts +325 -0
- package/lib/node_modules/web-tree-sitter/src/query.ts +973 -0
- package/lib/node_modules/web-tree-sitter/src/tree.ts +145 -0
- package/lib/node_modules/web-tree-sitter/src/tree_cursor.ts +318 -0
- package/lib/node_modules/web-tree-sitter/tree-sitter.cjs +4031 -0
- package/lib/node_modules/web-tree-sitter/tree-sitter.cjs.map +7 -0
- package/lib/node_modules/web-tree-sitter/tree-sitter.js +3980 -0
- package/lib/node_modules/web-tree-sitter/tree-sitter.js.map +7 -0
- package/lib/node_modules/web-tree-sitter/tree-sitter.wasm +0 -0
- package/lib/node_modules/web-tree-sitter/tree-sitter.wasm.map +30 -0
- package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts +1030 -0
- package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +56 -0
- package/lib/package.json +64 -0
- package/node.exe +0 -0
- package/package.json +17 -0
|
@@ -0,0 +1,1387 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* BHGraph
|
|
4
|
+
*
|
|
5
|
+
* A local-first code intelligence system that builds a semantic
|
|
6
|
+
* knowledge graph from any codebase.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
42
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.BHGraph = 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.BHGraphError = exports.loadAllGrammars = exports.loadGrammarsForLanguages = exports.initGrammars = exports.getSupportedLanguages = exports.isGrammarLoaded = exports.isLanguageSupported = exports.detectLanguage = exports.BHGRAPH_DIR = exports.findNearestBHGraphRoot = exports.isInitialized = exports.getBHGraphDir = exports.QueryBuilder = exports.DatabaseConnection = exports.getDatabasePath = void 0;
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
const db_1 = require("./db");
|
|
48
|
+
const queries_1 = require("./db/queries");
|
|
49
|
+
const directory_1 = require("./directory");
|
|
50
|
+
const extraction_1 = require("./extraction");
|
|
51
|
+
const resolution_1 = require("./resolution");
|
|
52
|
+
const graph_1 = require("./graph");
|
|
53
|
+
const context_1 = require("./context");
|
|
54
|
+
const utils_1 = require("./utils");
|
|
55
|
+
const sync_1 = require("./sync");
|
|
56
|
+
const extraction_version_1 = require("./extraction/extraction-version");
|
|
57
|
+
const directory_2 = require("./directory");
|
|
58
|
+
const query_utils_1 = require("./search/query-utils");
|
|
59
|
+
const version_1 = require("./mcp/version");
|
|
60
|
+
const identifier_segments_1 = require("./search/identifier-segments");
|
|
61
|
+
const cooperative_yield_1 = require("./resolution/cooperative-yield");
|
|
62
|
+
// Re-export types for consumers
|
|
63
|
+
__exportStar(require("./types"), exports);
|
|
64
|
+
// Storage building blocks for embedded/SDK consumers that drive the graph
|
|
65
|
+
// directly (open a DB, run prepared queries) rather than through the BHGraph
|
|
66
|
+
// facade. Exposed from the package entry so they no longer require deep imports
|
|
67
|
+
// into dist/ (issue #354).
|
|
68
|
+
var db_2 = require("./db");
|
|
69
|
+
Object.defineProperty(exports, "getDatabasePath", { enumerable: true, get: function () { return db_2.getDatabasePath; } });
|
|
70
|
+
Object.defineProperty(exports, "DatabaseConnection", { enumerable: true, get: function () { return db_2.DatabaseConnection; } });
|
|
71
|
+
var queries_2 = require("./db/queries");
|
|
72
|
+
Object.defineProperty(exports, "QueryBuilder", { enumerable: true, get: function () { return queries_2.QueryBuilder; } });
|
|
73
|
+
var directory_3 = require("./directory");
|
|
74
|
+
Object.defineProperty(exports, "getBHGraphDir", { enumerable: true, get: function () { return directory_3.getBHGraphDir; } });
|
|
75
|
+
Object.defineProperty(exports, "isInitialized", { enumerable: true, get: function () { return directory_3.isInitialized; } });
|
|
76
|
+
Object.defineProperty(exports, "findNearestBHGraphRoot", { enumerable: true, get: function () { return directory_3.findNearestBHGraphRoot; } });
|
|
77
|
+
Object.defineProperty(exports, "BHGRAPH_DIR", { enumerable: true, get: function () { return directory_3.BHGRAPH_DIR; } });
|
|
78
|
+
var extraction_2 = require("./extraction");
|
|
79
|
+
Object.defineProperty(exports, "detectLanguage", { enumerable: true, get: function () { return extraction_2.detectLanguage; } });
|
|
80
|
+
Object.defineProperty(exports, "isLanguageSupported", { enumerable: true, get: function () { return extraction_2.isLanguageSupported; } });
|
|
81
|
+
Object.defineProperty(exports, "isGrammarLoaded", { enumerable: true, get: function () { return extraction_2.isGrammarLoaded; } });
|
|
82
|
+
Object.defineProperty(exports, "getSupportedLanguages", { enumerable: true, get: function () { return extraction_2.getSupportedLanguages; } });
|
|
83
|
+
Object.defineProperty(exports, "initGrammars", { enumerable: true, get: function () { return extraction_2.initGrammars; } });
|
|
84
|
+
Object.defineProperty(exports, "loadGrammarsForLanguages", { enumerable: true, get: function () { return extraction_2.loadGrammarsForLanguages; } });
|
|
85
|
+
Object.defineProperty(exports, "loadAllGrammars", { enumerable: true, get: function () { return extraction_2.loadAllGrammars; } });
|
|
86
|
+
var errors_1 = require("./errors");
|
|
87
|
+
Object.defineProperty(exports, "BHGraphError", { enumerable: true, get: function () { return errors_1.BHGraphError; } });
|
|
88
|
+
Object.defineProperty(exports, "FileError", { enumerable: true, get: function () { return errors_1.FileError; } });
|
|
89
|
+
Object.defineProperty(exports, "ParseError", { enumerable: true, get: function () { return errors_1.ParseError; } });
|
|
90
|
+
Object.defineProperty(exports, "DatabaseError", { enumerable: true, get: function () { return errors_1.DatabaseError; } });
|
|
91
|
+
Object.defineProperty(exports, "SearchError", { enumerable: true, get: function () { return errors_1.SearchError; } });
|
|
92
|
+
Object.defineProperty(exports, "VectorError", { enumerable: true, get: function () { return errors_1.VectorError; } });
|
|
93
|
+
Object.defineProperty(exports, "ConfigError", { enumerable: true, get: function () { return errors_1.ConfigError; } });
|
|
94
|
+
Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return errors_1.setLogger; } });
|
|
95
|
+
Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return errors_1.getLogger; } });
|
|
96
|
+
Object.defineProperty(exports, "silentLogger", { enumerable: true, get: function () { return errors_1.silentLogger; } });
|
|
97
|
+
Object.defineProperty(exports, "defaultLogger", { enumerable: true, get: function () { return errors_1.defaultLogger; } });
|
|
98
|
+
var utils_2 = require("./utils");
|
|
99
|
+
Object.defineProperty(exports, "Mutex", { enumerable: true, get: function () { return utils_2.Mutex; } });
|
|
100
|
+
Object.defineProperty(exports, "FileLock", { enumerable: true, get: function () { return utils_2.FileLock; } });
|
|
101
|
+
Object.defineProperty(exports, "processInBatches", { enumerable: true, get: function () { return utils_2.processInBatches; } });
|
|
102
|
+
Object.defineProperty(exports, "debounce", { enumerable: true, get: function () { return utils_2.debounce; } });
|
|
103
|
+
Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return utils_2.throttle; } });
|
|
104
|
+
Object.defineProperty(exports, "MemoryMonitor", { enumerable: true, get: function () { return utils_2.MemoryMonitor; } });
|
|
105
|
+
var sync_2 = require("./sync");
|
|
106
|
+
Object.defineProperty(exports, "FileWatcher", { enumerable: true, get: function () { return sync_2.FileWatcher; } });
|
|
107
|
+
Object.defineProperty(exports, "LockUnavailableError", { enumerable: true, get: function () { return sync_2.LockUnavailableError; } });
|
|
108
|
+
var mcp_1 = require("./mcp");
|
|
109
|
+
Object.defineProperty(exports, "MCPServer", { enumerable: true, get: function () { return mcp_1.MCPServer; } });
|
|
110
|
+
/**
|
|
111
|
+
* Main BHGraph class
|
|
112
|
+
*
|
|
113
|
+
* Provides the primary interface for interacting with the code knowledge graph.
|
|
114
|
+
*/
|
|
115
|
+
class BHGraph {
|
|
116
|
+
db;
|
|
117
|
+
queries;
|
|
118
|
+
projectRoot;
|
|
119
|
+
// Assigned via wireLayers() from the constructor (and again on reopen) — the
|
|
120
|
+
// `!` tells TS these are definitely set even though the assignment is one
|
|
121
|
+
// method call away from the constructor body.
|
|
122
|
+
orchestrator;
|
|
123
|
+
resolver;
|
|
124
|
+
graphManager;
|
|
125
|
+
traverser;
|
|
126
|
+
contextBuilder;
|
|
127
|
+
// Mutex for preventing concurrent indexing operations (in-process)
|
|
128
|
+
indexMutex = new utils_1.Mutex();
|
|
129
|
+
// File lock for preventing concurrent writes across processes (CLI, MCP, git hooks)
|
|
130
|
+
fileLock;
|
|
131
|
+
// File watcher for auto-sync on file changes
|
|
132
|
+
watcher = null;
|
|
133
|
+
constructor(db, queries, projectRoot) {
|
|
134
|
+
this.db = db;
|
|
135
|
+
this.queries = queries;
|
|
136
|
+
this.projectRoot = projectRoot;
|
|
137
|
+
this.fileLock = new utils_1.FileLock(path.join((0, directory_2.getBHGraphDir)(projectRoot), 'bhgraph.lock'));
|
|
138
|
+
this.wireLayers();
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* (Re)build the query/extraction/graph layers over the current `this.queries`
|
|
142
|
+
* (which wraps `this.db`). Factored out of the constructor so `reopenIfReplaced`
|
|
143
|
+
* can rebuild them against a fresh connection without duplicating the wiring.
|
|
144
|
+
* The path-based `fileLock` is independent of the DB handle, so it stays put.
|
|
145
|
+
*/
|
|
146
|
+
wireLayers() {
|
|
147
|
+
// Down-weight the project name as a query term in search ranking — it names
|
|
148
|
+
// the whole repo, not a symbol, so it has no discriminative value (#720).
|
|
149
|
+
try {
|
|
150
|
+
this.queries.setProjectNameTokens((0, query_utils_1.deriveProjectNameTokens)(this.projectRoot));
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
// Best-effort: ranking still works without it.
|
|
154
|
+
}
|
|
155
|
+
this.orchestrator = new extraction_1.ExtractionOrchestrator(this.projectRoot, this.queries);
|
|
156
|
+
this.resolver = (0, resolution_1.createResolver)(this.projectRoot, this.queries);
|
|
157
|
+
this.graphManager = new graph_1.GraphQueryManager(this.queries);
|
|
158
|
+
this.traverser = new graph_1.GraphTraverser(this.queries);
|
|
159
|
+
this.contextBuilder = (0, context_1.createContextBuilder)(this.projectRoot, this.queries, this.traverser);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Heal a stale database handle in place. If `.bhgraph/` was removed and
|
|
163
|
+
* recreated at the SAME path while this instance held the DB open — a git
|
|
164
|
+
* worktree removed and re-added, or `rm -rf .bhgraph` + `bhgraph init` —
|
|
165
|
+
* our open fd points at the now-unlinked inode and can never see the new
|
|
166
|
+
* index, so every query returns the pre-removal snapshot until the process
|
|
167
|
+
* restarts (#925). When that's detected, open the live file at the same path,
|
|
168
|
+
* rebuild the query layers, and swap them IN PLACE, so every holder of this
|
|
169
|
+
* instance (the MCP daemon's default project, cached projectPath connections)
|
|
170
|
+
* heals without a restart. Returns true iff it reopened.
|
|
171
|
+
*
|
|
172
|
+
* POSIX-only in practice: `isReplacedOnDisk` never fires on Windows (an open
|
|
173
|
+
* file can't be unlinked there, and st_ino is unreliable).
|
|
174
|
+
*/
|
|
175
|
+
reopenIfReplaced() {
|
|
176
|
+
if (!this.db.isReplacedOnDisk())
|
|
177
|
+
return false;
|
|
178
|
+
const dbPath = this.db.getPath();
|
|
179
|
+
// Open the live file FIRST — if that throws (e.g. mid-recreate), the old
|
|
180
|
+
// handle stays in place and the caller retries on the next query, rather
|
|
181
|
+
// than leaving this instance with no connection at all.
|
|
182
|
+
const fresh = db_1.DatabaseConnection.open(dbPath);
|
|
183
|
+
const stale = this.db;
|
|
184
|
+
this.db = fresh;
|
|
185
|
+
this.queries = new queries_1.QueryBuilder(fresh.getDb());
|
|
186
|
+
this.wireLayers();
|
|
187
|
+
// Releasing the dead handle also frees the leaked db/-wal/-shm fds that were
|
|
188
|
+
// pinning the unlinked inode (#925).
|
|
189
|
+
try {
|
|
190
|
+
stale.close();
|
|
191
|
+
}
|
|
192
|
+
catch { /* the old inode is gone; closing just frees fds */ }
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
// ===========================================================================
|
|
196
|
+
// Lifecycle Methods
|
|
197
|
+
// ===========================================================================
|
|
198
|
+
/**
|
|
199
|
+
* Initialize a new BHGraph project
|
|
200
|
+
*
|
|
201
|
+
* Creates the .BHGraph directory, database, and configuration.
|
|
202
|
+
*
|
|
203
|
+
* @param projectRoot - Path to the project root directory
|
|
204
|
+
* @param options - Initialization options
|
|
205
|
+
* @returns A new BHGraph instance
|
|
206
|
+
*/
|
|
207
|
+
static async init(projectRoot, options = {}) {
|
|
208
|
+
await (0, extraction_1.initGrammars)();
|
|
209
|
+
const resolvedRoot = path.resolve(projectRoot);
|
|
210
|
+
// Check if already initialized
|
|
211
|
+
if ((0, directory_1.isInitialized)(resolvedRoot)) {
|
|
212
|
+
throw new Error(`BHGraph already initialized in ${resolvedRoot}`);
|
|
213
|
+
}
|
|
214
|
+
// Create directory structure
|
|
215
|
+
(0, directory_1.createDirectory)(resolvedRoot);
|
|
216
|
+
// Initialize database
|
|
217
|
+
const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
|
|
218
|
+
const db = db_1.DatabaseConnection.initialize(dbPath);
|
|
219
|
+
const queries = new queries_1.QueryBuilder(db.getDb());
|
|
220
|
+
const instance = new BHGraph(db, queries, resolvedRoot);
|
|
221
|
+
// Run initial indexing if requested
|
|
222
|
+
if (options.index) {
|
|
223
|
+
await instance.indexAll({ onProgress: options.onProgress });
|
|
224
|
+
}
|
|
225
|
+
return instance;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Initialize synchronously (without indexing)
|
|
229
|
+
*/
|
|
230
|
+
static initSync(projectRoot) {
|
|
231
|
+
const resolvedRoot = path.resolve(projectRoot);
|
|
232
|
+
// Check if already initialized
|
|
233
|
+
if ((0, directory_1.isInitialized)(resolvedRoot)) {
|
|
234
|
+
throw new Error(`BHGraph already initialized in ${resolvedRoot}`);
|
|
235
|
+
}
|
|
236
|
+
// Create directory structure
|
|
237
|
+
(0, directory_1.createDirectory)(resolvedRoot);
|
|
238
|
+
// Initialize database
|
|
239
|
+
const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
|
|
240
|
+
const db = db_1.DatabaseConnection.initialize(dbPath);
|
|
241
|
+
const queries = new queries_1.QueryBuilder(db.getDb());
|
|
242
|
+
return new BHGraph(db, queries, resolvedRoot);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Open an existing BHGraph project
|
|
246
|
+
*
|
|
247
|
+
* @param projectRoot - Path to the project root directory
|
|
248
|
+
* @param options - Open options
|
|
249
|
+
* @returns A BHGraph instance
|
|
250
|
+
*/
|
|
251
|
+
static async open(projectRoot, options = {}) {
|
|
252
|
+
await (0, extraction_1.initGrammars)();
|
|
253
|
+
const resolvedRoot = path.resolve(projectRoot);
|
|
254
|
+
// Check if initialized
|
|
255
|
+
if (!(0, directory_1.isInitialized)(resolvedRoot)) {
|
|
256
|
+
throw new Error(`BHGraph not initialized in ${resolvedRoot}. Run init() first.`);
|
|
257
|
+
}
|
|
258
|
+
// Validate directory structure
|
|
259
|
+
const validation = (0, directory_1.validateDirectory)(resolvedRoot);
|
|
260
|
+
if (!validation.valid) {
|
|
261
|
+
throw new Error(`Invalid BHGraph directory: ${validation.errors.join(', ')}`);
|
|
262
|
+
}
|
|
263
|
+
// Open database
|
|
264
|
+
const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
|
|
265
|
+
const db = db_1.DatabaseConnection.open(dbPath);
|
|
266
|
+
const queries = new queries_1.QueryBuilder(db.getDb());
|
|
267
|
+
const instance = new BHGraph(db, queries, resolvedRoot);
|
|
268
|
+
// Sync if requested
|
|
269
|
+
if (options.sync) {
|
|
270
|
+
await instance.sync();
|
|
271
|
+
}
|
|
272
|
+
return instance;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Rebuild the project's database from scratch and return a fresh, empty
|
|
276
|
+
* instance — the "same result as a fresh init" semantics that `bhgraph
|
|
277
|
+
* index` documents.
|
|
278
|
+
*
|
|
279
|
+
* Unlike `open()` followed by `clear()`, this DISCARDS the existing
|
|
280
|
+
* `.bhgraph/bhgraph.db` (and its `-wal`/`-shm` sidecars) before
|
|
281
|
+
* re-initializing, instead of opening the old database and DELETE-ing every
|
|
282
|
+
* row. On a large or pre-fix poisoned index — e.g. an old graph that scanned
|
|
283
|
+
* an ignored gitlink corpus (#1065) into ~1.6M nodes with a multi-GB WAL —
|
|
284
|
+
* the per-row `nodes_fts` delete-trigger churn blocks the main thread long
|
|
285
|
+
* enough to trip the #850 liveness watchdog before indexing even starts, so a
|
|
286
|
+
* full re-index could never recover the bad state (#1067). Discarding the
|
|
287
|
+
* files is O(1) regardless of size, reclaims the disk, and sidesteps opening
|
|
288
|
+
* (and running migrations against) the poisoned database entirely.
|
|
289
|
+
*/
|
|
290
|
+
static async recreate(projectRoot) {
|
|
291
|
+
await (0, extraction_1.initGrammars)();
|
|
292
|
+
const resolvedRoot = path.resolve(projectRoot);
|
|
293
|
+
// Check if initialized — recreate REBUILDS an existing project; it is not a
|
|
294
|
+
// first-time `init`.
|
|
295
|
+
if (!(0, directory_1.isInitialized)(resolvedRoot)) {
|
|
296
|
+
throw new Error(`BHGraph not initialized in ${resolvedRoot}. Run init() first.`);
|
|
297
|
+
}
|
|
298
|
+
const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
|
|
299
|
+
try {
|
|
300
|
+
(0, db_1.removeDatabaseFiles)(dbPath);
|
|
301
|
+
}
|
|
302
|
+
catch (err) {
|
|
303
|
+
// POSIX unlinks an open file fine; this fires mainly on Windows when a
|
|
304
|
+
// live daemon/MCP server still holds the database. Turn the raw EBUSY into
|
|
305
|
+
// an actionable instruction instead of a generic failure.
|
|
306
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
307
|
+
throw new Error(`Could not rebuild the index — the database file is in use (${reason}). ` +
|
|
308
|
+
`Stop any running BHGraph MCP server/daemon for this project and retry, ` +
|
|
309
|
+
`or remove the ${(0, directory_2.getBHGraphDir)(resolvedRoot)} directory and run "bhgraph init".`);
|
|
310
|
+
}
|
|
311
|
+
// Re-create an empty, freshly-schema'd database at the same path.
|
|
312
|
+
const db = db_1.DatabaseConnection.initialize(dbPath);
|
|
313
|
+
const queries = new queries_1.QueryBuilder(db.getDb());
|
|
314
|
+
return new BHGraph(db, queries, resolvedRoot);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Open synchronously (without sync)
|
|
318
|
+
*/
|
|
319
|
+
static openSync(projectRoot) {
|
|
320
|
+
const resolvedRoot = path.resolve(projectRoot);
|
|
321
|
+
// Check if initialized
|
|
322
|
+
if (!(0, directory_1.isInitialized)(resolvedRoot)) {
|
|
323
|
+
throw new Error(`BHGraph not initialized in ${resolvedRoot}. Run init() first.`);
|
|
324
|
+
}
|
|
325
|
+
// Validate directory structure
|
|
326
|
+
const validation = (0, directory_1.validateDirectory)(resolvedRoot);
|
|
327
|
+
if (!validation.valid) {
|
|
328
|
+
throw new Error(`Invalid BHGraph directory: ${validation.errors.join(', ')}`);
|
|
329
|
+
}
|
|
330
|
+
// Open database
|
|
331
|
+
const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
|
|
332
|
+
const db = db_1.DatabaseConnection.open(dbPath);
|
|
333
|
+
const queries = new queries_1.QueryBuilder(db.getDb());
|
|
334
|
+
return new BHGraph(db, queries, resolvedRoot);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Check if a directory has been initialized as a BHGraph project
|
|
338
|
+
*/
|
|
339
|
+
static isInitialized(projectRoot) {
|
|
340
|
+
return (0, directory_1.isInitialized)(path.resolve(projectRoot));
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Close the BHGraph instance and release resources
|
|
344
|
+
*/
|
|
345
|
+
close() {
|
|
346
|
+
this.unwatch();
|
|
347
|
+
// Release file lock if held
|
|
348
|
+
this.fileLock.release();
|
|
349
|
+
this.db.close();
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Get the project root directory
|
|
353
|
+
*/
|
|
354
|
+
getProjectRoot() {
|
|
355
|
+
return this.projectRoot;
|
|
356
|
+
}
|
|
357
|
+
// ===========================================================================
|
|
358
|
+
// Indexing
|
|
359
|
+
// ===========================================================================
|
|
360
|
+
/**
|
|
361
|
+
* Index all files in the project
|
|
362
|
+
*
|
|
363
|
+
* Uses a mutex to prevent concurrent indexing operations.
|
|
364
|
+
*/
|
|
365
|
+
async indexAll(options = {}) {
|
|
366
|
+
return this.indexMutex.withLock(async () => {
|
|
367
|
+
try {
|
|
368
|
+
this.fileLock.acquire();
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
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 };
|
|
372
|
+
}
|
|
373
|
+
try {
|
|
374
|
+
const before = this.queries.getNodeAndEdgeCount();
|
|
375
|
+
// Mark the index as in-flight BEFORE any writes: a run killed
|
|
376
|
+
// mid-index (OOM, SIGKILL, the #850 liveness watchdog) leaves this
|
|
377
|
+
// marker behind, so `bhgraph status` can tell a truncated index
|
|
378
|
+
// from a completed one instead of silently serving partial results.
|
|
379
|
+
try {
|
|
380
|
+
this.queries.setMetadata('index_state', 'indexing');
|
|
381
|
+
}
|
|
382
|
+
catch { /* metadata is advisory */ }
|
|
383
|
+
// Segment vocabulary starts empty and is repopulated by the node write
|
|
384
|
+
// path as every file (re-)indexes below — so a full index is also the
|
|
385
|
+
// orphan-cleanup pass for names deleted since the last one.
|
|
386
|
+
try {
|
|
387
|
+
this.queries.clearNameSegmentVocab();
|
|
388
|
+
}
|
|
389
|
+
catch { /* vocab is advisory — never fail an index over it */ }
|
|
390
|
+
const result = await this.orchestrator.indexAll(options.onProgress, options.signal, options.verbose);
|
|
391
|
+
// Re-detect frameworks now that the index is populated. The resolver
|
|
392
|
+
// is constructed with createResolver() before any files exist, so
|
|
393
|
+
// framework resolvers whose detect() consults the indexed file list
|
|
394
|
+
// (e.g. UIKit/SwiftUI scanning for imports, swift-objc-bridge looking
|
|
395
|
+
// for both Swift and ObjC files) all return false on that initial pass
|
|
396
|
+
// and silently drop themselves. Re-initializing here gives them a
|
|
397
|
+
// chance to see the actual project before resolution runs.
|
|
398
|
+
if (result.success && result.filesIndexed > 0) {
|
|
399
|
+
this.resolver.initialize();
|
|
400
|
+
// Cross-file finalization (e.g. NestJS RouterModule prefixes). Runs
|
|
401
|
+
// before resolution so updated names show up in subsequent reads.
|
|
402
|
+
this.resolver.runPostExtract();
|
|
403
|
+
}
|
|
404
|
+
// Resolve references to create call/import/extends edges
|
|
405
|
+
if (result.success && result.filesIndexed > 0) {
|
|
406
|
+
// Get count without loading all refs into memory
|
|
407
|
+
const unresolvedCount = this.queries.getUnresolvedReferencesCount();
|
|
408
|
+
options.onProgress?.({
|
|
409
|
+
phase: 'resolving',
|
|
410
|
+
current: 0,
|
|
411
|
+
total: unresolvedCount,
|
|
412
|
+
});
|
|
413
|
+
await this.resolveReferencesBatched((current, total) => {
|
|
414
|
+
options.onProgress?.({
|
|
415
|
+
phase: 'resolving',
|
|
416
|
+
current,
|
|
417
|
+
total,
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
// Second pass: chained calls whose method lives on a supertype the
|
|
421
|
+
// receiver conforms to (protocol-extension / inherited / default-
|
|
422
|
+
// interface). Needs the implements/extends edges the main pass just
|
|
423
|
+
// built, so it runs after resolution (#750).
|
|
424
|
+
await this.resolver.resolveChainedCallsViaConformance();
|
|
425
|
+
// Same lifecycle for `this.<member>` callback registrations whose
|
|
426
|
+
// member is inherited from a supertype (#808).
|
|
427
|
+
await this.resolver.resolveDeferredThisMemberRefs();
|
|
428
|
+
}
|
|
429
|
+
// Refresh planner stats + checkpoint the WAL after bulk writes.
|
|
430
|
+
// Cheap and non-blocking; never load-bearing for correctness.
|
|
431
|
+
if (result.success && result.filesIndexed > 0) {
|
|
432
|
+
this.db.runMaintenance();
|
|
433
|
+
}
|
|
434
|
+
// The orchestrator only sees extraction-phase counts; resolution and
|
|
435
|
+
// synthesizer edges (often >50% of the graph on JVM repos) come later.
|
|
436
|
+
// Recompute against the DB so the CLI summary reports the true totals.
|
|
437
|
+
if (result.success && result.filesIndexed > 0) {
|
|
438
|
+
const after = this.queries.getNodeAndEdgeCount();
|
|
439
|
+
result.nodesCreated = after.nodes - before.nodes;
|
|
440
|
+
result.edgesCreated = after.edges - before.edges;
|
|
441
|
+
}
|
|
442
|
+
// Stamp the index with the engine that built it, so `bhgraph status`
|
|
443
|
+
// and `bhgraph upgrade` can recommend a re-index when the running
|
|
444
|
+
// engine produces richer extraction than the one on disk. Only on a
|
|
445
|
+
// real full index — a sync touches a subset, so it must NOT advance the
|
|
446
|
+
// extraction stamp (the bulk would still be stale). See extraction-version.ts.
|
|
447
|
+
if (result.success && result.filesIndexed > 0) {
|
|
448
|
+
try {
|
|
449
|
+
this.queries.setMetadata('indexed_with_version', version_1.BHGraphPackageVersion);
|
|
450
|
+
this.queries.setMetadata('indexed_with_extraction_version', String(extraction_version_1.EXTRACTION_VERSION));
|
|
451
|
+
}
|
|
452
|
+
catch { /* metadata is advisory — never fail an index over it */ }
|
|
453
|
+
}
|
|
454
|
+
// Reconcile the scan's ground truth against what the pipeline
|
|
455
|
+
// accounted for. A shortfall means files were silently dropped
|
|
456
|
+
// (observed in the wild: a run under heavy load came up 37 files
|
|
457
|
+
// short with no error) — record it and tell the user, don't let the
|
|
458
|
+
// index pass as complete.
|
|
459
|
+
try {
|
|
460
|
+
if (!result.success) {
|
|
461
|
+
this.queries.setMetadata('index_state', 'failed');
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
const accounted = result.filesIndexed + result.filesSkipped + result.filesErrored;
|
|
465
|
+
const discovered = result.filesDiscovered;
|
|
466
|
+
const shortfall = discovered !== undefined ? discovered - accounted : 0;
|
|
467
|
+
if (discovered !== undefined && shortfall > 0) {
|
|
468
|
+
this.queries.setMetadata('index_state', 'partial');
|
|
469
|
+
this.queries.setMetadata('index_files_discovered', String(discovered));
|
|
470
|
+
this.queries.setMetadata('index_files_accounted', String(accounted));
|
|
471
|
+
result.errors.push({
|
|
472
|
+
message: `Index is missing ${shortfall} of ${discovered} discovered files (indexed ${result.filesIndexed}, skipped ${result.filesSkipped}, errored ${result.filesErrored}). The index is PARTIAL — re-run \`bhgraph index\`.`,
|
|
473
|
+
severity: 'warning',
|
|
474
|
+
code: 'index_partial',
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
this.queries.setMetadata('index_state', 'complete');
|
|
479
|
+
if (discovered !== undefined) {
|
|
480
|
+
this.queries.setMetadata('index_files_discovered', String(discovered));
|
|
481
|
+
this.queries.setMetadata('index_files_accounted', String(accounted));
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
catch { /* metadata is advisory — never fail an index over it */ }
|
|
487
|
+
return result;
|
|
488
|
+
}
|
|
489
|
+
finally {
|
|
490
|
+
this.fileLock.release();
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Index specific files
|
|
496
|
+
*
|
|
497
|
+
* Uses a mutex to prevent concurrent indexing operations.
|
|
498
|
+
*/
|
|
499
|
+
async indexFiles(filePaths) {
|
|
500
|
+
return this.indexMutex.withLock(async () => {
|
|
501
|
+
try {
|
|
502
|
+
this.fileLock.acquire();
|
|
503
|
+
}
|
|
504
|
+
catch {
|
|
505
|
+
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 };
|
|
506
|
+
}
|
|
507
|
+
try {
|
|
508
|
+
return this.orchestrator.indexFiles(filePaths);
|
|
509
|
+
}
|
|
510
|
+
finally {
|
|
511
|
+
this.fileLock.release();
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Sync with current file state (incremental update)
|
|
517
|
+
*
|
|
518
|
+
* Uses a mutex to prevent concurrent indexing operations.
|
|
519
|
+
*/
|
|
520
|
+
async sync(options = {}) {
|
|
521
|
+
return this.indexMutex.withLock(async () => {
|
|
522
|
+
try {
|
|
523
|
+
this.fileLock.acquire();
|
|
524
|
+
}
|
|
525
|
+
catch {
|
|
526
|
+
return { filesChecked: 0, filesAdded: 0, filesModified: 0, filesRemoved: 0, nodesUpdated: 0, durationMs: 0 };
|
|
527
|
+
}
|
|
528
|
+
try {
|
|
529
|
+
// Captured BEFORE the sync runs: the sync's own incremental writes
|
|
530
|
+
// populate vocab rows for the files it touches, so an end-of-sync
|
|
531
|
+
// emptiness check would see "non-empty" and skip the backfill forever,
|
|
532
|
+
// leaving every unchanged file's names unsegmented.
|
|
533
|
+
const vocabWasEmpty = (() => {
|
|
534
|
+
try {
|
|
535
|
+
return this.queries.isNameSegmentVocabEmpty();
|
|
536
|
+
}
|
|
537
|
+
catch {
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
})();
|
|
541
|
+
const result = await this.orchestrator.sync(options.onProgress);
|
|
542
|
+
// Cross-file finalization (e.g. NestJS RouterModule prefixes). Run on
|
|
543
|
+
// every sync that touched files so edits to `app.module.ts` propagate
|
|
544
|
+
// to controllers in unchanged files. The pass is idempotent and cheap
|
|
545
|
+
// (regex over *.module.ts only).
|
|
546
|
+
if (result.filesAdded > 0 || result.filesModified > 0) {
|
|
547
|
+
this.resolver.runPostExtract();
|
|
548
|
+
}
|
|
549
|
+
// Resolve references if files were updated
|
|
550
|
+
const filesChanged = result.filesAdded > 0 || result.filesModified > 0;
|
|
551
|
+
if (filesChanged) {
|
|
552
|
+
if (result.changedFilePaths) {
|
|
553
|
+
// Scope resolution to changed files (git fast path — bounded set)
|
|
554
|
+
const unresolvedRefs = this.queries.getUnresolvedReferencesByFiles(result.changedFilePaths);
|
|
555
|
+
options.onProgress?.({
|
|
556
|
+
phase: 'resolving',
|
|
557
|
+
current: 0,
|
|
558
|
+
total: unresolvedRefs.length,
|
|
559
|
+
});
|
|
560
|
+
this.resolver.resolveAndPersist(unresolvedRefs, (current, total) => {
|
|
561
|
+
options.onProgress?.({
|
|
562
|
+
phase: 'resolving',
|
|
563
|
+
current,
|
|
564
|
+
total,
|
|
565
|
+
});
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
else {
|
|
569
|
+
// No git info — use batched resolution to avoid OOM
|
|
570
|
+
const unresolvedCount = this.queries.getUnresolvedReferencesCount();
|
|
571
|
+
options.onProgress?.({
|
|
572
|
+
phase: 'resolving',
|
|
573
|
+
current: 0,
|
|
574
|
+
total: unresolvedCount,
|
|
575
|
+
});
|
|
576
|
+
await this.resolveReferencesBatched((current, total) => {
|
|
577
|
+
options.onProgress?.({
|
|
578
|
+
phase: 'resolving',
|
|
579
|
+
current,
|
|
580
|
+
total,
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
// Orphan sweep (#1187). A resolution pass that dies mid-run — the #850
|
|
586
|
+
// daemon liveness watchdog's SIGKILL (#1122), Ctrl-C, a crash — leaves
|
|
587
|
+
// the refs it never reached in unresolved_refs, and the git-scoped fast
|
|
588
|
+
// path above never revisits them (it reads only the changed files'
|
|
589
|
+
// rows). Those files' call edges were then missing PERMANENTLY, with
|
|
590
|
+
// nothing to see except a too-small blast radius, until a full
|
|
591
|
+
// re-index. A completed pass deletes every row it processed (resolved
|
|
592
|
+
// or not), so any row still present now is such an orphan — or a row
|
|
593
|
+
// parked by an older engine whose scoped pass kept unresolvable refs.
|
|
594
|
+
// Grind them down with the batched resolver; this also makes a bare
|
|
595
|
+
// `bhgraph sync` the recovery command for a wedged index. On a
|
|
596
|
+
// healthy index this is one COUNT query.
|
|
597
|
+
const orphanCount = this.queries.getUnresolvedReferencesCount();
|
|
598
|
+
if (orphanCount > 0) {
|
|
599
|
+
options.onProgress?.({
|
|
600
|
+
phase: 'resolving',
|
|
601
|
+
current: 0,
|
|
602
|
+
total: orphanCount,
|
|
603
|
+
});
|
|
604
|
+
await this.resolveReferencesBatched((current, total) => {
|
|
605
|
+
options.onProgress?.({
|
|
606
|
+
phase: 'resolving',
|
|
607
|
+
current,
|
|
608
|
+
total,
|
|
609
|
+
});
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
if (filesChanged || orphanCount > 0) {
|
|
613
|
+
// Second pass: chained calls whose method lives on a supertype the
|
|
614
|
+
// receiver conforms to (protocol-extension / inherited). Needs the
|
|
615
|
+
// implements/extends edges built above (#750).
|
|
616
|
+
await this.resolver.resolveChainedCallsViaConformance();
|
|
617
|
+
// Same lifecycle for `this.<member>` callback registrations whose
|
|
618
|
+
// member is inherited from a supertype (#808).
|
|
619
|
+
await this.resolver.resolveDeferredThisMemberRefs();
|
|
620
|
+
}
|
|
621
|
+
// Refresh planner stats + checkpoint the WAL after bulk writes.
|
|
622
|
+
if (filesChanged || result.filesRemoved > 0 || orphanCount > 0) {
|
|
623
|
+
this.db.runMaintenance();
|
|
624
|
+
}
|
|
625
|
+
// Heal the segment vocabulary on indexes built before the table
|
|
626
|
+
// existed (upgrade path): incremental writes above only cover changed
|
|
627
|
+
// files, so a vocab that was empty when this sync STARTED means the
|
|
628
|
+
// bulk was never segmented — backfill it (INSERT OR IGNORE, so the
|
|
629
|
+
// rows the sync just wrote are fine). Batched + yielding — sync can
|
|
630
|
+
// run on the daemon's liveness-watchdog thread (#850/#1091).
|
|
631
|
+
try {
|
|
632
|
+
if (vocabWasEmpty && this.queries.getNodeAndEdgeCount().nodes > 0) {
|
|
633
|
+
await this.rebuildNameSegmentVocab();
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
catch { /* vocab is advisory — never fail a sync over it */ }
|
|
637
|
+
return result;
|
|
638
|
+
}
|
|
639
|
+
finally {
|
|
640
|
+
this.fileLock.release();
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Check if an indexing operation is currently in progress
|
|
646
|
+
*/
|
|
647
|
+
isIndexing() {
|
|
648
|
+
return this.indexMutex.isLocked();
|
|
649
|
+
}
|
|
650
|
+
// ===========================================================================
|
|
651
|
+
// File Watching
|
|
652
|
+
// ===========================================================================
|
|
653
|
+
/**
|
|
654
|
+
* Start watching for file changes and auto-syncing.
|
|
655
|
+
*
|
|
656
|
+
* Uses native OS file events (FSEvents on macOS, inotify on Linux 19+,
|
|
657
|
+
* ReadDirectoryChangesW on Windows) with debouncing to avoid thrashing.
|
|
658
|
+
*
|
|
659
|
+
* @param options - Watch options (debounce delay, callbacks)
|
|
660
|
+
* @returns true if watching started successfully
|
|
661
|
+
*/
|
|
662
|
+
watch(options = {}) {
|
|
663
|
+
if (this.watcher?.isActive())
|
|
664
|
+
return true;
|
|
665
|
+
this.watcher = new sync_1.FileWatcher(this.projectRoot, async () => {
|
|
666
|
+
const result = await this.sync();
|
|
667
|
+
// sync() returns this exact zero-shape iff it failed to acquire the
|
|
668
|
+
// file lock (a real empty sync always has filesChecked > 0 because
|
|
669
|
+
// scanDirectory ran). Surface that to the watcher as a typed error
|
|
670
|
+
// so it keeps pendingFiles + reschedules instead of clearing them
|
|
671
|
+
// (#449).
|
|
672
|
+
if (result.filesChecked === 0 && result.durationMs === 0) {
|
|
673
|
+
throw new sync_1.LockUnavailableError();
|
|
674
|
+
}
|
|
675
|
+
const filesChanged = result.filesAdded + result.filesModified + result.filesRemoved;
|
|
676
|
+
return { filesChanged, durationMs: result.durationMs };
|
|
677
|
+
}, options);
|
|
678
|
+
return this.watcher.start();
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Stop watching for file changes.
|
|
682
|
+
*/
|
|
683
|
+
unwatch() {
|
|
684
|
+
if (this.watcher) {
|
|
685
|
+
this.watcher.stop();
|
|
686
|
+
this.watcher = null;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Check if the file watcher is active.
|
|
691
|
+
*/
|
|
692
|
+
isWatching() {
|
|
693
|
+
return this.watcher?.isActive() ?? false;
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* True once live watching has permanently degraded (OS watch-resource
|
|
697
|
+
* exhaustion, or a write lock held past the retry budget) and auto-sync is
|
|
698
|
+
* disabled until the next {@link watch} call. Distinct from `!isWatching()`:
|
|
699
|
+
* a stopped/never-started watcher is inactive but NOT degraded. MCP tools use
|
|
700
|
+
* this to surface a whole-index "results may be stale" notice, since
|
|
701
|
+
* `getPendingFiles()` goes empty once watching stops (#876).
|
|
702
|
+
*/
|
|
703
|
+
isWatcherDegraded() {
|
|
704
|
+
return this.watcher?.isDegraded() ?? false;
|
|
705
|
+
}
|
|
706
|
+
/** The reason live watching degraded, or null if it is healthy (#876). */
|
|
707
|
+
getWatcherDegradedReason() {
|
|
708
|
+
return this.watcher?.getDegradedReason() ?? null;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Files seen by the file watcher since the last successful sync —
|
|
712
|
+
* the per-file "stale" signal MCP tools attach to responses so an agent
|
|
713
|
+
* can fall back to {@link Read} for just the affected file without
|
|
714
|
+
* waiting for a debounced sync to complete (issue #403).
|
|
715
|
+
*
|
|
716
|
+
* Returns an empty list when the watcher isn't active, or no events have
|
|
717
|
+
* arrived. Each entry includes `firstSeenMs` and `lastSeenMs` (wall-clock
|
|
718
|
+
* `Date.now()` values) so callers can render "edited Nms ago", plus an
|
|
719
|
+
* `indexing` flag indicating whether the in-flight sync (if any) will
|
|
720
|
+
* absorb that file.
|
|
721
|
+
*/
|
|
722
|
+
getPendingFiles() {
|
|
723
|
+
return this.watcher?.getPendingFiles() ?? [];
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Resolves once the file watcher has installed its watch set. Useful for
|
|
727
|
+
* tests that need a deterministic boundary before asserting on
|
|
728
|
+
* `getPendingFiles()`. Resolves immediately when no watcher is active.
|
|
729
|
+
*/
|
|
730
|
+
waitUntilWatcherReady(timeoutMs) {
|
|
731
|
+
return this.watcher ? this.watcher.waitUntilReady(timeoutMs) : Promise.resolve();
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Get files that have changed since last index
|
|
735
|
+
*/
|
|
736
|
+
getChangedFiles() {
|
|
737
|
+
return this.orchestrator.getChangedFiles();
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Most recent index timestamp (ms since epoch) across all tracked files, or
|
|
741
|
+
* null when nothing is indexed yet. Lets library consumers check index
|
|
742
|
+
* freshness without shelling out to `bhgraph status --json`. (#329)
|
|
743
|
+
*/
|
|
744
|
+
getLastIndexedAt() {
|
|
745
|
+
return this.queries.getLastIndexedAt();
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Completeness of the last full index run. `'complete'` is the only good
|
|
749
|
+
* state. `'indexing'` after the fact means a run was killed mid-index (OOM,
|
|
750
|
+
* SIGKILL, liveness watchdog) and the on-disk index is truncated;
|
|
751
|
+
* `'partial'` means the run finished but silently dropped files
|
|
752
|
+
* (discovered > indexed+skipped+errored); `'failed'` means it reported
|
|
753
|
+
* failure. `null` = index predates this marker. Surfaced by
|
|
754
|
+
* `bhgraph status`.
|
|
755
|
+
*/
|
|
756
|
+
getIndexState() {
|
|
757
|
+
const raw = this.queries.getMetadata('index_state');
|
|
758
|
+
return raw === 'indexing' || raw === 'complete' || raw === 'partial' || raw === 'failed'
|
|
759
|
+
? raw
|
|
760
|
+
: null;
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Which engine built the current index: the package version + extraction
|
|
764
|
+
* version stamped at the last full `indexAll`. Either field is null for an
|
|
765
|
+
* index built before stamping existed (treated as stale). See
|
|
766
|
+
* `extraction-version.ts` and `isIndexStale()`.
|
|
767
|
+
*/
|
|
768
|
+
getIndexBuildInfo() {
|
|
769
|
+
const version = this.queries.getMetadata('indexed_with_version');
|
|
770
|
+
const ev = this.queries.getMetadata('indexed_with_extraction_version');
|
|
771
|
+
const parsed = ev != null ? parseInt(ev, 10) : NaN;
|
|
772
|
+
return { version, extractionVersion: Number.isFinite(parsed) ? parsed : null };
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* True when the on-disk index was built by an engine whose extraction is
|
|
776
|
+
* older than the one now running — i.e. a re-index would add data a migration
|
|
777
|
+
* can't backfill. False when there's no index yet (nothing to refresh) or the
|
|
778
|
+
* stamp is current. This is the signal behind `bhgraph status`'s re-index
|
|
779
|
+
* hint and `bhgraph upgrade`'s reminder.
|
|
780
|
+
*/
|
|
781
|
+
isIndexStale() {
|
|
782
|
+
if (this.queries.getLastIndexedAt() == null)
|
|
783
|
+
return false;
|
|
784
|
+
const { extractionVersion } = this.getIndexBuildInfo();
|
|
785
|
+
return extractionVersion == null || extractionVersion < extraction_version_1.EXTRACTION_VERSION;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Extract nodes and edges from source code (without storing)
|
|
789
|
+
*/
|
|
790
|
+
extractFromSource(filePath, source) {
|
|
791
|
+
return (0, extraction_1.extractFromSource)(filePath, source);
|
|
792
|
+
}
|
|
793
|
+
// ===========================================================================
|
|
794
|
+
// Reference Resolution
|
|
795
|
+
// ===========================================================================
|
|
796
|
+
/**
|
|
797
|
+
* Resolve unresolved references and create edges
|
|
798
|
+
*
|
|
799
|
+
* This method takes unresolved references from extraction and attempts
|
|
800
|
+
* to resolve them using multiple strategies:
|
|
801
|
+
* - Framework-specific patterns (React, Express, Laravel)
|
|
802
|
+
* - Import-based resolution
|
|
803
|
+
* - Name-based symbol matching
|
|
804
|
+
*/
|
|
805
|
+
resolveReferences(onProgress) {
|
|
806
|
+
// Get all unresolved references from the database
|
|
807
|
+
const unresolvedRefs = this.queries.getUnresolvedReferences();
|
|
808
|
+
return this.resolver.resolveAndPersist(unresolvedRefs, onProgress);
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Resolve references in batches to keep memory bounded on large codebases.
|
|
812
|
+
* Processes chunks of unresolved refs, persisting results after each batch.
|
|
813
|
+
*/
|
|
814
|
+
async resolveReferencesBatched(onProgress) {
|
|
815
|
+
return this.resolver.resolveAndPersistBatched(onProgress);
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* References extracted but not yet resolved into edges. Zero on a healthy
|
|
819
|
+
* index — a completed resolution pass consumes every row. Non-zero at rest
|
|
820
|
+
* means a pass was interrupted mid-run (killed indexer, crash — #1187), so
|
|
821
|
+
* some files' call edges are missing; the next `sync` sweeps them.
|
|
822
|
+
*/
|
|
823
|
+
getPendingReferenceCount() {
|
|
824
|
+
return this.queries.getUnresolvedReferencesCount();
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Get detected frameworks in the project
|
|
828
|
+
*/
|
|
829
|
+
getDetectedFrameworks() {
|
|
830
|
+
return this.resolver.getDetectedFrameworks();
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Re-initialize the resolver (useful after adding new files)
|
|
834
|
+
*/
|
|
835
|
+
reinitializeResolver() {
|
|
836
|
+
this.resolver.initialize();
|
|
837
|
+
}
|
|
838
|
+
// ===========================================================================
|
|
839
|
+
// Graph Statistics
|
|
840
|
+
// ===========================================================================
|
|
841
|
+
/**
|
|
842
|
+
* Get statistics about the knowledge graph
|
|
843
|
+
*/
|
|
844
|
+
getStats() {
|
|
845
|
+
const stats = this.queries.getStats();
|
|
846
|
+
stats.dbSizeBytes = this.db.getSize();
|
|
847
|
+
return stats;
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Active SQLite backend for this project's connection (`node-sqlite` — Node's
|
|
851
|
+
* built-in real-SQLite module). Surfaced via `bhgraph status` and the
|
|
852
|
+
* `bhgraph_status` MCP tool alongside the effective journal mode.
|
|
853
|
+
*/
|
|
854
|
+
getBackend() {
|
|
855
|
+
return this.db.getBackend();
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* The journal mode actually in effect ('wal', 'delete', …). 'wal' means
|
|
859
|
+
* readers never block on a concurrent writer; anything else means they can,
|
|
860
|
+
* which is the precondition for the "database is locked" failures in issue
|
|
861
|
+
* #238. Surfaced via `bhgraph status` and the `bhgraph_status` MCP tool.
|
|
862
|
+
*/
|
|
863
|
+
getJournalMode() {
|
|
864
|
+
return this.db.getJournalMode();
|
|
865
|
+
}
|
|
866
|
+
// ===========================================================================
|
|
867
|
+
// Node Operations
|
|
868
|
+
// ===========================================================================
|
|
869
|
+
/**
|
|
870
|
+
* Get a node by ID
|
|
871
|
+
*/
|
|
872
|
+
getNode(id) {
|
|
873
|
+
return this.queries.getNodeById(id);
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Get all nodes in a file
|
|
877
|
+
*/
|
|
878
|
+
getNodesInFile(filePath) {
|
|
879
|
+
return this.queries.getNodesByFile(filePath);
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Get all nodes of a specific kind
|
|
883
|
+
*/
|
|
884
|
+
getNodesByKind(kind) {
|
|
885
|
+
return this.queries.getNodesByKind(kind);
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Get ALL nodes with an exact name (direct index lookup, not FTS-ranked/capped).
|
|
889
|
+
* Used to enumerate every overload of a heavily-overloaded name so the specific
|
|
890
|
+
* definition the caller wants is never dropped below a search cut.
|
|
891
|
+
*/
|
|
892
|
+
getNodesByName(name) {
|
|
893
|
+
return this.queries.getNodesByName(name);
|
|
894
|
+
}
|
|
895
|
+
/** Nodes whose name starts with `prefix` (index range scan, capped). */
|
|
896
|
+
getNodesByNamePrefix(prefix, limit = 20) {
|
|
897
|
+
return this.queries.getNodesByNamePrefix(prefix, limit);
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Search nodes by text
|
|
901
|
+
*/
|
|
902
|
+
searchNodes(query, options) {
|
|
903
|
+
return this.queries.searchNodes(query, options);
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Graph-derived prompt matching for the front-load hook's MEDIUM tier:
|
|
907
|
+
* which indexed symbols do these prose words name? "state machine des
|
|
908
|
+
* commandes" → `OrderStateMachine`, in any human language whose technical
|
|
909
|
+
* nouns are Latin script — no keyword list involved.
|
|
910
|
+
*
|
|
911
|
+
* Precision comes from the repo's own naming statistics, not vocabulary:
|
|
912
|
+
* - CO-OCCURRENCE: ≥2 words that are segments of the SAME name ("state" +
|
|
913
|
+
* "machine" → OrderStateMachine) is strong evidence and always qualifies.
|
|
914
|
+
* - RARITY: a single matched word qualifies only when its segment is
|
|
915
|
+
* discriminative here (≤ {@link SEGMENT_RARITY_CEILING} distinct names) —
|
|
916
|
+
* "checkout" in a shop backend yes, "state" in a react app no.
|
|
917
|
+
* Every candidate is re-verified against `nodes` before being returned
|
|
918
|
+
* (vocab rows are proposals; deletions leave orphans by design), so a
|
|
919
|
+
* returned symbol is guaranteed to exist right now.
|
|
920
|
+
*/
|
|
921
|
+
getSegmentMatches(words, limit = 6) {
|
|
922
|
+
if (words.length === 0)
|
|
923
|
+
return [];
|
|
924
|
+
// Variant → original word (plural folding), for coverage accounting.
|
|
925
|
+
const variantToWord = new Map();
|
|
926
|
+
for (const word of words) {
|
|
927
|
+
for (const variant of (0, identifier_segments_1.segmentLookupVariants)(word)) {
|
|
928
|
+
if (!variantToWord.has(variant))
|
|
929
|
+
variantToWord.set(variant, word);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
const variants = [...variantToWord.keys()];
|
|
933
|
+
// Tier A: co-occurrence. The SQL folds variants back to their original
|
|
934
|
+
// word (#1146), so minWords=2 means two distinct PROMPT WORDS — a name
|
|
935
|
+
// matching both `service` and `services` can't tie with (or crowd past
|
|
936
|
+
// the LIMIT) a genuine two-word match. The JS re-check below recomputes
|
|
937
|
+
// the fold from live segments as the honesty layer.
|
|
938
|
+
const variantPairs = [...variantToWord.entries()].map(([segment, word]) => ({ segment, word }));
|
|
939
|
+
const candidates = [];
|
|
940
|
+
for (const hit of this.queries.getSegmentCoOccurrence(variantPairs, 2, 24)) {
|
|
941
|
+
const matched = this.wordsMatchingName(hit.name, variantToWord);
|
|
942
|
+
if (matched.size >= 2)
|
|
943
|
+
candidates.push({ name: hit.name, matchedWords: matched });
|
|
944
|
+
}
|
|
945
|
+
// Tier B: single rare word. Only when co-occurrence found nothing — a
|
|
946
|
+
// co-occurring name is categorically stronger evidence — and under
|
|
947
|
+
// stricter rules, because one word is thin: the word must be ≥5 chars
|
|
948
|
+
// (measured FPs: "this", "typo"); the segment must appear in AT LEAST TWO
|
|
949
|
+
// names (a concept the codebase is about clusters across names —
|
|
950
|
+
// CheckoutService/CheckoutController — while a prose coincidence is a
|
|
951
|
+
// singleton: measured FP "deploy to PRODUCTION" → the one name
|
|
952
|
+
// matchesNonProductionDir); and the candidate name must have ≥2 segments
|
|
953
|
+
// (a bare common verb matching a bare function name — "write" → `write` —
|
|
954
|
+
// is prose coincidence, not the user naming a symbol).
|
|
955
|
+
if (candidates.length === 0) {
|
|
956
|
+
const singleWordVariants = variants.filter((v) => variantToWord.get(v).length >= 5);
|
|
957
|
+
const counts = this.queries.getSegmentNameCounts(singleWordVariants);
|
|
958
|
+
const rare = [...counts.entries()]
|
|
959
|
+
.filter(([, n]) => n >= 2 && n <= BHGraph.SEGMENT_RARITY_CEILING)
|
|
960
|
+
.sort((a, b) => a[1] - b[1])
|
|
961
|
+
.slice(0, 2);
|
|
962
|
+
for (const [variant] of rare) {
|
|
963
|
+
const word = variantToWord.get(variant);
|
|
964
|
+
for (const name of this.queries.getNamesForSegment(variant, 12)) {
|
|
965
|
+
if ((0, identifier_segments_1.splitIdentifierSegments)(name).length < 2)
|
|
966
|
+
continue;
|
|
967
|
+
candidates.push({ name, matchedWords: new Set([word]) });
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
// Verify against nodes (the honesty gate) and pick a representative
|
|
972
|
+
// definition per name. A name whose only nodes are file/import kind has
|
|
973
|
+
// no real definition to point at — surfacing the import statement instead
|
|
974
|
+
// reads as a matched symbol but isn't one (#1144) — so it's skipped, the
|
|
975
|
+
// same way an orphaned vocab row is. (Import names no longer enter the
|
|
976
|
+
// vocab at write time, but rows written before that exclusion persist
|
|
977
|
+
// until the next full index.)
|
|
978
|
+
const out = [];
|
|
979
|
+
const seen = new Set();
|
|
980
|
+
candidates.sort((a, b) => b.matchedWords.size - a.matchedWords.size || a.name.length - b.name.length);
|
|
981
|
+
for (const candidate of candidates) {
|
|
982
|
+
if (out.length >= limit)
|
|
983
|
+
break;
|
|
984
|
+
if (seen.has(candidate.name))
|
|
985
|
+
continue;
|
|
986
|
+
seen.add(candidate.name);
|
|
987
|
+
const nodes = this.queries.getNodesByName(candidate.name);
|
|
988
|
+
if (nodes.length === 0)
|
|
989
|
+
continue; // orphaned vocab row — name no longer exists
|
|
990
|
+
const rep = nodes.find((n) => n.kind !== 'file' && n.kind !== 'import');
|
|
991
|
+
if (!rep)
|
|
992
|
+
continue; // no real definition — don't surface an import/file as one
|
|
993
|
+
out.push({
|
|
994
|
+
name: candidate.name,
|
|
995
|
+
kind: rep.kind,
|
|
996
|
+
filePath: rep.filePath,
|
|
997
|
+
startLine: rep.startLine ?? 0,
|
|
998
|
+
matchedWords: [...candidate.matchedWords].sort(),
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
return out;
|
|
1002
|
+
}
|
|
1003
|
+
/** A single word ("state") can match hundreds of names in a big repo — that
|
|
1004
|
+
* is noise, not signal. Ceiling for the single-word tier; co-occurrence is
|
|
1005
|
+
* exempt because two words on one name is already discriminative. */
|
|
1006
|
+
static SEGMENT_RARITY_CEILING = 25;
|
|
1007
|
+
/** Which of the prompt's original words match `name`'s segments (via
|
|
1008
|
+
* variants). Segments are recomputed in JS — a name-keyed vocab lookup
|
|
1009
|
+
* would scan the (segment, name) primary key. */
|
|
1010
|
+
wordsMatchingName(name, variantToWord) {
|
|
1011
|
+
const segments = new Set((0, identifier_segments_1.splitIdentifierSegments)(name));
|
|
1012
|
+
const matched = new Set();
|
|
1013
|
+
for (const [variant, word] of variantToWord) {
|
|
1014
|
+
if (segments.has(variant))
|
|
1015
|
+
matched.add(word);
|
|
1016
|
+
}
|
|
1017
|
+
return matched;
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* One-shot upgrade heal for callers that open the graph WITHOUT syncing —
|
|
1021
|
+
* concretely the prompt hook, whose MEDIUM tier reads the segment
|
|
1022
|
+
* vocabulary: a database migrated from before the vocab table existed
|
|
1023
|
+
* starts with it empty, and the only other backfill lives inside `sync()`,
|
|
1024
|
+
* which such callers never run (#1142). Returns true when the vocab is
|
|
1025
|
+
* usable (already populated — the overwhelmingly common one-SELECT case —
|
|
1026
|
+
* or healed here); false when it isn't (empty graph, or another process
|
|
1027
|
+
* holds the index lock — that process's own sync heals it).
|
|
1028
|
+
*/
|
|
1029
|
+
async healSegmentVocabIfEmpty() {
|
|
1030
|
+
const empty = (() => {
|
|
1031
|
+
try {
|
|
1032
|
+
return this.queries.isNameSegmentVocabEmpty();
|
|
1033
|
+
}
|
|
1034
|
+
catch {
|
|
1035
|
+
return false;
|
|
1036
|
+
}
|
|
1037
|
+
})();
|
|
1038
|
+
if (!empty)
|
|
1039
|
+
return true;
|
|
1040
|
+
if (this.queries.getNodeAndEdgeCount().nodes === 0)
|
|
1041
|
+
return false;
|
|
1042
|
+
return this.indexMutex.withLock(async () => {
|
|
1043
|
+
try {
|
|
1044
|
+
this.fileLock.acquire();
|
|
1045
|
+
}
|
|
1046
|
+
catch {
|
|
1047
|
+
return false; // an index/sync is running — it backfills the vocab itself
|
|
1048
|
+
}
|
|
1049
|
+
try {
|
|
1050
|
+
if (!this.queries.isNameSegmentVocabEmpty())
|
|
1051
|
+
return true; // raced: healed meanwhile
|
|
1052
|
+
await this.rebuildNameSegmentVocab();
|
|
1053
|
+
return true;
|
|
1054
|
+
}
|
|
1055
|
+
finally {
|
|
1056
|
+
this.fileLock.release();
|
|
1057
|
+
}
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Rebuild the segment vocabulary from the current graph, batched and
|
|
1062
|
+
* yielding — the upgrade-heal path for indexes built before the vocab table
|
|
1063
|
+
* existed. Runs inside the index mutex/lock (sync and
|
|
1064
|
+
* healSegmentVocabIfEmpty hold them).
|
|
1065
|
+
*/
|
|
1066
|
+
async rebuildNameSegmentVocab() {
|
|
1067
|
+
const maybeYield = (0, cooperative_yield_1.createYielder)();
|
|
1068
|
+
const BATCH = 2000;
|
|
1069
|
+
for (let offset = 0;; offset += BATCH) {
|
|
1070
|
+
const names = this.queries.getDistinctNodeNames(BATCH, offset);
|
|
1071
|
+
if (names.length === 0)
|
|
1072
|
+
break;
|
|
1073
|
+
this.queries.insertNameSegmentsBatch(names);
|
|
1074
|
+
await maybeYield();
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Normalized project-name tokens (go.mod / package.json / repo dir) used to
|
|
1079
|
+
* down-weight the non-discriminative project name in search ranking (#720).
|
|
1080
|
+
* Exposed so explore can exclude it from the PascalCase type-disambiguation
|
|
1081
|
+
* bias, which would otherwise pull overloaded tokens toward whichever stack
|
|
1082
|
+
* embeds the project name.
|
|
1083
|
+
*/
|
|
1084
|
+
getProjectNameTokens() {
|
|
1085
|
+
return this.queries.getProjectNameTokens();
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1088
|
+
* Find the project's "primary route file" — the file with the densest
|
|
1089
|
+
* concentration of framework-emitted `route` nodes (≥3 routes, ≥30%
|
|
1090
|
+
* of all non-test routes). Used to inline the routing config in
|
|
1091
|
+
* `bhgraph_explore` responses on small realworld template repos
|
|
1092
|
+
* (rails-realworld, laravel-realworld, drupal-admintoolbar, …) where
|
|
1093
|
+
* Glob+Read of `routes.rb`/`urls.py`/etc. otherwise beats bhgraph.
|
|
1094
|
+
*/
|
|
1095
|
+
getTopRouteFile() {
|
|
1096
|
+
return this.queries.getTopRouteFile();
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Build a URL → handler routing manifest from the index. Each entry
|
|
1100
|
+
* pairs a route node (URL + method) with its handler function/method
|
|
1101
|
+
* via the `references` edge that framework resolvers emit. Returns
|
|
1102
|
+
* null when fewer than 3 valid (non-test) routes exist.
|
|
1103
|
+
*/
|
|
1104
|
+
getRoutingManifest(limit) {
|
|
1105
|
+
return this.queries.getRoutingManifest(limit);
|
|
1106
|
+
}
|
|
1107
|
+
// ===========================================================================
|
|
1108
|
+
// Edge Operations
|
|
1109
|
+
// ===========================================================================
|
|
1110
|
+
/**
|
|
1111
|
+
* Get outgoing edges from a node
|
|
1112
|
+
*/
|
|
1113
|
+
getOutgoingEdges(nodeId) {
|
|
1114
|
+
return this.queries.getOutgoingEdges(nodeId);
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Get incoming edges to a node
|
|
1118
|
+
*/
|
|
1119
|
+
getIncomingEdges(nodeId) {
|
|
1120
|
+
return this.queries.getIncomingEdges(nodeId);
|
|
1121
|
+
}
|
|
1122
|
+
// ===========================================================================
|
|
1123
|
+
// File Operations
|
|
1124
|
+
// ===========================================================================
|
|
1125
|
+
/**
|
|
1126
|
+
* Get a file record by path
|
|
1127
|
+
*/
|
|
1128
|
+
getFile(filePath) {
|
|
1129
|
+
return this.queries.getFileByPath(filePath);
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Get all tracked files
|
|
1133
|
+
*/
|
|
1134
|
+
getFiles() {
|
|
1135
|
+
return this.queries.getAllFiles();
|
|
1136
|
+
}
|
|
1137
|
+
// ===========================================================================
|
|
1138
|
+
// Graph Query Methods
|
|
1139
|
+
// ===========================================================================
|
|
1140
|
+
/**
|
|
1141
|
+
* Get the context for a node (ancestors, children, references)
|
|
1142
|
+
*
|
|
1143
|
+
* Returns comprehensive context about a node including its containment
|
|
1144
|
+
* hierarchy, children, incoming/outgoing references, type information,
|
|
1145
|
+
* and relevant imports.
|
|
1146
|
+
*
|
|
1147
|
+
* @param nodeId - ID of the focal node
|
|
1148
|
+
* @returns Context object with all related information
|
|
1149
|
+
*/
|
|
1150
|
+
getContext(nodeId) {
|
|
1151
|
+
return this.graphManager.getContext(nodeId);
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Traverse the graph from a starting node
|
|
1155
|
+
*
|
|
1156
|
+
* Uses breadth-first search by default. Supports filtering by edge types,
|
|
1157
|
+
* node types, and traversal direction.
|
|
1158
|
+
*
|
|
1159
|
+
* @param startId - Starting node ID
|
|
1160
|
+
* @param options - Traversal options
|
|
1161
|
+
* @returns Subgraph containing traversed nodes and edges
|
|
1162
|
+
*/
|
|
1163
|
+
traverse(startId, options) {
|
|
1164
|
+
return this.traverser.traverseBFS(startId, options);
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Get the call graph for a function
|
|
1168
|
+
*
|
|
1169
|
+
* Returns both callers (functions that call this function) and
|
|
1170
|
+
* callees (functions called by this function) up to the specified depth.
|
|
1171
|
+
*
|
|
1172
|
+
* @param nodeId - ID of the function/method node
|
|
1173
|
+
* @param depth - Maximum depth in each direction (default: 2)
|
|
1174
|
+
* @returns Subgraph containing the call graph
|
|
1175
|
+
*/
|
|
1176
|
+
getCallGraph(nodeId, depth = 2) {
|
|
1177
|
+
return this.traverser.getCallGraph(nodeId, depth);
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Get the type hierarchy for a class/interface
|
|
1181
|
+
*
|
|
1182
|
+
* Returns both ancestors (types this extends/implements) and
|
|
1183
|
+
* descendants (types that extend/implement this).
|
|
1184
|
+
*
|
|
1185
|
+
* @param nodeId - ID of the class/interface node
|
|
1186
|
+
* @returns Subgraph containing the type hierarchy
|
|
1187
|
+
*/
|
|
1188
|
+
getTypeHierarchy(nodeId) {
|
|
1189
|
+
return this.traverser.getTypeHierarchy(nodeId);
|
|
1190
|
+
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Find all usages of a symbol
|
|
1193
|
+
*
|
|
1194
|
+
* Returns all nodes that reference the specified symbol through
|
|
1195
|
+
* any edge type (calls, references, type_of, etc.).
|
|
1196
|
+
*
|
|
1197
|
+
* @param nodeId - ID of the symbol node
|
|
1198
|
+
* @returns Array of nodes and edges that reference this symbol
|
|
1199
|
+
*/
|
|
1200
|
+
findUsages(nodeId) {
|
|
1201
|
+
return this.traverser.findUsages(nodeId);
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Get callers of a function/method
|
|
1205
|
+
*
|
|
1206
|
+
* @param nodeId - ID of the function/method node
|
|
1207
|
+
* @param maxDepth - Maximum depth to traverse (default: 1)
|
|
1208
|
+
* @returns Array of nodes that call this function
|
|
1209
|
+
*/
|
|
1210
|
+
getCallers(nodeId, maxDepth = 1) {
|
|
1211
|
+
return this.traverser.getCallers(nodeId, maxDepth);
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Get callees of a function/method
|
|
1215
|
+
*
|
|
1216
|
+
* @param nodeId - ID of the function/method node
|
|
1217
|
+
* @param maxDepth - Maximum depth to traverse (default: 1)
|
|
1218
|
+
* @returns Array of nodes called by this function
|
|
1219
|
+
*/
|
|
1220
|
+
getCallees(nodeId, maxDepth = 1) {
|
|
1221
|
+
return this.traverser.getCallees(nodeId, maxDepth);
|
|
1222
|
+
}
|
|
1223
|
+
/**
|
|
1224
|
+
* Calculate the impact radius of a node
|
|
1225
|
+
*
|
|
1226
|
+
* Returns all nodes that could be affected by changes to this node.
|
|
1227
|
+
*
|
|
1228
|
+
* @param nodeId - ID of the node
|
|
1229
|
+
* @param maxDepth - Maximum depth to traverse (default: 3)
|
|
1230
|
+
* @returns Subgraph containing potentially impacted nodes
|
|
1231
|
+
*/
|
|
1232
|
+
getImpactRadius(nodeId, maxDepth = 3) {
|
|
1233
|
+
return this.traverser.getImpactRadius(nodeId, maxDepth);
|
|
1234
|
+
}
|
|
1235
|
+
/**
|
|
1236
|
+
* Find the shortest path between two nodes
|
|
1237
|
+
*
|
|
1238
|
+
* @param fromId - Starting node ID
|
|
1239
|
+
* @param toId - Target node ID
|
|
1240
|
+
* @param edgeKinds - Edge types to consider (all if empty)
|
|
1241
|
+
* @returns Array of nodes and edges forming the path, or null if no path exists
|
|
1242
|
+
*/
|
|
1243
|
+
findPath(fromId, toId, edgeKinds) {
|
|
1244
|
+
return this.traverser.findPath(fromId, toId, edgeKinds);
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Get ancestors of a node in the containment hierarchy
|
|
1248
|
+
*
|
|
1249
|
+
* @param nodeId - ID of the node
|
|
1250
|
+
* @returns Array of ancestor nodes from immediate parent to root
|
|
1251
|
+
*/
|
|
1252
|
+
getAncestors(nodeId) {
|
|
1253
|
+
return this.traverser.getAncestors(nodeId);
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Get immediate children of a node
|
|
1257
|
+
*
|
|
1258
|
+
* @param nodeId - ID of the node
|
|
1259
|
+
* @returns Array of child nodes
|
|
1260
|
+
*/
|
|
1261
|
+
getChildren(nodeId) {
|
|
1262
|
+
return this.traverser.getChildren(nodeId);
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Get dependencies of a file
|
|
1266
|
+
*
|
|
1267
|
+
* @param filePath - Path to the file
|
|
1268
|
+
* @returns Array of file paths this file depends on
|
|
1269
|
+
*/
|
|
1270
|
+
getFileDependencies(filePath) {
|
|
1271
|
+
return this.graphManager.getFileDependencies(filePath);
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Get dependents of a file
|
|
1275
|
+
*
|
|
1276
|
+
* @param filePath - Path to the file
|
|
1277
|
+
* @returns Array of file paths that depend on this file
|
|
1278
|
+
*/
|
|
1279
|
+
getFileDependents(filePath) {
|
|
1280
|
+
return this.graphManager.getFileDependents(filePath);
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Find circular dependencies in the codebase
|
|
1284
|
+
*
|
|
1285
|
+
* @returns Array of cycles, each cycle is an array of file paths
|
|
1286
|
+
*/
|
|
1287
|
+
findCircularDependencies() {
|
|
1288
|
+
return this.graphManager.findCircularDependencies();
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Find dead code (unreferenced symbols)
|
|
1292
|
+
*
|
|
1293
|
+
* @param kinds - Node kinds to check (default: functions, methods, classes)
|
|
1294
|
+
* @returns Array of unreferenced nodes
|
|
1295
|
+
*/
|
|
1296
|
+
findDeadCode(kinds) {
|
|
1297
|
+
return this.graphManager.findDeadCode(kinds);
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Get complexity metrics for a node
|
|
1301
|
+
*
|
|
1302
|
+
* @param nodeId - ID of the node
|
|
1303
|
+
* @returns Object containing various complexity metrics
|
|
1304
|
+
*/
|
|
1305
|
+
getNodeMetrics(nodeId) {
|
|
1306
|
+
return this.graphManager.getNodeMetrics(nodeId);
|
|
1307
|
+
}
|
|
1308
|
+
// ===========================================================================
|
|
1309
|
+
// Context Building
|
|
1310
|
+
// ===========================================================================
|
|
1311
|
+
/**
|
|
1312
|
+
* Get the source code for a node
|
|
1313
|
+
*
|
|
1314
|
+
* Reads the file and extracts the code between startLine and endLine.
|
|
1315
|
+
*
|
|
1316
|
+
* @param nodeId - ID of the node
|
|
1317
|
+
* @returns Code string or null if not found
|
|
1318
|
+
*/
|
|
1319
|
+
async getCode(nodeId) {
|
|
1320
|
+
return this.contextBuilder.getCode(nodeId);
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Find relevant subgraph for a query
|
|
1324
|
+
*
|
|
1325
|
+
* Combines semantic search with graph traversal to find the most
|
|
1326
|
+
* relevant nodes and their relationships for a given query.
|
|
1327
|
+
*
|
|
1328
|
+
* @param query - Natural language query describing the task
|
|
1329
|
+
* @param options - Search and traversal options
|
|
1330
|
+
* @returns Subgraph of relevant nodes and edges
|
|
1331
|
+
*/
|
|
1332
|
+
async findRelevantContext(query, options) {
|
|
1333
|
+
return this.contextBuilder.findRelevantContext(query, options);
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* Build context for a task
|
|
1337
|
+
*
|
|
1338
|
+
* Creates comprehensive context by:
|
|
1339
|
+
* 1. Running FTS search to find entry points
|
|
1340
|
+
* 2. Expanding the graph around entry points
|
|
1341
|
+
* 3. Extracting code blocks for key nodes
|
|
1342
|
+
* 4. Formatting output for Claude
|
|
1343
|
+
*
|
|
1344
|
+
* @param input - Task description (string or {title, description})
|
|
1345
|
+
* @param options - Build options (maxNodes, includeCode, format, etc.)
|
|
1346
|
+
* @returns TaskContext object or formatted string (markdown/JSON)
|
|
1347
|
+
*/
|
|
1348
|
+
async buildContext(input, options) {
|
|
1349
|
+
return this.contextBuilder.buildContext(input, options);
|
|
1350
|
+
}
|
|
1351
|
+
// ===========================================================================
|
|
1352
|
+
// Database Management
|
|
1353
|
+
// ===========================================================================
|
|
1354
|
+
/**
|
|
1355
|
+
* Optimize the database (vacuum and analyze)
|
|
1356
|
+
*/
|
|
1357
|
+
optimize() {
|
|
1358
|
+
this.db.optimize();
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Clear all data from the graph
|
|
1362
|
+
*/
|
|
1363
|
+
clear() {
|
|
1364
|
+
this.queries.clear();
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Alias for close() for backwards compatibility.
|
|
1368
|
+
* @deprecated Use close() instead
|
|
1369
|
+
*/
|
|
1370
|
+
destroy() {
|
|
1371
|
+
this.close();
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Completely remove BHGraph from the project.
|
|
1375
|
+
* This closes the database and deletes the .BHGraph directory.
|
|
1376
|
+
*
|
|
1377
|
+
* WARNING: This permanently deletes all BHGraph data for the project.
|
|
1378
|
+
*/
|
|
1379
|
+
uninitialize() {
|
|
1380
|
+
this.close();
|
|
1381
|
+
(0, directory_1.removeDirectory)(this.projectRoot);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
exports.BHGraph = BHGraph;
|
|
1385
|
+
// Default export
|
|
1386
|
+
exports.default = BHGraph;
|
|
1387
|
+
//# sourceMappingURL=index.js.map
|