@colbymchenry/codegraph-win32-arm64 1.6.0 → 1.6.2
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/codegraph +5 -0
- package/lib/dist/.test-build-engine.json +1 -0
- package/lib/dist/.test-build-viewer.json +1 -0
- package/lib/dist/bin/codegraph.d.ts +1 -0
- package/lib/dist/bin/codegraph.d.ts.map +1 -1
- package/lib/dist/bin/codegraph.js +605 -291
- package/lib/dist/bin/codegraph.js.map +1 -1
- package/lib/dist/bin/command-supervision.d.ts +7 -0
- package/lib/dist/bin/command-supervision.d.ts.map +1 -1
- package/lib/dist/bin/command-supervision.js +39 -27
- package/lib/dist/bin/command-supervision.js.map +1 -1
- package/lib/dist/bin/viewer-gate.d.ts +17 -0
- package/lib/dist/bin/viewer-gate.d.ts.map +1 -0
- package/lib/dist/bin/viewer-gate.js +31 -0
- package/lib/dist/bin/viewer-gate.js.map +1 -0
- package/lib/dist/context/index.d.ts.map +1 -1
- package/lib/dist/context/index.js +43 -2
- package/lib/dist/context/index.js.map +1 -1
- package/lib/dist/db/index.d.ts +21 -2
- package/lib/dist/db/index.d.ts.map +1 -1
- package/lib/dist/db/index.js +86 -31
- package/lib/dist/db/index.js.map +1 -1
- package/lib/dist/db/migrations.d.ts +1 -1
- package/lib/dist/db/migrations.d.ts.map +1 -1
- package/lib/dist/db/migrations.js +40 -1
- package/lib/dist/db/migrations.js.map +1 -1
- package/lib/dist/db/queries.d.ts +454 -10
- package/lib/dist/db/queries.d.ts.map +1 -1
- package/lib/dist/db/queries.js +1080 -41
- package/lib/dist/db/queries.js.map +1 -1
- package/lib/dist/db/schema.sql +11 -1
- package/lib/dist/db/sqlite-adapter.d.ts +2 -0
- package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
- package/lib/dist/db/sqlite-adapter.js +56 -7
- package/lib/dist/db/sqlite-adapter.js.map +1 -1
- package/lib/dist/db/synthesis-stage.d.ts +12 -0
- package/lib/dist/db/synthesis-stage.d.ts.map +1 -0
- package/lib/dist/db/synthesis-stage.js +89 -0
- package/lib/dist/db/synthesis-stage.js.map +1 -0
- package/lib/dist/db/wal-valve.d.ts +32 -12
- package/lib/dist/db/wal-valve.d.ts.map +1 -1
- package/lib/dist/db/wal-valve.js +65 -22
- package/lib/dist/db/wal-valve.js.map +1 -1
- package/lib/dist/db/wsl-shared-index.d.ts +53 -0
- package/lib/dist/db/wsl-shared-index.d.ts.map +1 -0
- package/lib/dist/db/wsl-shared-index.js +121 -0
- package/lib/dist/db/wsl-shared-index.js.map +1 -0
- package/lib/dist/directory.d.ts +131 -2
- package/lib/dist/directory.d.ts.map +1 -1
- package/lib/dist/directory.js +299 -23
- package/lib/dist/directory.js.map +1 -1
- package/lib/dist/errors.d.ts +14 -0
- package/lib/dist/errors.d.ts.map +1 -1
- package/lib/dist/errors.js +16 -1
- package/lib/dist/errors.js.map +1 -1
- package/lib/dist/extraction/astro-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/astro-extractor.js +7 -35
- package/lib/dist/extraction/astro-extractor.js.map +1 -1
- package/lib/dist/extraction/cfml-extractor.d.ts +77 -10
- package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/cfml-extractor.js +302 -71
- package/lib/dist/extraction/cfml-extractor.js.map +1 -1
- package/lib/dist/extraction/commonjs-requires.d.ts +23 -0
- package/lib/dist/extraction/commonjs-requires.d.ts.map +1 -0
- package/lib/dist/extraction/commonjs-requires.js +68 -0
- package/lib/dist/extraction/commonjs-requires.js.map +1 -0
- package/lib/dist/extraction/dfm-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/dfm-extractor.js +14 -10
- package/lib/dist/extraction/dfm-extractor.js.map +1 -1
- package/lib/dist/extraction/extraction-version.d.ts +1 -1
- package/lib/dist/extraction/extraction-version.js +1 -1
- package/lib/dist/extraction/function-ref.d.ts +6 -4
- package/lib/dist/extraction/function-ref.d.ts.map +1 -1
- package/lib/dist/extraction/function-ref.js +35 -14
- package/lib/dist/extraction/function-ref.js.map +1 -1
- package/lib/dist/extraction/generated-detection.d.ts +9 -0
- package/lib/dist/extraction/generated-detection.d.ts.map +1 -1
- package/lib/dist/extraction/generated-detection.js +42 -2
- package/lib/dist/extraction/generated-detection.js.map +1 -1
- package/lib/dist/extraction/grammars.d.ts +40 -0
- package/lib/dist/extraction/grammars.d.ts.map +1 -1
- package/lib/dist/extraction/grammars.js +171 -1
- package/lib/dist/extraction/grammars.js.map +1 -1
- package/lib/dist/extraction/index.d.ts +132 -19
- package/lib/dist/extraction/index.d.ts.map +1 -1
- package/lib/dist/extraction/index.js +825 -195
- package/lib/dist/extraction/index.js.map +1 -1
- package/lib/dist/extraction/kernel/index.d.ts.map +1 -1
- package/lib/dist/extraction/kernel/index.js +6 -0
- package/lib/dist/extraction/kernel/index.js.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.d.ts +73 -0
- package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.js +412 -16
- package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
- package/lib/dist/extraction/languages/csharp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/csharp.js +14 -5
- package/lib/dist/extraction/languages/csharp.js.map +1 -1
- package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
- package/lib/dist/extraction/languages/dart.js +16 -3
- package/lib/dist/extraction/languages/dart.js.map +1 -1
- package/lib/dist/extraction/languages/javascript.js +1 -1
- package/lib/dist/extraction/languages/javascript.js.map +1 -1
- package/lib/dist/extraction/languages/kotlin.d.ts +4 -0
- package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
- package/lib/dist/extraction/languages/kotlin.js +237 -36
- package/lib/dist/extraction/languages/kotlin.js.map +1 -1
- package/lib/dist/extraction/languages/lua.d.ts.map +1 -1
- package/lib/dist/extraction/languages/lua.js +4 -1
- package/lib/dist/extraction/languages/lua.js.map +1 -1
- package/lib/dist/extraction/languages/python.d.ts.map +1 -1
- package/lib/dist/extraction/languages/python.js +71 -0
- package/lib/dist/extraction/languages/python.js.map +1 -1
- package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
- package/lib/dist/extraction/languages/rust.js +3 -0
- package/lib/dist/extraction/languages/rust.js.map +1 -1
- package/lib/dist/extraction/languages/scala.d.ts.map +1 -1
- package/lib/dist/extraction/languages/scala.js +18 -3
- package/lib/dist/extraction/languages/scala.js.map +1 -1
- package/lib/dist/extraction/languages/swift.d.ts +15 -0
- package/lib/dist/extraction/languages/swift.d.ts.map +1 -1
- package/lib/dist/extraction/languages/swift.js +50 -0
- package/lib/dist/extraction/languages/swift.js.map +1 -1
- package/lib/dist/extraction/languages/typescript.d.ts +7 -0
- package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
- package/lib/dist/extraction/languages/typescript.js +30 -2
- package/lib/dist/extraction/languages/typescript.js.map +1 -1
- package/lib/dist/extraction/liquid-extractor.d.ts +18 -0
- package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/liquid-extractor.js +98 -22
- package/lib/dist/extraction/liquid-extractor.js.map +1 -1
- package/lib/dist/extraction/mybatis-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/mybatis-extractor.js +6 -4
- package/lib/dist/extraction/mybatis-extractor.js.map +1 -1
- package/lib/dist/extraction/parse-budget.d.ts +16 -0
- package/lib/dist/extraction/parse-budget.d.ts.map +1 -0
- package/lib/dist/extraction/parse-budget.js +24 -0
- package/lib/dist/extraction/parse-budget.js.map +1 -0
- package/lib/dist/extraction/parse-pool.d.ts +12 -0
- package/lib/dist/extraction/parse-pool.d.ts.map +1 -1
- package/lib/dist/extraction/parse-pool.js +51 -3
- package/lib/dist/extraction/parse-pool.js.map +1 -1
- package/lib/dist/extraction/parse-worker.js +3 -1
- package/lib/dist/extraction/parse-worker.js.map +1 -1
- package/lib/dist/extraction/sfc-script.d.ts +43 -0
- package/lib/dist/extraction/sfc-script.d.ts.map +1 -0
- package/lib/dist/extraction/sfc-script.js +135 -0
- package/lib/dist/extraction/sfc-script.js.map +1 -0
- package/lib/dist/extraction/store-worker.js +5 -0
- package/lib/dist/extraction/store-worker.js.map +1 -1
- package/lib/dist/extraction/store-writer.d.ts +10 -2
- package/lib/dist/extraction/store-writer.d.ts.map +1 -1
- package/lib/dist/extraction/store-writer.js +12 -4
- package/lib/dist/extraction/store-writer.js.map +1 -1
- package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/svelte-extractor.js +7 -37
- package/lib/dist/extraction/svelte-extractor.js.map +1 -1
- package/lib/dist/extraction/syntax-tokens.d.ts +103 -0
- package/lib/dist/extraction/syntax-tokens.d.ts.map +1 -0
- package/lib/dist/extraction/syntax-tokens.js +382 -0
- package/lib/dist/extraction/syntax-tokens.js.map +1 -0
- package/lib/dist/extraction/tree-sitter-helpers.d.ts +5 -0
- package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter-helpers.js +17 -0
- package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
- package/lib/dist/extraction/tree-sitter-types.d.ts +29 -3
- package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.d.ts +104 -17
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.js +943 -88
- package/lib/dist/extraction/tree-sitter.js.map +1 -1
- package/lib/dist/extraction/vue-extractor.d.ts +7 -0
- package/lib/dist/extraction/vue-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/vue-extractor.js +73 -35
- package/lib/dist/extraction/vue-extractor.js.map +1 -1
- package/lib/dist/extraction/vue-options-api.d.ts +28 -0
- package/lib/dist/extraction/vue-options-api.d.ts.map +1 -0
- package/lib/dist/extraction/vue-options-api.js +196 -0
- package/lib/dist/extraction/vue-options-api.js.map +1 -0
- package/lib/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
- package/lib/dist/file-limits.d.ts +40 -0
- package/lib/dist/file-limits.d.ts.map +1 -0
- package/lib/dist/file-limits.js +147 -0
- package/lib/dist/file-limits.js.map +1 -0
- package/lib/dist/graph/branch-guards.d.ts +265 -0
- package/lib/dist/graph/branch-guards.d.ts.map +1 -0
- package/lib/dist/graph/branch-guards.js +2326 -0
- package/lib/dist/graph/branch-guards.js.map +1 -0
- package/lib/dist/graph/dead-code.d.ts +251 -0
- package/lib/dist/graph/dead-code.d.ts.map +1 -0
- package/lib/dist/graph/dead-code.js +776 -0
- package/lib/dist/graph/dead-code.js.map +1 -0
- package/lib/dist/graph/dynamic-boundary-report.d.ts +121 -0
- package/lib/dist/graph/dynamic-boundary-report.d.ts.map +1 -0
- package/lib/dist/graph/dynamic-boundary-report.js +283 -0
- package/lib/dist/graph/dynamic-boundary-report.js.map +1 -0
- package/lib/dist/graph/index.d.ts +4 -0
- package/lib/dist/graph/index.d.ts.map +1 -1
- package/lib/dist/graph/index.js +16 -1
- package/lib/dist/graph/index.js.map +1 -1
- package/lib/dist/graph/named-symbol-flow.d.ts +125 -0
- package/lib/dist/graph/named-symbol-flow.d.ts.map +1 -0
- package/lib/dist/graph/named-symbol-flow.js +559 -0
- package/lib/dist/graph/named-symbol-flow.js.map +1 -0
- package/lib/dist/graph/symbol-lookup.d.ts +83 -0
- package/lib/dist/graph/symbol-lookup.d.ts.map +1 -0
- package/lib/dist/graph/symbol-lookup.js +181 -0
- package/lib/dist/graph/symbol-lookup.js.map +1 -0
- package/lib/dist/graph/traversal.d.ts +9 -0
- package/lib/dist/graph/traversal.d.ts.map +1 -1
- package/lib/dist/graph/traversal.js +61 -35
- package/lib/dist/graph/traversal.js.map +1 -1
- package/lib/dist/graph/type-hierarchy.d.ts +155 -0
- package/lib/dist/graph/type-hierarchy.d.ts.map +1 -0
- package/lib/dist/graph/type-hierarchy.js +382 -0
- package/lib/dist/graph/type-hierarchy.js.map +1 -0
- package/lib/dist/index.d.ts +256 -11
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +402 -34
- package/lib/dist/index.js.map +1 -1
- package/lib/dist/installer/index.d.ts.map +1 -1
- package/lib/dist/installer/index.js +3 -2
- package/lib/dist/installer/index.js.map +1 -1
- package/lib/dist/installer/targets/antigravity.d.ts.map +1 -1
- package/lib/dist/installer/targets/antigravity.js +14 -2
- package/lib/dist/installer/targets/antigravity.js.map +1 -1
- package/lib/dist/installer/targets/claude.d.ts +3 -0
- package/lib/dist/installer/targets/claude.d.ts.map +1 -1
- package/lib/dist/installer/targets/claude.js +35 -7
- package/lib/dist/installer/targets/claude.js.map +1 -1
- package/lib/dist/installer/targets/codex.d.ts +2 -1
- package/lib/dist/installer/targets/codex.d.ts.map +1 -1
- package/lib/dist/installer/targets/codex.js +14 -4
- package/lib/dist/installer/targets/codex.js.map +1 -1
- package/lib/dist/installer/targets/copilot-cli.d.ts.map +1 -1
- package/lib/dist/installer/targets/copilot-cli.js +7 -1
- package/lib/dist/installer/targets/copilot-cli.js.map +1 -1
- package/lib/dist/installer/targets/opencode.d.ts +16 -5
- package/lib/dist/installer/targets/opencode.d.ts.map +1 -1
- package/lib/dist/installer/targets/opencode.js +73 -22
- package/lib/dist/installer/targets/opencode.js.map +1 -1
- package/lib/dist/installer/targets/shared.d.ts +14 -3
- package/lib/dist/installer/targets/shared.d.ts.map +1 -1
- package/lib/dist/installer/targets/shared.js +39 -11
- package/lib/dist/installer/targets/shared.js.map +1 -1
- package/lib/dist/installer/targets/types.d.ts +7 -0
- package/lib/dist/installer/targets/types.d.ts.map +1 -1
- package/lib/dist/mcp/answer-freshness.d.ts +10 -0
- package/lib/dist/mcp/answer-freshness.d.ts.map +1 -0
- package/lib/dist/mcp/answer-freshness.js +68 -0
- package/lib/dist/mcp/answer-freshness.js.map +1 -0
- package/lib/dist/mcp/daemon-manager.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-manager.js +16 -0
- package/lib/dist/mcp/daemon-manager.js.map +1 -1
- package/lib/dist/mcp/daemon-paths.d.ts +2 -0
- package/lib/dist/mcp/daemon-paths.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-paths.js +20 -5
- package/lib/dist/mcp/daemon-paths.js.map +1 -1
- package/lib/dist/mcp/daemon-registry.d.ts +11 -4
- package/lib/dist/mcp/daemon-registry.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-registry.js +132 -36
- package/lib/dist/mcp/daemon-registry.js.map +1 -1
- package/lib/dist/mcp/daemon.d.ts +17 -7
- package/lib/dist/mcp/daemon.d.ts.map +1 -1
- package/lib/dist/mcp/daemon.js +116 -24
- package/lib/dist/mcp/daemon.js.map +1 -1
- package/lib/dist/mcp/dynamic-boundaries.d.ts +1 -10
- package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -1
- package/lib/dist/mcp/dynamic-boundaries.js +46 -42
- package/lib/dist/mcp/dynamic-boundaries.js.map +1 -1
- package/lib/dist/mcp/engine.d.ts +30 -9
- package/lib/dist/mcp/engine.d.ts.map +1 -1
- package/lib/dist/mcp/engine.js +158 -66
- package/lib/dist/mcp/engine.js.map +1 -1
- package/lib/dist/mcp/explore-dedup.d.ts +5 -2
- package/lib/dist/mcp/explore-dedup.d.ts.map +1 -1
- package/lib/dist/mcp/explore-dedup.js +8 -5
- package/lib/dist/mcp/explore-dedup.js.map +1 -1
- package/lib/dist/mcp/index-freshness-worker.d.ts +2 -0
- package/lib/dist/mcp/index-freshness-worker.d.ts.map +1 -0
- package/lib/dist/mcp/index-freshness-worker.js +36 -0
- package/lib/dist/mcp/index-freshness-worker.js.map +1 -0
- package/lib/dist/mcp/index-freshness.d.ts +13 -0
- package/lib/dist/mcp/index-freshness.d.ts.map +1 -0
- package/lib/dist/mcp/index-freshness.js +117 -0
- package/lib/dist/mcp/index-freshness.js.map +1 -0
- package/lib/dist/mcp/index.d.ts +3 -1
- package/lib/dist/mcp/index.d.ts.map +1 -1
- package/lib/dist/mcp/index.js +95 -11
- package/lib/dist/mcp/index.js.map +1 -1
- package/lib/dist/mcp/liveness-watchdog.d.ts +4 -1
- package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -1
- package/lib/dist/mcp/liveness-watchdog.js +11 -2
- package/lib/dist/mcp/liveness-watchdog.js.map +1 -1
- package/lib/dist/mcp/project-lifecycle.d.ts +9 -0
- package/lib/dist/mcp/project-lifecycle.d.ts.map +1 -0
- package/lib/dist/mcp/project-lifecycle.js +182 -0
- package/lib/dist/mcp/project-lifecycle.js.map +1 -0
- package/lib/dist/mcp/proxy.d.ts +9 -2
- package/lib/dist/mcp/proxy.d.ts.map +1 -1
- package/lib/dist/mcp/proxy.js +201 -32
- package/lib/dist/mcp/proxy.js.map +1 -1
- package/lib/dist/mcp/query-pool.d.ts +18 -3
- package/lib/dist/mcp/query-pool.d.ts.map +1 -1
- package/lib/dist/mcp/query-pool.js +67 -11
- package/lib/dist/mcp/query-pool.js.map +1 -1
- package/lib/dist/mcp/query-worker.js +2 -2
- package/lib/dist/mcp/query-worker.js.map +1 -1
- package/lib/dist/mcp/server-instructions.d.ts +1 -1
- package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
- package/lib/dist/mcp/server-instructions.js +6 -3
- package/lib/dist/mcp/server-instructions.js.map +1 -1
- package/lib/dist/mcp/startup-handshake.d.ts +3 -1
- package/lib/dist/mcp/startup-handshake.d.ts.map +1 -1
- package/lib/dist/mcp/startup-handshake.js +10 -2
- package/lib/dist/mcp/startup-handshake.js.map +1 -1
- package/lib/dist/mcp/tools.d.ts +306 -36
- package/lib/dist/mcp/tools.d.ts.map +1 -1
- package/lib/dist/mcp/tools.js +2395 -966
- package/lib/dist/mcp/tools.js.map +1 -1
- package/lib/dist/mcp/writer-lock.d.ts +61 -0
- package/lib/dist/mcp/writer-lock.d.ts.map +1 -0
- package/lib/dist/mcp/writer-lock.js +260 -0
- package/lib/dist/mcp/writer-lock.js.map +1 -0
- package/lib/dist/resolution/alias-binding.d.ts +56 -0
- package/lib/dist/resolution/alias-binding.d.ts.map +1 -0
- package/lib/dist/resolution/alias-binding.js +143 -0
- package/lib/dist/resolution/alias-binding.js.map +1 -0
- package/lib/dist/resolution/angular-template-synthesizer.d.ts +49 -0
- package/lib/dist/resolution/angular-template-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/angular-template-synthesizer.js +359 -0
- package/lib/dist/resolution/angular-template-synthesizer.js.map +1 -0
- package/lib/dist/resolution/callback-synthesizer.d.ts +23 -1
- package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.js +460 -144
- package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
- package/lib/dist/resolution/cpp-constructor.d.ts +4 -0
- package/lib/dist/resolution/cpp-constructor.d.ts.map +1 -0
- package/lib/dist/resolution/cpp-constructor.js +123 -0
- package/lib/dist/resolution/cpp-constructor.js.map +1 -0
- package/lib/dist/resolution/cpp-macro-visibility.d.ts +12 -0
- package/lib/dist/resolution/cpp-macro-visibility.d.ts.map +1 -0
- package/lib/dist/resolution/cpp-macro-visibility.js +392 -0
- package/lib/dist/resolution/cpp-macro-visibility.js.map +1 -0
- package/lib/dist/resolution/expo-router-synthesizer.d.ts +32 -0
- package/lib/dist/resolution/expo-router-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/expo-router-synthesizer.js +189 -0
- package/lib/dist/resolution/expo-router-synthesizer.js.map +1 -0
- package/lib/dist/resolution/frameworks/angular-router.d.ts +142 -0
- package/lib/dist/resolution/frameworks/angular-router.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/angular-router.js +1126 -0
- package/lib/dist/resolution/frameworks/angular-router.js.map +1 -0
- package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/astro.js +32 -6
- package/lib/dist/resolution/frameworks/astro.js.map +1 -1
- package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/csharp.js +186 -24
- package/lib/dist/resolution/frameworks/csharp.js.map +1 -1
- package/lib/dist/resolution/frameworks/expo-modules.d.ts +10 -0
- package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/expo-modules.js +95 -1
- package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -1
- package/lib/dist/resolution/frameworks/expo-router.d.ts +195 -0
- package/lib/dist/resolution/frameworks/expo-router.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/expo-router.js +847 -0
- package/lib/dist/resolution/frameworks/expo-router.js.map +1 -0
- package/lib/dist/resolution/frameworks/express.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/express.js +339 -45
- package/lib/dist/resolution/frameworks/express.js.map +1 -1
- package/lib/dist/resolution/frameworks/fabric.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/fabric.js +13 -11
- package/lib/dist/resolution/frameworks/fabric.js.map +1 -1
- package/lib/dist/resolution/frameworks/go.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/go.js +11 -28
- package/lib/dist/resolution/frameworks/go.js.map +1 -1
- package/lib/dist/resolution/frameworks/index.d.ts +8 -2
- package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/index.js +39 -1
- package/lib/dist/resolution/frameworks/index.js.map +1 -1
- package/lib/dist/resolution/frameworks/java.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/java.js +88 -68
- package/lib/dist/resolution/frameworks/java.js.map +1 -1
- package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/laravel.js +369 -26
- package/lib/dist/resolution/frameworks/laravel.js.map +1 -1
- package/lib/dist/resolution/frameworks/name-heuristic.d.ts +35 -0
- package/lib/dist/resolution/frameworks/name-heuristic.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/name-heuristic.js +45 -0
- package/lib/dist/resolution/frameworks/name-heuristic.js.map +1 -0
- package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/nestjs.js +288 -55
- package/lib/dist/resolution/frameworks/nestjs.js.map +1 -1
- package/lib/dist/resolution/frameworks/nextjs.d.ts +76 -0
- package/lib/dist/resolution/frameworks/nextjs.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/nextjs.js +329 -0
- package/lib/dist/resolution/frameworks/nextjs.js.map +1 -0
- package/lib/dist/resolution/frameworks/object-literal.d.ts +32 -0
- package/lib/dist/resolution/frameworks/object-literal.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/object-literal.js +139 -0
- package/lib/dist/resolution/frameworks/object-literal.js.map +1 -0
- package/lib/dist/resolution/frameworks/package-deps.d.ts +14 -0
- package/lib/dist/resolution/frameworks/package-deps.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/package-deps.js +78 -0
- package/lib/dist/resolution/frameworks/package-deps.js.map +1 -0
- package/lib/dist/resolution/frameworks/page-component.d.ts +20 -0
- package/lib/dist/resolution/frameworks/page-component.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/page-component.js +45 -0
- package/lib/dist/resolution/frameworks/page-component.js.map +1 -0
- package/lib/dist/resolution/frameworks/play.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/play.js +3 -1
- package/lib/dist/resolution/frameworks/play.js.map +1 -1
- package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/python.js +279 -26
- package/lib/dist/resolution/frameworks/python.js.map +1 -1
- package/lib/dist/resolution/frameworks/react-native.d.ts +26 -0
- package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react-native.js +153 -14
- package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
- package/lib/dist/resolution/frameworks/react-router.d.ts +47 -0
- package/lib/dist/resolution/frameworks/react-router.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/react-router.js +201 -0
- package/lib/dist/resolution/frameworks/react-router.js.map +1 -0
- package/lib/dist/resolution/frameworks/react.d.ts +13 -2
- package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react.js +542 -144
- package/lib/dist/resolution/frameworks/react.js.map +1 -1
- package/lib/dist/resolution/frameworks/ruby.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/ruby.js +177 -17
- package/lib/dist/resolution/frameworks/ruby.js.map +1 -1
- package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/rust.js +24 -22
- package/lib/dist/resolution/frameworks/rust.js.map +1 -1
- package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/svelte.js +14 -6
- package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
- package/lib/dist/resolution/frameworks/sveltekit-router.d.ts +36 -0
- package/lib/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/sveltekit-router.js +156 -0
- package/lib/dist/resolution/frameworks/sveltekit-router.js.map +1 -0
- package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/swift.js +253 -124
- package/lib/dist/resolution/frameworks/swift.js.map +1 -1
- package/lib/dist/resolution/frameworks/tanstack-router.d.ts +84 -0
- package/lib/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/tanstack-router.js +437 -0
- package/lib/dist/resolution/frameworks/tanstack-router.js.map +1 -0
- package/lib/dist/resolution/frameworks/vue-router.d.ts +98 -0
- package/lib/dist/resolution/frameworks/vue-router.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/vue-router.js +500 -0
- package/lib/dist/resolution/frameworks/vue-router.js.map +1 -0
- package/lib/dist/resolution/frameworks/vue.d.ts +9 -2
- package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/vue.js +45 -11
- package/lib/dist/resolution/frameworks/vue.js.map +1 -1
- package/lib/dist/resolution/import-resolver.d.ts +66 -0
- package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
- package/lib/dist/resolution/import-resolver.js +643 -61
- package/lib/dist/resolution/import-resolver.js.map +1 -1
- package/lib/dist/resolution/index.d.ts +124 -25
- package/lib/dist/resolution/index.d.ts.map +1 -1
- package/lib/dist/resolution/index.js +769 -152
- package/lib/dist/resolution/index.js.map +1 -1
- package/lib/dist/resolution/js-builtins.d.ts +13 -0
- package/lib/dist/resolution/js-builtins.d.ts.map +1 -0
- package/lib/dist/resolution/js-builtins.js +48 -0
- package/lib/dist/resolution/js-builtins.js.map +1 -0
- package/lib/dist/resolution/name-matcher.d.ts +101 -22
- package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
- package/lib/dist/resolution/name-matcher.js +8267 -287
- package/lib/dist/resolution/name-matcher.js.map +1 -1
- package/lib/dist/resolution/next-router-synthesizer.d.ts +27 -0
- package/lib/dist/resolution/next-router-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/next-router-synthesizer.js +113 -0
- package/lib/dist/resolution/next-router-synthesizer.js.map +1 -0
- package/lib/dist/resolution/react-router-synthesizer.d.ts +35 -0
- package/lib/dist/resolution/react-router-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/react-router-synthesizer.js +197 -0
- package/lib/dist/resolution/react-router-synthesizer.js.map +1 -0
- package/lib/dist/resolution/resolver-pool.d.ts +22 -1
- package/lib/dist/resolution/resolver-pool.d.ts.map +1 -1
- package/lib/dist/resolution/resolver-pool.js +35 -5
- package/lib/dist/resolution/resolver-pool.js.map +1 -1
- package/lib/dist/resolution/resolver-worker.js +3 -0
- package/lib/dist/resolution/resolver-worker.js.map +1 -1
- package/lib/dist/resolution/strip-comments.d.ts +6 -0
- package/lib/dist/resolution/strip-comments.d.ts.map +1 -1
- package/lib/dist/resolution/strip-comments.js +58 -0
- package/lib/dist/resolution/strip-comments.js.map +1 -1
- package/lib/dist/resolution/sveltekit-synthesizer.d.ts +58 -0
- package/lib/dist/resolution/sveltekit-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/sveltekit-synthesizer.js +173 -0
- package/lib/dist/resolution/sveltekit-synthesizer.js.map +1 -0
- package/lib/dist/resolution/swift-type-visibility.d.ts +68 -0
- package/lib/dist/resolution/swift-type-visibility.d.ts.map +1 -0
- package/lib/dist/resolution/swift-type-visibility.js +454 -0
- package/lib/dist/resolution/swift-type-visibility.js.map +1 -0
- package/lib/dist/resolution/synth-utils.d.ts +26 -0
- package/lib/dist/resolution/synth-utils.d.ts.map +1 -0
- package/lib/dist/resolution/synth-utils.js +75 -0
- package/lib/dist/resolution/synth-utils.js.map +1 -0
- package/lib/dist/resolution/tanstack-router-synthesizer.d.ts +31 -0
- package/lib/dist/resolution/tanstack-router-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/tanstack-router-synthesizer.js +114 -0
- package/lib/dist/resolution/tanstack-router-synthesizer.js.map +1 -0
- package/lib/dist/resolution/tier-synthesizer.d.ts +54 -0
- package/lib/dist/resolution/tier-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/tier-synthesizer.js +1294 -0
- package/lib/dist/resolution/tier-synthesizer.js.map +1 -0
- package/lib/dist/resolution/type-parameters.d.ts +11 -0
- package/lib/dist/resolution/type-parameters.d.ts.map +1 -0
- package/lib/dist/resolution/type-parameters.js +287 -0
- package/lib/dist/resolution/type-parameters.js.map +1 -0
- package/lib/dist/resolution/types.d.ts +105 -2
- package/lib/dist/resolution/types.d.ts.map +1 -1
- package/lib/dist/resolution/types.js +64 -0
- package/lib/dist/resolution/types.js.map +1 -1
- package/lib/dist/resolution/vue-router-synthesizer.d.ts +30 -0
- package/lib/dist/resolution/vue-router-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/vue-router-synthesizer.js +115 -0
- package/lib/dist/resolution/vue-router-synthesizer.js.map +1 -0
- package/lib/dist/search/query-paths.d.ts +50 -1
- package/lib/dist/search/query-paths.d.ts.map +1 -1
- package/lib/dist/search/query-paths.js +227 -12
- package/lib/dist/search/query-paths.js.map +1 -1
- package/lib/dist/search/query-utils.d.ts +15 -0
- package/lib/dist/search/query-utils.d.ts.map +1 -1
- package/lib/dist/search/query-utils.js +35 -7
- package/lib/dist/search/query-utils.js.map +1 -1
- package/lib/dist/sync/watch-policy.d.ts +14 -0
- package/lib/dist/sync/watch-policy.d.ts.map +1 -1
- package/lib/dist/sync/watch-policy.js +19 -0
- package/lib/dist/sync/watch-policy.js.map +1 -1
- package/lib/dist/sync/watcher.d.ts +52 -35
- package/lib/dist/sync/watcher.d.ts.map +1 -1
- package/lib/dist/sync/watcher.js +236 -100
- package/lib/dist/sync/watcher.js.map +1 -1
- package/lib/dist/sync/worktree.d.ts +22 -0
- package/lib/dist/sync/worktree.d.ts.map +1 -1
- package/lib/dist/sync/worktree.js +54 -0
- package/lib/dist/sync/worktree.js.map +1 -1
- package/lib/dist/telemetry/index.d.ts +4 -2
- package/lib/dist/telemetry/index.d.ts.map +1 -1
- package/lib/dist/telemetry/index.js +159 -66
- package/lib/dist/telemetry/index.js.map +1 -1
- package/lib/dist/types.d.ts +1 -1
- package/lib/dist/types.d.ts.map +1 -1
- package/lib/dist/types.js +1 -0
- package/lib/dist/types.js.map +1 -1
- package/lib/dist/ui-server/api/deadcode.d.ts +84 -0
- package/lib/dist/ui-server/api/deadcode.d.ts.map +1 -0
- package/lib/dist/ui-server/api/deadcode.js +136 -0
- package/lib/dist/ui-server/api/deadcode.js.map +1 -0
- package/lib/dist/ui-server/api/effects.d.ts +94 -0
- package/lib/dist/ui-server/api/effects.d.ts.map +1 -0
- package/lib/dist/ui-server/api/effects.js +527 -0
- package/lib/dist/ui-server/api/effects.js.map +1 -0
- package/lib/dist/ui-server/api/entrypoints.d.ts +92 -0
- package/lib/dist/ui-server/api/entrypoints.d.ts.map +1 -0
- package/lib/dist/ui-server/api/entrypoints.js +364 -0
- package/lib/dist/ui-server/api/entrypoints.js.map +1 -0
- package/lib/dist/ui-server/api/events.d.ts +183 -0
- package/lib/dist/ui-server/api/events.d.ts.map +1 -0
- package/lib/dist/ui-server/api/events.js +430 -0
- package/lib/dist/ui-server/api/events.js.map +1 -0
- package/lib/dist/ui-server/api/file.d.ts +66 -0
- package/lib/dist/ui-server/api/file.d.ts.map +1 -0
- package/lib/dist/ui-server/api/file.js +235 -0
- package/lib/dist/ui-server/api/file.js.map +1 -0
- package/lib/dist/ui-server/api/filecode.d.ts +126 -0
- package/lib/dist/ui-server/api/filecode.d.ts.map +1 -0
- package/lib/dist/ui-server/api/filecode.js +205 -0
- package/lib/dist/ui-server/api/filecode.js.map +1 -0
- package/lib/dist/ui-server/api/flow.d.ts +226 -0
- package/lib/dist/ui-server/api/flow.d.ts.map +1 -0
- package/lib/dist/ui-server/api/flow.js +612 -0
- package/lib/dist/ui-server/api/flow.js.map +1 -0
- package/lib/dist/ui-server/api/hierarchy.d.ts +81 -0
- package/lib/dist/ui-server/api/hierarchy.d.ts.map +1 -0
- package/lib/dist/ui-server/api/hierarchy.js +92 -0
- package/lib/dist/ui-server/api/hierarchy.js.map +1 -0
- package/lib/dist/ui-server/api/index.d.ts +90 -0
- package/lib/dist/ui-server/api/index.d.ts.map +1 -0
- package/lib/dist/ui-server/api/index.js +332 -0
- package/lib/dist/ui-server/api/index.js.map +1 -0
- package/lib/dist/ui-server/api/map.d.ts +273 -0
- package/lib/dist/ui-server/api/map.d.ts.map +1 -0
- package/lib/dist/ui-server/api/map.js +781 -0
- package/lib/dist/ui-server/api/map.js.map +1 -0
- package/lib/dist/ui-server/api/node.d.ts +81 -0
- package/lib/dist/ui-server/api/node.d.ts.map +1 -0
- package/lib/dist/ui-server/api/node.js +394 -0
- package/lib/dist/ui-server/api/node.js.map +1 -0
- package/lib/dist/ui-server/api/nodes.d.ts +25 -0
- package/lib/dist/ui-server/api/nodes.d.ts.map +1 -0
- package/lib/dist/ui-server/api/nodes.js +45 -0
- package/lib/dist/ui-server/api/nodes.js.map +1 -0
- package/lib/dist/ui-server/api/program.d.ts +139 -0
- package/lib/dist/ui-server/api/program.d.ts.map +1 -0
- package/lib/dist/ui-server/api/program.js +315 -0
- package/lib/dist/ui-server/api/program.js.map +1 -0
- package/lib/dist/ui-server/api/respond.d.ts +76 -0
- package/lib/dist/ui-server/api/respond.d.ts.map +1 -0
- package/lib/dist/ui-server/api/respond.js +186 -0
- package/lib/dist/ui-server/api/respond.js.map +1 -0
- package/lib/dist/ui-server/api/route-roots.d.ts +45 -0
- package/lib/dist/ui-server/api/route-roots.d.ts.map +1 -0
- package/lib/dist/ui-server/api/route-roots.js +117 -0
- package/lib/dist/ui-server/api/route-roots.js.map +1 -0
- package/lib/dist/ui-server/api/routes.d.ts +61 -0
- package/lib/dist/ui-server/api/routes.d.ts.map +1 -0
- package/lib/dist/ui-server/api/routes.js +164 -0
- package/lib/dist/ui-server/api/routes.js.map +1 -0
- package/lib/dist/ui-server/api/screens.d.ts +117 -0
- package/lib/dist/ui-server/api/screens.d.ts.map +1 -0
- package/lib/dist/ui-server/api/screens.js +626 -0
- package/lib/dist/ui-server/api/screens.js.map +1 -0
- package/lib/dist/ui-server/api/search.d.ts +29 -0
- package/lib/dist/ui-server/api/search.d.ts.map +1 -0
- package/lib/dist/ui-server/api/search.js +232 -0
- package/lib/dist/ui-server/api/search.js.map +1 -0
- package/lib/dist/ui-server/api/session.d.ts +52 -0
- package/lib/dist/ui-server/api/session.d.ts.map +1 -0
- package/lib/dist/ui-server/api/session.js +196 -0
- package/lib/dist/ui-server/api/session.js.map +1 -0
- package/lib/dist/ui-server/api/source.d.ts +200 -0
- package/lib/dist/ui-server/api/source.d.ts.map +1 -0
- package/lib/dist/ui-server/api/source.js +422 -0
- package/lib/dist/ui-server/api/source.js.map +1 -0
- package/lib/dist/ui-server/api/stats.d.ts +27 -0
- package/lib/dist/ui-server/api/stats.d.ts.map +1 -0
- package/lib/dist/ui-server/api/stats.js +164 -0
- package/lib/dist/ui-server/api/stats.js.map +1 -0
- package/lib/dist/ui-server/api/steps.d.ts +274 -0
- package/lib/dist/ui-server/api/steps.d.ts.map +1 -0
- package/lib/dist/ui-server/api/steps.js +1554 -0
- package/lib/dist/ui-server/api/steps.js.map +1 -0
- package/lib/dist/ui-server/api/trail-store.d.ts +142 -0
- package/lib/dist/ui-server/api/trail-store.d.ts.map +1 -0
- package/lib/dist/ui-server/api/trail-store.js +323 -0
- package/lib/dist/ui-server/api/trail-store.js.map +1 -0
- package/lib/dist/ui-server/api/trails.d.ts +163 -0
- package/lib/dist/ui-server/api/trails.d.ts.map +1 -0
- package/lib/dist/ui-server/api/trails.js +370 -0
- package/lib/dist/ui-server/api/trails.js.map +1 -0
- package/lib/dist/ui-server/api/when.d.ts +133 -0
- package/lib/dist/ui-server/api/when.d.ts.map +1 -0
- package/lib/dist/ui-server/api/when.js +275 -0
- package/lib/dist/ui-server/api/when.js.map +1 -0
- package/lib/dist/ui-server/api/wire.d.ts +179 -0
- package/lib/dist/ui-server/api/wire.d.ts.map +1 -0
- package/lib/dist/ui-server/api/wire.js +231 -0
- package/lib/dist/ui-server/api/wire.js.map +1 -0
- package/lib/dist/ui-server/assets.d.ts +40 -0
- package/lib/dist/ui-server/assets.d.ts.map +1 -0
- package/lib/dist/ui-server/assets.js +110 -0
- package/lib/dist/ui-server/assets.js.map +1 -0
- package/lib/dist/ui-server/constants.d.ts +32 -0
- package/lib/dist/ui-server/constants.d.ts.map +1 -0
- package/lib/dist/ui-server/constants.js +35 -0
- package/lib/dist/ui-server/constants.js.map +1 -0
- package/lib/dist/ui-server/highlight/bounded-tokenize.d.ts +28 -0
- package/lib/dist/ui-server/highlight/bounded-tokenize.d.ts.map +1 -0
- package/lib/dist/ui-server/highlight/bounded-tokenize.js +139 -0
- package/lib/dist/ui-server/highlight/bounded-tokenize.js.map +1 -0
- package/lib/dist/ui-server/highlight/index.d.ts +113 -0
- package/lib/dist/ui-server/highlight/index.d.ts.map +1 -0
- package/lib/dist/ui-server/highlight/index.js +312 -0
- package/lib/dist/ui-server/highlight/index.js.map +1 -0
- package/lib/dist/ui-server/highlight/languages.d.ts +36 -0
- package/lib/dist/ui-server/highlight/languages.d.ts.map +1 -0
- package/lib/dist/ui-server/highlight/languages.js +50 -0
- package/lib/dist/ui-server/highlight/languages.js.map +1 -0
- package/lib/dist/ui-server/highlight/tokenize-worker.d.ts +7 -0
- package/lib/dist/ui-server/highlight/tokenize-worker.d.ts.map +1 -0
- package/lib/dist/ui-server/highlight/tokenize-worker.js +20 -0
- package/lib/dist/ui-server/highlight/tokenize-worker.js.map +1 -0
- package/lib/dist/ui-server/index.d.ts +92 -0
- package/lib/dist/ui-server/index.d.ts.map +1 -0
- package/lib/dist/ui-server/index.js +399 -0
- package/lib/dist/ui-server/index.js.map +1 -0
- package/lib/dist/ui-server/open-browser.d.ts +31 -0
- package/lib/dist/ui-server/open-browser.d.ts.map +1 -0
- package/lib/dist/ui-server/open-browser.js +79 -0
- package/lib/dist/ui-server/open-browser.js.map +1 -0
- package/lib/dist/ui-server/security.d.ts +127 -0
- package/lib/dist/ui-server/security.d.ts.map +1 -0
- package/lib/dist/ui-server/security.js +332 -0
- package/lib/dist/ui-server/security.js.map +1 -0
- package/lib/dist/ui-server/static.d.ts +45 -0
- package/lib/dist/ui-server/static.d.ts.map +1 -0
- package/lib/dist/ui-server/static.js +165 -0
- package/lib/dist/ui-server/static.js.map +1 -0
- package/lib/dist/upgrade/index.d.ts +43 -5
- package/lib/dist/upgrade/index.d.ts.map +1 -1
- package/lib/dist/upgrade/index.js +157 -35
- package/lib/dist/upgrade/index.js.map +1 -1
- package/lib/dist/utils.d.ts +14 -2
- package/lib/dist/utils.d.ts.map +1 -1
- package/lib/dist/utils.js +25 -10
- package/lib/dist/utils.js.map +1 -1
- package/lib/dist/viewer/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
- package/lib/dist/viewer/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
- package/lib/dist/viewer/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-2syK4fUT.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-CBJ8pzag.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-B4oTjJdl.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-CBjNughH.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-italic-66oory27.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-italic-BqAiT5Ww.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-B7_fu1kp.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-Bg0ZHwF4.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-D6eaYXMU.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-DRuN92E5.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
- package/lib/dist/viewer/assets/index-BSGpxBr9.js +99 -0
- package/lib/dist/viewer/assets/index-CF9yvio6.css +1 -0
- package/lib/dist/viewer/index.html +16 -0
- package/lib/dist/worker-teardown.d.ts +48 -0
- package/lib/dist/worker-teardown.d.ts.map +1 -0
- package/lib/dist/worker-teardown.js +100 -0
- package/lib/dist/worker-teardown.js.map +1 -0
- package/lib/kernel/codegraph-kernel.node +2 -2
- package/lib/node_modules/.package-lock.json +4 -4
- package/lib/node_modules/picomatch/README.md +56 -51
- package/lib/node_modules/picomatch/lib/constants.js +4 -0
- package/lib/node_modules/picomatch/lib/parse.js +341 -1
- package/lib/node_modules/picomatch/lib/picomatch.js +25 -5
- package/lib/node_modules/picomatch/lib/scan.js +30 -18
- package/lib/node_modules/picomatch/package.json +4 -4
- package/lib/package.json +9 -2
- package/package.json +1 -1
package/lib/dist/db/queries.js
CHANGED
|
@@ -40,6 +40,23 @@ function isLowValueFile(filePath, generated) {
|
|
|
40
40
|
(0, generated_detection_1.isGeneratedFile)(filePath));
|
|
41
41
|
}
|
|
42
42
|
const SQLITE_PARAM_CHUNK_SIZE = 500;
|
|
43
|
+
/**
|
|
44
|
+
* A SQL predicate: is the node aliased `alias` a member an INTERFACE declares?
|
|
45
|
+
*
|
|
46
|
+
* `method_signature` / `property_signature` enter the graph as `method` /
|
|
47
|
+
* `property` nodes hung off their interface by a `contains` edge (#1638). They
|
|
48
|
+
* have no body and originate no behaviour, so for a structural judgement about
|
|
49
|
+
* a FILE they are the interface restated, not an extra thing the file declares.
|
|
50
|
+
* See {@link QueryBuilder.getAmbientDeclarationPathsAmong}, the one caller, for
|
|
51
|
+
* why treating them as opaque would break that rule in three places at once.
|
|
52
|
+
*
|
|
53
|
+
* Seeks `idx_edges_target_kind`, so it costs a key lookup per row rather than a
|
|
54
|
+
* join over the whole edge table.
|
|
55
|
+
*/
|
|
56
|
+
const IS_INTERFACE_MEMBER = (alias) => `EXISTS (
|
|
57
|
+
SELECT 1 FROM edges ce JOIN nodes owner ON owner.id = ce.source
|
|
58
|
+
WHERE ce.target = ${alias}.id AND ce.kind = 'contains' AND owner.kind = 'interface'
|
|
59
|
+
)`;
|
|
43
60
|
/**
|
|
44
61
|
* How much of the exact-name bonus a `deprioritize`d path keeps (#982). Damped
|
|
45
62
|
* rather than zeroed: a query that genuinely targets that tree must still rank
|
|
@@ -139,9 +156,15 @@ class QueryBuilder {
|
|
|
139
156
|
// Set once by the CodeGraph instance; empty by default (no down-weighting).
|
|
140
157
|
projectNameTokens = new Set();
|
|
141
158
|
isDeprioritizedPath;
|
|
159
|
+
// FTS5 availability flag — detected once at construction time (#1532)
|
|
160
|
+
_fts5Available;
|
|
142
161
|
// Node cache for frequently accessed nodes (LRU-style, max 1000 entries)
|
|
143
162
|
nodeCache = new Map();
|
|
144
163
|
maxCacheSize = 1000;
|
|
164
|
+
// getDominantFile()'s answer, tagged with the database change stamp it was
|
|
165
|
+
// computed under (see getChangeStamp). Query-independent, so one value
|
|
166
|
+
// serves every explore until the database changes (#1864).
|
|
167
|
+
dominantFileMemo;
|
|
145
168
|
// Prepared statements (lazily initialized)
|
|
146
169
|
stmts = {};
|
|
147
170
|
// Names whose segments were already written this session — skips re-splitting
|
|
@@ -158,6 +181,11 @@ class QueryBuilder {
|
|
|
158
181
|
// (and therefore resolution's insertion-order disambiguation) is identical
|
|
159
182
|
// to the one-row-per-run path.
|
|
160
183
|
batchStmts = new Map();
|
|
184
|
+
// Kind-filtered edge reads build their SQL per call (a variable IN list),
|
|
185
|
+
// but from a handful of kind sets: prepare each shape once. Supertype walks
|
|
186
|
+
// and the member-lookup passes issue them per node, and preparing cost
|
|
187
|
+
// about a third of the read.
|
|
188
|
+
edgeKindStmts = new Map();
|
|
161
189
|
static BATCH_SIZES = [128, 32, 8, 1];
|
|
162
190
|
/**
|
|
163
191
|
* Run `rows` through a multi-row `INSERT` built as `head + (tuple,)*n`,
|
|
@@ -193,6 +221,14 @@ class QueryBuilder {
|
|
|
193
221
|
}
|
|
194
222
|
constructor(db) {
|
|
195
223
|
this.db = db;
|
|
224
|
+
// Detect FTS5 availability once (#1532)
|
|
225
|
+
try {
|
|
226
|
+
db.prepare("SELECT * FROM nodes_fts LIMIT 0").get();
|
|
227
|
+
this._fts5Available = true;
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
this._fts5Available = false;
|
|
231
|
+
}
|
|
196
232
|
}
|
|
197
233
|
/**
|
|
198
234
|
* Swap the underlying connection in place. Used by pool workers'
|
|
@@ -210,6 +246,21 @@ class QueryBuilder {
|
|
|
210
246
|
this.db = db;
|
|
211
247
|
this.stmts = {};
|
|
212
248
|
this.batchStmts.clear();
|
|
249
|
+
this.edgeKindStmts.clear();
|
|
250
|
+
// The change stamp is per connection, and fresh connections to two
|
|
251
|
+
// different databases report the same one — the memo goes with the old
|
|
252
|
+
// connection, or a worker following a rebuilt index keeps its answer (#1864).
|
|
253
|
+
this.dominantFileMemo = undefined;
|
|
254
|
+
}
|
|
255
|
+
edgeKindStmt(sql) {
|
|
256
|
+
let stmt = this.edgeKindStmts.get(sql);
|
|
257
|
+
if (!stmt) {
|
|
258
|
+
if (this.edgeKindStmts.size >= 64)
|
|
259
|
+
this.edgeKindStmts.delete(this.edgeKindStmts.keys().next().value);
|
|
260
|
+
stmt = this.db.prepare(sql);
|
|
261
|
+
this.edgeKindStmts.set(sql, stmt);
|
|
262
|
+
}
|
|
263
|
+
return stmt;
|
|
213
264
|
}
|
|
214
265
|
/** Set the normalized project-name tokens used to down-weight non-discriminative
|
|
215
266
|
* query words in path scoring (#720). Called once when the project opens. */
|
|
@@ -380,6 +431,14 @@ class QueryBuilder {
|
|
|
380
431
|
this.runBatched('insertNameSegments', 'INSERT OR IGNORE INTO name_segment_vocab (segment, name) VALUES ', '(?,?)', segmentRows);
|
|
381
432
|
})();
|
|
382
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* Run `fn` as one transaction. The write helpers called inside join it
|
|
436
|
+
* rather than committing on their own, so a crash part-way leaves none of
|
|
437
|
+
* `fn`'s writes behind.
|
|
438
|
+
*/
|
|
439
|
+
runInTransaction(fn) {
|
|
440
|
+
return this.db.transaction(fn)();
|
|
441
|
+
}
|
|
383
442
|
/**
|
|
384
443
|
* Store one file's whole extraction bundle — nodes, edges, unresolved refs,
|
|
385
444
|
* and the file record — in a SINGLE transaction. The bulk-index path calls
|
|
@@ -688,10 +747,16 @@ class QueryBuilder {
|
|
|
688
747
|
const uniqueIds = [...new Set(ids)];
|
|
689
748
|
for (let i = 0; i < uniqueIds.length; i += SQLITE_PARAM_CHUNK_SIZE) {
|
|
690
749
|
const chunk = uniqueIds.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
750
|
+
// Every edge insert checks its endpoints here, a chunk at a time: the
|
|
751
|
+
// full-size statement is prepared once, the final partial chunk ad hoc.
|
|
752
|
+
let stmt;
|
|
753
|
+
if (chunk.length === SQLITE_PARAM_CHUNK_SIZE) {
|
|
754
|
+
stmt = this.stmts.existingNodeIdsFull ??= this.db.prepare(`SELECT id FROM nodes WHERE id IN (${new Array(SQLITE_PARAM_CHUNK_SIZE).fill('?').join(',')})`);
|
|
755
|
+
}
|
|
756
|
+
else {
|
|
757
|
+
stmt = this.db.prepare(`SELECT id FROM nodes WHERE id IN (${chunk.map(() => '?').join(',')})`);
|
|
758
|
+
}
|
|
759
|
+
const rows = stmt.all(...chunk);
|
|
695
760
|
for (const row of rows) {
|
|
696
761
|
out.add(row.id);
|
|
697
762
|
}
|
|
@@ -717,16 +782,78 @@ class QueryBuilder {
|
|
|
717
782
|
clearCache() {
|
|
718
783
|
this.nodeCache.clear();
|
|
719
784
|
}
|
|
785
|
+
/**
|
|
786
|
+
* Whether any node in `filePath` is exported — `getNodesByFile(f).some((n) =>
|
|
787
|
+
* n.isExported)` as one indexed probe, without decoding the file's nodes.
|
|
788
|
+
*/
|
|
789
|
+
fileHasExportedNode(filePath) {
|
|
790
|
+
if (!this.stmts.fileHasExportedNode) {
|
|
791
|
+
this.stmts.fileHasExportedNode = this.db.prepare('SELECT 1 FROM nodes WHERE file_path = ? AND is_exported = 1 LIMIT 1');
|
|
792
|
+
}
|
|
793
|
+
return this.stmts.fileHasExportedNode.get(filePath) !== undefined;
|
|
794
|
+
}
|
|
795
|
+
/** The exported nodes of a file, in {@link getNodesByFile} order, decoding only those rows. */
|
|
796
|
+
getExportedNodesByFile(filePath) {
|
|
797
|
+
if (!this.stmts.getExportedNodesByFile) {
|
|
798
|
+
this.stmts.getExportedNodesByFile = this.db.prepare('SELECT * FROM nodes WHERE file_path = ? AND is_exported = 1 ORDER BY start_line, id');
|
|
799
|
+
}
|
|
800
|
+
return this.stmts.getExportedNodesByFile.all(filePath).map(rowToNode);
|
|
801
|
+
}
|
|
802
|
+
/** The nodes of a file with one name, in {@link getNodesByFile} order, decoding only those rows. */
|
|
803
|
+
getNodesByFileAndName(filePath, name) {
|
|
804
|
+
if (!this.stmts.getNodesByFileAndName) {
|
|
805
|
+
this.stmts.getNodesByFileAndName = this.db.prepare('SELECT * FROM nodes WHERE file_path = ? AND name = ? ORDER BY start_line, id');
|
|
806
|
+
}
|
|
807
|
+
return this.stmts.getNodesByFileAndName.all(filePath, name).map(rowToNode);
|
|
808
|
+
}
|
|
720
809
|
/**
|
|
721
810
|
* Get all nodes in a file
|
|
722
811
|
*/
|
|
723
812
|
getNodesByFile(filePath) {
|
|
724
813
|
if (!this.stmts.getNodesByFile) {
|
|
725
|
-
this.stmts.getNodesByFile = this.db.prepare('SELECT * FROM nodes WHERE file_path = ? ORDER BY start_line');
|
|
814
|
+
this.stmts.getNodesByFile = this.db.prepare('SELECT * FROM nodes WHERE file_path = ? ORDER BY start_line, id');
|
|
726
815
|
}
|
|
727
816
|
const rows = this.stmts.getNodesByFile.all(filePath);
|
|
728
817
|
return rows.map(rowToNode);
|
|
729
818
|
}
|
|
819
|
+
/**
|
|
820
|
+
* The {@link NodeIdentity} of every node in a file, without decoding whole
|
|
821
|
+
* nodes. Read before a re-index deletes the file, so each incoming
|
|
822
|
+
* cross-file edge can follow its target to the node that replaces it (#2276).
|
|
823
|
+
*/
|
|
824
|
+
getNodeIdentitiesByFile(filePath) {
|
|
825
|
+
if (!this.stmts.getNodeIdentitiesByFile) {
|
|
826
|
+
this.stmts.getNodeIdentitiesByFile = this.db.prepare('SELECT id, kind, name, qualified_name, signature, start_line, start_column FROM nodes WHERE file_path = ?');
|
|
827
|
+
}
|
|
828
|
+
const rows = this.stmts.getNodeIdentitiesByFile.all(filePath);
|
|
829
|
+
return rows.map((row) => ({
|
|
830
|
+
id: row.id,
|
|
831
|
+
kind: row.kind,
|
|
832
|
+
name: row.name,
|
|
833
|
+
qualifiedName: row.qualified_name,
|
|
834
|
+
signature: row.signature ?? undefined,
|
|
835
|
+
startLine: row.start_line,
|
|
836
|
+
startColumn: row.start_column,
|
|
837
|
+
}));
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Get all nodes in several files at once — one chunked `IN` query rather than
|
|
841
|
+
* one {@link getNodesByFile} per file (#1975).
|
|
842
|
+
*/
|
|
843
|
+
getNodesByFiles(filePaths) {
|
|
844
|
+
const unique = [...new Set(filePaths)];
|
|
845
|
+
const out = [];
|
|
846
|
+
for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
|
|
847
|
+
const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
|
|
848
|
+
const placeholders = chunk.map(() => '?').join(',');
|
|
849
|
+
const rows = this.db
|
|
850
|
+
.prepare(`SELECT * FROM nodes WHERE file_path IN (${placeholders})`)
|
|
851
|
+
.all(...chunk);
|
|
852
|
+
for (const row of rows)
|
|
853
|
+
out.push(rowToNode(row));
|
|
854
|
+
}
|
|
855
|
+
return out;
|
|
856
|
+
}
|
|
730
857
|
/**
|
|
731
858
|
* Find the file that holds the densest concentration of the project's
|
|
732
859
|
* internal call graph — the "core" file. Used by context-builder to
|
|
@@ -744,8 +871,46 @@ class QueryBuilder {
|
|
|
744
871
|
* Excludes test/spec files from candidacy via path-pattern. The agent's
|
|
745
872
|
* typical question is "how does X work", not "how is X tested", so
|
|
746
873
|
* boosting a test file's directory would be a misfire.
|
|
874
|
+
*
|
|
875
|
+
* The answer depends only on the graph, never on the query, and the
|
|
876
|
+
* aggregation behind it scans every edge — seconds on a large index, paid
|
|
877
|
+
* by every generic explore (#1864). So it is memoized per database change
|
|
878
|
+
* stamp: recomputed only after something wrote to the database.
|
|
747
879
|
*/
|
|
748
880
|
getDominantFile() {
|
|
881
|
+
// total_changes() counts writes that are later rolled back, so a result
|
|
882
|
+
// read inside a transaction could outlive a ROLLBACK under an unchanged
|
|
883
|
+
// stamp. Never keep one; `undefined` (a runtime without the getter) is
|
|
884
|
+
// treated the same way.
|
|
885
|
+
if (this.db.inTransaction !== false) {
|
|
886
|
+
this.dominantFileMemo = undefined;
|
|
887
|
+
return this.computeDominantFile();
|
|
888
|
+
}
|
|
889
|
+
const stamp = this.getChangeStamp();
|
|
890
|
+
if (this.dominantFileMemo?.stamp === stamp)
|
|
891
|
+
return this.dominantFileMemo.value;
|
|
892
|
+
const value = this.computeDominantFile();
|
|
893
|
+
this.dominantFileMemo = { stamp, value };
|
|
894
|
+
return value;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* A value that differs whenever the database content may have changed
|
|
898
|
+
* since the last call, whoever changed it: `total_changes()` counts the
|
|
899
|
+
* rows this connection inserted, updated or deleted, and
|
|
900
|
+
* `PRAGMA data_version` moves when any OTHER connection — another process's
|
|
901
|
+
* sync, a CLI `codegraph index` beside a running MCP server — commits. Both
|
|
902
|
+
* are O(1), so no write path has to remember to invalidate anything.
|
|
903
|
+
* Coarse on purpose: any write, not just one to nodes/edges, forces a
|
|
904
|
+
* recompute, which only costs time, never a stale answer.
|
|
905
|
+
*/
|
|
906
|
+
getChangeStamp() {
|
|
907
|
+
if (!this.stmts.getChangeStamp) {
|
|
908
|
+
this.stmts.getChangeStamp = this.db.prepare('SELECT total_changes() AS changes, (SELECT data_version FROM pragma_data_version) AS version');
|
|
909
|
+
}
|
|
910
|
+
const row = this.stmts.getChangeStamp.get();
|
|
911
|
+
return `${row.changes}:${row.version}`;
|
|
912
|
+
}
|
|
913
|
+
computeDominantFile() {
|
|
749
914
|
if (!this.stmts.getDominantFile) {
|
|
750
915
|
// Pull top 20 candidates; we then filter out test/generated files
|
|
751
916
|
// in code (regex-grade matching that SQL LIKE can't express). The
|
|
@@ -827,10 +992,14 @@ class QueryBuilder {
|
|
|
827
992
|
if (!this.stmts.getRoutingManifest) {
|
|
828
993
|
// Edge kind varies across framework resolvers: Spring/Rails/
|
|
829
994
|
// Laravel/Drupal emit `references`, Express emits `calls`. Accept
|
|
830
|
-
// both — the semantic is the same (route → its handler).
|
|
995
|
+
// both — the semantic is the same (route → its handler). A screen in
|
|
996
|
+
// a Vue / Svelte / Astro app is served by a `component`.
|
|
831
997
|
this.stmts.getRoutingManifest = this.db.prepare(`
|
|
832
998
|
SELECT
|
|
833
999
|
r.name AS url,
|
|
1000
|
+
r.id AS route_id,
|
|
1001
|
+
r.file_path AS route_file,
|
|
1002
|
+
r.start_line AS route_line,
|
|
834
1003
|
h.name AS handler,
|
|
835
1004
|
h.file_path AS handler_file,
|
|
836
1005
|
h.start_line AS handler_line,
|
|
@@ -840,7 +1009,7 @@ class QueryBuilder {
|
|
|
840
1009
|
JOIN nodes h ON e.target = h.id
|
|
841
1010
|
WHERE r.kind = 'route'
|
|
842
1011
|
AND e.kind IN ('references', 'calls')
|
|
843
|
-
AND h.kind IN ('function', 'method', 'class')
|
|
1012
|
+
AND h.kind IN ('function', 'method', 'class', 'constant', 'variable', 'component')
|
|
844
1013
|
ORDER BY r.file_path, r.start_line
|
|
845
1014
|
LIMIT ?
|
|
846
1015
|
`);
|
|
@@ -871,6 +1040,9 @@ class QueryBuilder {
|
|
|
871
1040
|
handlerFile: r.handler_file,
|
|
872
1041
|
handlerLine: r.handler_line,
|
|
873
1042
|
handlerKind: r.handler_kind,
|
|
1043
|
+
routeId: r.route_id,
|
|
1044
|
+
routeFile: r.route_file,
|
|
1045
|
+
routeLine: r.route_line,
|
|
874
1046
|
})),
|
|
875
1047
|
topHandlerFile,
|
|
876
1048
|
topHandlerFileCount,
|
|
@@ -882,7 +1054,7 @@ class QueryBuilder {
|
|
|
882
1054
|
*/
|
|
883
1055
|
getNodesByKind(kind) {
|
|
884
1056
|
if (!this.stmts.getNodesByKind) {
|
|
885
|
-
this.stmts.getNodesByKind = this.db.prepare('SELECT * FROM nodes WHERE kind = ?');
|
|
1057
|
+
this.stmts.getNodesByKind = this.db.prepare('SELECT * FROM nodes WHERE kind = ? ORDER BY file_path, start_line, id');
|
|
886
1058
|
}
|
|
887
1059
|
const rows = this.stmts.getNodesByKind.all(kind);
|
|
888
1060
|
return rows.map(rowToNode);
|
|
@@ -897,11 +1069,29 @@ class QueryBuilder {
|
|
|
897
1069
|
*iterateNodesByKind(kind) {
|
|
898
1070
|
// Fresh statement per call (not a cached one): an iterator holds an open
|
|
899
1071
|
// cursor, so a shared statement would conflict across overlapping scans.
|
|
900
|
-
|
|
1072
|
+
// Synthesis uses first/last-match precedence and caps: insertion order
|
|
1073
|
+
// changes on sync. idx_nodes_kind streams this canonical order without
|
|
1074
|
+
// materializing/sorting all of a large project's methods in memory.
|
|
1075
|
+
const stmt = this.db.prepare('SELECT * FROM nodes WHERE kind = ? ORDER BY file_path, start_line, id');
|
|
901
1076
|
for (const row of stmt.iterate(kind)) {
|
|
902
1077
|
yield rowToNode(row);
|
|
903
1078
|
}
|
|
904
1079
|
}
|
|
1080
|
+
/**
|
|
1081
|
+
* iterateNodesByKind narrowed to some languages, in the same canonical
|
|
1082
|
+
* order — the ORDER BY is total (`id` is unique), so this yields exactly the
|
|
1083
|
+
* nodes a caller filtering iterateNodesByKind by language would keep, in the
|
|
1084
|
+
* same sequence. A Go pass on a TypeScript monorepo otherwise materialized
|
|
1085
|
+
* every method in the project to find a couple of Go ones.
|
|
1086
|
+
*/
|
|
1087
|
+
*iterateNodesByKindIn(kind, languages) {
|
|
1088
|
+
if (languages.length === 0)
|
|
1089
|
+
return;
|
|
1090
|
+
const stmt = this.db.prepare(`SELECT * FROM nodes WHERE kind = ? AND language IN (${languages.map(() => '?').join(', ')}) ORDER BY file_path, start_line, id`);
|
|
1091
|
+
for (const row of stmt.iterate(kind, ...languages)) {
|
|
1092
|
+
yield rowToNode(row);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
905
1095
|
/**
|
|
906
1096
|
* Get all nodes in the database
|
|
907
1097
|
*/
|
|
@@ -921,7 +1111,7 @@ class QueryBuilder {
|
|
|
921
1111
|
*iterateNodesByLanguageWithDecorator(language, decorator) {
|
|
922
1112
|
// Fresh statement per call — an iterator holds an open cursor (see
|
|
923
1113
|
// iterateNodesByKind).
|
|
924
|
-
const stmt = this.db.prepare("SELECT * FROM nodes WHERE language = ? AND decorators LIKE '%' || ? || '%'");
|
|
1114
|
+
const stmt = this.db.prepare("SELECT * FROM nodes WHERE language = ? AND decorators LIKE '%' || ? || '%' ORDER BY file_path, start_line, id");
|
|
925
1115
|
for (const row of stmt.iterate(language, `"${decorator}"`)) {
|
|
926
1116
|
yield rowToNode(row);
|
|
927
1117
|
}
|
|
@@ -956,7 +1146,7 @@ class QueryBuilder {
|
|
|
956
1146
|
*/
|
|
957
1147
|
getNodesByName(name) {
|
|
958
1148
|
if (!this.stmts.getNodesByName) {
|
|
959
|
-
this.stmts.getNodesByName = this.db.prepare('SELECT * FROM nodes WHERE name = ? ORDER BY file_path, start_line');
|
|
1149
|
+
this.stmts.getNodesByName = this.db.prepare('SELECT * FROM nodes WHERE name = ? ORDER BY file_path, start_line, id');
|
|
960
1150
|
}
|
|
961
1151
|
const rows = this.stmts.getNodesByName.all(name);
|
|
962
1152
|
return rows.map(rowToNode);
|
|
@@ -972,12 +1162,20 @@ class QueryBuilder {
|
|
|
972
1162
|
const rows = this.stmts.getNodesByNamePrefix.all(prefix, prefix + '', limit);
|
|
973
1163
|
return rows.map(rowToNode);
|
|
974
1164
|
}
|
|
1165
|
+
/** File nodes whose basename starts with `prefix`, without a result cap. */
|
|
1166
|
+
getFileNodesByNamePrefix(prefix) {
|
|
1167
|
+
if (!this.stmts.getFileNodesByNamePrefix) {
|
|
1168
|
+
this.stmts.getFileNodesByNamePrefix = this.db.prepare("SELECT * FROM nodes WHERE kind = 'file' AND name >= ? AND name < ? ORDER BY name");
|
|
1169
|
+
}
|
|
1170
|
+
const rows = this.stmts.getFileNodesByNamePrefix.all(prefix, prefix + '');
|
|
1171
|
+
return rows.map(rowToNode);
|
|
1172
|
+
}
|
|
975
1173
|
/**
|
|
976
1174
|
* Get nodes by exact qualified name match (uses idx_nodes_qualified_name index)
|
|
977
1175
|
*/
|
|
978
1176
|
getNodesByQualifiedNameExact(qualifiedName) {
|
|
979
1177
|
if (!this.stmts.getNodesByQualifiedNameExact) {
|
|
980
|
-
this.stmts.getNodesByQualifiedNameExact = this.db.prepare('SELECT * FROM nodes WHERE qualified_name = ?');
|
|
1178
|
+
this.stmts.getNodesByQualifiedNameExact = this.db.prepare('SELECT * FROM nodes WHERE qualified_name = ? ORDER BY file_path, start_line, id');
|
|
981
1179
|
}
|
|
982
1180
|
const rows = this.stmts.getNodesByQualifiedNameExact.all(qualifiedName);
|
|
983
1181
|
return rows.map(rowToNode);
|
|
@@ -1033,9 +1231,9 @@ class QueryBuilder {
|
|
|
1033
1231
|
const text = parsed.text;
|
|
1034
1232
|
const kinds = mergedKinds;
|
|
1035
1233
|
const languages = mergedLanguages;
|
|
1036
|
-
// First try FTS5 with prefix matching
|
|
1234
|
+
// First try FTS5 with prefix matching (skip if FTS5 not available, #1532)
|
|
1037
1235
|
let results = text
|
|
1038
|
-
? this.searchNodesFTS(text, { kinds, languages, limit, offset })
|
|
1236
|
+
? (this._fts5Available !== false ? this.searchNodesFTS(text, { kinds, languages, limit, offset }) : [])
|
|
1039
1237
|
// Over-fetch by 5× when running filter-only (no text). The
|
|
1040
1238
|
// post-scoring path: + name: filters can be very selective, so
|
|
1041
1239
|
// a smaller multiplier risks returning fewer than `limit`
|
|
@@ -1227,6 +1425,46 @@ class QueryBuilder {
|
|
|
1227
1425
|
}
|
|
1228
1426
|
return results;
|
|
1229
1427
|
}
|
|
1428
|
+
/** Bounded miss diagnostics, independent of relevance filters and ranking. */
|
|
1429
|
+
getExploreMissDiagnostics(query) {
|
|
1430
|
+
const words = [...new Set((query.match(/[\p{L}\p{N}]+/gu) ?? []).map(w => w.toLowerCase()))];
|
|
1431
|
+
const checked = words.filter(w => w.length <= 64).slice(0, 16);
|
|
1432
|
+
const limited = checked.length !== words.length;
|
|
1433
|
+
if (checked.length === 0)
|
|
1434
|
+
return { matched: [], unmatched: [], candidates: [], limited };
|
|
1435
|
+
// EXISTS uses FTS postings and the segment primary key, never source scans.
|
|
1436
|
+
// Vocab rows can outlive deleted definitions, so verify them against nodes.
|
|
1437
|
+
const rows = this.db.prepare(`
|
|
1438
|
+
WITH words(word, pattern) AS (VALUES ${checked.map(() => '(?, ?)').join(', ')})
|
|
1439
|
+
SELECT word, (
|
|
1440
|
+
EXISTS (SELECT 1 FROM nodes_fts WHERE nodes_fts MATCH pattern)
|
|
1441
|
+
OR EXISTS (
|
|
1442
|
+
SELECT 1 FROM name_segment_vocab v WHERE v.segment = word
|
|
1443
|
+
AND EXISTS (SELECT 1 FROM nodes n WHERE n.name = v.name AND n.kind NOT IN ('file', 'import'))
|
|
1444
|
+
)
|
|
1445
|
+
) AS matched FROM words
|
|
1446
|
+
`).all(...checked.flatMap(w => [w, `{name qualified_name signature docstring} : "${w}"*`]));
|
|
1447
|
+
const names = this.db.prepare(`
|
|
1448
|
+
SELECT name FROM (
|
|
1449
|
+
SELECT v.name FROM name_segment_vocab v
|
|
1450
|
+
WHERE v.segment IN (${checked.map(() => '?').join(', ')})
|
|
1451
|
+
AND EXISTS (SELECT 1 FROM nodes n WHERE n.name = v.name AND n.kind NOT IN ('file', 'import'))
|
|
1452
|
+
LIMIT 12
|
|
1453
|
+
)
|
|
1454
|
+
UNION ALL
|
|
1455
|
+
SELECT name FROM (
|
|
1456
|
+
SELECT n.name FROM nodes_fts JOIN nodes n ON n.rowid = nodes_fts.rowid
|
|
1457
|
+
WHERE nodes_fts MATCH ? AND n.kind NOT IN ('file', 'import')
|
|
1458
|
+
LIMIT 12
|
|
1459
|
+
)
|
|
1460
|
+
`).all(...checked, `name : (${checked.map(w => `"${w}"*`).join(' OR ')})`);
|
|
1461
|
+
return {
|
|
1462
|
+
matched: rows.filter(r => r.matched).map(r => r.word),
|
|
1463
|
+
unmatched: rows.filter(r => !r.matched).map(r => r.word),
|
|
1464
|
+
candidates: [...new Set(names.map(r => r.name))].slice(0, 12),
|
|
1465
|
+
limited,
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1230
1468
|
/**
|
|
1231
1469
|
* FTS5 search with prefix matching
|
|
1232
1470
|
*/
|
|
@@ -1464,6 +1702,30 @@ class QueryBuilder {
|
|
|
1464
1702
|
// ===========================================================================
|
|
1465
1703
|
// Edge Operations
|
|
1466
1704
|
// ===========================================================================
|
|
1705
|
+
/** Must run before file replacement/deletion cascades the endpoint edges. */
|
|
1706
|
+
hasSynthesizedEdgesTouchingFile(filePath) {
|
|
1707
|
+
const owned = "CASE WHEN json_valid(e.metadata) THEN json_extract(e.metadata, '$.synthesizedBy') END IS NOT NULL";
|
|
1708
|
+
for (const endpoint of ['source', 'target']) {
|
|
1709
|
+
if (this.db.prepare(`SELECT 1 FROM nodes n JOIN edges e ON e.${endpoint} = n.id
|
|
1710
|
+
WHERE n.file_path = ? AND ${owned} LIMIT 1`).get(filePath))
|
|
1711
|
+
return true;
|
|
1712
|
+
}
|
|
1713
|
+
// Wiring often lives in a third file, with neither endpoint in it.
|
|
1714
|
+
return !!this.db.prepare(`SELECT 1 FROM edges e WHERE ${owned}
|
|
1715
|
+
AND CASE WHEN json_valid(e.metadata) THEN json_extract(e.metadata, '$.registeredAt') END >= ?
|
|
1716
|
+
AND CASE WHEN json_valid(e.metadata) THEN json_extract(e.metadata, '$.registeredAt') END < ? LIMIT 1`).get(`${filePath}:`, `${filePath};`);
|
|
1717
|
+
}
|
|
1718
|
+
wasSynthesisInput(filePath) {
|
|
1719
|
+
return !!this.db.prepare('SELECT 1 FROM synthesis_inputs WHERE file_path = ?').get(filePath);
|
|
1720
|
+
}
|
|
1721
|
+
replaceSynthesisInputs(files) {
|
|
1722
|
+
this.db.transaction(() => {
|
|
1723
|
+
this.db.exec('DELETE FROM synthesis_inputs');
|
|
1724
|
+
const insert = this.db.prepare('INSERT INTO synthesis_inputs(file_path) VALUES (?)');
|
|
1725
|
+
for (const file of files)
|
|
1726
|
+
insert.run(file);
|
|
1727
|
+
})();
|
|
1728
|
+
}
|
|
1467
1729
|
/**
|
|
1468
1730
|
* Insert a new edge
|
|
1469
1731
|
*/
|
|
@@ -1525,7 +1787,8 @@ class QueryBuilder {
|
|
|
1525
1787
|
this.stmts.deleteEdgesBySource.run(sourceId);
|
|
1526
1788
|
}
|
|
1527
1789
|
/**
|
|
1528
|
-
* Get outgoing edges from a node
|
|
1790
|
+
* Get outgoing edges from a node. Preserve the source/kind index order
|
|
1791
|
+
* (calls before imports/references), then break ties deterministically.
|
|
1529
1792
|
*/
|
|
1530
1793
|
getOutgoingEdges(sourceId, kinds, provenance) {
|
|
1531
1794
|
if ((kinds && kinds.length > 0) || provenance) {
|
|
@@ -1539,30 +1802,645 @@ class QueryBuilder {
|
|
|
1539
1802
|
sql += ' AND provenance = ?';
|
|
1540
1803
|
params.push(provenance);
|
|
1541
1804
|
}
|
|
1542
|
-
|
|
1805
|
+
sql += ' ORDER BY kind, target, line, col';
|
|
1806
|
+
const rows = this.edgeKindStmt(sql).all(...params);
|
|
1543
1807
|
return rows.map(rowToEdge);
|
|
1544
1808
|
}
|
|
1545
1809
|
if (!this.stmts.getEdgesBySource) {
|
|
1546
|
-
this.stmts.getEdgesBySource = this.db.prepare('SELECT * FROM edges WHERE source = ?');
|
|
1810
|
+
this.stmts.getEdgesBySource = this.db.prepare('SELECT * FROM edges WHERE source = ? ORDER BY kind, target, line, col');
|
|
1547
1811
|
}
|
|
1548
1812
|
const rows = this.stmts.getEdgesBySource.all(sourceId);
|
|
1549
1813
|
return rows.map(rowToEdge);
|
|
1550
1814
|
}
|
|
1551
1815
|
/**
|
|
1552
|
-
* Get incoming edges to a node
|
|
1816
|
+
* Get incoming edges to a node. Kind must precede opaque source IDs:
|
|
1817
|
+
* file IDs sort before function IDs, so source-first ordering lets imports
|
|
1818
|
+
* displace actual calls in capped caller lists. Keep deterministic ties
|
|
1819
|
+
* without changing the target/kind index's established kind precedence.
|
|
1553
1820
|
*/
|
|
1554
1821
|
getIncomingEdges(targetId, kinds) {
|
|
1555
1822
|
if (kinds && kinds.length > 0) {
|
|
1556
|
-
const sql = `SELECT * FROM edges WHERE target = ? AND kind IN (${kinds.map(() => '?').join(',')})`;
|
|
1557
|
-
const rows = this.
|
|
1823
|
+
const sql = `SELECT * FROM edges WHERE target = ? AND kind IN (${kinds.map(() => '?').join(',')}) ORDER BY kind, source, line, col`;
|
|
1824
|
+
const rows = this.edgeKindStmt(sql).all(targetId, ...kinds);
|
|
1558
1825
|
return rows.map(rowToEdge);
|
|
1559
1826
|
}
|
|
1560
1827
|
if (!this.stmts.getEdgesByTarget) {
|
|
1561
|
-
this.stmts.getEdgesByTarget = this.db.prepare('SELECT * FROM edges WHERE target = ?');
|
|
1828
|
+
this.stmts.getEdgesByTarget = this.db.prepare('SELECT * FROM edges WHERE target = ? ORDER BY kind, source, line, col');
|
|
1562
1829
|
}
|
|
1563
1830
|
const rows = this.stmts.getEdgesByTarget.all(targetId);
|
|
1564
1831
|
return rows.map(rowToEdge);
|
|
1565
1832
|
}
|
|
1833
|
+
/**
|
|
1834
|
+
* Outgoing edges for MANY source nodes in one query.
|
|
1835
|
+
*
|
|
1836
|
+
* The batch form of {@link getOutgoingEdges}. Building a nested outline needs
|
|
1837
|
+
* the `contains` edges of every container in a file at once; doing that one
|
|
1838
|
+
* source at a time is a query per symbol on files that have hundreds.
|
|
1839
|
+
*/
|
|
1840
|
+
getOutgoingEdgesFrom(sourceIds, kinds) {
|
|
1841
|
+
if (sourceIds.length === 0)
|
|
1842
|
+
return [];
|
|
1843
|
+
const unique = [...new Set(sourceIds)];
|
|
1844
|
+
const out = [];
|
|
1845
|
+
for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
|
|
1846
|
+
const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
|
|
1847
|
+
const placeholders = chunk.map(() => '?').join(',');
|
|
1848
|
+
let sql = `SELECT * FROM edges WHERE source IN (${placeholders})`;
|
|
1849
|
+
const params = [...chunk];
|
|
1850
|
+
if (kinds && kinds.length > 0) {
|
|
1851
|
+
sql += ` AND kind IN (${kinds.map(() => '?').join(',')})`;
|
|
1852
|
+
params.push(...kinds);
|
|
1853
|
+
}
|
|
1854
|
+
const rows = this.db.prepare(sql).all(...params);
|
|
1855
|
+
for (const row of rows)
|
|
1856
|
+
out.push(rowToEdge(row));
|
|
1857
|
+
}
|
|
1858
|
+
return out;
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Fan-in (total incoming edge count) for MANY nodes in one query.
|
|
1862
|
+
*
|
|
1863
|
+
* The per-node alternative — `getIncomingEdges(id).length` — is an indexed
|
|
1864
|
+
* lookup each, but a symbol screen rendering a couple of hundred callees
|
|
1865
|
+
* would issue a couple of hundred of them. Ids with no incoming edges are
|
|
1866
|
+
* absent from the map rather than present as 0, so callers can tell "no
|
|
1867
|
+
* edges" from "not asked about".
|
|
1868
|
+
*/
|
|
1869
|
+
countIncomingEdges(ids) {
|
|
1870
|
+
const out = new Map();
|
|
1871
|
+
if (ids.length === 0)
|
|
1872
|
+
return out;
|
|
1873
|
+
const unique = [...new Set(ids)];
|
|
1874
|
+
for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
|
|
1875
|
+
const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
|
|
1876
|
+
const placeholders = chunk.map(() => '?').join(',');
|
|
1877
|
+
const rows = this.db
|
|
1878
|
+
.prepare(
|
|
1879
|
+
// A test's request onto a route (tier-synthesizer's `test-request`)
|
|
1880
|
+
// is not a production caller: forty tests hitting one endpoint must
|
|
1881
|
+
// not make it a hub the Steps walk refuses to enter.
|
|
1882
|
+
`SELECT target, COUNT(*) AS count FROM edges WHERE target IN (${placeholders})
|
|
1883
|
+
AND (metadata IS NULL OR metadata NOT LIKE '%"synthesizedBy":"test-request"%') GROUP BY target`)
|
|
1884
|
+
.all(...chunk);
|
|
1885
|
+
for (const row of rows)
|
|
1886
|
+
out.set(row.target, row.count);
|
|
1887
|
+
}
|
|
1888
|
+
return out;
|
|
1889
|
+
}
|
|
1890
|
+
/**
|
|
1891
|
+
* Incoming edges for MANY target nodes in one query — the mirror of
|
|
1892
|
+
* {@link getOutgoingEdgesFrom}. Needed wherever a whole file's inbound edges
|
|
1893
|
+
* are wanted at once ("which files import anything in this one?").
|
|
1894
|
+
*/
|
|
1895
|
+
getIncomingEdgesTo(targetIds, kinds) {
|
|
1896
|
+
if (targetIds.length === 0)
|
|
1897
|
+
return [];
|
|
1898
|
+
const unique = [...new Set(targetIds)];
|
|
1899
|
+
const out = [];
|
|
1900
|
+
for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
|
|
1901
|
+
const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
|
|
1902
|
+
const placeholders = chunk.map(() => '?').join(',');
|
|
1903
|
+
let sql = `SELECT * FROM edges WHERE target IN (${placeholders})`;
|
|
1904
|
+
const params = [...chunk];
|
|
1905
|
+
if (kinds && kinds.length > 0) {
|
|
1906
|
+
sql += ` AND kind IN (${kinds.map(() => '?').join(',')})`;
|
|
1907
|
+
params.push(...kinds);
|
|
1908
|
+
}
|
|
1909
|
+
const rows = this.db.prepare(sql).all(...params);
|
|
1910
|
+
for (const row of rows)
|
|
1911
|
+
out.push(rowToEdge(row));
|
|
1912
|
+
}
|
|
1913
|
+
return out;
|
|
1914
|
+
}
|
|
1915
|
+
/**
|
|
1916
|
+
* Fan-out (total outgoing edge count) for MANY nodes in one query — the
|
|
1917
|
+
* mirror of {@link countIncomingEdges}. Ids with no outgoing edges are absent
|
|
1918
|
+
* from the map rather than present as 0.
|
|
1919
|
+
*/
|
|
1920
|
+
countOutgoingEdges(ids) {
|
|
1921
|
+
const out = new Map();
|
|
1922
|
+
if (ids.length === 0)
|
|
1923
|
+
return out;
|
|
1924
|
+
const unique = [...new Set(ids)];
|
|
1925
|
+
for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
|
|
1926
|
+
const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
|
|
1927
|
+
const placeholders = chunk.map(() => '?').join(',');
|
|
1928
|
+
const rows = this.db
|
|
1929
|
+
.prepare(`SELECT source, COUNT(*) AS count FROM edges WHERE source IN (${placeholders}) GROUP BY source`)
|
|
1930
|
+
.all(...chunk);
|
|
1931
|
+
for (const row of rows)
|
|
1932
|
+
out.set(row.source, row.count);
|
|
1933
|
+
}
|
|
1934
|
+
return out;
|
|
1935
|
+
}
|
|
1936
|
+
/**
|
|
1937
|
+
* Symbols nothing in the index points at — the candidate set behind the dead
|
|
1938
|
+
* code list (`src/graph/dead-code.ts`).
|
|
1939
|
+
*
|
|
1940
|
+
* "Points at" is every edge kind EXCEPT `contains`: a class containing a
|
|
1941
|
+
* method is structure, not use, and counting it would make every member look
|
|
1942
|
+
* reached by its own container. A self-edge is excluded for the same reason
|
|
1943
|
+
* a recursive function is not its own caller.
|
|
1944
|
+
*
|
|
1945
|
+
* One scan, one index probe per candidate. `NOT EXISTS` over
|
|
1946
|
+
* `idx_edges_target_kind` is what keeps it that way — the alternative
|
|
1947
|
+
* (`LEFT JOIN edges … GROUP BY`) builds a row per edge for the whole table
|
|
1948
|
+
* before discarding all but the empty groups. Ordered by position so the
|
|
1949
|
+
* answer is stable across runs and groups by file without a second sort.
|
|
1950
|
+
*
|
|
1951
|
+
* The result is deliberately NOT called dead code: an unreferenced symbol is
|
|
1952
|
+
* a symbol with no STATIC reference, and the caller applies the exclusions
|
|
1953
|
+
* (tests, generated files, overrides, unresolved names) that turn the
|
|
1954
|
+
* candidate set into a claim worth making.
|
|
1955
|
+
*/
|
|
1956
|
+
getUnreferencedNodes(kinds, limit) {
|
|
1957
|
+
if (kinds.length === 0 || limit <= 0)
|
|
1958
|
+
return [];
|
|
1959
|
+
const placeholders = kinds.map(() => '?').join(',');
|
|
1960
|
+
const rows = this.db
|
|
1961
|
+
.prepare(`SELECT n.*, COALESCE(f.generated, 0) AS file_generated
|
|
1962
|
+
FROM nodes n
|
|
1963
|
+
LEFT JOIN files f ON f.path = n.file_path
|
|
1964
|
+
WHERE n.kind IN (${placeholders})
|
|
1965
|
+
AND NOT EXISTS (
|
|
1966
|
+
SELECT 1 FROM edges e
|
|
1967
|
+
WHERE e.target = n.id
|
|
1968
|
+
AND e.kind != 'contains'
|
|
1969
|
+
AND e.source != n.id
|
|
1970
|
+
)
|
|
1971
|
+
ORDER BY n.file_path, n.start_line, n.name
|
|
1972
|
+
LIMIT ?`)
|
|
1973
|
+
.all(...kinds, limit);
|
|
1974
|
+
return rows.map((row) => ({ node: rowToNode(row), generated: row.file_generated === 1 }));
|
|
1975
|
+
}
|
|
1976
|
+
/**
|
|
1977
|
+
* Which of `names` the index holds an UNRESOLVED reference to.
|
|
1978
|
+
*
|
|
1979
|
+
* The point is honesty about our own blind spots. A `failed` row in
|
|
1980
|
+
* `unresolved_refs` records that some file referenced a name and the resolver
|
|
1981
|
+
* could not decide what it meant — so a symbol with that name cannot be
|
|
1982
|
+
* called unreferenced, whatever the edge table says. It is deliberately
|
|
1983
|
+
* matched loosely, on the reference name AND on its tail (`util.greet` →
|
|
1984
|
+
* `greet`), because the question being asked is "could this name be the one
|
|
1985
|
+
* we failed to follow", and a maybe has to count as a yes.
|
|
1986
|
+
*
|
|
1987
|
+
* Bounded-lookup like {@link getGeneratedPathsAmong}: the caller holds a
|
|
1988
|
+
* candidate list, so this is a chunked probe over `idx_unresolved_name`, not
|
|
1989
|
+
* a scan of the table.
|
|
1990
|
+
*/
|
|
1991
|
+
getUnresolvedNamesAmong(names) {
|
|
1992
|
+
const unique = [...new Set(names)].filter((name) => name.length > 0);
|
|
1993
|
+
const found = new Set();
|
|
1994
|
+
if (unique.length === 0)
|
|
1995
|
+
return found;
|
|
1996
|
+
for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
|
|
1997
|
+
const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
|
|
1998
|
+
const placeholders = chunk.map(() => '?').join(',');
|
|
1999
|
+
const rows = this.db
|
|
2000
|
+
.prepare(`SELECT DISTINCT reference_name AS name FROM unresolved_refs
|
|
2001
|
+
WHERE reference_name IN (${placeholders})
|
|
2002
|
+
UNION
|
|
2003
|
+
SELECT DISTINCT name_tail AS name FROM unresolved_refs
|
|
2004
|
+
WHERE name_tail IN (${placeholders})`)
|
|
2005
|
+
.all(...chunk, ...chunk);
|
|
2006
|
+
for (const row of rows)
|
|
2007
|
+
found.add(row.name);
|
|
2008
|
+
}
|
|
2009
|
+
return found;
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Which of `nodeIds` extend or implement a type the resolver could not follow.
|
|
2013
|
+
* An ancestor outside the index (`React.Component`, `stream.Transform`, a
|
|
2014
|
+
* framework interface) leaves no edge, only this `extends` / `implements`
|
|
2015
|
+
* row, so it is the one record that such an ancestor exists (#1973).
|
|
2016
|
+
* Chunked probe over `idx_unresolved_from_node`.
|
|
2017
|
+
*/
|
|
2018
|
+
getUnresolvedSupertypeSourcesAmong(nodeIds) {
|
|
2019
|
+
const unique = [...new Set(nodeIds)];
|
|
2020
|
+
const found = new Set();
|
|
2021
|
+
for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
|
|
2022
|
+
const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
|
|
2023
|
+
const placeholders = chunk.map(() => '?').join(',');
|
|
2024
|
+
const rows = this.db
|
|
2025
|
+
.prepare(`SELECT DISTINCT from_node_id AS id FROM unresolved_refs
|
|
2026
|
+
WHERE from_node_id IN (${placeholders})
|
|
2027
|
+
AND reference_kind IN ('extends', 'implements')`)
|
|
2028
|
+
.all(...chunk);
|
|
2029
|
+
for (const row of rows)
|
|
2030
|
+
found.add(row.id);
|
|
2031
|
+
}
|
|
2032
|
+
return found;
|
|
2033
|
+
}
|
|
2034
|
+
/**
|
|
2035
|
+
* Which of `names` are carried by MORE THAN ONE symbol, at least one of which
|
|
2036
|
+
* something points at.
|
|
2037
|
+
*
|
|
2038
|
+
* The false positive this exists to kill: `CodeGraph.getTopRouteFile` calls
|
|
2039
|
+
* `this.queries.getTopRouteFile()`, and the resolver — which prefers a
|
|
2040
|
+
* same-name definition in the call site's own file — attaches that edge to
|
|
2041
|
+
* the *calling* method. One of the two ends up with a self-edge and the other
|
|
2042
|
+
* with nothing at all, and neither is unreferenced. From the edge table the
|
|
2043
|
+
* mis-resolution and a genuinely unused twin are the same picture, so the
|
|
2044
|
+
* claim is not made about either.
|
|
2045
|
+
*
|
|
2046
|
+
* Both halves of the condition are load-bearing. **More than one symbol**:
|
|
2047
|
+
* a uniquely-named function that only calls itself is genuinely dead, and
|
|
2048
|
+
* excluding every recursive function would gut the list. **Self-edges
|
|
2049
|
+
* counted**: the self-edge IS the fingerprint of the mis-resolution above, so
|
|
2050
|
+
* it has to count as evidence that this name resolves somewhere.
|
|
2051
|
+
*
|
|
2052
|
+
* Chunked probe over `idx_nodes_name`, bounded by the caller's candidate list.
|
|
2053
|
+
*/
|
|
2054
|
+
getAmbiguousReferencedNames(names) {
|
|
2055
|
+
const unique = [...new Set(names)].filter((name) => name.length > 0);
|
|
2056
|
+
const found = new Set();
|
|
2057
|
+
if (unique.length === 0)
|
|
2058
|
+
return found;
|
|
2059
|
+
for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
|
|
2060
|
+
const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
|
|
2061
|
+
const placeholders = chunk.map(() => '?').join(',');
|
|
2062
|
+
const rows = this.db
|
|
2063
|
+
.prepare(`SELECT name FROM (
|
|
2064
|
+
SELECT n.name AS name,
|
|
2065
|
+
EXISTS (
|
|
2066
|
+
SELECT 1 FROM edges e
|
|
2067
|
+
WHERE e.target = n.id AND e.kind != 'contains'
|
|
2068
|
+
) AS referenced
|
|
2069
|
+
FROM nodes n
|
|
2070
|
+
WHERE n.name IN (${placeholders})
|
|
2071
|
+
)
|
|
2072
|
+
GROUP BY name
|
|
2073
|
+
HAVING COUNT(*) > 1 AND SUM(referenced) > 0`)
|
|
2074
|
+
.all(...chunk);
|
|
2075
|
+
for (const row of rows)
|
|
2076
|
+
found.add(row.name);
|
|
2077
|
+
}
|
|
2078
|
+
return found;
|
|
2079
|
+
}
|
|
2080
|
+
/**
|
|
2081
|
+
* Which of the given languages the index records an EXPORT marker for.
|
|
2082
|
+
*
|
|
2083
|
+
* A self-measurement, and the honest basis for a whole class of exclusion.
|
|
2084
|
+
* The dead code report's strongest filter is "exported symbols may be reached
|
|
2085
|
+
* from outside this repository" — and that filter silently does nothing for a
|
|
2086
|
+
* language whose exports are not recorded, either because the extractor does
|
|
2087
|
+
* not record them (Rust `pub`) or because the language has no such concept at
|
|
2088
|
+
* all (Python, C, Ruby: the header or the module IS the surface). Rather than
|
|
2089
|
+
* carry a table of which is which, ask the index: if nothing in this language
|
|
2090
|
+
* is marked exported, the filter did not run, and no claim about outside
|
|
2091
|
+
* reachability can be made for it.
|
|
2092
|
+
*
|
|
2093
|
+
* `idx_nodes_language` covers the grouping; the caller passes the handful of
|
|
2094
|
+
* languages its candidates are actually in.
|
|
2095
|
+
*/
|
|
2096
|
+
getLanguagesWithExports(languages) {
|
|
2097
|
+
const unique = [...new Set(languages)].filter((language) => language.length > 0);
|
|
2098
|
+
const found = new Set();
|
|
2099
|
+
if (unique.length === 0)
|
|
2100
|
+
return found;
|
|
2101
|
+
for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
|
|
2102
|
+
const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
|
|
2103
|
+
const placeholders = chunk.map(() => '?').join(',');
|
|
2104
|
+
const rows = this.db
|
|
2105
|
+
.prepare(`SELECT language, MAX(is_exported) AS any_exported
|
|
2106
|
+
FROM nodes
|
|
2107
|
+
WHERE language IN (${placeholders})
|
|
2108
|
+
GROUP BY language`)
|
|
2109
|
+
.all(...chunk);
|
|
2110
|
+
for (const row of rows)
|
|
2111
|
+
if (row.any_exported === 1)
|
|
2112
|
+
found.add(row.language);
|
|
2113
|
+
}
|
|
2114
|
+
return found;
|
|
2115
|
+
}
|
|
2116
|
+
/**
|
|
2117
|
+
* The nodes with the most DISTINCT dependents, most first.
|
|
2118
|
+
*
|
|
2119
|
+
* "Distinct" is the difference that matters: a helper called forty times from
|
|
2120
|
+
* one function has a fan-in of 40 but exactly one dependent. This counts the
|
|
2121
|
+
* second thing — the number a reader means by "N callers" — so the top of
|
|
2122
|
+
* this list is the set of symbols a change actually radiates furthest from.
|
|
2123
|
+
*
|
|
2124
|
+
* `contains` is excluded because it is structure, not dependency: counting it
|
|
2125
|
+
* would rank every file and class above the code they hold.
|
|
2126
|
+
*/
|
|
2127
|
+
getTopDependedOn(limit) {
|
|
2128
|
+
if (limit <= 0)
|
|
2129
|
+
return [];
|
|
2130
|
+
const rows = this.db
|
|
2131
|
+
.prepare(`SELECT target AS nodeId, COUNT(DISTINCT source) AS dependents
|
|
2132
|
+
FROM edges
|
|
2133
|
+
WHERE kind != 'contains' AND source != target
|
|
2134
|
+
GROUP BY target
|
|
2135
|
+
ORDER BY dependents DESC
|
|
2136
|
+
LIMIT ?`)
|
|
2137
|
+
.all(limit);
|
|
2138
|
+
return rows;
|
|
2139
|
+
}
|
|
2140
|
+
/**
|
|
2141
|
+
* The graph's executable roots — files that RUN something at module level,
|
|
2142
|
+
* ranked by how much of the project they set in motion.
|
|
2143
|
+
*
|
|
2144
|
+
* The engine records a statement at the top level of a file as an edge from
|
|
2145
|
+
* the *file* node, so `src/bin/codegraph.ts` calling `program.parse()` at
|
|
2146
|
+
* module scope is a `calls` edge out of a `file`. That set is what makes the
|
|
2147
|
+
* roots of a dependency graph visible: a library module holds definitions and
|
|
2148
|
+
* runs nothing until someone imports it, while a CLI, a worker entry or a
|
|
2149
|
+
* build script does its work on the way down the file. `instantiates` counts
|
|
2150
|
+
* the same way — `new Server(...)` at module scope is the same act.
|
|
2151
|
+
*
|
|
2152
|
+
* A call made while initializing a module-level `variable` / `constant` —
|
|
2153
|
+
* `const service = new Service()`, `app = FastAPI()` — is attributed to the
|
|
2154
|
+
* declared name (#693), not to the file, so the file's own edges alone would
|
|
2155
|
+
* miss most of what a real entry point runs. Those names are the file's
|
|
2156
|
+
* top-level code too, so `tops` counts them alongside the file node.
|
|
2157
|
+
*
|
|
2158
|
+
* Ranking multiplies the two things an entry point does: it runs (calls), and
|
|
2159
|
+
* it wires the project together (distinct other files its symbols reach). One
|
|
2160
|
+
* alone is misleading — a registration table makes hundreds of module-level
|
|
2161
|
+
* calls into itself, and a barrel file imports everything and runs nothing.
|
|
2162
|
+
* The product puts the file that does both at the top.
|
|
2163
|
+
*/
|
|
2164
|
+
getTopCallingFiles(limit) {
|
|
2165
|
+
if (limit <= 0)
|
|
2166
|
+
return [];
|
|
2167
|
+
return this.db
|
|
2168
|
+
.prepare(`WITH tops AS (
|
|
2169
|
+
SELECT n.id AS file_id, n.id AS src
|
|
2170
|
+
FROM nodes n
|
|
2171
|
+
WHERE n.kind = 'file'
|
|
2172
|
+
UNION ALL
|
|
2173
|
+
SELECT c.source AS file_id, c.target AS src
|
|
2174
|
+
FROM edges c
|
|
2175
|
+
JOIN nodes f ON f.id = c.source
|
|
2176
|
+
JOIN nodes v ON v.id = c.target
|
|
2177
|
+
WHERE c.kind = 'contains'
|
|
2178
|
+
AND f.kind = 'file'
|
|
2179
|
+
AND v.kind IN ('variable', 'constant')
|
|
2180
|
+
),
|
|
2181
|
+
runs AS (
|
|
2182
|
+
SELECT t.file_id AS id, COUNT(*) AS calls
|
|
2183
|
+
FROM tops t
|
|
2184
|
+
JOIN edges e ON e.source = t.src
|
|
2185
|
+
WHERE e.kind IN ('calls', 'instantiates')
|
|
2186
|
+
GROUP BY t.file_id
|
|
2187
|
+
),
|
|
2188
|
+
cand AS (
|
|
2189
|
+
SELECT r.id AS id, n.file_path AS fp, r.calls AS calls
|
|
2190
|
+
FROM runs r JOIN nodes n ON n.id = r.id
|
|
2191
|
+
),
|
|
2192
|
+
wires AS (
|
|
2193
|
+
SELECT sn.file_path AS fp, COUNT(DISTINCT tn.file_path) AS reaches
|
|
2194
|
+
FROM edges e
|
|
2195
|
+
JOIN nodes sn ON sn.id = e.source
|
|
2196
|
+
JOIN nodes tn ON tn.id = e.target
|
|
2197
|
+
WHERE e.kind != 'contains'
|
|
2198
|
+
AND sn.file_path <> tn.file_path
|
|
2199
|
+
AND sn.file_path IN (SELECT fp FROM cand)
|
|
2200
|
+
GROUP BY sn.file_path
|
|
2201
|
+
)
|
|
2202
|
+
SELECT c.id AS nodeId,
|
|
2203
|
+
c.fp AS filePath,
|
|
2204
|
+
c.calls AS calls,
|
|
2205
|
+
COALESCE(w.reaches, 0) AS reaches,
|
|
2206
|
+
c.calls * (1 + COALESCE(w.reaches, 0)) AS score
|
|
2207
|
+
FROM cand c LEFT JOIN wires w ON w.fp = c.fp
|
|
2208
|
+
ORDER BY score DESC, calls DESC, filePath
|
|
2209
|
+
LIMIT ?`)
|
|
2210
|
+
.all(limit);
|
|
2211
|
+
}
|
|
2212
|
+
/**
|
|
2213
|
+
* How many OTHER files depend on each of the given files.
|
|
2214
|
+
*
|
|
2215
|
+
* Counted through the symbols, not the file nodes: an `imports` edge points
|
|
2216
|
+
* at the imported symbol, so a file node almost never receives one and
|
|
2217
|
+
* counting edges into it would report every file as depended on by nobody.
|
|
2218
|
+
* Same-file edges are excluded, which is what makes zero mean "nothing else
|
|
2219
|
+
* in the index reaches into this file" — the honest reading of a root.
|
|
2220
|
+
*/
|
|
2221
|
+
getFileDependentCounts(filePaths) {
|
|
2222
|
+
if (filePaths.length === 0)
|
|
2223
|
+
return [];
|
|
2224
|
+
return this.db
|
|
2225
|
+
.prepare(`SELECT tn.file_path AS filePath, COUNT(DISTINCT sn.file_path) AS dependents
|
|
2226
|
+
FROM edges e
|
|
2227
|
+
JOIN nodes tn ON tn.id = e.target
|
|
2228
|
+
JOIN nodes sn ON sn.id = e.source
|
|
2229
|
+
WHERE e.kind != 'contains'
|
|
2230
|
+
AND tn.file_path IN (SELECT value FROM json_each(?))
|
|
2231
|
+
AND sn.file_path <> tn.file_path
|
|
2232
|
+
GROUP BY tn.file_path`)
|
|
2233
|
+
.all(JSON.stringify(filePaths));
|
|
2234
|
+
}
|
|
2235
|
+
/**
|
|
2236
|
+
* How far each of the given files reaches OUT: distinct other files its
|
|
2237
|
+
* symbols touch, and how many references that is.
|
|
2238
|
+
*
|
|
2239
|
+
* The mirror of {@link getFileDependentCounts}, and the same reasoning about
|
|
2240
|
+
* `contains` and same-file edges applies. It is driven from `nodes` rather
|
|
2241
|
+
* than from `edges` so the work is proportional to the files asked about —
|
|
2242
|
+
* the entry-points endpoint asks it about every test file in the index, and
|
|
2243
|
+
* an edge-first plan would scan the whole table to answer a question about a
|
|
2244
|
+
* tenth of it.
|
|
2245
|
+
*/
|
|
2246
|
+
getFileReachCounts(filePaths) {
|
|
2247
|
+
if (filePaths.length === 0)
|
|
2248
|
+
return [];
|
|
2249
|
+
return this.db
|
|
2250
|
+
.prepare(`SELECT sn.file_path AS filePath,
|
|
2251
|
+
COUNT(DISTINCT tn.file_path) AS reaches,
|
|
2252
|
+
COUNT(*) AS refs
|
|
2253
|
+
FROM nodes sn
|
|
2254
|
+
JOIN edges e ON e.source = sn.id
|
|
2255
|
+
JOIN nodes tn ON tn.id = e.target
|
|
2256
|
+
WHERE sn.file_path IN (SELECT value FROM json_each(?))
|
|
2257
|
+
AND e.kind != 'contains'
|
|
2258
|
+
AND tn.file_path <> sn.file_path
|
|
2259
|
+
GROUP BY sn.file_path`)
|
|
2260
|
+
.all(JSON.stringify(filePaths));
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* The `file` nodes for the given paths, in one query.
|
|
2264
|
+
*
|
|
2265
|
+
* A file's own node is what makes a file row navigable, and looking it up
|
|
2266
|
+
* with {@link getNodesInFile} means materialising every symbol in the file to
|
|
2267
|
+
* throw all but one away.
|
|
2268
|
+
*/
|
|
2269
|
+
getFileNodes(filePaths) {
|
|
2270
|
+
if (filePaths.length === 0)
|
|
2271
|
+
return [];
|
|
2272
|
+
const rows = this.db
|
|
2273
|
+
.prepare(`SELECT * FROM nodes
|
|
2274
|
+
WHERE kind = 'file'
|
|
2275
|
+
AND file_path IN (SELECT value FROM json_each(?))`)
|
|
2276
|
+
.all(JSON.stringify(filePaths));
|
|
2277
|
+
return rows.map(rowToNode);
|
|
2278
|
+
}
|
|
2279
|
+
/**
|
|
2280
|
+
* Roll the whole edge table up to module granularity in one pass.
|
|
2281
|
+
*
|
|
2282
|
+
* The caller decides what a module IS — it hands in a file → module
|
|
2283
|
+
* assignment and gets back the cross-module traffic. That split is
|
|
2284
|
+
* deliberate: naming modules is a *policy* (top-level directories, a façade
|
|
2285
|
+
* file kept separate, a monorepo root) that belongs where the reader lives,
|
|
2286
|
+
* while grouping a million edges by it is *mechanics* that must happen in
|
|
2287
|
+
* SQLite. Doing the fold in JavaScript instead means materialising every
|
|
2288
|
+
* cross-file edge in memory; doing the naming in SQL means a tower of
|
|
2289
|
+
* `instr`/`substr` no one can read.
|
|
2290
|
+
*
|
|
2291
|
+
* The assignment lands in a TEMP table with a primary key, so the join is
|
|
2292
|
+
* indexed and the result set is bounded by modules², not by edges. Temp
|
|
2293
|
+
* tables live in SQLite's own temp database, so this stays valid against a
|
|
2294
|
+
* read-only main.
|
|
2295
|
+
*
|
|
2296
|
+
* Two result sets, because they need two different groupings over the same
|
|
2297
|
+
* join: `links` counts edges per (module, module, kind), and `pairs` names
|
|
2298
|
+
* the busiest symbol pairs behind each link (the map's tooltip). `pairs` is
|
|
2299
|
+
* ranked and cut inside SQLite — the un-cut grouping is the one thing here
|
|
2300
|
+
* that scales with distinct symbol names rather than with modules. Pairs are
|
|
2301
|
+
* ranked by `declared` before raw count, so a link's tooltip names the
|
|
2302
|
+
* symbols the source actually points at rather than whichever `has`/`get`
|
|
2303
|
+
* happened to name-match most often.
|
|
2304
|
+
*
|
|
2305
|
+
* `declared` is the subset of a link's edges that came from something the
|
|
2306
|
+
* source *writes down*: an import, a qualified name, an inheritance clause,
|
|
2307
|
+
* or a call through a typed receiver. It exists because bare name matching
|
|
2308
|
+
* (`resolvedBy: 'exact-match'`) is what invents cross-module links out of
|
|
2309
|
+
* common method names — `run`, `push`, `finish` — and a map that lets those
|
|
2310
|
+
* decide the layering puts the storage layer above the CLI.
|
|
2311
|
+
*/
|
|
2312
|
+
aggregateModuleGraph(assignments, options) {
|
|
2313
|
+
if (assignments.length === 0 || options.kinds.length === 0)
|
|
2314
|
+
return { links: [], pairs: [] };
|
|
2315
|
+
const CONFIDENCE = `COALESCE(json_extract(e.metadata, '$.confidence'), 1)`;
|
|
2316
|
+
const DECLARED = `(json_extract(e.metadata, '$.resolvedBy') IN ('import', 'qualified-name')
|
|
2317
|
+
OR e.kind IN ('extends', 'implements')
|
|
2318
|
+
OR (json_extract(e.metadata, '$.resolvedBy') = 'instance-method'
|
|
2319
|
+
AND ${CONFIDENCE} >= 0.9))`;
|
|
2320
|
+
this.db.exec('DROP TABLE IF EXISTS temp.cg_module_map');
|
|
2321
|
+
this.db.exec('CREATE TEMP TABLE cg_module_map (path TEXT PRIMARY KEY, mod TEXT NOT NULL)');
|
|
2322
|
+
try {
|
|
2323
|
+
const insert = this.db.prepare('INSERT OR REPLACE INTO cg_module_map (path, mod) VALUES (?, ?)');
|
|
2324
|
+
this.db.exec('BEGIN');
|
|
2325
|
+
try {
|
|
2326
|
+
for (const row of assignments)
|
|
2327
|
+
insert.run(row.filePath, row.module);
|
|
2328
|
+
this.db.exec('COMMIT');
|
|
2329
|
+
}
|
|
2330
|
+
catch (err) {
|
|
2331
|
+
this.db.exec('ROLLBACK');
|
|
2332
|
+
throw err;
|
|
2333
|
+
}
|
|
2334
|
+
// ONE pass over the edge table. Grouping by the symbol names as well as
|
|
2335
|
+
// the modules costs nothing extra in scan time — the join is what is
|
|
2336
|
+
// expensive — and it buys both results from a single scan. Measured on
|
|
2337
|
+
// this index inflated to 1.6M edges: 1.66s for this query against 3.0s
|
|
2338
|
+
// for the module-level and name-level queries run separately, which is
|
|
2339
|
+
// the difference between meeting and missing the map's cold budget on a
|
|
2340
|
+
// ten-thousand-file repository.
|
|
2341
|
+
const rows = this.db
|
|
2342
|
+
.prepare(`SELECT ms.mod AS source, mt.mod AS target, e.kind AS kind,
|
|
2343
|
+
sn.name AS "from", tn.name AS "to",
|
|
2344
|
+
SUM(CASE WHEN ${CONFIDENCE} >= ? THEN 1 ELSE 0 END) AS count,
|
|
2345
|
+
SUM(CASE WHEN ${CONFIDENCE} >= ? AND ${DECLARED} THEN 1 ELSE 0 END) AS declared,
|
|
2346
|
+
SUM(CASE WHEN ${CONFIDENCE} < ? THEN 1 ELSE 0 END) AS uncertain
|
|
2347
|
+
FROM edges e
|
|
2348
|
+
JOIN nodes sn ON sn.id = e.source
|
|
2349
|
+
JOIN nodes tn ON tn.id = e.target
|
|
2350
|
+
JOIN cg_module_map ms ON ms.path = sn.file_path
|
|
2351
|
+
JOIN cg_module_map mt ON mt.path = tn.file_path
|
|
2352
|
+
WHERE e.kind IN (SELECT value FROM json_each(?))
|
|
2353
|
+
AND ms.mod <> mt.mod
|
|
2354
|
+
GROUP BY ms.mod, mt.mod, e.kind, sn.name, tn.name`)
|
|
2355
|
+
.all(options.minConfidence, options.minConfidence, options.minConfidence, JSON.stringify(options.kinds));
|
|
2356
|
+
return foldModuleRows(rows, options);
|
|
2357
|
+
}
|
|
2358
|
+
finally {
|
|
2359
|
+
this.db.exec('DROP TABLE IF EXISTS temp.cg_module_map');
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
/**
|
|
2363
|
+
* Every ordered pair of files where one reaches into the other, once each.
|
|
2364
|
+
*
|
|
2365
|
+
* The input a cycle finder wants: file-level circular dependencies are the
|
|
2366
|
+
* strongly connected components of this graph. One query instead of the
|
|
2367
|
+
* dependency lookup per file that {@link GraphQueryManager.findCircularDependencies}
|
|
2368
|
+
* does — which matters because a cycle report is only interesting on a large
|
|
2369
|
+
* repo, and that is exactly where a query per file stops being affordable.
|
|
2370
|
+
*
|
|
2371
|
+
* `contains` is excluded (a file "contains" its own symbols, which is not a
|
|
2372
|
+
* dependency), and so are same-file edges and low-confidence name matches:
|
|
2373
|
+
* a cycle conjured by a common method name is a false alarm a reader cannot
|
|
2374
|
+
* check.
|
|
2375
|
+
*/
|
|
2376
|
+
getCrossFileDependencyPairs(minConfidence) {
|
|
2377
|
+
return this.db
|
|
2378
|
+
.prepare(`SELECT DISTINCT sn.file_path AS source, tn.file_path AS target
|
|
2379
|
+
FROM edges e
|
|
2380
|
+
JOIN nodes sn ON sn.id = e.source
|
|
2381
|
+
JOIN nodes tn ON tn.id = e.target
|
|
2382
|
+
WHERE e.kind <> 'contains'
|
|
2383
|
+
AND sn.file_path <> tn.file_path
|
|
2384
|
+
AND COALESCE(json_extract(e.metadata, '$.confidence'), 1) >= ?`)
|
|
2385
|
+
.all(minConfidence);
|
|
2386
|
+
}
|
|
2387
|
+
/**
|
|
2388
|
+
* Every unresolved reference recorded in one FILE, ordered by line.
|
|
2389
|
+
*
|
|
2390
|
+
* The per-symbol form above answers "what does this body reach that the
|
|
2391
|
+
* index does not hold". A whole-file reader asks the same question of every
|
|
2392
|
+
* line at once, and asking it one symbol at a time is a query per symbol —
|
|
2393
|
+
* 153 of them on this repo's largest file. `unresolved_refs.file_path` is
|
|
2394
|
+
* indexed, so this is one lookup whatever the file holds.
|
|
2395
|
+
*
|
|
2396
|
+
* `limit` bounds the answer rather than the work: the caller draws a marker
|
|
2397
|
+
* per row, and a generated file with fifty thousand of them would ship
|
|
2398
|
+
* megabytes to say something a count already says. Rows come back in line
|
|
2399
|
+
* order, so a cap trims the END of the file, which is at least legible.
|
|
2400
|
+
*/
|
|
2401
|
+
getUnresolvedReferencesInFile(filePath, limit = 5000) {
|
|
2402
|
+
if (!this.stmts.getUnresolvedInFile) {
|
|
2403
|
+
this.stmts.getUnresolvedInFile = this.db.prepare('SELECT * FROM unresolved_refs WHERE file_path = ? ORDER BY line, col LIMIT ?');
|
|
2404
|
+
}
|
|
2405
|
+
const rows = this.stmts.getUnresolvedInFile.all(filePath, limit);
|
|
2406
|
+
return rows.map((row) => ({
|
|
2407
|
+
fromNodeId: row.from_node_id,
|
|
2408
|
+
referenceName: row.reference_name,
|
|
2409
|
+
referenceKind: row.reference_kind,
|
|
2410
|
+
line: row.line,
|
|
2411
|
+
column: row.col,
|
|
2412
|
+
candidates: row.candidates ? (0, utils_1.safeJsonParse)(row.candidates, undefined) : undefined,
|
|
2413
|
+
filePath: row.file_path,
|
|
2414
|
+
language: row.language,
|
|
2415
|
+
rowId: row.id,
|
|
2416
|
+
}));
|
|
2417
|
+
}
|
|
2418
|
+
/**
|
|
2419
|
+
* References recorded against a symbol that never resolved to a node — the
|
|
2420
|
+
* calls and type mentions that leave the index (a third-party package, a
|
|
2421
|
+
* runtime builtin, a language construct extraction doesn't model).
|
|
2422
|
+
*
|
|
2423
|
+
* Read-only. It exists so a reader can say "N calls into symbols outside the
|
|
2424
|
+
* index" instead of silently showing a callee list shorter than the body's
|
|
2425
|
+
* call sites, which reads as "nothing else happens here".
|
|
2426
|
+
*/
|
|
2427
|
+
getUnresolvedReferencesFrom(fromNodeId) {
|
|
2428
|
+
if (!this.stmts.getUnresolvedFromNode) {
|
|
2429
|
+
this.stmts.getUnresolvedFromNode = this.db.prepare('SELECT * FROM unresolved_refs WHERE from_node_id = ?');
|
|
2430
|
+
}
|
|
2431
|
+
const rows = this.stmts.getUnresolvedFromNode.all(fromNodeId);
|
|
2432
|
+
return rows.map((row) => ({
|
|
2433
|
+
fromNodeId: row.from_node_id,
|
|
2434
|
+
referenceName: row.reference_name,
|
|
2435
|
+
referenceKind: row.reference_kind,
|
|
2436
|
+
line: row.line,
|
|
2437
|
+
column: row.col,
|
|
2438
|
+
candidates: row.candidates ? (0, utils_1.safeJsonParse)(row.candidates, undefined) : undefined,
|
|
2439
|
+
filePath: row.file_path,
|
|
2440
|
+
language: row.language,
|
|
2441
|
+
rowId: row.id,
|
|
2442
|
+
}));
|
|
2443
|
+
}
|
|
1566
2444
|
/**
|
|
1567
2445
|
* Find all edges where both source and target are in the given node set.
|
|
1568
2446
|
* Useful for recovering inter-node connectivity after BFS.
|
|
@@ -1626,13 +2504,14 @@ class QueryBuilder {
|
|
|
1626
2504
|
}
|
|
1627
2505
|
/**
|
|
1628
2506
|
* Cross-file edges whose TARGET is a node in `filePath` and whose SOURCE is a
|
|
1629
|
-
* node in a *different* file, paired with the target node's (name, kind)
|
|
1630
|
-
*
|
|
1631
|
-
*
|
|
1632
|
-
*
|
|
1633
|
-
*
|
|
1634
|
-
* re-index (issue #899). Same
|
|
1635
|
-
* {@link getDependentFilePaths}: all kinds except
|
|
2507
|
+
* node in a *different* file, paired with the target node's (name, kind).
|
|
2508
|
+
* Node IDs are `sha256(filePath:kind:name:line)`, so any line shift in the
|
|
2509
|
+
* callee file changes target IDs and a naive re-insert by old ID silently
|
|
2510
|
+
* drops them; `storeExtractionResult` instead follows each old target to the
|
|
2511
|
+
* re-indexed node that replaces it (see {@link getNodeIdentitiesByFile}) to
|
|
2512
|
+
* preserve incoming edges across a file re-index (issue #899). Same
|
|
2513
|
+
* edge-kind rules as {@link getDependentFilePaths}: all kinds except
|
|
2514
|
+
* `contains`.
|
|
1636
2515
|
*/
|
|
1637
2516
|
getCrossFileIncomingEdgesWithTarget(filePath) {
|
|
1638
2517
|
const sql = `SELECT e.*, tgt.name AS target_name, tgt.kind AS target_kind,
|
|
@@ -1755,6 +2634,29 @@ class QueryBuilder {
|
|
|
1755
2634
|
* restricted to the candidate list: the file that imports it is usually
|
|
1756
2635
|
* not itself a candidate.
|
|
1757
2636
|
*
|
|
2637
|
+
* ### Interface MEMBERS are transparent to all four conditions
|
|
2638
|
+
*
|
|
2639
|
+
* A `method_signature` / `property_signature` inside an interface enters the
|
|
2640
|
+
* graph as a `method` / `property` node (#1638). Read literally that would
|
|
2641
|
+
* break every condition here at once: condition 2 sees non-type kinds and
|
|
2642
|
+
* stops flagging, and — worse, because it is silent — condition 4 starts
|
|
2643
|
+
* seeing inbound `calls` edges the moment a call site through the shim's API
|
|
2644
|
+
* finally has a signature to land on. An ambient `.d.ts` would quietly lose
|
|
2645
|
+
* its damping precisely BECAUSE the platform API it declares is widely used.
|
|
2646
|
+
*
|
|
2647
|
+
* So an interface-owned member is treated the way `parameter` already is: it
|
|
2648
|
+
* neither qualifies, disqualifies, nor counts as inbound dependency. That is
|
|
2649
|
+
* not a new judgement call, it is what keeps the rule measuring what it was
|
|
2650
|
+
* measured on — before #1638 these nodes did not exist, so excluding them
|
|
2651
|
+
* reproduces the 0–4% flag rate the thresholds above were tuned against. It
|
|
2652
|
+
* is also the semantically right answer: a signature with no body is on the
|
|
2653
|
+
* same side of the line as the interface that owns it, and a call edge
|
|
2654
|
+
* landing on one is still not a file that can answer a flow question.
|
|
2655
|
+
*
|
|
2656
|
+
* The interface ITSELF is untouched: the `references` edges an importing
|
|
2657
|
+
* module aims at `UploadStorage` still disqualify the file under (4), which
|
|
2658
|
+
* is what keeps a depended-on `types.ts` out of the flag.
|
|
2659
|
+
*
|
|
1758
2660
|
* Bounded-lookup like {@link getGeneratedPathsAmong}: callers hold a ranked
|
|
1759
2661
|
* candidate list, so this is a partial-index probe over a handful of paths.
|
|
1760
2662
|
*/
|
|
@@ -1770,14 +2672,15 @@ class QueryBuilder {
|
|
|
1770
2672
|
// things the file declares, so they neither qualify nor disqualify.
|
|
1771
2673
|
const rows = this.db
|
|
1772
2674
|
.prepare(`
|
|
1773
|
-
SELECT file_path,
|
|
1774
|
-
SUM(CASE WHEN kind NOT IN ('file','import','export','parameter')
|
|
2675
|
+
SELECT n.file_path AS file_path,
|
|
2676
|
+
SUM(CASE WHEN n.kind NOT IN ('file','import','export','parameter')
|
|
2677
|
+
AND NOT ${IS_INTERFACE_MEMBER('n')}
|
|
1775
2678
|
THEN 1 ELSE 0 END) AS declared,
|
|
1776
|
-
SUM(CASE WHEN kind IN ('interface','type_alias','enum','enum_member','namespace')
|
|
2679
|
+
SUM(CASE WHEN n.kind IN ('interface','type_alias','enum','enum_member','namespace')
|
|
1777
2680
|
THEN 1 ELSE 0 END) AS typeDeclared
|
|
1778
|
-
FROM nodes
|
|
1779
|
-
WHERE file_path IN (${placeholders})
|
|
1780
|
-
GROUP BY file_path
|
|
2681
|
+
FROM nodes n
|
|
2682
|
+
WHERE n.file_path IN (${placeholders})
|
|
2683
|
+
GROUP BY n.file_path
|
|
1781
2684
|
`)
|
|
1782
2685
|
.all(...chunk);
|
|
1783
2686
|
let candidates = rows
|
|
@@ -1793,17 +2696,22 @@ class QueryBuilder {
|
|
|
1793
2696
|
.all(...candidates).map((r) => r.file_path));
|
|
1794
2697
|
candidates = candidates.filter((p) => !hit.has(p));
|
|
1795
2698
|
};
|
|
1796
|
-
// (3) originates behaviour
|
|
2699
|
+
// (3) originates behaviour — a signature has no body to originate from,
|
|
2700
|
+
// so an edge attributed to one is not evidence about this file.
|
|
1797
2701
|
disqualify(`
|
|
1798
2702
|
SELECT DISTINCT n.file_path AS file_path
|
|
1799
2703
|
FROM edges e JOIN nodes n ON n.id = e.source
|
|
1800
2704
|
WHERE e.kind IN ('calls','instantiates') AND n.file_path IN ($IN$)
|
|
2705
|
+
AND NOT ${IS_INTERFACE_MEMBER('n')}
|
|
1801
2706
|
`);
|
|
1802
|
-
// (4) something outside the file depends on it
|
|
2707
|
+
// (4) something outside the file depends on it — but a call that lands on
|
|
2708
|
+
// an interface's own signature is a use of the API, not a dependency on
|
|
2709
|
+
// this file's structure. The edges aimed at the interface still count.
|
|
1803
2710
|
disqualify(`
|
|
1804
2711
|
SELECT DISTINCT t.file_path AS file_path
|
|
1805
2712
|
FROM edges e JOIN nodes t ON t.id = e.target JOIN nodes s ON s.id = e.source
|
|
1806
2713
|
WHERE t.file_path IN ($IN$) AND s.file_path <> t.file_path
|
|
2714
|
+
AND NOT ${IS_INTERFACE_MEMBER('t')}
|
|
1807
2715
|
`);
|
|
1808
2716
|
for (const path of candidates)
|
|
1809
2717
|
found.add(path);
|
|
@@ -1848,6 +2756,17 @@ class QueryBuilder {
|
|
|
1848
2756
|
const row = this.stmts.getFileByPath.get(filePath);
|
|
1849
2757
|
return row ? rowToFileRecord(row) : null;
|
|
1850
2758
|
}
|
|
2759
|
+
/**
|
|
2760
|
+
* Whether any tracked file lives under the project-relative POSIX directory
|
|
2761
|
+
* `dir`. A range scan on the `path` primary key — `dir/` up to `dir0` ('0'
|
|
2762
|
+
* is the byte after '/') — so it costs one index probe at any repo size.
|
|
2763
|
+
*/
|
|
2764
|
+
hasFilesUnder(dir) {
|
|
2765
|
+
if (!this.stmts.hasFilesUnder) {
|
|
2766
|
+
this.stmts.hasFilesUnder = this.db.prepare('SELECT 1 FROM files WHERE path >= ? AND path < ? LIMIT 1');
|
|
2767
|
+
}
|
|
2768
|
+
return this.stmts.hasFilesUnder.get(`${dir}/`, `${dir}0`) !== undefined;
|
|
2769
|
+
}
|
|
1851
2770
|
/**
|
|
1852
2771
|
* Get all tracked files
|
|
1853
2772
|
*/
|
|
@@ -1868,6 +2787,40 @@ class QueryBuilder {
|
|
|
1868
2787
|
.get();
|
|
1869
2788
|
return row?.last ?? null;
|
|
1870
2789
|
}
|
|
2790
|
+
/**
|
|
2791
|
+
* The index's revision marker: how far the last sync got, and how many files
|
|
2792
|
+
* it left behind — one query, both numbers.
|
|
2793
|
+
*
|
|
2794
|
+
* This is the cheapest honest answer to "has the index moved since I last
|
|
2795
|
+
* looked". `MAX(indexed_at)` alone is not enough: a sync that only DELETES
|
|
2796
|
+
* files (a branch checkout that removed a directory) advances nothing, and
|
|
2797
|
+
* the graph the viewer is showing has still changed underneath it. The row
|
|
2798
|
+
* count catches exactly that case.
|
|
2799
|
+
*/
|
|
2800
|
+
getIndexRevision() {
|
|
2801
|
+
const row = this.db
|
|
2802
|
+
.prepare('SELECT MAX(indexed_at) AS last, COUNT(*) AS files FROM files')
|
|
2803
|
+
.get();
|
|
2804
|
+
return { lastIndexedAt: row?.last ?? null, fileCount: row?.files ?? 0 };
|
|
2805
|
+
}
|
|
2806
|
+
/**
|
|
2807
|
+
* Files re-indexed strictly after `since` (ms since epoch), newest first.
|
|
2808
|
+
*
|
|
2809
|
+
* `total` is the real count; `paths` is capped at `limit`. Used by the
|
|
2810
|
+
* viewer's live channel to name what a sync just picked up. A file the same
|
|
2811
|
+
* sync DELETED cannot appear here — it has no row left — which is why the
|
|
2812
|
+
* caller compares {@link getIndexRevision} as well rather than treating an
|
|
2813
|
+
* empty list as "nothing happened".
|
|
2814
|
+
*/
|
|
2815
|
+
getFilesIndexedSince(since, limit) {
|
|
2816
|
+
const count = this.db
|
|
2817
|
+
.prepare('SELECT COUNT(*) AS n FROM files WHERE indexed_at > ?')
|
|
2818
|
+
.get(since);
|
|
2819
|
+
const rows = this.db
|
|
2820
|
+
.prepare('SELECT path FROM files WHERE indexed_at > ? ORDER BY indexed_at DESC, path LIMIT ?')
|
|
2821
|
+
.all(since, Math.max(0, limit));
|
|
2822
|
+
return { paths: rows.map((r) => r.path), total: count?.n ?? rows.length };
|
|
2823
|
+
}
|
|
1871
2824
|
/**
|
|
1872
2825
|
* Get files that need re-indexing (hash changed)
|
|
1873
2826
|
*/
|
|
@@ -2022,11 +2975,19 @@ class QueryBuilder {
|
|
|
2022
2975
|
* (§7a.2) — while the seek is O(batch) forever. `id` is the rowid alias, so
|
|
2023
2976
|
* the enumeration order is identical to the OFFSET reader's.
|
|
2024
2977
|
*/
|
|
2025
|
-
getUnresolvedReferencesBatchAfter(afterRowId, limit) {
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2978
|
+
getUnresolvedReferencesBatchAfter(afterRowId, limit, prerequisites) {
|
|
2979
|
+
// Resolution prerequisites must be committed before dependent calls,
|
|
2980
|
+
// even when an interrupted sync queued their rows in a different order
|
|
2981
|
+
// from a clean index (#1577). Each phase still seeks by row id in bounded
|
|
2982
|
+
// memory; the default preserves the public reader's original enumeration.
|
|
2983
|
+
const key = prerequisites === undefined ? 'getUnresolvedBatchAfter'
|
|
2984
|
+
: prerequisites ? 'getUnresolvedPrerequisitesAfter' : 'getUnresolvedDependentsAfter';
|
|
2985
|
+
if (!this.stmts[key]) {
|
|
2986
|
+
const filter = prerequisites === undefined ? ''
|
|
2987
|
+
: ` AND reference_kind ${prerequisites ? 'IN' : 'NOT IN'} ('imports', 'extends', 'implements')`;
|
|
2988
|
+
this.stmts[key] = this.db.prepare(`SELECT * FROM unresolved_refs WHERE status = 'pending' AND id > ?${filter} ORDER BY id LIMIT ?`);
|
|
2989
|
+
}
|
|
2990
|
+
const rows = this.stmts[key].all(afterRowId, limit);
|
|
2030
2991
|
return rows.map((row) => ({
|
|
2031
2992
|
fromNodeId: row.from_node_id,
|
|
2032
2993
|
referenceName: row.reference_name,
|
|
@@ -2370,6 +3331,17 @@ class QueryBuilder {
|
|
|
2370
3331
|
})();
|
|
2371
3332
|
return changed;
|
|
2372
3333
|
}
|
|
3334
|
+
/**
|
|
3335
|
+
* Replace resolution edges with their original unresolved references as one
|
|
3336
|
+
* transaction. If ref insertion fails, the edge deletion is rolled back.
|
|
3337
|
+
*/
|
|
3338
|
+
replaceResolutionEdgesWithUnresolvedRefs(edgeIds, refs) {
|
|
3339
|
+
return this.db.transaction(() => {
|
|
3340
|
+
const changed = this.deleteEdgesByIds(edgeIds);
|
|
3341
|
+
this.insertUnresolvedRefsBatch(refs);
|
|
3342
|
+
return changed;
|
|
3343
|
+
})();
|
|
3344
|
+
}
|
|
2373
3345
|
/**
|
|
2374
3346
|
* Distinct node names present in the given files — the symbol names a sync
|
|
2375
3347
|
* pass uses to look up retryable failed refs after those files changed.
|
|
@@ -2517,4 +3489,71 @@ class QueryBuilder {
|
|
|
2517
3489
|
}
|
|
2518
3490
|
}
|
|
2519
3491
|
exports.QueryBuilder = QueryBuilder;
|
|
3492
|
+
function foldModuleRows(rows, options) {
|
|
3493
|
+
// A module id is a path and may contain anything printable, so the key
|
|
3494
|
+
// separator has to be something a path cannot hold.
|
|
3495
|
+
const SEP = '\u0000';
|
|
3496
|
+
const links = new Map();
|
|
3497
|
+
const pairKinds = new Set(options.pairKinds);
|
|
3498
|
+
const wantPairs = options.topPairsPerLink > 0 && pairKinds.size > 0;
|
|
3499
|
+
const pairTotals = new Map();
|
|
3500
|
+
for (const row of rows) {
|
|
3501
|
+
const linkKey = `${row.source}${SEP}${row.target}${SEP}${row.kind}`;
|
|
3502
|
+
const link = links.get(linkKey);
|
|
3503
|
+
if (link) {
|
|
3504
|
+
link.count += row.count;
|
|
3505
|
+
link.declared += row.declared;
|
|
3506
|
+
link.uncertain += row.uncertain;
|
|
3507
|
+
}
|
|
3508
|
+
else {
|
|
3509
|
+
links.set(linkKey, {
|
|
3510
|
+
source: row.source,
|
|
3511
|
+
target: row.target,
|
|
3512
|
+
kind: row.kind,
|
|
3513
|
+
count: row.count,
|
|
3514
|
+
declared: row.declared,
|
|
3515
|
+
uncertain: row.uncertain,
|
|
3516
|
+
});
|
|
3517
|
+
}
|
|
3518
|
+
// Only the confident half of a row can be named: an uncertain edge is a
|
|
3519
|
+
// guess, and printing "a to b, 12" for twelve guesses is the map claiming
|
|
3520
|
+
// something it does not know.
|
|
3521
|
+
if (!wantPairs || row.count === 0 || !pairKinds.has(row.kind))
|
|
3522
|
+
continue;
|
|
3523
|
+
const pairKey = `${row.source}${SEP}${row.target}${SEP}${row.from}${SEP}${row.to}`;
|
|
3524
|
+
const pair = pairTotals.get(pairKey);
|
|
3525
|
+
if (pair) {
|
|
3526
|
+
pair.count += row.count;
|
|
3527
|
+
pair.declared += row.declared;
|
|
3528
|
+
}
|
|
3529
|
+
else {
|
|
3530
|
+
pairTotals.set(pairKey, {
|
|
3531
|
+
source: row.source,
|
|
3532
|
+
target: row.target,
|
|
3533
|
+
from: row.from,
|
|
3534
|
+
to: row.to,
|
|
3535
|
+
count: row.count,
|
|
3536
|
+
declared: row.declared,
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
const byLink = new Map();
|
|
3541
|
+
for (const pair of pairTotals.values()) {
|
|
3542
|
+
const key = `${pair.source}${SEP}${pair.target}`;
|
|
3543
|
+
let list = byLink.get(key);
|
|
3544
|
+
if (!list)
|
|
3545
|
+
byLink.set(key, (list = []));
|
|
3546
|
+
list.push(pair);
|
|
3547
|
+
}
|
|
3548
|
+
const pairs = [];
|
|
3549
|
+
for (const list of byLink.values()) {
|
|
3550
|
+
list.sort((a, b) => b.declared - a.declared ||
|
|
3551
|
+
b.count - a.count ||
|
|
3552
|
+
a.from.localeCompare(b.from) ||
|
|
3553
|
+
a.to.localeCompare(b.to));
|
|
3554
|
+
for (const pair of list.slice(0, options.topPairsPerLink))
|
|
3555
|
+
pairs.push(pair);
|
|
3556
|
+
}
|
|
3557
|
+
return { links: [...links.values()], pairs };
|
|
3558
|
+
}
|
|
2520
3559
|
//# sourceMappingURL=queries.js.map
|