@kkvcrobatz107/codegraph 0.9.6-pkm.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +595 -0
- package/dist/bin/codegraph.d.ts +25 -0
- package/dist/bin/codegraph.d.ts.map +1 -0
- package/dist/bin/codegraph.js +1563 -0
- package/dist/bin/codegraph.js.map +1 -0
- package/dist/bin/node-version-check.d.ts +37 -0
- package/dist/bin/node-version-check.d.ts.map +1 -0
- package/dist/bin/node-version-check.js +79 -0
- package/dist/bin/node-version-check.js.map +1 -0
- package/dist/bin/uninstall.d.ts +14 -0
- package/dist/bin/uninstall.d.ts.map +1 -0
- package/dist/bin/uninstall.js +36 -0
- package/dist/bin/uninstall.js.map +1 -0
- package/dist/context/formatter.d.ts +30 -0
- package/dist/context/formatter.d.ts.map +1 -0
- package/dist/context/formatter.js +244 -0
- package/dist/context/formatter.js.map +1 -0
- package/dist/context/index.d.ts +110 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +1169 -0
- package/dist/context/index.js.map +1 -0
- package/dist/db/index.d.ts +101 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +251 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrations.d.ts +44 -0
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +131 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/queries.d.ts +281 -0
- package/dist/db/queries.d.ts.map +1 -0
- package/dist/db/queries.js +1300 -0
- package/dist/db/queries.js.map +1 -0
- package/dist/db/schema.sql +151 -0
- package/dist/db/sqlite-adapter.d.ts +46 -0
- package/dist/db/sqlite-adapter.d.ts.map +1 -0
- package/dist/db/sqlite-adapter.js +114 -0
- package/dist/db/sqlite-adapter.js.map +1 -0
- package/dist/directory.d.ts +57 -0
- package/dist/directory.d.ts.map +1 -0
- package/dist/directory.js +264 -0
- package/dist/directory.js.map +1 -0
- package/dist/errors.d.ts +136 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +219 -0
- package/dist/errors.js.map +1 -0
- package/dist/extraction/dfm-extractor.d.ts +31 -0
- package/dist/extraction/dfm-extractor.d.ts.map +1 -0
- package/dist/extraction/dfm-extractor.js +151 -0
- package/dist/extraction/dfm-extractor.js.map +1 -0
- package/dist/extraction/grammars.d.ts +90 -0
- package/dist/extraction/grammars.d.ts.map +1 -0
- package/dist/extraction/grammars.js +407 -0
- package/dist/extraction/grammars.js.map +1 -0
- package/dist/extraction/index.d.ts +138 -0
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/index.js +1378 -0
- package/dist/extraction/index.js.map +1 -0
- package/dist/extraction/languages/c-cpp.d.ts +4 -0
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
- package/dist/extraction/languages/c-cpp.js +171 -0
- package/dist/extraction/languages/c-cpp.js.map +1 -0
- package/dist/extraction/languages/csharp.d.ts +3 -0
- package/dist/extraction/languages/csharp.d.ts.map +1 -0
- package/dist/extraction/languages/csharp.js +73 -0
- package/dist/extraction/languages/csharp.js.map +1 -0
- package/dist/extraction/languages/dart.d.ts +3 -0
- package/dist/extraction/languages/dart.d.ts.map +1 -0
- package/dist/extraction/languages/dart.js +192 -0
- package/dist/extraction/languages/dart.js.map +1 -0
- package/dist/extraction/languages/go.d.ts +3 -0
- package/dist/extraction/languages/go.d.ts.map +1 -0
- package/dist/extraction/languages/go.js +70 -0
- package/dist/extraction/languages/go.js.map +1 -0
- package/dist/extraction/languages/index.d.ts +10 -0
- package/dist/extraction/languages/index.d.ts.map +1 -0
- package/dist/extraction/languages/index.js +51 -0
- package/dist/extraction/languages/index.js.map +1 -0
- package/dist/extraction/languages/java.d.ts +3 -0
- package/dist/extraction/languages/java.d.ts.map +1 -0
- package/dist/extraction/languages/java.js +70 -0
- package/dist/extraction/languages/java.js.map +1 -0
- package/dist/extraction/languages/javascript.d.ts +3 -0
- package/dist/extraction/languages/javascript.d.ts.map +1 -0
- package/dist/extraction/languages/javascript.js +90 -0
- package/dist/extraction/languages/javascript.js.map +1 -0
- package/dist/extraction/languages/kotlin.d.ts +3 -0
- package/dist/extraction/languages/kotlin.d.ts.map +1 -0
- package/dist/extraction/languages/kotlin.js +259 -0
- package/dist/extraction/languages/kotlin.js.map +1 -0
- package/dist/extraction/languages/lua.d.ts +3 -0
- package/dist/extraction/languages/lua.d.ts.map +1 -0
- package/dist/extraction/languages/lua.js +150 -0
- package/dist/extraction/languages/lua.js.map +1 -0
- package/dist/extraction/languages/luau.d.ts +3 -0
- package/dist/extraction/languages/luau.d.ts.map +1 -0
- package/dist/extraction/languages/luau.js +37 -0
- package/dist/extraction/languages/luau.js.map +1 -0
- package/dist/extraction/languages/objc.d.ts +3 -0
- package/dist/extraction/languages/objc.d.ts.map +1 -0
- package/dist/extraction/languages/objc.js +133 -0
- package/dist/extraction/languages/objc.js.map +1 -0
- package/dist/extraction/languages/pascal.d.ts +3 -0
- package/dist/extraction/languages/pascal.d.ts.map +1 -0
- package/dist/extraction/languages/pascal.js +66 -0
- package/dist/extraction/languages/pascal.js.map +1 -0
- package/dist/extraction/languages/php.d.ts +3 -0
- package/dist/extraction/languages/php.d.ts.map +1 -0
- package/dist/extraction/languages/php.js +107 -0
- package/dist/extraction/languages/php.js.map +1 -0
- package/dist/extraction/languages/python.d.ts +3 -0
- package/dist/extraction/languages/python.d.ts.map +1 -0
- package/dist/extraction/languages/python.js +56 -0
- package/dist/extraction/languages/python.js.map +1 -0
- package/dist/extraction/languages/ruby.d.ts +3 -0
- package/dist/extraction/languages/ruby.d.ts.map +1 -0
- package/dist/extraction/languages/ruby.js +114 -0
- package/dist/extraction/languages/ruby.js.map +1 -0
- package/dist/extraction/languages/rust.d.ts +3 -0
- package/dist/extraction/languages/rust.d.ts.map +1 -0
- package/dist/extraction/languages/rust.js +109 -0
- package/dist/extraction/languages/rust.js.map +1 -0
- package/dist/extraction/languages/scala.d.ts +3 -0
- package/dist/extraction/languages/scala.d.ts.map +1 -0
- package/dist/extraction/languages/scala.js +139 -0
- package/dist/extraction/languages/scala.js.map +1 -0
- package/dist/extraction/languages/swift.d.ts +3 -0
- package/dist/extraction/languages/swift.d.ts.map +1 -0
- package/dist/extraction/languages/swift.js +91 -0
- package/dist/extraction/languages/swift.js.map +1 -0
- package/dist/extraction/languages/typescript.d.ts +3 -0
- package/dist/extraction/languages/typescript.d.ts.map +1 -0
- package/dist/extraction/languages/typescript.js +129 -0
- package/dist/extraction/languages/typescript.js.map +1 -0
- package/dist/extraction/liquid-extractor.d.ts +52 -0
- package/dist/extraction/liquid-extractor.d.ts.map +1 -0
- package/dist/extraction/liquid-extractor.js +313 -0
- package/dist/extraction/liquid-extractor.js.map +1 -0
- package/dist/extraction/mybatis-extractor.d.ts +48 -0
- package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
- package/dist/extraction/mybatis-extractor.js +198 -0
- package/dist/extraction/mybatis-extractor.js.map +1 -0
- package/dist/extraction/parse-worker.d.ts +8 -0
- package/dist/extraction/parse-worker.d.ts.map +1 -0
- package/dist/extraction/parse-worker.js +94 -0
- package/dist/extraction/parse-worker.js.map +1 -0
- package/dist/extraction/svelte-extractor.d.ts +56 -0
- package/dist/extraction/svelte-extractor.d.ts.map +1 -0
- package/dist/extraction/svelte-extractor.js +272 -0
- package/dist/extraction/svelte-extractor.js.map +1 -0
- package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
- package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
- package/dist/extraction/tree-sitter-helpers.js +103 -0
- package/dist/extraction/tree-sitter-helpers.js.map +1 -0
- package/dist/extraction/tree-sitter-types.d.ts +193 -0
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
- package/dist/extraction/tree-sitter-types.js +10 -0
- package/dist/extraction/tree-sitter-types.js.map +1 -0
- package/dist/extraction/tree-sitter.d.ts +291 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -0
- package/dist/extraction/tree-sitter.js +2961 -0
- package/dist/extraction/tree-sitter.js.map +1 -0
- package/dist/extraction/vue-extractor.d.ts +36 -0
- package/dist/extraction/vue-extractor.d.ts.map +1 -0
- package/dist/extraction/vue-extractor.js +163 -0
- package/dist/extraction/vue-extractor.js.map +1 -0
- package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
- package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
- package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
- package/dist/extraction/wasm-runtime-flags.js +105 -0
- package/dist/extraction/wasm-runtime-flags.js.map +1 -0
- package/dist/graph/index.d.ts +8 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +13 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/queries.d.ts +106 -0
- package/dist/graph/queries.d.ts.map +1 -0
- package/dist/graph/queries.js +366 -0
- package/dist/graph/queries.js.map +1 -0
- package/dist/graph/traversal.d.ts +127 -0
- package/dist/graph/traversal.d.ts.map +1 -0
- package/dist/graph/traversal.js +528 -0
- package/dist/graph/traversal.js.map +1 -0
- package/dist/index.d.ts +460 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +863 -0
- package/dist/index.js.map +1 -0
- package/dist/installer/claude-md-template.d.ts +14 -0
- package/dist/installer/claude-md-template.d.ts.map +1 -0
- package/dist/installer/claude-md-template.js +21 -0
- package/dist/installer/claude-md-template.js.map +1 -0
- package/dist/installer/config-writer.d.ts +29 -0
- package/dist/installer/config-writer.d.ts.map +1 -0
- package/dist/installer/config-writer.js +111 -0
- package/dist/installer/config-writer.js.map +1 -0
- package/dist/installer/index.d.ts +117 -0
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +528 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/installer/instructions-template.d.ts +28 -0
- package/dist/installer/instructions-template.d.ts.map +1 -0
- package/dist/installer/instructions-template.js +65 -0
- package/dist/installer/instructions-template.js.map +1 -0
- package/dist/installer/targets/antigravity.d.ts +57 -0
- package/dist/installer/targets/antigravity.d.ts.map +1 -0
- package/dist/installer/targets/antigravity.js +307 -0
- package/dist/installer/targets/antigravity.js.map +1 -0
- package/dist/installer/targets/claude.d.ts +47 -0
- package/dist/installer/targets/claude.d.ts.map +1 -0
- package/dist/installer/targets/claude.js +401 -0
- package/dist/installer/targets/claude.js.map +1 -0
- package/dist/installer/targets/codex.d.ts +18 -0
- package/dist/installer/targets/codex.d.ts.map +1 -0
- package/dist/installer/targets/codex.js +185 -0
- package/dist/installer/targets/codex.js.map +1 -0
- package/dist/installer/targets/cursor.d.ts +35 -0
- package/dist/installer/targets/cursor.d.ts.map +1 -0
- package/dist/installer/targets/cursor.js +283 -0
- package/dist/installer/targets/cursor.js.map +1 -0
- package/dist/installer/targets/gemini.d.ts +26 -0
- package/dist/installer/targets/gemini.d.ts.map +1 -0
- package/dist/installer/targets/gemini.js +165 -0
- package/dist/installer/targets/gemini.js.map +1 -0
- package/dist/installer/targets/hermes.d.ts +18 -0
- package/dist/installer/targets/hermes.d.ts.map +1 -0
- package/dist/installer/targets/hermes.js +359 -0
- package/dist/installer/targets/hermes.js.map +1 -0
- package/dist/installer/targets/kiro.d.ts +27 -0
- package/dist/installer/targets/kiro.d.ts.map +1 -0
- package/dist/installer/targets/kiro.js +196 -0
- package/dist/installer/targets/kiro.js.map +1 -0
- package/dist/installer/targets/opencode.d.ts +30 -0
- package/dist/installer/targets/opencode.d.ts.map +1 -0
- package/dist/installer/targets/opencode.js +235 -0
- package/dist/installer/targets/opencode.js.map +1 -0
- package/dist/installer/targets/registry.d.ts +35 -0
- package/dist/installer/targets/registry.d.ts.map +1 -0
- package/dist/installer/targets/registry.js +91 -0
- package/dist/installer/targets/registry.js.map +1 -0
- package/dist/installer/targets/shared.d.ts +77 -0
- package/dist/installer/targets/shared.d.ts.map +1 -0
- package/dist/installer/targets/shared.js +246 -0
- package/dist/installer/targets/shared.js.map +1 -0
- package/dist/installer/targets/toml.d.ts +52 -0
- package/dist/installer/targets/toml.d.ts.map +1 -0
- package/dist/installer/targets/toml.js +147 -0
- package/dist/installer/targets/toml.js.map +1 -0
- package/dist/installer/targets/types.d.ts +116 -0
- package/dist/installer/targets/types.d.ts.map +1 -0
- package/dist/installer/targets/types.js +16 -0
- package/dist/installer/targets/types.js.map +1 -0
- package/dist/mcp/daemon-paths.d.ts +46 -0
- package/dist/mcp/daemon-paths.d.ts.map +1 -0
- package/dist/mcp/daemon-paths.js +125 -0
- package/dist/mcp/daemon-paths.js.map +1 -0
- package/dist/mcp/daemon.d.ts +161 -0
- package/dist/mcp/daemon.d.ts.map +1 -0
- package/dist/mcp/daemon.js +403 -0
- package/dist/mcp/daemon.js.map +1 -0
- package/dist/mcp/engine.d.ts +100 -0
- package/dist/mcp/engine.d.ts.map +1 -0
- package/dist/mcp/engine.js +291 -0
- package/dist/mcp/engine.js.map +1 -0
- package/dist/mcp/index.d.ts +109 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +470 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/proxy.d.ts +46 -0
- package/dist/mcp/proxy.d.ts.map +1 -0
- package/dist/mcp/proxy.js +276 -0
- package/dist/mcp/proxy.js.map +1 -0
- package/dist/mcp/server-instructions.d.ts +19 -0
- package/dist/mcp/server-instructions.d.ts.map +1 -0
- package/dist/mcp/server-instructions.js +73 -0
- package/dist/mcp/server-instructions.js.map +1 -0
- package/dist/mcp/session.d.ts +67 -0
- package/dist/mcp/session.d.ts.map +1 -0
- package/dist/mcp/session.js +276 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/tools.d.ts +385 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +2545 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/transport.d.ts +188 -0
- package/dist/mcp/transport.d.ts.map +1 -0
- package/dist/mcp/transport.js +343 -0
- package/dist/mcp/transport.js.map +1 -0
- package/dist/mcp/version.d.ts +19 -0
- package/dist/mcp/version.d.ts.map +1 -0
- package/dist/mcp/version.js +71 -0
- package/dist/mcp/version.js.map +1 -0
- package/dist/resolution/callback-synthesizer.d.ts +10 -0
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
- package/dist/resolution/callback-synthesizer.js +924 -0
- package/dist/resolution/callback-synthesizer.js.map +1 -0
- package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
- package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
- package/dist/resolution/frameworks/cargo-workspace.js +225 -0
- package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
- package/dist/resolution/frameworks/csharp.d.ts +8 -0
- package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
- package/dist/resolution/frameworks/csharp.js +241 -0
- package/dist/resolution/frameworks/csharp.js.map +1 -0
- package/dist/resolution/frameworks/drupal.d.ts +51 -0
- package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
- package/dist/resolution/frameworks/drupal.js +367 -0
- package/dist/resolution/frameworks/drupal.js.map +1 -0
- package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
- package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
- package/dist/resolution/frameworks/expo-modules.js +143 -0
- package/dist/resolution/frameworks/expo-modules.js.map +1 -0
- package/dist/resolution/frameworks/express.d.ts +8 -0
- package/dist/resolution/frameworks/express.d.ts.map +1 -0
- package/dist/resolution/frameworks/express.js +308 -0
- package/dist/resolution/frameworks/express.js.map +1 -0
- package/dist/resolution/frameworks/fabric.d.ts +3 -0
- package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
- package/dist/resolution/frameworks/fabric.js +354 -0
- package/dist/resolution/frameworks/fabric.js.map +1 -0
- package/dist/resolution/frameworks/go.d.ts +8 -0
- package/dist/resolution/frameworks/go.d.ts.map +1 -0
- package/dist/resolution/frameworks/go.js +161 -0
- package/dist/resolution/frameworks/go.js.map +1 -0
- package/dist/resolution/frameworks/index.d.ts +48 -0
- package/dist/resolution/frameworks/index.d.ts.map +1 -0
- package/dist/resolution/frameworks/index.js +161 -0
- package/dist/resolution/frameworks/index.js.map +1 -0
- package/dist/resolution/frameworks/java.d.ts +8 -0
- package/dist/resolution/frameworks/java.d.ts.map +1 -0
- package/dist/resolution/frameworks/java.js +504 -0
- package/dist/resolution/frameworks/java.js.map +1 -0
- package/dist/resolution/frameworks/laravel.d.ts +13 -0
- package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
- package/dist/resolution/frameworks/laravel.js +257 -0
- package/dist/resolution/frameworks/laravel.js.map +1 -0
- package/dist/resolution/frameworks/nestjs.d.ts +26 -0
- package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
- package/dist/resolution/frameworks/nestjs.js +698 -0
- package/dist/resolution/frameworks/nestjs.js.map +1 -0
- package/dist/resolution/frameworks/play.d.ts +19 -0
- package/dist/resolution/frameworks/play.d.ts.map +1 -0
- package/dist/resolution/frameworks/play.js +111 -0
- package/dist/resolution/frameworks/play.js.map +1 -0
- package/dist/resolution/frameworks/python.d.ts +10 -0
- package/dist/resolution/frameworks/python.d.ts.map +1 -0
- package/dist/resolution/frameworks/python.js +396 -0
- package/dist/resolution/frameworks/python.js.map +1 -0
- package/dist/resolution/frameworks/react-native.d.ts +3 -0
- package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
- package/dist/resolution/frameworks/react-native.js +360 -0
- package/dist/resolution/frameworks/react-native.js.map +1 -0
- package/dist/resolution/frameworks/react.d.ts +8 -0
- package/dist/resolution/frameworks/react.d.ts.map +1 -0
- package/dist/resolution/frameworks/react.js +365 -0
- package/dist/resolution/frameworks/react.js.map +1 -0
- package/dist/resolution/frameworks/ruby.d.ts +8 -0
- package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
- package/dist/resolution/frameworks/ruby.js +302 -0
- package/dist/resolution/frameworks/ruby.js.map +1 -0
- package/dist/resolution/frameworks/rust.d.ts +8 -0
- package/dist/resolution/frameworks/rust.d.ts.map +1 -0
- package/dist/resolution/frameworks/rust.js +304 -0
- package/dist/resolution/frameworks/rust.js.map +1 -0
- package/dist/resolution/frameworks/svelte.d.ts +9 -0
- package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
- package/dist/resolution/frameworks/svelte.js +249 -0
- package/dist/resolution/frameworks/svelte.js.map +1 -0
- package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
- package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
- package/dist/resolution/frameworks/swift-objc.js +252 -0
- package/dist/resolution/frameworks/swift-objc.js.map +1 -0
- package/dist/resolution/frameworks/swift.d.ts +10 -0
- package/dist/resolution/frameworks/swift.d.ts.map +1 -0
- package/dist/resolution/frameworks/swift.js +400 -0
- package/dist/resolution/frameworks/swift.js.map +1 -0
- package/dist/resolution/frameworks/vue.d.ts +9 -0
- package/dist/resolution/frameworks/vue.d.ts.map +1 -0
- package/dist/resolution/frameworks/vue.js +306 -0
- package/dist/resolution/frameworks/vue.js.map +1 -0
- package/dist/resolution/go-module.d.ts +26 -0
- package/dist/resolution/go-module.d.ts.map +1 -0
- package/dist/resolution/go-module.js +78 -0
- package/dist/resolution/go-module.js.map +1 -0
- package/dist/resolution/import-resolver.d.ts +68 -0
- package/dist/resolution/import-resolver.d.ts.map +1 -0
- package/dist/resolution/import-resolver.js +1231 -0
- package/dist/resolution/import-resolver.js.map +1 -0
- package/dist/resolution/index.d.ts +116 -0
- package/dist/resolution/index.d.ts.map +1 -0
- package/dist/resolution/index.js +878 -0
- package/dist/resolution/index.js.map +1 -0
- package/dist/resolution/lru-cache.d.ts +24 -0
- package/dist/resolution/lru-cache.d.ts.map +1 -0
- package/dist/resolution/lru-cache.js +62 -0
- package/dist/resolution/lru-cache.js.map +1 -0
- package/dist/resolution/name-matcher.d.ts +32 -0
- package/dist/resolution/name-matcher.d.ts.map +1 -0
- package/dist/resolution/name-matcher.js +596 -0
- package/dist/resolution/name-matcher.js.map +1 -0
- package/dist/resolution/path-aliases.d.ts +68 -0
- package/dist/resolution/path-aliases.d.ts.map +1 -0
- package/dist/resolution/path-aliases.js +238 -0
- package/dist/resolution/path-aliases.js.map +1 -0
- package/dist/resolution/strip-comments.d.ts +27 -0
- package/dist/resolution/strip-comments.d.ts.map +1 -0
- package/dist/resolution/strip-comments.js +441 -0
- package/dist/resolution/strip-comments.js.map +1 -0
- package/dist/resolution/swift-objc-bridge.d.ts +134 -0
- package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
- package/dist/resolution/swift-objc-bridge.js +256 -0
- package/dist/resolution/swift-objc-bridge.js.map +1 -0
- package/dist/resolution/types.d.ts +209 -0
- package/dist/resolution/types.d.ts.map +1 -0
- package/dist/resolution/types.js +8 -0
- package/dist/resolution/types.js.map +1 -0
- package/dist/search/query-parser.d.ts +57 -0
- package/dist/search/query-parser.d.ts.map +1 -0
- package/dist/search/query-parser.js +177 -0
- package/dist/search/query-parser.js.map +1 -0
- package/dist/search/query-utils.d.ts +53 -0
- package/dist/search/query-utils.d.ts.map +1 -0
- package/dist/search/query-utils.js +350 -0
- package/dist/search/query-utils.js.map +1 -0
- package/dist/sync/git-hooks.d.ts +45 -0
- package/dist/sync/git-hooks.d.ts.map +1 -0
- package/dist/sync/git-hooks.js +223 -0
- package/dist/sync/git-hooks.js.map +1 -0
- package/dist/sync/index.d.ts +19 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +35 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/watch-policy.d.ts +48 -0
- package/dist/sync/watch-policy.d.ts.map +1 -0
- package/dist/sync/watch-policy.js +124 -0
- package/dist/sync/watch-policy.js.map +1 -0
- package/dist/sync/watcher.d.ts +191 -0
- package/dist/sync/watcher.d.ts.map +1 -0
- package/dist/sync/watcher.js +398 -0
- package/dist/sync/watcher.js.map +1 -0
- package/dist/sync/worktree.d.ts +54 -0
- package/dist/sync/worktree.d.ts.map +1 -0
- package/dist/sync/worktree.js +136 -0
- package/dist/sync/worktree.js.map +1 -0
- package/dist/types.d.ts +369 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +78 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/glyphs.d.ts +42 -0
- package/dist/ui/glyphs.d.ts.map +1 -0
- package/dist/ui/glyphs.js +78 -0
- package/dist/ui/glyphs.js.map +1 -0
- package/dist/ui/shimmer-progress.d.ts +11 -0
- package/dist/ui/shimmer-progress.d.ts.map +1 -0
- package/dist/ui/shimmer-progress.js +90 -0
- package/dist/ui/shimmer-progress.js.map +1 -0
- package/dist/ui/shimmer-worker.d.ts +2 -0
- package/dist/ui/shimmer-worker.d.ts.map +1 -0
- package/dist/ui/shimmer-worker.js +118 -0
- package/dist/ui/shimmer-worker.js.map +1 -0
- package/dist/ui/types.d.ts +17 -0
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui/types.js +3 -0
- package/dist/ui/types.js.map +1 -0
- package/dist/utils.d.ts +205 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +549 -0
- package/dist/utils.js.map +1 -0
- package/package.json +59 -0
- package/scripts/add-lang/bench.sh +60 -0
- package/scripts/add-lang/check-grammar.mjs +75 -0
- package/scripts/add-lang/dump-ast.mjs +103 -0
- package/scripts/add-lang/verify-extraction.mjs +70 -0
- package/scripts/agent-eval/arms-F.sh +21 -0
- package/scripts/agent-eval/arms-matrix.sh +37 -0
- package/scripts/agent-eval/audit.sh +68 -0
- package/scripts/agent-eval/bench-readme.sh +28 -0
- package/scripts/agent-eval/block-read-hook.sh +19 -0
- package/scripts/agent-eval/hook-settings.json +15 -0
- package/scripts/agent-eval/itrun.sh +107 -0
- package/scripts/agent-eval/parse-arms.mjs +116 -0
- package/scripts/agent-eval/parse-bench-readme.mjs +67 -0
- package/scripts/agent-eval/parse-run.mjs +45 -0
- package/scripts/agent-eval/parse-session.mjs +93 -0
- package/scripts/agent-eval/probe-context.mjs +21 -0
- package/scripts/agent-eval/probe-explore.mjs +40 -0
- package/scripts/agent-eval/probe-node.mjs +20 -0
- package/scripts/agent-eval/probe-trace.mjs +20 -0
- package/scripts/agent-eval/run-agent.sh +34 -0
- package/scripts/agent-eval/run-all.sh +67 -0
- package/scripts/agent-eval/run-arms.sh +56 -0
- package/scripts/agent-eval/seq-matrix.mjs +137 -0
- package/scripts/build-bundle.sh +118 -0
- package/scripts/extract-release-notes.mjs +130 -0
- package/scripts/local-install.sh +41 -0
- package/scripts/npm-shim.js +246 -0
- package/scripts/pack-npm.sh +95 -0
- package/scripts/prepare-release.mjs +270 -0
|
@@ -0,0 +1,878 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Reference Resolution Orchestrator
|
|
4
|
+
*
|
|
5
|
+
* Coordinates all reference resolution strategies.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
41
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.ReferenceResolver = void 0;
|
|
45
|
+
exports.createResolver = createResolver;
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
const name_matcher_1 = require("./name-matcher");
|
|
49
|
+
const import_resolver_1 = require("./import-resolver");
|
|
50
|
+
const frameworks_1 = require("./frameworks");
|
|
51
|
+
const callback_synthesizer_1 = require("./callback-synthesizer");
|
|
52
|
+
const path_aliases_1 = require("./path-aliases");
|
|
53
|
+
const go_module_1 = require("./go-module");
|
|
54
|
+
const errors_1 = require("../errors");
|
|
55
|
+
const lru_cache_1 = require("./lru-cache");
|
|
56
|
+
/**
|
|
57
|
+
* Cache size limits. Each per-resolver cache is bounded so memory
|
|
58
|
+
* stays flat on large codebases (20k+ files). Sizes were chosen to
|
|
59
|
+
* cover the working set for typical resolution batches without
|
|
60
|
+
* exceeding a few hundred MB worst-case. Override via the env var
|
|
61
|
+
* `CODEGRAPH_RESOLVER_CACHE_SIZE` (single integer applied to all
|
|
62
|
+
* caches) when tuning for very large or very small projects.
|
|
63
|
+
*/
|
|
64
|
+
const DEFAULT_CACHE_LIMIT = 5_000;
|
|
65
|
+
function resolveCacheLimit() {
|
|
66
|
+
const raw = process.env.CODEGRAPH_RESOLVER_CACHE_SIZE;
|
|
67
|
+
if (!raw)
|
|
68
|
+
return DEFAULT_CACHE_LIMIT;
|
|
69
|
+
const parsed = Number.parseInt(raw, 10);
|
|
70
|
+
if (Number.isFinite(parsed) && parsed > 0)
|
|
71
|
+
return parsed;
|
|
72
|
+
return DEFAULT_CACHE_LIMIT;
|
|
73
|
+
}
|
|
74
|
+
// Re-export types
|
|
75
|
+
__exportStar(require("./types"), exports);
|
|
76
|
+
// Pre-built Sets for O(1) built-in lookups (allocated once, shared across all instances)
|
|
77
|
+
const JS_BUILT_INS = new Set([
|
|
78
|
+
'console', 'window', 'document', 'global', 'process',
|
|
79
|
+
'Promise', 'Array', 'Object', 'String', 'Number', 'Boolean',
|
|
80
|
+
'Date', 'Math', 'JSON', 'RegExp', 'Error', 'Map', 'Set',
|
|
81
|
+
'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval',
|
|
82
|
+
'fetch', 'require', 'module', 'exports', '__dirname', '__filename',
|
|
83
|
+
]);
|
|
84
|
+
const REACT_HOOKS = new Set([
|
|
85
|
+
'useState', 'useEffect', 'useContext', 'useReducer', 'useCallback',
|
|
86
|
+
'useMemo', 'useRef', 'useLayoutEffect', 'useImperativeHandle', 'useDebugValue',
|
|
87
|
+
]);
|
|
88
|
+
const PYTHON_BUILT_INS = new Set([
|
|
89
|
+
'print', 'len', 'range', 'str', 'int', 'float', 'list', 'dict', 'set', 'tuple',
|
|
90
|
+
'open', 'input', 'type', 'isinstance', 'hasattr', 'getattr', 'setattr',
|
|
91
|
+
'super', 'self', 'cls', 'None', 'True', 'False',
|
|
92
|
+
]);
|
|
93
|
+
const PYTHON_BUILT_IN_TYPES = new Set([
|
|
94
|
+
'list', 'dict', 'set', 'tuple', 'str', 'int', 'float', 'bool',
|
|
95
|
+
'bytes', 'bytearray', 'frozenset', 'object', 'super',
|
|
96
|
+
]);
|
|
97
|
+
const PYTHON_BUILT_IN_METHODS = new Set([
|
|
98
|
+
'append', 'extend', 'insert', 'remove', 'pop', 'clear', 'sort', 'reverse', 'copy',
|
|
99
|
+
'update', 'keys', 'values', 'items', 'get',
|
|
100
|
+
'add', 'discard', 'union', 'intersection', 'difference',
|
|
101
|
+
'split', 'join', 'strip', 'lstrip', 'rstrip', 'replace', 'lower', 'upper',
|
|
102
|
+
'startswith', 'endswith', 'find', 'index', 'count', 'encode', 'decode',
|
|
103
|
+
'format', 'isdigit', 'isalpha', 'isalnum',
|
|
104
|
+
'read', 'write', 'readline', 'readlines', 'close', 'flush', 'seek',
|
|
105
|
+
]);
|
|
106
|
+
const GO_STDLIB_PACKAGES = new Set([
|
|
107
|
+
'fmt', 'os', 'io', 'net', 'http', 'log', 'math', 'sort', 'sync',
|
|
108
|
+
'time', 'path', 'bytes', 'strings', 'strconv', 'errors', 'context',
|
|
109
|
+
'json', 'xml', 'csv', 'html', 'template', 'regexp', 'reflect',
|
|
110
|
+
'runtime', 'testing', 'flag', 'bufio', 'crypto', 'encoding',
|
|
111
|
+
'filepath', 'hash', 'mime', 'rand', 'signal', 'sql', 'syscall',
|
|
112
|
+
'unicode', 'unsafe', 'atomic', 'binary', 'debug', 'exec', 'heap',
|
|
113
|
+
'ring', 'scanner', 'tar', 'zip', 'gzip', 'zlib', 'tls', 'url',
|
|
114
|
+
'user', 'pprof', 'trace', 'ast', 'build', 'parser', 'printer',
|
|
115
|
+
'token', 'types', 'cgo', 'plugin', 'race', 'ioutil',
|
|
116
|
+
// Kubernetes-common stdlib aliases
|
|
117
|
+
'utilruntime', 'utilwait', 'utilnet',
|
|
118
|
+
]);
|
|
119
|
+
const GO_BUILT_INS = new Set([
|
|
120
|
+
'make', 'new', 'len', 'cap', 'append', 'copy', 'delete', 'close',
|
|
121
|
+
'panic', 'recover', 'print', 'println', 'complex', 'real', 'imag',
|
|
122
|
+
'error', 'nil', 'true', 'false', 'iota',
|
|
123
|
+
'int', 'int8', 'int16', 'int32', 'int64',
|
|
124
|
+
'uint', 'uint8', 'uint16', 'uint32', 'uint64', 'uintptr',
|
|
125
|
+
'float32', 'float64', 'complex64', 'complex128',
|
|
126
|
+
'string', 'bool', 'byte', 'rune', 'any',
|
|
127
|
+
]);
|
|
128
|
+
const PASCAL_UNIT_PREFIXES = [
|
|
129
|
+
'System.', 'Winapi.', 'Vcl.', 'Fmx.', 'Data.', 'Datasnap.',
|
|
130
|
+
'Soap.', 'Xml.', 'Web.', 'REST.', 'FireDAC.', 'IBX.',
|
|
131
|
+
'IdHTTP', 'IdTCP', 'IdSSL',
|
|
132
|
+
];
|
|
133
|
+
const PASCAL_BUILT_INS = new Set([
|
|
134
|
+
'System', 'SysUtils', 'Classes', 'Types', 'Variants', 'StrUtils',
|
|
135
|
+
'Math', 'DateUtils', 'IOUtils', 'Generics.Collections', 'Generics.Defaults',
|
|
136
|
+
'Rtti', 'TypInfo', 'SyncObjs', 'RegularExpressions',
|
|
137
|
+
'SysInit', 'Windows', 'Messages', 'Graphics', 'Controls', 'Forms',
|
|
138
|
+
'Dialogs', 'StdCtrls', 'ExtCtrls', 'ComCtrls', 'Menus', 'ActnList',
|
|
139
|
+
'WriteLn', 'Write', 'ReadLn', 'Read', 'Inc', 'Dec', 'Ord', 'Chr',
|
|
140
|
+
'Length', 'SetLength', 'High', 'Low', 'Assigned', 'FreeAndNil',
|
|
141
|
+
'Format', 'IntToStr', 'StrToInt', 'FloatToStr', 'StrToFloat',
|
|
142
|
+
'Trim', 'UpperCase', 'LowerCase', 'Pos', 'Copy', 'Delete', 'Insert',
|
|
143
|
+
'Now', 'Date', 'Time', 'DateToStr', 'StrToDate',
|
|
144
|
+
'Raise', 'Exit', 'Break', 'Continue', 'Abort',
|
|
145
|
+
'True', 'False', 'nil', 'Self', 'Result',
|
|
146
|
+
'Create', 'Destroy', 'Free',
|
|
147
|
+
'TObject', 'TComponent', 'TPersistent', 'TInterfacedObject',
|
|
148
|
+
'TList', 'TStringList', 'TStrings', 'TStream', 'TMemoryStream', 'TFileStream',
|
|
149
|
+
'Exception', 'EAbort', 'EConvertError', 'EAccessViolation',
|
|
150
|
+
'IInterface', 'IUnknown',
|
|
151
|
+
]);
|
|
152
|
+
const C_BUILT_INS = new Set([
|
|
153
|
+
// Standard C library functions
|
|
154
|
+
'printf', 'fprintf', 'sprintf', 'snprintf', 'scanf', 'fscanf', 'sscanf',
|
|
155
|
+
'malloc', 'calloc', 'realloc', 'free',
|
|
156
|
+
'memcpy', 'memmove', 'memset', 'memcmp', 'memchr',
|
|
157
|
+
'strlen', 'strcpy', 'strncpy', 'strcat', 'strncat', 'strcmp', 'strncmp',
|
|
158
|
+
'strstr', 'strchr', 'strrchr', 'strtok', 'strdup',
|
|
159
|
+
'fopen', 'fclose', 'fread', 'fwrite', 'fgets', 'fputs', 'fputc', 'fgetc',
|
|
160
|
+
'feof', 'ferror', 'fflush', 'fseek', 'ftell', 'rewind',
|
|
161
|
+
'exit', 'abort', 'atexit', 'atoi', 'atol', 'atof', 'strtol', 'strtoul', 'strtod',
|
|
162
|
+
'qsort', 'bsearch',
|
|
163
|
+
'abs', 'labs', 'rand', 'srand',
|
|
164
|
+
'sin', 'cos', 'tan', 'sqrt', 'pow', 'log', 'log10', 'exp', 'ceil', 'floor', 'fabs',
|
|
165
|
+
'time', 'clock', 'difftime', 'mktime', 'localtime', 'gmtime', 'strftime', 'asctime',
|
|
166
|
+
'assert', 'errno',
|
|
167
|
+
'perror', 'remove', 'rename', 'tmpfile', 'tmpnam',
|
|
168
|
+
'getenv', 'system',
|
|
169
|
+
'signal', 'raise',
|
|
170
|
+
'setjmp', 'longjmp',
|
|
171
|
+
'va_start', 'va_end', 'va_arg', 'va_copy',
|
|
172
|
+
'NULL', 'EOF', 'BUFSIZ', 'FILENAME_MAX', 'RAND_MAX', 'EXIT_SUCCESS', 'EXIT_FAILURE',
|
|
173
|
+
'size_t', 'ptrdiff_t', 'wchar_t', 'intptr_t', 'uintptr_t',
|
|
174
|
+
'int8_t', 'int16_t', 'int32_t', 'int64_t',
|
|
175
|
+
'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t',
|
|
176
|
+
'FILE',
|
|
177
|
+
// POSIX additions commonly seen
|
|
178
|
+
'stat', 'lstat', 'fstat', 'open', 'close', 'read', 'write', 'pipe',
|
|
179
|
+
'fork', 'exec', 'waitpid', 'getpid', 'getppid', 'kill', 'sleep', 'usleep',
|
|
180
|
+
'pthread_create', 'pthread_join', 'pthread_mutex_lock', 'pthread_mutex_unlock',
|
|
181
|
+
'dlopen', 'dlsym', 'dlclose',
|
|
182
|
+
]);
|
|
183
|
+
const CPP_BUILT_INS = new Set([
|
|
184
|
+
// iostream objects (often used without std:: prefix via using)
|
|
185
|
+
'cout', 'cin', 'cerr', 'clog', 'endl', 'flush', 'ws',
|
|
186
|
+
'std', // the namespace itself when used as std::something
|
|
187
|
+
// Common C++ keywords that leak as references
|
|
188
|
+
'nullptr', 'true', 'false', 'this', 'sizeof', 'alignof', 'typeid',
|
|
189
|
+
'static_cast', 'dynamic_cast', 'reinterpret_cast', 'const_cast',
|
|
190
|
+
'make_unique', 'make_shared', 'make_pair',
|
|
191
|
+
'move', 'forward', 'swap',
|
|
192
|
+
]);
|
|
193
|
+
/**
|
|
194
|
+
* Reference Resolver
|
|
195
|
+
*
|
|
196
|
+
* Orchestrates reference resolution using multiple strategies.
|
|
197
|
+
*/
|
|
198
|
+
class ReferenceResolver {
|
|
199
|
+
projectRoot;
|
|
200
|
+
queries;
|
|
201
|
+
context;
|
|
202
|
+
frameworks = [];
|
|
203
|
+
// All per-resolver caches are LRU-bounded. Previously these were
|
|
204
|
+
// unbounded Maps that grew with every distinct lookup and OOM'd on
|
|
205
|
+
// codebases with 20k+ files (see issue: unbounded cache growth).
|
|
206
|
+
nodeCache; // per-file node cache
|
|
207
|
+
fileCache; // per-file content cache
|
|
208
|
+
importMappingCache;
|
|
209
|
+
reExportCache;
|
|
210
|
+
nameCache; // name → nodes cache
|
|
211
|
+
lowerNameCache; // lower(name) → nodes cache
|
|
212
|
+
qualifiedNameCache; // qualified_name → nodes cache
|
|
213
|
+
knownNames = null; // all known symbol names for fast pre-filtering
|
|
214
|
+
knownFiles = null;
|
|
215
|
+
cachesWarmed = false;
|
|
216
|
+
// tsconfig/jsconfig path-alias map. `undefined` = not yet computed,
|
|
217
|
+
// `null` = computed and absent. Treated as immutable for the
|
|
218
|
+
// resolver's lifetime; callers re-create the resolver if config changes.
|
|
219
|
+
projectAliases = undefined;
|
|
220
|
+
// go.mod module path. Same lazy/immutable convention as projectAliases.
|
|
221
|
+
goModule = undefined;
|
|
222
|
+
constructor(projectRoot, queries) {
|
|
223
|
+
this.projectRoot = projectRoot;
|
|
224
|
+
this.queries = queries;
|
|
225
|
+
const limit = resolveCacheLimit();
|
|
226
|
+
// The content cache is heavier (full file text), so we give it a
|
|
227
|
+
// smaller budget than the metadata caches.
|
|
228
|
+
const contentLimit = Math.max(64, Math.floor(limit / 5));
|
|
229
|
+
this.nodeCache = new lru_cache_1.LRUCache(limit);
|
|
230
|
+
this.fileCache = new lru_cache_1.LRUCache(contentLimit);
|
|
231
|
+
this.importMappingCache = new lru_cache_1.LRUCache(limit);
|
|
232
|
+
this.reExportCache = new lru_cache_1.LRUCache(limit);
|
|
233
|
+
this.nameCache = new lru_cache_1.LRUCache(limit);
|
|
234
|
+
this.lowerNameCache = new lru_cache_1.LRUCache(limit);
|
|
235
|
+
this.qualifiedNameCache = new lru_cache_1.LRUCache(limit);
|
|
236
|
+
this.context = this.createContext();
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Initialize the resolver (detect frameworks, etc.)
|
|
240
|
+
*/
|
|
241
|
+
initialize() {
|
|
242
|
+
this.frameworks = (0, frameworks_1.detectFrameworks)(this.context);
|
|
243
|
+
this.clearCaches();
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Run each framework resolver's cross-file finalization pass and persist
|
|
247
|
+
* the returned node updates. Idempotent — safe to call after every indexAll
|
|
248
|
+
* and every incremental sync. Returns the number of nodes updated.
|
|
249
|
+
*
|
|
250
|
+
* Caches are cleared before/after so the post-extract pass sees fresh DB
|
|
251
|
+
* state and downstream queries see the updated names.
|
|
252
|
+
*/
|
|
253
|
+
runPostExtract() {
|
|
254
|
+
let updated = 0;
|
|
255
|
+
this.clearCaches();
|
|
256
|
+
for (const fw of this.frameworks) {
|
|
257
|
+
if (!fw.postExtract)
|
|
258
|
+
continue;
|
|
259
|
+
try {
|
|
260
|
+
const nodes = fw.postExtract(this.context);
|
|
261
|
+
for (const node of nodes) {
|
|
262
|
+
this.queries.updateNode(node);
|
|
263
|
+
updated++;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
catch (err) {
|
|
267
|
+
(0, errors_1.logDebug)(`Framework '${fw.name}' postExtract failed`, {
|
|
268
|
+
error: err instanceof Error ? err.message : String(err),
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (updated > 0)
|
|
273
|
+
this.clearCaches();
|
|
274
|
+
return updated;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Pre-build lightweight caches for resolution.
|
|
278
|
+
* Node lookups are now handled by indexed SQLite queries instead of
|
|
279
|
+
* loading all nodes into memory (which caused OOM on large codebases).
|
|
280
|
+
* We cache the set of known symbol names for fast pre-filtering.
|
|
281
|
+
*/
|
|
282
|
+
warmCaches() {
|
|
283
|
+
if (this.cachesWarmed)
|
|
284
|
+
return;
|
|
285
|
+
// Only cache the set of known file paths (lightweight string set)
|
|
286
|
+
this.knownFiles = new Set(this.queries.getAllFilePaths());
|
|
287
|
+
// Cache all distinct symbol names for fast pre-filtering (just strings, not full nodes)
|
|
288
|
+
this.knownNames = new Set(this.queries.getAllNodeNames());
|
|
289
|
+
this.cachesWarmed = true;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Clear internal caches
|
|
293
|
+
*/
|
|
294
|
+
clearCaches() {
|
|
295
|
+
this.nodeCache.clear();
|
|
296
|
+
this.fileCache.clear();
|
|
297
|
+
this.importMappingCache.clear();
|
|
298
|
+
this.reExportCache.clear();
|
|
299
|
+
this.nameCache.clear();
|
|
300
|
+
this.lowerNameCache.clear();
|
|
301
|
+
this.qualifiedNameCache.clear();
|
|
302
|
+
this.knownNames = null;
|
|
303
|
+
this.knownFiles = null;
|
|
304
|
+
this.cachesWarmed = false;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Create the resolution context
|
|
308
|
+
*/
|
|
309
|
+
createContext() {
|
|
310
|
+
return {
|
|
311
|
+
getNodesInFile: (filePath) => {
|
|
312
|
+
if (!this.nodeCache.has(filePath)) {
|
|
313
|
+
this.nodeCache.set(filePath, this.queries.getNodesByFile(filePath));
|
|
314
|
+
}
|
|
315
|
+
return this.nodeCache.get(filePath);
|
|
316
|
+
},
|
|
317
|
+
getNodesByName: (name) => {
|
|
318
|
+
const cached = this.nameCache.get(name);
|
|
319
|
+
if (cached !== undefined)
|
|
320
|
+
return cached;
|
|
321
|
+
const result = this.queries.getNodesByName(name);
|
|
322
|
+
this.nameCache.set(name, result);
|
|
323
|
+
return result;
|
|
324
|
+
},
|
|
325
|
+
getNodesByQualifiedName: (qualifiedName) => {
|
|
326
|
+
const cached = this.qualifiedNameCache.get(qualifiedName);
|
|
327
|
+
if (cached !== undefined)
|
|
328
|
+
return cached;
|
|
329
|
+
const result = this.queries.getNodesByQualifiedNameExact(qualifiedName);
|
|
330
|
+
this.qualifiedNameCache.set(qualifiedName, result);
|
|
331
|
+
return result;
|
|
332
|
+
},
|
|
333
|
+
getNodesByKind: (kind) => {
|
|
334
|
+
return this.queries.getNodesByKind(kind);
|
|
335
|
+
},
|
|
336
|
+
fileExists: (filePath) => {
|
|
337
|
+
// Check pre-built known files set first (O(1))
|
|
338
|
+
if (this.knownFiles) {
|
|
339
|
+
const normalized = filePath.replace(/\\/g, '/');
|
|
340
|
+
if (this.knownFiles.has(filePath) || this.knownFiles.has(normalized)) {
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
// Fall back to filesystem for files not yet indexed
|
|
345
|
+
const fullPath = path.join(this.projectRoot, filePath);
|
|
346
|
+
try {
|
|
347
|
+
return fs.existsSync(fullPath);
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
(0, errors_1.logDebug)('Error checking file existence', { filePath, error: String(error) });
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
readFile: (filePath) => {
|
|
355
|
+
if (this.fileCache.has(filePath)) {
|
|
356
|
+
return this.fileCache.get(filePath);
|
|
357
|
+
}
|
|
358
|
+
const fullPath = path.join(this.projectRoot, filePath);
|
|
359
|
+
try {
|
|
360
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
361
|
+
this.fileCache.set(filePath, content);
|
|
362
|
+
return content;
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
(0, errors_1.logDebug)('Failed to read file for resolution', { filePath, error: String(error) });
|
|
366
|
+
this.fileCache.set(filePath, null);
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
getProjectRoot: () => this.projectRoot,
|
|
371
|
+
getAllFiles: () => {
|
|
372
|
+
return this.queries.getAllFilePaths();
|
|
373
|
+
},
|
|
374
|
+
listDirectories: (relativePath) => {
|
|
375
|
+
const target = relativePath === '.' || relativePath === ''
|
|
376
|
+
? this.projectRoot
|
|
377
|
+
: path.join(this.projectRoot, relativePath);
|
|
378
|
+
try {
|
|
379
|
+
return fs
|
|
380
|
+
.readdirSync(target, { withFileTypes: true })
|
|
381
|
+
.filter((entry) => entry.isDirectory())
|
|
382
|
+
.map((entry) => entry.name);
|
|
383
|
+
}
|
|
384
|
+
catch (error) {
|
|
385
|
+
(0, errors_1.logDebug)('Failed to list directory for resolution', {
|
|
386
|
+
relativePath,
|
|
387
|
+
error: String(error),
|
|
388
|
+
});
|
|
389
|
+
return [];
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
getNodesByLowerName: (lowerName) => {
|
|
393
|
+
const cached = this.lowerNameCache.get(lowerName);
|
|
394
|
+
if (cached !== undefined)
|
|
395
|
+
return cached;
|
|
396
|
+
const result = this.queries.getNodesByLowerName(lowerName);
|
|
397
|
+
this.lowerNameCache.set(lowerName, result);
|
|
398
|
+
return result;
|
|
399
|
+
},
|
|
400
|
+
getImportMappings: (filePath, language) => {
|
|
401
|
+
const cacheKey = filePath;
|
|
402
|
+
const cached = this.importMappingCache.get(cacheKey);
|
|
403
|
+
if (cached)
|
|
404
|
+
return cached;
|
|
405
|
+
const content = this.context.readFile(filePath);
|
|
406
|
+
if (!content) {
|
|
407
|
+
this.importMappingCache.set(cacheKey, []);
|
|
408
|
+
return [];
|
|
409
|
+
}
|
|
410
|
+
const mappings = (0, import_resolver_1.extractImportMappings)(filePath, content, language);
|
|
411
|
+
this.importMappingCache.set(cacheKey, mappings);
|
|
412
|
+
return mappings;
|
|
413
|
+
},
|
|
414
|
+
getProjectAliases: () => {
|
|
415
|
+
if (this.projectAliases === undefined) {
|
|
416
|
+
this.projectAliases = (0, path_aliases_1.loadProjectAliases)(this.projectRoot);
|
|
417
|
+
}
|
|
418
|
+
return this.projectAliases;
|
|
419
|
+
},
|
|
420
|
+
getGoModule: () => {
|
|
421
|
+
if (this.goModule === undefined) {
|
|
422
|
+
this.goModule = (0, go_module_1.loadGoModule)(this.projectRoot);
|
|
423
|
+
}
|
|
424
|
+
return this.goModule;
|
|
425
|
+
},
|
|
426
|
+
getReExports: (filePath, language) => {
|
|
427
|
+
const cached = this.reExportCache.get(filePath);
|
|
428
|
+
if (cached)
|
|
429
|
+
return cached;
|
|
430
|
+
const content = this.context.readFile(filePath);
|
|
431
|
+
if (!content) {
|
|
432
|
+
this.reExportCache.set(filePath, []);
|
|
433
|
+
return [];
|
|
434
|
+
}
|
|
435
|
+
const reExports = (0, import_resolver_1.extractReExports)(content, language);
|
|
436
|
+
this.reExportCache.set(filePath, reExports);
|
|
437
|
+
return reExports;
|
|
438
|
+
},
|
|
439
|
+
getCppIncludeDirs: () => {
|
|
440
|
+
return (0, import_resolver_1.loadCppIncludeDirs)(this.projectRoot);
|
|
441
|
+
},
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Resolve all unresolved references
|
|
446
|
+
*/
|
|
447
|
+
resolveAll(unresolvedRefs, onProgress) {
|
|
448
|
+
// Pre-load all nodes into memory for fast lookups
|
|
449
|
+
this.warmCaches();
|
|
450
|
+
const resolved = [];
|
|
451
|
+
const unresolved = [];
|
|
452
|
+
const byMethod = {};
|
|
453
|
+
// Convert to our internal format, using denormalized fields when available
|
|
454
|
+
const refs = unresolvedRefs.map((ref) => ({
|
|
455
|
+
fromNodeId: ref.fromNodeId,
|
|
456
|
+
referenceName: ref.referenceName,
|
|
457
|
+
referenceKind: ref.referenceKind,
|
|
458
|
+
line: ref.line,
|
|
459
|
+
column: ref.column,
|
|
460
|
+
filePath: ref.filePath || this.getFilePathFromNodeId(ref.fromNodeId),
|
|
461
|
+
language: ref.language || this.getLanguageFromNodeId(ref.fromNodeId),
|
|
462
|
+
}));
|
|
463
|
+
const total = refs.length;
|
|
464
|
+
let lastReportedPercent = -1;
|
|
465
|
+
for (let i = 0; i < refs.length; i++) {
|
|
466
|
+
const ref = refs[i]; // Array index is guaranteed to be in bounds
|
|
467
|
+
const result = this.resolveOne(ref);
|
|
468
|
+
if (result) {
|
|
469
|
+
resolved.push(result);
|
|
470
|
+
byMethod[result.resolvedBy] = (byMethod[result.resolvedBy] || 0) + 1;
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
unresolved.push(ref);
|
|
474
|
+
}
|
|
475
|
+
// Report progress every 1% to avoid too many updates
|
|
476
|
+
if (onProgress) {
|
|
477
|
+
const currentPercent = Math.floor((i / total) * 100);
|
|
478
|
+
if (currentPercent > lastReportedPercent) {
|
|
479
|
+
lastReportedPercent = currentPercent;
|
|
480
|
+
onProgress(i + 1, total);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
// Final progress report
|
|
485
|
+
if (onProgress && total > 0) {
|
|
486
|
+
onProgress(total, total);
|
|
487
|
+
}
|
|
488
|
+
return {
|
|
489
|
+
resolved,
|
|
490
|
+
unresolved,
|
|
491
|
+
stats: {
|
|
492
|
+
total: refs.length,
|
|
493
|
+
resolved: resolved.length,
|
|
494
|
+
unresolved: unresolved.length,
|
|
495
|
+
byMethod,
|
|
496
|
+
},
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Check if a reference name has any possible match in the codebase.
|
|
501
|
+
* Uses the pre-built knownNames set to skip expensive resolution
|
|
502
|
+
* for names that definitely don't exist as symbols.
|
|
503
|
+
*/
|
|
504
|
+
hasAnyPossibleMatch(name) {
|
|
505
|
+
if (!this.knownNames)
|
|
506
|
+
return true; // no pre-filter available
|
|
507
|
+
// Direct name match
|
|
508
|
+
if (this.knownNames.has(name))
|
|
509
|
+
return true;
|
|
510
|
+
// For qualified names like "obj.method" or "Class::method", check the parts
|
|
511
|
+
const dotIdx = name.indexOf('.');
|
|
512
|
+
if (dotIdx > 0) {
|
|
513
|
+
const receiver = name.substring(0, dotIdx);
|
|
514
|
+
const member = name.substring(dotIdx + 1);
|
|
515
|
+
if (this.knownNames.has(receiver) || this.knownNames.has(member))
|
|
516
|
+
return true;
|
|
517
|
+
// Also check capitalized receiver (instance-method resolution)
|
|
518
|
+
const capitalized = receiver.charAt(0).toUpperCase() + receiver.slice(1);
|
|
519
|
+
if (this.knownNames.has(capitalized))
|
|
520
|
+
return true;
|
|
521
|
+
// JVM FQN: `com.example.foo.Bar` — the only useful segment is the
|
|
522
|
+
// last one (`Bar`); the earlier check finds `example.foo.Bar` which
|
|
523
|
+
// never matches a node name.
|
|
524
|
+
const lastDot = name.lastIndexOf('.');
|
|
525
|
+
if (lastDot > dotIdx) {
|
|
526
|
+
const tail = name.substring(lastDot + 1);
|
|
527
|
+
if (tail && this.knownNames.has(tail))
|
|
528
|
+
return true;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
const colonIdx = name.indexOf('::');
|
|
532
|
+
if (colonIdx > 0) {
|
|
533
|
+
const receiver = name.substring(0, colonIdx);
|
|
534
|
+
const member = name.substring(colonIdx + 2);
|
|
535
|
+
if (this.knownNames.has(receiver) || this.knownNames.has(member))
|
|
536
|
+
return true;
|
|
537
|
+
}
|
|
538
|
+
// For path-like references (e.g., "snippets/drawer-menu.liquid"), check the filename
|
|
539
|
+
const slashIdx = name.lastIndexOf('/');
|
|
540
|
+
if (slashIdx > 0) {
|
|
541
|
+
const fileName = name.substring(slashIdx + 1);
|
|
542
|
+
if (this.knownNames.has(fileName))
|
|
543
|
+
return true;
|
|
544
|
+
}
|
|
545
|
+
return false;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Does `ref.referenceName` match an import declared in its containing
|
|
549
|
+
* file? Used as a pre-filter escape so re-export chain resolution
|
|
550
|
+
* still gets a chance when the name has no project-wide declaration.
|
|
551
|
+
*/
|
|
552
|
+
matchesAnyImport(ref) {
|
|
553
|
+
const imports = this.context.getImportMappings(ref.filePath, ref.language);
|
|
554
|
+
if (imports.length === 0)
|
|
555
|
+
return false;
|
|
556
|
+
for (const imp of imports) {
|
|
557
|
+
if (imp.localName === ref.referenceName ||
|
|
558
|
+
ref.referenceName.startsWith(imp.localName + '.')) {
|
|
559
|
+
return true;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
return false;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Resolve a single reference
|
|
566
|
+
*/
|
|
567
|
+
resolveOne(ref) {
|
|
568
|
+
// Skip built-in/external references
|
|
569
|
+
if (this.isBuiltInOrExternal(ref)) {
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
// Fast pre-filter: skip if no symbol with this name exists anywhere
|
|
573
|
+
// AND the name doesn't match a local import. The import escape is
|
|
574
|
+
// necessary because re-export rename chains (`import { login }
|
|
575
|
+
// from './barrel'` where the barrel has `export { signIn as login }
|
|
576
|
+
// from './auth'`) intentionally call a name that has no
|
|
577
|
+
// declaration anywhere — only the renamed upstream symbol does.
|
|
578
|
+
if (!this.hasAnyPossibleMatch(ref.referenceName) &&
|
|
579
|
+
!this.matchesAnyImport(ref) &&
|
|
580
|
+
!this.frameworks.some((f) => f.claimsReference?.(ref.referenceName))) {
|
|
581
|
+
return null;
|
|
582
|
+
}
|
|
583
|
+
// JVM FQN imports skip framework/name-matcher: `import com.example.Bar`
|
|
584
|
+
// resolves directly through the qualifiedName index, which is unambiguous
|
|
585
|
+
// even when several `Bar` classes exist in different packages.
|
|
586
|
+
const jvmImport = (0, import_resolver_1.resolveJvmImport)(ref, this.context);
|
|
587
|
+
if (jvmImport)
|
|
588
|
+
return jvmImport;
|
|
589
|
+
const candidates = [];
|
|
590
|
+
// Strategy 1: Try framework-specific resolution
|
|
591
|
+
for (const framework of this.frameworks) {
|
|
592
|
+
const result = framework.resolve(ref, this.context);
|
|
593
|
+
if (result) {
|
|
594
|
+
if (result.confidence >= 0.9)
|
|
595
|
+
return result; // High confidence, return immediately
|
|
596
|
+
candidates.push(result);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
// Strategy 2: Try import-based resolution
|
|
600
|
+
const importResult = (0, import_resolver_1.resolveViaImport)(ref, this.context);
|
|
601
|
+
if (importResult) {
|
|
602
|
+
if (importResult.confidence >= 0.9)
|
|
603
|
+
return importResult;
|
|
604
|
+
candidates.push(importResult);
|
|
605
|
+
}
|
|
606
|
+
// Strategy 3: Try name matching
|
|
607
|
+
const nameResult = (0, name_matcher_1.matchReference)(ref, this.context);
|
|
608
|
+
if (nameResult) {
|
|
609
|
+
candidates.push(nameResult);
|
|
610
|
+
}
|
|
611
|
+
if (candidates.length === 0)
|
|
612
|
+
return null;
|
|
613
|
+
// Return highest confidence candidate
|
|
614
|
+
return candidates.reduce((best, curr) => curr.confidence > best.confidence ? curr : best);
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Create edges from resolved references
|
|
618
|
+
*/
|
|
619
|
+
createEdges(resolved) {
|
|
620
|
+
return resolved.map((ref) => {
|
|
621
|
+
let kind = ref.original.referenceKind;
|
|
622
|
+
// Promote "extends" to "implements" when a class/struct targets an interface
|
|
623
|
+
if (kind === 'extends') {
|
|
624
|
+
const targetNode = this.queries.getNodeById(ref.targetNodeId);
|
|
625
|
+
if (targetNode && (targetNode.kind === 'interface' || targetNode.kind === 'protocol')) {
|
|
626
|
+
const sourceNode = this.queries.getNodeById(ref.original.fromNodeId);
|
|
627
|
+
if (sourceNode && sourceNode.kind !== 'interface' && sourceNode.kind !== 'protocol') {
|
|
628
|
+
kind = 'implements';
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
// Promote "calls" to "instantiates" when the resolved target is a
|
|
633
|
+
// class/struct. Languages without a `new` keyword (Python, Ruby)
|
|
634
|
+
// express instantiation as `Foo()` — extraction can't tell that
|
|
635
|
+
// apart from a function call without symbol info, but resolution
|
|
636
|
+
// can: if `Foo` resolves to a class, the call IS an instantiation.
|
|
637
|
+
if (kind === 'calls') {
|
|
638
|
+
const targetNode = this.queries.getNodeById(ref.targetNodeId);
|
|
639
|
+
if (targetNode && (targetNode.kind === 'class' || targetNode.kind === 'struct')) {
|
|
640
|
+
kind = 'instantiates';
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return {
|
|
644
|
+
source: ref.original.fromNodeId,
|
|
645
|
+
target: ref.targetNodeId,
|
|
646
|
+
kind,
|
|
647
|
+
line: ref.original.line,
|
|
648
|
+
column: ref.original.column,
|
|
649
|
+
metadata: {
|
|
650
|
+
confidence: ref.confidence,
|
|
651
|
+
resolvedBy: ref.resolvedBy,
|
|
652
|
+
},
|
|
653
|
+
};
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Resolve and persist edges to database
|
|
658
|
+
*/
|
|
659
|
+
resolveAndPersist(unresolvedRefs, onProgress) {
|
|
660
|
+
const result = this.resolveAll(unresolvedRefs, onProgress);
|
|
661
|
+
// Create edges from resolved references
|
|
662
|
+
const edges = this.createEdges(result.resolved);
|
|
663
|
+
// Insert edges into database
|
|
664
|
+
if (edges.length > 0) {
|
|
665
|
+
this.queries.insertEdges(edges);
|
|
666
|
+
}
|
|
667
|
+
// Clean up resolved refs from unresolved_refs table so metrics are accurate
|
|
668
|
+
if (result.resolved.length > 0) {
|
|
669
|
+
this.queries.deleteSpecificResolvedReferences(result.resolved.map((r) => ({
|
|
670
|
+
fromNodeId: r.original.fromNodeId,
|
|
671
|
+
referenceName: r.original.referenceName,
|
|
672
|
+
referenceKind: r.original.referenceKind,
|
|
673
|
+
})));
|
|
674
|
+
}
|
|
675
|
+
return result;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Resolve and persist in batches to keep memory bounded.
|
|
679
|
+
* Processes unresolved references in chunks, persisting edges and cleaning
|
|
680
|
+
* up resolved refs after each batch to avoid accumulating large arrays.
|
|
681
|
+
*/
|
|
682
|
+
async resolveAndPersistBatched(onProgress, batchSize = 5000) {
|
|
683
|
+
this.warmCaches();
|
|
684
|
+
const total = this.queries.getUnresolvedReferencesCount();
|
|
685
|
+
let processed = 0;
|
|
686
|
+
const aggregateStats = {
|
|
687
|
+
total: 0,
|
|
688
|
+
resolved: 0,
|
|
689
|
+
unresolved: 0,
|
|
690
|
+
byMethod: {},
|
|
691
|
+
};
|
|
692
|
+
// Process in batches. We always read from offset 0 because resolved refs
|
|
693
|
+
// are deleted after each batch, shifting the remaining rows forward.
|
|
694
|
+
while (true) {
|
|
695
|
+
const batch = this.queries.getUnresolvedReferencesBatch(0, batchSize);
|
|
696
|
+
if (batch.length === 0)
|
|
697
|
+
break;
|
|
698
|
+
const result = this.resolveAll(batch);
|
|
699
|
+
// Persist edges immediately
|
|
700
|
+
const edges = this.createEdges(result.resolved);
|
|
701
|
+
if (edges.length > 0) {
|
|
702
|
+
this.queries.insertEdges(edges);
|
|
703
|
+
}
|
|
704
|
+
// Clean up resolved refs so they don't appear in the next batch
|
|
705
|
+
if (result.resolved.length > 0) {
|
|
706
|
+
this.queries.deleteSpecificResolvedReferences(result.resolved.map((r) => ({
|
|
707
|
+
fromNodeId: r.original.fromNodeId,
|
|
708
|
+
referenceName: r.original.referenceName,
|
|
709
|
+
referenceKind: r.original.referenceKind,
|
|
710
|
+
})));
|
|
711
|
+
}
|
|
712
|
+
// Delete unresolvable refs from this batch to avoid re-processing them
|
|
713
|
+
if (result.unresolved.length > 0) {
|
|
714
|
+
this.queries.deleteSpecificResolvedReferences(result.unresolved.map((r) => ({
|
|
715
|
+
fromNodeId: r.fromNodeId,
|
|
716
|
+
referenceName: r.referenceName,
|
|
717
|
+
referenceKind: r.referenceKind,
|
|
718
|
+
})));
|
|
719
|
+
}
|
|
720
|
+
// Aggregate stats
|
|
721
|
+
aggregateStats.total += result.stats.total;
|
|
722
|
+
aggregateStats.resolved += result.stats.resolved;
|
|
723
|
+
aggregateStats.unresolved += result.stats.unresolved;
|
|
724
|
+
for (const [method, count] of Object.entries(result.stats.byMethod)) {
|
|
725
|
+
aggregateStats.byMethod[method] = (aggregateStats.byMethod[method] || 0) + count;
|
|
726
|
+
}
|
|
727
|
+
processed += batch.length;
|
|
728
|
+
onProgress?.(processed, total);
|
|
729
|
+
// Yield so progress UI can render between batches
|
|
730
|
+
await new Promise(resolve => setImmediate(resolve));
|
|
731
|
+
// If nothing was resolved or removed in this batch, we'd loop forever
|
|
732
|
+
// on the same rows. Break to avoid infinite loop.
|
|
733
|
+
if (result.resolved.length === 0 && result.unresolved.length === batch.length) {
|
|
734
|
+
break;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
// Dynamic-edge synthesis: now that all base `calls` edges are persisted,
|
|
738
|
+
// synthesize observer/callback dispatch edges (dispatcher → registered
|
|
739
|
+
// callbacks) that static parsing leaves out. Best-effort — never fail the
|
|
740
|
+
// index on it. See docs/design/callback-edge-synthesis.md.
|
|
741
|
+
try {
|
|
742
|
+
aggregateStats.byMethod['callback-synthesis'] = (0, callback_synthesizer_1.synthesizeCallbackEdges)(this.queries, this.context);
|
|
743
|
+
}
|
|
744
|
+
catch {
|
|
745
|
+
// synthesis is additive and optional; ignore failures
|
|
746
|
+
}
|
|
747
|
+
return {
|
|
748
|
+
resolved: [],
|
|
749
|
+
unresolved: [],
|
|
750
|
+
stats: aggregateStats,
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Get detected frameworks
|
|
755
|
+
*/
|
|
756
|
+
getDetectedFrameworks() {
|
|
757
|
+
return this.frameworks.map((f) => f.name);
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Check if reference is to a built-in or external symbol
|
|
761
|
+
*/
|
|
762
|
+
isBuiltInOrExternal(ref) {
|
|
763
|
+
const name = ref.referenceName;
|
|
764
|
+
const isJsTs = ref.language === 'typescript' || ref.language === 'javascript'
|
|
765
|
+
|| ref.language === 'tsx' || ref.language === 'jsx';
|
|
766
|
+
// JavaScript/TypeScript built-ins
|
|
767
|
+
if (isJsTs && JS_BUILT_INS.has(name)) {
|
|
768
|
+
return true;
|
|
769
|
+
}
|
|
770
|
+
// Common JS/TS library calls (console.log, Math.floor, JSON.parse)
|
|
771
|
+
if (isJsTs && (name.startsWith('console.') || name.startsWith('Math.') || name.startsWith('JSON.'))) {
|
|
772
|
+
return true;
|
|
773
|
+
}
|
|
774
|
+
// React hooks from React itself
|
|
775
|
+
if (isJsTs && REACT_HOOKS.has(name)) {
|
|
776
|
+
return true;
|
|
777
|
+
}
|
|
778
|
+
// Python built-ins (bare calls only — dotted calls like console.print are method calls)
|
|
779
|
+
if (ref.language === 'python' && PYTHON_BUILT_INS.has(name)) {
|
|
780
|
+
return true;
|
|
781
|
+
}
|
|
782
|
+
// Python built-in method calls (e.g., list.extend, dict.update)
|
|
783
|
+
if (ref.language === 'python') {
|
|
784
|
+
const dotIdx = name.indexOf('.');
|
|
785
|
+
if (dotIdx > 0) {
|
|
786
|
+
const receiver = name.substring(0, dotIdx);
|
|
787
|
+
const method = name.substring(dotIdx + 1);
|
|
788
|
+
// Filter calls on built-in types (list.append, dict.update, etc.)
|
|
789
|
+
if (PYTHON_BUILT_IN_TYPES.has(receiver)) {
|
|
790
|
+
return true;
|
|
791
|
+
}
|
|
792
|
+
// Filter built-in methods on non-class receivers
|
|
793
|
+
// (e.g., items.append where items is a local list variable)
|
|
794
|
+
// But allow if the capitalized receiver matches a known codebase class
|
|
795
|
+
if (PYTHON_BUILT_IN_METHODS.has(method)) {
|
|
796
|
+
const capitalized = receiver.charAt(0).toUpperCase() + receiver.slice(1);
|
|
797
|
+
if (!this.knownNames?.has(capitalized)) {
|
|
798
|
+
return true;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
// A bare name colliding with a builtin method (index, get, update, count…)
|
|
803
|
+
// is only a builtin when NOTHING in the codebase declares it. A declared
|
|
804
|
+
// symbol with that exact name — e.g. a Flask/FastAPI view `def index()` or
|
|
805
|
+
// `def get()` — is a real reference target. Mirrors the knownNames guard on
|
|
806
|
+
// the dotted branch above; without it, every handler named after a builtin
|
|
807
|
+
// method silently loses its route→handler edge.
|
|
808
|
+
if (PYTHON_BUILT_IN_METHODS.has(name) && !this.knownNames?.has(name)) {
|
|
809
|
+
return true;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
// Go standard library packages — refs like "fmt.Println", "http.ListenAndServe", etc.
|
|
813
|
+
if (ref.language === 'go') {
|
|
814
|
+
const dotIdx = name.indexOf('.');
|
|
815
|
+
if (dotIdx > 0) {
|
|
816
|
+
const pkg = name.substring(0, dotIdx);
|
|
817
|
+
if (GO_STDLIB_PACKAGES.has(pkg)) {
|
|
818
|
+
return true;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
if (GO_BUILT_INS.has(name)) {
|
|
822
|
+
return true;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
// Pascal/Delphi built-ins and standard library units
|
|
826
|
+
if (ref.language === 'pascal') {
|
|
827
|
+
if (PASCAL_UNIT_PREFIXES.some((p) => name.startsWith(p))) {
|
|
828
|
+
return true;
|
|
829
|
+
}
|
|
830
|
+
if (PASCAL_BUILT_INS.has(name)) {
|
|
831
|
+
return true;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
// C/C++ standard library symbols (printf, malloc, std::vector, etc.).
|
|
835
|
+
// Names that collide with user-defined symbols are NOT filtered —
|
|
836
|
+
// C and C++ projects routinely shadow stdlib names (custom allocators
|
|
837
|
+
// define `malloc`/`free`, stream wrappers define `read`/`write`/`open`,
|
|
838
|
+
// containers define `move`/`swap`, logging libs wrap `printf`). Killing
|
|
839
|
+
// those resolutions makes the graph wrong, not cleaner. We only filter
|
|
840
|
+
// when there's no user node with this name — then name-matching would
|
|
841
|
+
// produce zero edges anyway and the filter just short-circuits work.
|
|
842
|
+
if (ref.language === 'c' || ref.language === 'cpp') {
|
|
843
|
+
// C++ std:: namespace prefix — safe to filter unconditionally,
|
|
844
|
+
// since `std::foo` is never a user-defined qualified name in
|
|
845
|
+
// tree-sitter output.
|
|
846
|
+
if (name.startsWith('std::'))
|
|
847
|
+
return true;
|
|
848
|
+
if (C_BUILT_INS.has(name) || CPP_BUILT_INS.has(name)) {
|
|
849
|
+
return !this.hasAnyPossibleMatch(name);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
return false;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Get file path from node ID
|
|
856
|
+
*/
|
|
857
|
+
getFilePathFromNodeId(nodeId) {
|
|
858
|
+
const node = this.queries.getNodeById(nodeId);
|
|
859
|
+
return node?.filePath || '';
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Get language from node ID
|
|
863
|
+
*/
|
|
864
|
+
getLanguageFromNodeId(nodeId) {
|
|
865
|
+
const node = this.queries.getNodeById(nodeId);
|
|
866
|
+
return node?.language || 'unknown';
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
exports.ReferenceResolver = ReferenceResolver;
|
|
870
|
+
/**
|
|
871
|
+
* Create a reference resolver instance
|
|
872
|
+
*/
|
|
873
|
+
function createResolver(projectRoot, queries) {
|
|
874
|
+
const resolver = new ReferenceResolver(projectRoot, queries);
|
|
875
|
+
resolver.initialize();
|
|
876
|
+
return resolver;
|
|
877
|
+
}
|
|
878
|
+
//# sourceMappingURL=index.js.map
|