@lzehrung/codegraph 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/codegraph-skill/codegraph/SKILL.md +25 -7
- package/dist/agent/artifact.d.ts.map +1 -1
- package/dist/agent/artifact.js +105 -14
- package/dist/agent/artifact.js.map +1 -1
- package/dist/agent/explain.d.ts +3 -0
- package/dist/agent/explain.d.ts.map +1 -1
- package/dist/agent/explain.js +8 -0
- package/dist/agent/explain.js.map +1 -1
- package/dist/agent/explore.d.ts.map +1 -1
- package/dist/agent/explore.js +8 -1
- package/dist/agent/explore.js.map +1 -1
- package/dist/agent/handles.d.ts.map +1 -1
- package/dist/agent/handles.js +2 -8
- package/dist/agent/handles.js.map +1 -1
- package/dist/agent/orient.js +2 -16
- package/dist/agent/orient.js.map +1 -1
- package/dist/agent/packet.d.ts.map +1 -1
- package/dist/agent/packet.js +5 -12
- package/dist/agent/packet.js.map +1 -1
- package/dist/agent/query-index/content.d.ts +1 -1
- package/dist/agent/query-index/content.js +4 -4
- package/dist/agent/query-index/content.js.map +1 -1
- package/dist/agent/query-index/store.d.ts +5 -4
- package/dist/agent/query-index/store.d.ts.map +1 -1
- package/dist/agent/query-index/store.js +56 -18
- package/dist/agent/query-index/store.js.map +1 -1
- package/dist/agent/query-index/update.d.ts.map +1 -1
- package/dist/agent/query-index/update.js +24 -9
- package/dist/agent/query-index/update.js.map +1 -1
- package/dist/agent/renamePreview.d.ts.map +1 -1
- package/dist/agent/renamePreview.js +51 -2
- package/dist/agent/renamePreview.js.map +1 -1
- package/dist/agent/search.d.ts +3 -1
- package/dist/agent/search.d.ts.map +1 -1
- package/dist/agent/search.js +64 -18
- package/dist/agent/search.js.map +1 -1
- package/dist/agent/session.d.ts.map +1 -1
- package/dist/agent/session.js +4 -4
- package/dist/agent/session.js.map +1 -1
- package/dist/agent-tools.js +6 -6
- package/dist/agent-tools.js.map +1 -1
- package/dist/bin/cli.js +9242 -6344
- package/dist/bin/queryIndexWorker.js +437 -86
- package/dist/bin/rawQueryWorker.js +26 -2
- package/dist/chunking/chunkSplit.js +0 -15
- package/dist/chunking/chunkSplit.js.map +1 -1
- package/dist/cli/callHierarchy.d.ts.map +1 -1
- package/dist/cli/callHierarchy.js +9 -2
- package/dist/cli/callHierarchy.js.map +1 -1
- package/dist/cli/commandCatalog.d.ts.map +1 -1
- package/dist/cli/commandCatalog.js +1 -0
- package/dist/cli/commandCatalog.js.map +1 -1
- package/dist/cli/commandTable.d.ts.map +1 -1
- package/dist/cli/commandTable.js +18 -1
- package/dist/cli/commandTable.js.map +1 -1
- package/dist/cli/compileCache.d.ts +5 -0
- package/dist/cli/compileCache.d.ts.map +1 -1
- package/dist/cli/compileCache.js +18 -0
- package/dist/cli/compileCache.js.map +1 -1
- package/dist/cli/context.d.ts.map +1 -1
- package/dist/cli/context.js +0 -1
- package/dist/cli/context.js.map +1 -1
- package/dist/cli/graph.d.ts.map +1 -1
- package/dist/cli/graph.js +52 -16
- package/dist/cli/graph.js.map +1 -1
- package/dist/cli/grep.d.ts +1 -1
- package/dist/cli/grep.d.ts.map +1 -1
- package/dist/cli/grep.js +14 -4
- package/dist/cli/grep.js.map +1 -1
- package/dist/cli/help.d.ts +2 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +23 -2
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/indexPolicy.d.ts.map +1 -1
- package/dist/cli/indexPolicy.js +1 -0
- package/dist/cli/indexPolicy.js.map +1 -1
- package/dist/cli/inspect.d.ts.map +1 -1
- package/dist/cli/inspect.js +5 -2
- package/dist/cli/inspect.js.map +1 -1
- package/dist/cli/install.js +1 -1
- package/dist/cli/install.js.map +1 -1
- package/dist/cli/options.d.ts +1 -1
- package/dist/cli/options.d.ts.map +1 -1
- package/dist/cli/options.js +54 -5
- package/dist/cli/options.js.map +1 -1
- package/dist/cli/renamePreview.d.ts.map +1 -1
- package/dist/cli/renamePreview.js +7 -1
- package/dist/cli/renamePreview.js.map +1 -1
- package/dist/cli/rootPolicy.d.ts.map +1 -1
- package/dist/cli/rootPolicy.js +36 -3
- package/dist/cli/rootPolicy.js.map +1 -1
- package/dist/cli/server.d.ts +59 -0
- package/dist/cli/server.d.ts.map +1 -0
- package/dist/cli/server.js +906 -0
- package/dist/cli/server.js.map +1 -0
- package/dist/cli/skill.js +1 -1
- package/dist/cli/skill.js.map +1 -1
- package/dist/cli/sql.js +1 -1
- package/dist/cli/symbols.d.ts.map +1 -1
- package/dist/cli/symbols.js +4 -2
- package/dist/cli/symbols.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +37 -16
- package/dist/cli.js.map +1 -1
- package/dist/documentLinks/check.d.ts.map +1 -1
- package/dist/documentLinks/check.js +20 -9
- package/dist/documentLinks/check.js.map +1 -1
- package/dist/documentLinks.d.ts.map +1 -1
- package/dist/documentLinks.js +0 -1
- package/dist/documentLinks.js.map +1 -1
- package/dist/drift/snapshot.js +1 -1
- package/dist/drift/snapshot.js.map +1 -1
- package/dist/duplicates/scoring.d.ts.map +1 -1
- package/dist/duplicates/scoring.js.map +1 -1
- package/dist/duplicates/types.d.ts +2 -0
- package/dist/duplicates/types.d.ts.map +1 -1
- package/dist/duplicates/unitCache.d.ts.map +1 -1
- package/dist/duplicates/unitCache.js +1 -1
- package/dist/duplicates/unitCache.js.map +1 -1
- package/dist/duplicates/units.d.ts.map +1 -1
- package/dist/duplicates/units.js +8 -5
- package/dist/duplicates/units.js.map +1 -1
- package/dist/duplicates.d.ts.map +1 -1
- package/dist/duplicates.js +59 -6
- package/dist/duplicates.js.map +1 -1
- package/dist/graph-edge-collector.d.ts +0 -2
- package/dist/graph-edge-collector.d.ts.map +1 -1
- package/dist/graph-edge-collector.js +2 -4
- package/dist/graph-edge-collector.js.map +1 -1
- package/dist/graphs/edgeResolution.d.ts.map +1 -1
- package/dist/graphs/specifiers.d.ts +1 -1
- package/dist/graphs/specifiers.d.ts.map +1 -1
- package/dist/graphs/specifiers.js +1 -1
- package/dist/graphs/specifiers.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed.d.ts +10 -1
- package/dist/graphs/symbol-graph-detailed.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed.js +18 -5
- package/dist/graphs/symbol-graph-detailed.js.map +1 -1
- package/dist/impact/analyzer.d.ts.map +1 -1
- package/dist/impact/analyzer.js +4 -1
- package/dist/impact/analyzer.js.map +1 -1
- package/dist/impact/budgets.d.ts.map +1 -1
- package/dist/impact/budgets.js +5 -3
- package/dist/impact/budgets.js.map +1 -1
- package/dist/impact/callCompatibility.d.ts +8 -1
- package/dist/impact/callCompatibility.d.ts.map +1 -1
- package/dist/impact/callCompatibility.js +55 -17
- package/dist/impact/callCompatibility.js.map +1 -1
- package/dist/impact/context.d.ts.map +1 -1
- package/dist/impact/context.js +4 -1
- package/dist/impact/context.js.map +1 -1
- package/dist/impact/direct.d.ts +1 -1
- package/dist/impact/direct.d.ts.map +1 -1
- package/dist/impact/parse.d.ts.map +1 -1
- package/dist/impact/parse.js +10 -1
- package/dist/impact/parse.js.map +1 -1
- package/dist/impact/report-suggestions.d.ts.map +1 -1
- package/dist/impact/report-suggestions.js +17 -11
- package/dist/impact/report-suggestions.js.map +1 -1
- package/dist/impact/report.d.ts.map +1 -1
- package/dist/impact/report.js +13 -2
- package/dist/impact/report.js.map +1 -1
- package/dist/impact/reportCompact.d.ts.map +1 -1
- package/dist/impact/reportCompact.js +1 -0
- package/dist/impact/reportCompact.js.map +1 -1
- package/dist/impact/reportFull.d.ts.map +1 -1
- package/dist/impact/reportFull.js +1 -0
- package/dist/impact/reportFull.js.map +1 -1
- package/dist/impact/reportParts.d.ts +9 -0
- package/dist/impact/reportParts.d.ts.map +1 -1
- package/dist/impact/severity.d.ts +3 -2
- package/dist/impact/severity.d.ts.map +1 -1
- package/dist/impact/severity.js +16 -5
- package/dist/impact/severity.js.map +1 -1
- package/dist/impact/streaming.d.ts.map +1 -1
- package/dist/impact/streaming.js +5 -5
- package/dist/impact/streaming.js.map +1 -1
- package/dist/impact/transitive.d.ts.map +1 -1
- package/dist/impact/transitive.js +13 -5
- package/dist/impact/transitive.js.map +1 -1
- package/dist/impact/types.d.ts +14 -0
- package/dist/impact/types.d.ts.map +1 -1
- package/dist/impact/types.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/indexer/build-cache/manifest.d.ts +5 -3
- package/dist/indexer/build-cache/manifest.d.ts.map +1 -1
- package/dist/indexer/build-cache/manifest.js +122 -15
- package/dist/indexer/build-cache/manifest.js.map +1 -1
- package/dist/indexer/build-cache/module-cache.d.ts +1 -0
- package/dist/indexer/build-cache/module-cache.d.ts.map +1 -1
- package/dist/indexer/build-cache/module-cache.js +7 -1
- package/dist/indexer/build-cache/module-cache.js.map +1 -1
- package/dist/indexer/build-cache/options.d.ts.map +1 -1
- package/dist/indexer/build-cache/options.js +0 -2
- package/dist/indexer/build-cache/options.js.map +1 -1
- package/dist/indexer/build-cache/project-snapshot.d.ts +15 -11
- package/dist/indexer/build-cache/project-snapshot.d.ts.map +1 -1
- package/dist/indexer/build-cache/project-snapshot.js +167 -79
- package/dist/indexer/build-cache/project-snapshot.js.map +1 -1
- package/dist/indexer/build-cache/resolver-environment.d.ts +2 -2
- package/dist/indexer/build-cache/resolver-environment.d.ts.map +1 -1
- package/dist/indexer/build-cache/resolver-environment.js +33 -6
- package/dist/indexer/build-cache/resolver-environment.js.map +1 -1
- package/dist/indexer/build-cache.d.ts +2 -2
- package/dist/indexer/build-cache.d.ts.map +1 -1
- package/dist/indexer/build-cache.js +2 -2
- package/dist/indexer/build-cache.js.map +1 -1
- package/dist/indexer/build-index.d.ts.map +1 -1
- package/dist/indexer/build-index.js +164 -84
- package/dist/indexer/build-index.js.map +1 -1
- package/dist/indexer/build-manifest.d.ts.map +1 -1
- package/dist/indexer/build-manifest.js +3 -0
- package/dist/indexer/build-manifest.js.map +1 -1
- package/dist/indexer/build-workers.d.ts +30 -3
- package/dist/indexer/build-workers.d.ts.map +1 -1
- package/dist/indexer/build-workers.js +111 -45
- package/dist/indexer/build-workers.js.map +1 -1
- package/dist/indexer/call-hierarchy.d.ts.map +1 -1
- package/dist/indexer/import-types.d.ts +8 -0
- package/dist/indexer/import-types.d.ts.map +1 -1
- package/dist/indexer/imports/python.d.ts.map +1 -1
- package/dist/indexer/imports/python.js +13 -8
- package/dist/indexer/imports/python.js.map +1 -1
- package/dist/indexer/imports.d.ts +0 -3
- package/dist/indexer/imports.d.ts.map +1 -1
- package/dist/indexer/imports.js +1 -1
- package/dist/indexer/imports.js.map +1 -1
- package/dist/indexer/incremental-plan.d.ts +2 -1
- package/dist/indexer/incremental-plan.d.ts.map +1 -1
- package/dist/indexer/incremental-plan.js +7 -4
- package/dist/indexer/incremental-plan.js.map +1 -1
- package/dist/indexer/locals-and-exports.d.ts +2 -2
- package/dist/indexer/locals-and-exports.d.ts.map +1 -1
- package/dist/indexer/locals-and-exports.js +27 -3
- package/dist/indexer/locals-and-exports.js.map +1 -1
- package/dist/indexer/navigation-local.d.ts +2 -2
- package/dist/indexer/navigation-local.d.ts.map +1 -1
- package/dist/indexer/navigation-local.js +2 -2
- package/dist/indexer/navigation-local.js.map +1 -1
- package/dist/indexer/navigation-references.d.ts +1 -2
- package/dist/indexer/navigation-references.d.ts.map +1 -1
- package/dist/indexer/navigation-references.js +8 -2
- package/dist/indexer/navigation-references.js.map +1 -1
- package/dist/indexer/navigation.d.ts.map +1 -1
- package/dist/indexer/navigation.js +12 -4
- package/dist/indexer/navigation.js.map +1 -1
- package/dist/indexer/parse-context.d.ts +2 -5
- package/dist/indexer/parse-context.d.ts.map +1 -1
- package/dist/indexer/parse-context.js +34 -8
- package/dist/indexer/parse-context.js.map +1 -1
- package/dist/indexer/scope.d.ts +2 -2
- package/dist/indexer/scope.d.ts.map +1 -1
- package/dist/indexer/scope.js +1 -1
- package/dist/indexer/scope.js.map +1 -1
- package/dist/indexer/types.d.ts +5 -1
- package/dist/indexer/types.d.ts.map +1 -1
- package/dist/indexer.d.ts +3 -6
- package/dist/indexer.d.ts.map +1 -1
- package/dist/indexer.js +5 -8
- package/dist/indexer.js.map +1 -1
- package/dist/installer/locks.d.ts.map +1 -1
- package/dist/installer/locks.js +1 -3
- package/dist/installer/locks.js.map +1 -1
- package/dist/installer/registry.d.ts.map +1 -1
- package/dist/installer/registry.js +63 -32
- package/dist/installer/registry.js.map +1 -1
- package/dist/languages/definitions/c.d.ts.map +1 -1
- package/dist/languages/definitions/c.js +0 -1
- package/dist/languages/definitions/c.js.map +1 -1
- package/dist/languages/definitions/cFamily.d.ts +0 -1
- package/dist/languages/definitions/cFamily.d.ts.map +1 -1
- package/dist/languages/definitions/cFamily.js +0 -2
- package/dist/languages/definitions/cFamily.js.map +1 -1
- package/dist/languages/definitions/cpp.d.ts.map +1 -1
- package/dist/languages/definitions/cpp.js +0 -1
- package/dist/languages/definitions/cpp.js.map +1 -1
- package/dist/languages/definitions/csharp.d.ts.map +1 -1
- package/dist/languages/definitions/csharp.js +0 -2
- package/dist/languages/definitions/csharp.js.map +1 -1
- package/dist/languages/definitions/css.d.ts.map +1 -1
- package/dist/languages/definitions/css.js +0 -2
- package/dist/languages/definitions/css.js.map +1 -1
- package/dist/languages/definitions/go.d.ts.map +1 -1
- package/dist/languages/definitions/go.js +0 -2
- package/dist/languages/definitions/go.js.map +1 -1
- package/dist/languages/definitions/html.d.ts.map +1 -1
- package/dist/languages/definitions/html.js +0 -2
- package/dist/languages/definitions/html.js.map +1 -1
- package/dist/languages/definitions/htmlStub.d.ts.map +1 -1
- package/dist/languages/definitions/htmlStub.js +0 -2
- package/dist/languages/definitions/htmlStub.js.map +1 -1
- package/dist/languages/definitions/java.d.ts.map +1 -1
- package/dist/languages/definitions/java.js +0 -2
- package/dist/languages/definitions/java.js.map +1 -1
- package/dist/languages/definitions/javascript.d.ts.map +1 -1
- package/dist/languages/definitions/javascript.js +0 -2
- package/dist/languages/definitions/javascript.js.map +1 -1
- package/dist/languages/definitions/kotlin.d.ts.map +1 -1
- package/dist/languages/definitions/kotlin.js +0 -2
- package/dist/languages/definitions/kotlin.js.map +1 -1
- package/dist/languages/definitions/less.d.ts.map +1 -1
- package/dist/languages/definitions/less.js +0 -2
- package/dist/languages/definitions/less.js.map +1 -1
- package/dist/languages/definitions/php.d.ts.map +1 -1
- package/dist/languages/definitions/php.js +0 -2
- package/dist/languages/definitions/php.js.map +1 -1
- package/dist/languages/definitions/python.d.ts.map +1 -1
- package/dist/languages/definitions/python.js +0 -2
- package/dist/languages/definitions/python.js.map +1 -1
- package/dist/languages/definitions/ruby.d.ts.map +1 -1
- package/dist/languages/definitions/ruby.js +0 -2
- package/dist/languages/definitions/ruby.js.map +1 -1
- package/dist/languages/definitions/rust.d.ts.map +1 -1
- package/dist/languages/definitions/rust.js +0 -2
- package/dist/languages/definitions/rust.js.map +1 -1
- package/dist/languages/definitions/scss.d.ts.map +1 -1
- package/dist/languages/definitions/scss.js +0 -2
- package/dist/languages/definitions/scss.js.map +1 -1
- package/dist/languages/definitions/sql.d.ts.map +1 -1
- package/dist/languages/definitions/sql.js +0 -2
- package/dist/languages/definitions/sql.js.map +1 -1
- package/dist/languages/definitions/svelte.d.ts.map +1 -1
- package/dist/languages/definitions/svelte.js +0 -2
- package/dist/languages/definitions/svelte.js.map +1 -1
- package/dist/languages/definitions/swift.d.ts.map +1 -1
- package/dist/languages/definitions/swift.js +0 -2
- package/dist/languages/definitions/swift.js.map +1 -1
- package/dist/languages/definitions/typescript.d.ts.map +1 -1
- package/dist/languages/definitions/typescript.js +0 -3
- package/dist/languages/definitions/typescript.js.map +1 -1
- package/dist/languages/definitions/vue.d.ts.map +1 -1
- package/dist/languages/definitions/vue.js +0 -2
- package/dist/languages/definitions/vue.js.map +1 -1
- package/dist/languages/definitions/zig.d.ts.map +1 -1
- package/dist/languages/definitions/zig.js +0 -2
- package/dist/languages/definitions/zig.js.map +1 -1
- package/dist/languages/filePrep.d.ts +0 -2
- package/dist/languages/filePrep.d.ts.map +1 -1
- package/dist/languages/filePrep.js +0 -1
- package/dist/languages/filePrep.js.map +1 -1
- package/dist/languages/types.d.ts +19 -5
- package/dist/languages/types.d.ts.map +1 -1
- package/dist/languages.d.ts +1 -3
- package/dist/languages.d.ts.map +1 -1
- package/dist/languages.js +0 -7
- package/dist/languages.js.map +1 -1
- package/dist/lifecycle/manifest.d.ts.map +1 -1
- package/dist/lifecycle/manifest.js +21 -4
- package/dist/lifecycle/manifest.js.map +1 -1
- package/dist/mcp/handlers.d.ts +275 -0
- package/dist/mcp/handlers.d.ts.map +1 -0
- package/dist/mcp/handlers.js +657 -0
- package/dist/mcp/handlers.js.map +1 -0
- package/dist/mcp/httpTransport.d.ts +14 -0
- package/dist/mcp/httpTransport.d.ts.map +1 -0
- package/dist/mcp/httpTransport.js +185 -0
- package/dist/mcp/httpTransport.js.map +1 -0
- package/dist/mcp/legacySessions.d.ts +38 -0
- package/dist/mcp/legacySessions.d.ts.map +1 -0
- package/dist/mcp/legacySessions.js +264 -0
- package/dist/mcp/legacySessions.js.map +1 -0
- package/dist/mcp/lifecycleHealth.d.ts +12 -0
- package/dist/mcp/lifecycleHealth.d.ts.map +1 -0
- package/dist/mcp/lifecycleHealth.js +37 -0
- package/dist/mcp/lifecycleHealth.js.map +1 -0
- package/dist/mcp/protocol.d.ts +35 -0
- package/dist/mcp/protocol.d.ts.map +1 -0
- package/dist/mcp/protocol.js +577 -0
- package/dist/mcp/protocol.js.map +1 -0
- package/dist/mcp/server.d.ts +9 -291
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +13 -1517
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +8 -1
- package/dist/mcp/tools.js.map +1 -1
- package/dist/native/bindingLoader.d.ts +27 -0
- package/dist/native/bindingLoader.d.ts.map +1 -1
- package/dist/native/bindingLoader.js +18 -1
- package/dist/native/bindingLoader.js.map +1 -1
- package/dist/native/contracts.d.ts +59 -12
- package/dist/native/contracts.d.ts.map +1 -1
- package/dist/native/execution.d.ts +10 -1
- package/dist/native/execution.d.ts.map +1 -1
- package/dist/native/execution.js +59 -3
- package/dist/native/execution.js.map +1 -1
- package/dist/native/projectedTree.d.ts +20 -5
- package/dist/native/projectedTree.d.ts.map +1 -1
- package/dist/native/projectedTree.js +100 -48
- package/dist/native/projectedTree.js.map +1 -1
- package/dist/native/runtime.d.ts +47 -1
- package/dist/native/runtime.d.ts.map +1 -1
- package/dist/native/runtime.js +151 -8
- package/dist/native/runtime.js.map +1 -1
- package/dist/native/runtimeCache.d.ts +92 -0
- package/dist/native/runtimeCache.d.ts.map +1 -1
- package/dist/native/runtimeCache.js +443 -13
- package/dist/native/runtimeCache.js.map +1 -1
- package/dist/native/treeShape.d.ts +21 -0
- package/dist/native/treeShape.d.ts.map +1 -0
- package/dist/native/treeShape.js +28 -0
- package/dist/native/treeShape.js.map +1 -0
- package/dist/native/treeSitterNative.d.ts +3 -3
- package/dist/native/treeSitterNative.d.ts.map +1 -1
- package/dist/native/treeSitterNative.js +2 -2
- package/dist/native/treeSitterNative.js.map +1 -1
- package/dist/presets.d.ts +7 -1
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +4 -0
- package/dist/presets.js.map +1 -1
- package/dist/review/candidates.d.ts.map +1 -1
- package/dist/review/candidates.js +4 -1
- package/dist/review/candidates.js.map +1 -1
- package/dist/review/deleted.js +2 -2
- package/dist/review/deleted.js.map +1 -1
- package/dist/review/summaries.d.ts +5 -0
- package/dist/review/summaries.d.ts.map +1 -1
- package/dist/review/summaries.js +19 -11
- package/dist/review/summaries.js.map +1 -1
- package/dist/review/types.d.ts +3 -1
- package/dist/review/types.d.ts.map +1 -1
- package/dist/review/types.js +8 -1
- package/dist/review/types.js.map +1 -1
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +7 -3
- package/dist/review.js.map +1 -1
- package/dist/sql/extractFacts.d.ts.map +1 -1
- package/dist/sql/extractFacts.js +1 -1
- package/dist/sql/extractFacts.js.map +1 -1
- package/dist/sqlite/schema.d.ts +2 -1
- package/dist/sqlite/schema.d.ts.map +1 -1
- package/dist/sqlite/schema.js +15 -1
- package/dist/sqlite/schema.js.map +1 -1
- package/dist/sqlite/write.d.ts.map +1 -1
- package/dist/sqlite/write.js +15 -0
- package/dist/sqlite/write.js.map +1 -1
- package/dist/sqlite-driver.d.ts +11 -0
- package/dist/sqlite-driver.d.ts.map +1 -1
- package/dist/sqlite-driver.js +27 -2
- package/dist/sqlite-driver.js.map +1 -1
- package/dist/util/concurrency.d.ts +1 -0
- package/dist/util/concurrency.d.ts.map +1 -1
- package/dist/util/concurrency.js +9 -2
- package/dist/util/concurrency.js.map +1 -1
- package/dist/util/confinedFile.d.ts +1 -0
- package/dist/util/confinedFile.d.ts.map +1 -1
- package/dist/util/confinedFile.js +17 -5
- package/dist/util/confinedFile.js.map +1 -1
- package/dist/util/errors.d.ts +2 -0
- package/dist/util/errors.d.ts.map +1 -1
- package/dist/util/errors.js +18 -0
- package/dist/util/errors.js.map +1 -1
- package/dist/util/git.d.ts.map +1 -1
- package/dist/util/git.js +72 -7
- package/dist/util/git.js.map +1 -1
- package/dist/util/lazySymbols.js +1 -1
- package/dist/util/lazySymbols.js.map +1 -1
- package/dist/util/paths.d.ts.map +1 -1
- package/dist/util/paths.js +45 -9
- package/dist/util/paths.js.map +1 -1
- package/dist/util/resolution/jvm.d.ts.map +1 -1
- package/dist/util/resolution/jvm.js +14 -8
- package/dist/util/resolution/jvm.js.map +1 -1
- package/dist/util/resolution/php.d.ts.map +1 -1
- package/dist/util/resolution/php.js +0 -1
- package/dist/util/resolution/php.js.map +1 -1
- package/dist/util/resolution/tsconfig.d.ts.map +1 -1
- package/dist/util/resolution/tsconfig.js +26 -12
- package/dist/util/resolution/tsconfig.js.map +1 -1
- package/dist/util/resolution.d.ts.map +1 -1
- package/dist/util/resolution.js +5 -5
- package/dist/util/resolution.js.map +1 -1
- package/dist/worker/nativeExtractWorker.d.ts +14 -6
- package/dist/worker/nativeExtractWorker.d.ts.map +1 -1
- package/dist/worker/nativeExtractWorker.js +67 -14
- package/dist/worker/nativeExtractWorker.js.map +1 -1
- package/dist/worker/nativeWorkerPool.d.ts +4 -0
- package/dist/worker/nativeWorkerPool.d.ts.map +1 -1
- package/dist/worker/nativeWorkerPool.js +6 -1
- package/dist/worker/nativeWorkerPool.js.map +1 -1
- package/docs/mcp.md +22 -6
- package/package.json +3 -3
- package/dist/languages/definitions/loadLanguage.d.ts +0 -2
- package/dist/languages/definitions/loadLanguage.d.ts.map +0 -1
- package/dist/languages/definitions/loadLanguage.js +0 -2
- package/dist/languages/definitions/loadLanguage.js.map +0 -1
- package/dist/parserBackend.d.ts +0 -57
- package/dist/parserBackend.d.ts.map +0 -1
- package/dist/parserBackend.js +0 -33
- package/dist/parserBackend.js.map +0 -1
|
@@ -3,7 +3,7 @@ const require = __codegraphCreateRequire(import.meta.url);
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
// dist/agent/query-index/content.js
|
|
6
|
-
import
|
|
6
|
+
import fs6 from "node:fs/promises";
|
|
7
7
|
import { brotliCompressSync, constants as zlibConstants } from "node:zlib";
|
|
8
8
|
|
|
9
9
|
// dist/languages/queryGenerator.js
|
|
@@ -75,17 +75,6 @@ function getLanguageById(id) {
|
|
|
75
75
|
return registry.get(id);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
// dist/parserBackend.js
|
|
79
|
-
function loadTreeSitterLanguage(packageName) {
|
|
80
|
-
return { name: packageName };
|
|
81
|
-
}
|
|
82
|
-
function loadTypeScriptGrammars() {
|
|
83
|
-
return {
|
|
84
|
-
typescript: { name: "tree-sitter-typescript/typescript" },
|
|
85
|
-
tsx: { name: "tree-sitter-typescript/tsx" }
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
78
|
// dist/languages/definitions/jsFamily.js
|
|
90
79
|
var ECMASCRIPT_CONTROL_SPLIT_POINTS = [
|
|
91
80
|
"if_statement",
|
|
@@ -331,7 +320,6 @@ var BASE_HELPERS = {
|
|
|
331
320
|
var TYPESCRIPT_DEF = {
|
|
332
321
|
id: "ts",
|
|
333
322
|
extensions: [".ts", ".mts", ".cts"],
|
|
334
|
-
grammar: () => loadTypeScriptGrammars().typescript,
|
|
335
323
|
structure: BASE_STRUCTURE,
|
|
336
324
|
graph: BASE_GRAPH,
|
|
337
325
|
...BASE_HELPERS,
|
|
@@ -346,7 +334,6 @@ registerLanguage(TYPESCRIPT_DEF);
|
|
|
346
334
|
var TSX_DEF = {
|
|
347
335
|
id: "tsx",
|
|
348
336
|
extensions: [".tsx"],
|
|
349
|
-
grammar: () => loadTypeScriptGrammars().tsx,
|
|
350
337
|
structure: {
|
|
351
338
|
...BASE_STRUCTURE,
|
|
352
339
|
blocks: [
|
|
@@ -384,7 +371,6 @@ var JS_OBJECT_METHOD_EXPORT_NATIVE_PATTERN = `
|
|
|
384
371
|
var JAVASCRIPT_DEF = {
|
|
385
372
|
id: "js",
|
|
386
373
|
extensions: [".js", ".jsx", ".mjs", ".cjs"],
|
|
387
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-javascript"),
|
|
388
374
|
structure: {
|
|
389
375
|
blocks: [...ECMASCRIPT_CORE_FUNCTION_BLOCKS, ...ECMASCRIPT_MODULE_VAR_BLOCKS],
|
|
390
376
|
splitPoints: [...ECMASCRIPT_CONTROL_SPLIT_POINTS],
|
|
@@ -553,7 +539,6 @@ var KOTLIN_IDENTIFIER_SOURCE = String.raw`[\p{L}_][\p{L}\p{Nd}_]*`;
|
|
|
553
539
|
var PYTHON_DEF = {
|
|
554
540
|
id: "python",
|
|
555
541
|
extensions: [".py", ".pyi"],
|
|
556
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-python"),
|
|
557
542
|
usesQueryDrivenLocals: true,
|
|
558
543
|
structure: {
|
|
559
544
|
blocks: [
|
|
@@ -684,7 +669,6 @@ registerLanguage(PYTHON_DEF);
|
|
|
684
669
|
var PHP_DEF = {
|
|
685
670
|
id: "php",
|
|
686
671
|
extensions: [".php"],
|
|
687
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-php"),
|
|
688
672
|
usesQueryDrivenLocals: true,
|
|
689
673
|
structure: {
|
|
690
674
|
blocks: [
|
|
@@ -839,7 +823,6 @@ registerLanguage(PHP_DEF);
|
|
|
839
823
|
var HTML_DEF = {
|
|
840
824
|
id: "html",
|
|
841
825
|
extensions: [".html", ".htm"],
|
|
842
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-html"),
|
|
843
826
|
structure: {
|
|
844
827
|
blocks: [
|
|
845
828
|
{
|
|
@@ -884,7 +867,6 @@ function htmlStubLanguage(id, extensions) {
|
|
|
884
867
|
return {
|
|
885
868
|
id,
|
|
886
869
|
extensions,
|
|
887
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-html"),
|
|
888
870
|
structure: {
|
|
889
871
|
blocks: [],
|
|
890
872
|
splitPoints: [],
|
|
@@ -963,7 +945,6 @@ function cssLikeNodeTypes() {
|
|
|
963
945
|
var CSS_DEF = {
|
|
964
946
|
id: "css",
|
|
965
947
|
extensions: [".css"],
|
|
966
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-css"),
|
|
967
948
|
structure: cssLikeStructure(),
|
|
968
949
|
graph: cssLikeGraph(),
|
|
969
950
|
nodeTypes: cssLikeNodeTypes()
|
|
@@ -981,7 +962,6 @@ var SCSS_SYMBOL_QUERY_PATTERNS = [
|
|
|
981
962
|
var SCSS_DEF = {
|
|
982
963
|
id: "scss",
|
|
983
964
|
extensions: [".scss"],
|
|
984
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-scss"),
|
|
985
965
|
structure: {
|
|
986
966
|
blocks: [
|
|
987
967
|
{ type: "rule_set", captureId: "rule" },
|
|
@@ -1031,7 +1011,6 @@ registerLanguage(SCSS_DEF);
|
|
|
1031
1011
|
var LESS_DEF = {
|
|
1032
1012
|
id: "less",
|
|
1033
1013
|
extensions: [".less"],
|
|
1034
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-css"),
|
|
1035
1014
|
structure: cssLikeStructure(),
|
|
1036
1015
|
graph: cssLikeGraph(),
|
|
1037
1016
|
nodeTypes: cssLikeNodeTypes()
|
|
@@ -1042,7 +1021,6 @@ registerLanguage(LESS_DEF);
|
|
|
1042
1021
|
var VUE_DEF = {
|
|
1043
1022
|
id: "vue",
|
|
1044
1023
|
extensions: [".vue"],
|
|
1045
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-vue"),
|
|
1046
1024
|
structure: {
|
|
1047
1025
|
blocks: [
|
|
1048
1026
|
{ type: "template_element", captureId: "template" },
|
|
@@ -1072,7 +1050,6 @@ registerLanguage(VUE_DEF);
|
|
|
1072
1050
|
var SVELTE_DEF = {
|
|
1073
1051
|
id: "svelte",
|
|
1074
1052
|
extensions: [".svelte"],
|
|
1075
|
-
grammar: () => loadTreeSitterLanguage("@tree-sitter-grammars/tree-sitter-svelte"),
|
|
1076
1053
|
structure: {
|
|
1077
1054
|
blocks: [
|
|
1078
1055
|
{ type: "script_element", captureId: "script" },
|
|
@@ -1102,7 +1079,6 @@ registerLanguage(SVELTE_DEF);
|
|
|
1102
1079
|
var RUBY_DEF = {
|
|
1103
1080
|
id: "ruby",
|
|
1104
1081
|
extensions: [".rb"],
|
|
1105
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-ruby"),
|
|
1106
1082
|
structure: {
|
|
1107
1083
|
blocks: [
|
|
1108
1084
|
{
|
|
@@ -1189,7 +1165,6 @@ registerLanguage(RUBY_DEF);
|
|
|
1189
1165
|
var GO_DEF = {
|
|
1190
1166
|
id: "go",
|
|
1191
1167
|
extensions: [".go"],
|
|
1192
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-go"),
|
|
1193
1168
|
usesQueryDrivenLocals: true,
|
|
1194
1169
|
structure: {
|
|
1195
1170
|
blocks: [
|
|
@@ -1298,7 +1273,6 @@ var JAVA_IDENTIFIER_IGNORABLE_PATTERN = new RegExp(`[${JAVA_IDENTIFIER_IGNORABLE
|
|
|
1298
1273
|
var JAVA_DEF = {
|
|
1299
1274
|
id: "java",
|
|
1300
1275
|
extensions: [".java"],
|
|
1301
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-java"),
|
|
1302
1276
|
usesQueryDrivenLocals: true,
|
|
1303
1277
|
structure: {
|
|
1304
1278
|
blocks: [
|
|
@@ -1423,7 +1397,6 @@ var CSHARP_IDENTIFIER_FORMAT_PATTERN = new RegExp(`[${CSHARP_IDENTIFIER_FORMAT_S
|
|
|
1423
1397
|
var CSHARP_DEF = {
|
|
1424
1398
|
id: "csharp",
|
|
1425
1399
|
extensions: [".cs"],
|
|
1426
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-c-sharp"),
|
|
1427
1400
|
usesQueryDrivenLocals: true,
|
|
1428
1401
|
structure: {
|
|
1429
1402
|
blocks: [
|
|
@@ -1552,7 +1525,6 @@ registerLanguage(CSHARP_DEF);
|
|
|
1552
1525
|
var RUST_DEF = {
|
|
1553
1526
|
id: "rust",
|
|
1554
1527
|
extensions: [".rs"],
|
|
1555
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-rust"),
|
|
1556
1528
|
usesQueryDrivenLocals: true,
|
|
1557
1529
|
structure: {
|
|
1558
1530
|
blocks: [
|
|
@@ -1784,7 +1756,6 @@ function createCFamilyLanguageDefinition(options) {
|
|
|
1784
1756
|
return {
|
|
1785
1757
|
id: options.id,
|
|
1786
1758
|
extensions: [...options.extensions],
|
|
1787
|
-
grammar: () => loadTreeSitterLanguage(options.grammarPackage),
|
|
1788
1759
|
structure: {
|
|
1789
1760
|
blocks: options.blocks(functionNameQuery),
|
|
1790
1761
|
splitPoints: [...options.splitPoints ?? cFamilyControlSplitPoints],
|
|
@@ -1877,7 +1848,6 @@ function isFunctionDeclarator(node) {
|
|
|
1877
1848
|
var C_DEF = createCFamilyLanguageDefinition({
|
|
1878
1849
|
id: "c",
|
|
1879
1850
|
extensions: [".c", ".h", ".i"],
|
|
1880
|
-
grammarPackage: "tree-sitter-c",
|
|
1881
1851
|
includeFieldIdentifier: false,
|
|
1882
1852
|
blocks: (functionNameQuery) => [
|
|
1883
1853
|
cFamilyFunctionBlock(functionNameQuery),
|
|
@@ -1950,7 +1920,6 @@ registerLanguage(C_DEF);
|
|
|
1950
1920
|
var CPP_DEF = createCFamilyLanguageDefinition({
|
|
1951
1921
|
id: "cpp",
|
|
1952
1922
|
extensions: [".cc", ".cpp", ".cxx", ".c++", ".hpp", ".hh", ".hxx", ".ipp", ".tpp", ".inl"],
|
|
1953
|
-
grammarPackage: "tree-sitter-cpp",
|
|
1954
1923
|
includeFieldIdentifier: true,
|
|
1955
1924
|
usesQueryDrivenLocals: true,
|
|
1956
1925
|
blocks: (functionNameQuery) => [
|
|
@@ -2044,7 +2013,6 @@ function normalizeKotlinNativeQuery(kind, query) {
|
|
|
2044
2013
|
var KOTLIN_DEF = {
|
|
2045
2014
|
id: "kotlin",
|
|
2046
2015
|
extensions: [".kt", ".kts"],
|
|
2047
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-kotlin"),
|
|
2048
2016
|
usesQueryDrivenLocals: true,
|
|
2049
2017
|
structure: {
|
|
2050
2018
|
blocks: [
|
|
@@ -2172,7 +2140,6 @@ registerLanguage(KOTLIN_DEF);
|
|
|
2172
2140
|
var SWIFT_DEF = {
|
|
2173
2141
|
id: "swift",
|
|
2174
2142
|
extensions: [".swift"],
|
|
2175
|
-
grammar: () => loadTreeSitterLanguage("tree-sitter-swift"),
|
|
2176
2143
|
usesQueryDrivenLocals: true,
|
|
2177
2144
|
structure: {
|
|
2178
2145
|
blocks: [
|
|
@@ -2345,7 +2312,6 @@ registerLanguage(SWIFT_DEF);
|
|
|
2345
2312
|
var SQL_DEF = {
|
|
2346
2313
|
id: "sql",
|
|
2347
2314
|
extensions: [".sql"],
|
|
2348
|
-
grammar: () => loadTreeSitterLanguage("@derekstride/tree-sitter-sql"),
|
|
2349
2315
|
structure: {
|
|
2350
2316
|
blocks: [
|
|
2351
2317
|
{ type: "statement", nameQuery: "(create_table)", captureId: "create" },
|
|
@@ -2388,7 +2354,6 @@ var ZIG_TYPE_INITIALIZER_TYPES = /* @__PURE__ */ new Set([
|
|
|
2388
2354
|
var ZIG_DEF = {
|
|
2389
2355
|
id: "zig",
|
|
2390
2356
|
extensions: [".zig"],
|
|
2391
|
-
grammar: () => loadTreeSitterLanguage("@tree-sitter-grammars/tree-sitter-zig"),
|
|
2392
2357
|
usesQueryDrivenLocals: true,
|
|
2393
2358
|
structure: {
|
|
2394
2359
|
blocks: [
|
|
@@ -2552,7 +2517,6 @@ function adaptDefinition(def) {
|
|
|
2552
2517
|
return {
|
|
2553
2518
|
id: def.id,
|
|
2554
2519
|
matchExts: def.extensions,
|
|
2555
|
-
language: (filename) => def.grammar(filename),
|
|
2556
2520
|
nodeTypes: def.nodeTypes || { identifier: ["identifier"] },
|
|
2557
2521
|
queries: def.graph,
|
|
2558
2522
|
classifyDefinition: def.classifyDefinition || (() => "variable"),
|
|
@@ -2646,6 +2610,7 @@ function isLikelyCppHeader(sample) {
|
|
|
2646
2610
|
}
|
|
2647
2611
|
|
|
2648
2612
|
// dist/native/runtime.js
|
|
2613
|
+
import fs5 from "node:fs";
|
|
2649
2614
|
import path5 from "node:path";
|
|
2650
2615
|
import { createRequire } from "node:module";
|
|
2651
2616
|
import { fileURLToPath } from "node:url";
|
|
@@ -2678,10 +2643,11 @@ function stringifyUnknown(value) {
|
|
|
2678
2643
|
}
|
|
2679
2644
|
|
|
2680
2645
|
// dist/native/bindingLoader.js
|
|
2681
|
-
import
|
|
2646
|
+
import fs4 from "node:fs";
|
|
2682
2647
|
import path4 from "node:path";
|
|
2683
2648
|
|
|
2684
2649
|
// dist/util/paths.js
|
|
2650
|
+
import fs2, {} from "node:fs";
|
|
2685
2651
|
import fsp from "node:fs/promises";
|
|
2686
2652
|
import path2 from "node:path";
|
|
2687
2653
|
|
|
@@ -2689,6 +2655,19 @@ import path2 from "node:path";
|
|
|
2689
2655
|
function errorMessage(error) {
|
|
2690
2656
|
if (error instanceof Error)
|
|
2691
2657
|
return error.message;
|
|
2658
|
+
if (typeof error === "string")
|
|
2659
|
+
return error;
|
|
2660
|
+
if (error === null || error === void 0)
|
|
2661
|
+
return String(error);
|
|
2662
|
+
if (typeof error === "object") {
|
|
2663
|
+
try {
|
|
2664
|
+
const serialized = JSON.stringify(error);
|
|
2665
|
+
if (serialized)
|
|
2666
|
+
return serialized;
|
|
2667
|
+
} catch {
|
|
2668
|
+
return String(error);
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2692
2671
|
return String(error);
|
|
2693
2672
|
}
|
|
2694
2673
|
|
|
@@ -2765,7 +2744,9 @@ function isRelativeToRoot(normalizedRoot, normalizedFile) {
|
|
|
2765
2744
|
function isFilePathWithinRoot(projectRoot, filePath) {
|
|
2766
2745
|
const normalizedRoot = normalizePath(resolveComparableProjectRoot(projectRoot));
|
|
2767
2746
|
const normalizedFile = normalizePath(resolveFilePathFromRoot(normalizedRoot, filePath));
|
|
2768
|
-
|
|
2747
|
+
if (isRelativeToRoot(normalizedRoot, normalizedFile))
|
|
2748
|
+
return true;
|
|
2749
|
+
return windowsAliasRelativePath(normalizedRoot, normalizedFile) !== null;
|
|
2769
2750
|
}
|
|
2770
2751
|
function assertFilePathWithinRoot(projectRoot, filePath, label = "File") {
|
|
2771
2752
|
const normalizedRoot = normalizePath(resolveComparableProjectRoot(projectRoot));
|
|
@@ -2775,13 +2756,50 @@ function assertFilePathWithinRoot(projectRoot, filePath, label = "File") {
|
|
|
2775
2756
|
}
|
|
2776
2757
|
return normalizedFile;
|
|
2777
2758
|
}
|
|
2759
|
+
function windowsAliasRelativePath(normalizedRoot, normalizedFile) {
|
|
2760
|
+
if (process.platform !== "win32")
|
|
2761
|
+
return null;
|
|
2762
|
+
if (!isWindowsQualifiedAbsolutePath(normalizedRoot) || !isWindowsQualifiedAbsolutePath(normalizedFile)) {
|
|
2763
|
+
return null;
|
|
2764
|
+
}
|
|
2765
|
+
try {
|
|
2766
|
+
const realRoot = fs2.realpathSync.native(normalizedRoot);
|
|
2767
|
+
const realFile = fs2.realpathSync.native(normalizedFile);
|
|
2768
|
+
const directRelativePath = path2.win32.relative(realRoot, realFile);
|
|
2769
|
+
if (!directRelativePath.startsWith("..") && !path2.win32.isAbsolute(directRelativePath)) {
|
|
2770
|
+
return normalizePath(directRelativePath);
|
|
2771
|
+
}
|
|
2772
|
+
const rootStat = fs2.statSync(realRoot, { bigint: true });
|
|
2773
|
+
let ancestorPath = realFile;
|
|
2774
|
+
while (true) {
|
|
2775
|
+
const ancestorStat = fs2.statSync(ancestorPath, { bigint: true });
|
|
2776
|
+
if (sameWindowsDirectoryIdentity(rootStat, ancestorStat)) {
|
|
2777
|
+
return normalizePath(path2.win32.relative(ancestorPath, realFile));
|
|
2778
|
+
}
|
|
2779
|
+
const parentPath = path2.dirname(ancestorPath);
|
|
2780
|
+
if (parentPath === ancestorPath)
|
|
2781
|
+
return null;
|
|
2782
|
+
ancestorPath = parentPath;
|
|
2783
|
+
}
|
|
2784
|
+
} catch {
|
|
2785
|
+
return null;
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
function sameWindowsDirectoryIdentity(left, right) {
|
|
2789
|
+
return left.ino !== 0n && left.dev === right.dev && left.ino === right.ino && left.birthtimeNs === right.birthtimeNs;
|
|
2790
|
+
}
|
|
2778
2791
|
|
|
2779
2792
|
// dist/native/runtimeCache.js
|
|
2780
2793
|
import { createHash, randomBytes } from "node:crypto";
|
|
2781
|
-
import
|
|
2794
|
+
import fs3 from "node:fs";
|
|
2782
2795
|
import path3 from "node:path";
|
|
2783
2796
|
var CACHE_SCHEMA_VERSION = 1;
|
|
2784
2797
|
var HASH_BUFFER_SIZE = 1024 * 1024;
|
|
2798
|
+
var IDENTITY_FILE_PREFIX = "identity-";
|
|
2799
|
+
var IDENTITY_FILE_SUFFIX = ".json";
|
|
2800
|
+
var IDENTITY_VERSION = 1;
|
|
2801
|
+
var IDENTITY_REVERIFY_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
2802
|
+
var ABANDONED_ENTRY_RETENTION_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
2785
2803
|
function asError(error) {
|
|
2786
2804
|
return error instanceof Error ? error : new Error(String(error));
|
|
2787
2805
|
}
|
|
@@ -2798,12 +2816,12 @@ function assertSafeCacheSegment(value, label) {
|
|
|
2798
2816
|
}
|
|
2799
2817
|
}
|
|
2800
2818
|
function assertSafePathComponent(componentPath) {
|
|
2801
|
-
const stats =
|
|
2819
|
+
const stats = fs3.lstatSync(componentPath);
|
|
2802
2820
|
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
2803
2821
|
throw new Error(`unsafe native cache path component: ${componentPath}`);
|
|
2804
2822
|
}
|
|
2805
2823
|
}
|
|
2806
|
-
function prepareSafeDirectory(directoryPath) {
|
|
2824
|
+
function prepareSafeDirectory(directoryPath, create = true) {
|
|
2807
2825
|
const absolute = path3.resolve(directoryPath);
|
|
2808
2826
|
const parsed = path3.parse(absolute);
|
|
2809
2827
|
let current = parsed.root;
|
|
@@ -2814,11 +2832,11 @@ function prepareSafeDirectory(directoryPath) {
|
|
|
2814
2832
|
try {
|
|
2815
2833
|
assertSafePathComponent(current);
|
|
2816
2834
|
} catch (error) {
|
|
2817
|
-
if (error.code !== "ENOENT") {
|
|
2835
|
+
if (error.code !== "ENOENT" || !create) {
|
|
2818
2836
|
throw error;
|
|
2819
2837
|
}
|
|
2820
2838
|
try {
|
|
2821
|
-
|
|
2839
|
+
fs3.mkdirSync(current);
|
|
2822
2840
|
} catch (mkdirError) {
|
|
2823
2841
|
if (mkdirError.code !== "EEXIST")
|
|
2824
2842
|
throw mkdirError;
|
|
@@ -2826,27 +2844,33 @@ function prepareSafeDirectory(directoryPath) {
|
|
|
2826
2844
|
assertSafePathComponent(current);
|
|
2827
2845
|
}
|
|
2828
2846
|
}
|
|
2829
|
-
return
|
|
2847
|
+
return fs3.realpathSync.native(absolute);
|
|
2830
2848
|
}
|
|
2831
|
-
function
|
|
2849
|
+
function findProductionCacheRoot() {
|
|
2832
2850
|
const localAppData = process.env.LOCALAPPDATA;
|
|
2833
|
-
if (!localAppData)
|
|
2851
|
+
if (!localAppData)
|
|
2852
|
+
return null;
|
|
2853
|
+
return path3.join(localAppData, "codegraph", "native-cache", `v${CACHE_SCHEMA_VERSION}`);
|
|
2854
|
+
}
|
|
2855
|
+
function resolveProductionCacheRoot() {
|
|
2856
|
+
const cacheRoot = findProductionCacheRoot();
|
|
2857
|
+
if (!cacheRoot) {
|
|
2834
2858
|
throw new Error("LOCALAPPDATA is unavailable; cannot prepare the Windows native runtime cache");
|
|
2835
2859
|
}
|
|
2836
|
-
return
|
|
2860
|
+
return cacheRoot;
|
|
2837
2861
|
}
|
|
2838
2862
|
function hashFileStreaming(filePath, onChunk) {
|
|
2839
|
-
const before =
|
|
2863
|
+
const before = fs3.statSync(filePath);
|
|
2840
2864
|
if (!before.isFile() || before.size <= 0) {
|
|
2841
2865
|
throw new Error(`native binary is not a non-empty regular file: ${filePath}`);
|
|
2842
2866
|
}
|
|
2843
2867
|
const hash = createHash("sha256");
|
|
2844
2868
|
const buffer = Buffer.allocUnsafe(HASH_BUFFER_SIZE);
|
|
2845
|
-
const descriptor =
|
|
2869
|
+
const descriptor = fs3.openSync(filePath, "r");
|
|
2846
2870
|
let size = 0;
|
|
2847
2871
|
try {
|
|
2848
2872
|
while (true) {
|
|
2849
|
-
const bytesRead =
|
|
2873
|
+
const bytesRead = fs3.readSync(descriptor, buffer, 0, buffer.length, null);
|
|
2850
2874
|
if (!bytesRead)
|
|
2851
2875
|
break;
|
|
2852
2876
|
hash.update(buffer.subarray(0, bytesRead));
|
|
@@ -2854,57 +2878,58 @@ function hashFileStreaming(filePath, onChunk) {
|
|
|
2854
2878
|
onChunk?.(bytesRead);
|
|
2855
2879
|
}
|
|
2856
2880
|
} finally {
|
|
2857
|
-
|
|
2881
|
+
fs3.closeSync(descriptor);
|
|
2858
2882
|
}
|
|
2859
|
-
|
|
2883
|
+
const after = fs3.statSync(filePath);
|
|
2884
|
+
if (!after.isFile() || size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs) {
|
|
2860
2885
|
throw new Error(`native binary changed while hashing: ${filePath}`);
|
|
2861
2886
|
}
|
|
2862
|
-
return { sha256: hash.digest("hex"), size };
|
|
2887
|
+
return { sha256: hash.digest("hex"), size, mtimeMs: before.mtimeMs };
|
|
2863
2888
|
}
|
|
2864
2889
|
function randomSuffix() {
|
|
2865
2890
|
return `${process.pid}.${randomBytes(8).toString("hex")}`;
|
|
2866
2891
|
}
|
|
2867
2892
|
function copyFileExclusive(sourcePath, destinationPath) {
|
|
2868
|
-
const source =
|
|
2893
|
+
const source = fs3.openSync(sourcePath, "r");
|
|
2869
2894
|
let destination;
|
|
2870
2895
|
const buffer = Buffer.allocUnsafe(HASH_BUFFER_SIZE);
|
|
2871
2896
|
try {
|
|
2872
|
-
destination =
|
|
2897
|
+
destination = fs3.openSync(destinationPath, "wx");
|
|
2873
2898
|
while (true) {
|
|
2874
|
-
const bytesRead =
|
|
2899
|
+
const bytesRead = fs3.readSync(source, buffer, 0, buffer.length, null);
|
|
2875
2900
|
if (!bytesRead)
|
|
2876
2901
|
break;
|
|
2877
2902
|
let written = 0;
|
|
2878
2903
|
while (written < bytesRead) {
|
|
2879
|
-
written +=
|
|
2904
|
+
written += fs3.writeSync(destination, buffer, written, bytesRead - written);
|
|
2880
2905
|
}
|
|
2881
2906
|
}
|
|
2882
|
-
|
|
2907
|
+
fs3.fsyncSync(destination);
|
|
2883
2908
|
} finally {
|
|
2884
2909
|
if (destination !== void 0)
|
|
2885
|
-
|
|
2886
|
-
|
|
2910
|
+
fs3.closeSync(destination);
|
|
2911
|
+
fs3.closeSync(source);
|
|
2887
2912
|
}
|
|
2888
2913
|
}
|
|
2889
2914
|
function removeRegularTemporaryFile(filePath) {
|
|
2890
2915
|
try {
|
|
2891
|
-
const stats =
|
|
2916
|
+
const stats = fs3.lstatSync(filePath);
|
|
2892
2917
|
if (stats.isFile() && !stats.isSymbolicLink())
|
|
2893
|
-
|
|
2918
|
+
fs3.unlinkSync(filePath);
|
|
2894
2919
|
} catch {
|
|
2895
2920
|
}
|
|
2896
2921
|
}
|
|
2897
2922
|
function verifyFile(filePath, expected) {
|
|
2898
2923
|
try {
|
|
2899
2924
|
const actual = hashFileStreaming(filePath);
|
|
2900
|
-
return actual.size === expected.size && actual.sha256 === expected.sha256;
|
|
2925
|
+
return actual.size === expected.size && actual.sha256 === expected.sha256 ? actual : null;
|
|
2901
2926
|
} catch {
|
|
2902
|
-
return
|
|
2927
|
+
return null;
|
|
2903
2928
|
}
|
|
2904
2929
|
}
|
|
2905
2930
|
function publishExclusive(temporaryPath, finalPath) {
|
|
2906
2931
|
try {
|
|
2907
|
-
|
|
2932
|
+
fs3.linkSync(temporaryPath, finalPath);
|
|
2908
2933
|
return true;
|
|
2909
2934
|
} catch (error) {
|
|
2910
2935
|
if (error.code === "EEXIST")
|
|
@@ -2929,21 +2954,21 @@ function populateBinary(sourcePath, finalPath, expected) {
|
|
|
2929
2954
|
}
|
|
2930
2955
|
function recoverCorruptFinal(finalPath) {
|
|
2931
2956
|
const recoveryPath = `${finalPath}.corrupt.${randomSuffix()}`;
|
|
2932
|
-
|
|
2957
|
+
fs3.renameSync(finalPath, recoveryPath);
|
|
2933
2958
|
}
|
|
2934
2959
|
function writeManifest(entryPath, manifest) {
|
|
2935
2960
|
const finalPath = path3.join(entryPath, "manifest.json");
|
|
2936
|
-
if (
|
|
2961
|
+
if (fs3.existsSync(finalPath))
|
|
2937
2962
|
return;
|
|
2938
2963
|
const temporaryPath = `${finalPath}.${randomSuffix()}.tmp`;
|
|
2939
2964
|
try {
|
|
2940
|
-
const descriptor =
|
|
2965
|
+
const descriptor = fs3.openSync(temporaryPath, "wx");
|
|
2941
2966
|
try {
|
|
2942
|
-
|
|
2967
|
+
fs3.writeFileSync(descriptor, `${JSON.stringify(manifest, null, 2)}
|
|
2943
2968
|
`, "utf8");
|
|
2944
|
-
|
|
2969
|
+
fs3.fsyncSync(descriptor);
|
|
2945
2970
|
} finally {
|
|
2946
|
-
|
|
2971
|
+
fs3.closeSync(descriptor);
|
|
2947
2972
|
}
|
|
2948
2973
|
publishExclusive(temporaryPath, finalPath);
|
|
2949
2974
|
} catch (error) {
|
|
@@ -2951,12 +2976,302 @@ function writeManifest(entryPath, manifest) {
|
|
|
2951
2976
|
throw error;
|
|
2952
2977
|
}
|
|
2953
2978
|
}
|
|
2979
|
+
function currentRuntimeStamp() {
|
|
2980
|
+
return { abi: process.versions.modules, platform: process.platform, arch: process.arch };
|
|
2981
|
+
}
|
|
2982
|
+
function identityFilePath(entryPath, sourcePath) {
|
|
2983
|
+
const sourceKey = createHash("sha256").update(sourcePath).digest("hex");
|
|
2984
|
+
return path3.join(entryPath, `${IDENTITY_FILE_PREFIX}${sourceKey}${IDENTITY_FILE_SUFFIX}`);
|
|
2985
|
+
}
|
|
2986
|
+
function isIdentityFileName(fileName) {
|
|
2987
|
+
return /^identity-[a-f0-9]{64}\.json$/.test(fileName);
|
|
2988
|
+
}
|
|
2989
|
+
function readCacheIdentityFile(filePath) {
|
|
2990
|
+
let parsed;
|
|
2991
|
+
try {
|
|
2992
|
+
parsed = JSON.parse(fs3.readFileSync(filePath, "utf8"));
|
|
2993
|
+
} catch {
|
|
2994
|
+
return null;
|
|
2995
|
+
}
|
|
2996
|
+
if (!parsed || typeof parsed !== "object")
|
|
2997
|
+
return null;
|
|
2998
|
+
const candidate = parsed;
|
|
2999
|
+
if (candidate.version !== IDENTITY_VERSION)
|
|
3000
|
+
return null;
|
|
3001
|
+
const numbers = [candidate.sourceSize, candidate.sourceMtimeMs, candidate.cachedSize, candidate.cachedMtimeMs];
|
|
3002
|
+
if (numbers.some((value) => typeof value !== "number" || !Number.isFinite(value)))
|
|
3003
|
+
return null;
|
|
3004
|
+
const strings = [
|
|
3005
|
+
candidate.sha256,
|
|
3006
|
+
candidate.cacheKey,
|
|
3007
|
+
candidate.sourcePath,
|
|
3008
|
+
candidate.loadedPath,
|
|
3009
|
+
candidate.verifiedAt
|
|
3010
|
+
];
|
|
3011
|
+
if (strings.some((value) => typeof value !== "string" || !value))
|
|
3012
|
+
return null;
|
|
3013
|
+
if (!Array.isArray(candidate.supportedLanguageIds))
|
|
3014
|
+
return null;
|
|
3015
|
+
if (candidate.supportedLanguageIds.some((value) => typeof value !== "string"))
|
|
3016
|
+
return null;
|
|
3017
|
+
const origin = candidate.origin;
|
|
3018
|
+
if (!origin || typeof origin !== "object" || origin.mode !== "cache" || typeof origin.packageName !== "string") {
|
|
3019
|
+
return null;
|
|
3020
|
+
}
|
|
3021
|
+
const runtime = candidate.runtime;
|
|
3022
|
+
if (!runtime || typeof runtime !== "object")
|
|
3023
|
+
return null;
|
|
3024
|
+
if (typeof runtime.abi !== "string" || typeof runtime.platform !== "string" || typeof runtime.arch !== "string") {
|
|
3025
|
+
return null;
|
|
3026
|
+
}
|
|
3027
|
+
return candidate;
|
|
3028
|
+
}
|
|
3029
|
+
function readCacheIdentity(entryPath, sourcePath) {
|
|
3030
|
+
return readCacheIdentityFile(identityFilePath(entryPath, sourcePath));
|
|
3031
|
+
}
|
|
3032
|
+
function latestCacheIdentityVerifiedAt(entryPath, now) {
|
|
3033
|
+
let fileNames;
|
|
3034
|
+
try {
|
|
3035
|
+
fileNames = fs3.readdirSync(entryPath);
|
|
3036
|
+
} catch {
|
|
3037
|
+
return Number.NaN;
|
|
3038
|
+
}
|
|
3039
|
+
let latest = Number.NaN;
|
|
3040
|
+
for (const fileName of fileNames) {
|
|
3041
|
+
if (!isIdentityFileName(fileName))
|
|
3042
|
+
continue;
|
|
3043
|
+
const identity = readCacheIdentityFile(path3.join(entryPath, fileName));
|
|
3044
|
+
const verifiedAt = identity ? Date.parse(identity.verifiedAt) : Number.NaN;
|
|
3045
|
+
if (!Number.isFinite(verifiedAt) || verifiedAt > now)
|
|
3046
|
+
continue;
|
|
3047
|
+
if (!Number.isFinite(latest) || verifiedAt > latest)
|
|
3048
|
+
latest = verifiedAt;
|
|
3049
|
+
}
|
|
3050
|
+
return latest;
|
|
3051
|
+
}
|
|
3052
|
+
function statOrNull(filePath) {
|
|
3053
|
+
try {
|
|
3054
|
+
const stats = fs3.statSync(filePath);
|
|
3055
|
+
return stats.isFile() ? stats : null;
|
|
3056
|
+
} catch {
|
|
3057
|
+
return null;
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
function lstatRegularFileOrNull(filePath) {
|
|
3061
|
+
try {
|
|
3062
|
+
const stats = fs3.lstatSync(filePath);
|
|
3063
|
+
return stats.isFile() && !stats.isSymbolicLink() ? stats : null;
|
|
3064
|
+
} catch {
|
|
3065
|
+
return null;
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
function isSafeExistingDirectory(directoryPath) {
|
|
3069
|
+
try {
|
|
3070
|
+
prepareSafeDirectory(directoryPath, false);
|
|
3071
|
+
return true;
|
|
3072
|
+
} catch {
|
|
3073
|
+
return false;
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
function pathsResolveEqual(left, right) {
|
|
3077
|
+
return path3.resolve(left) === path3.resolve(right);
|
|
3078
|
+
}
|
|
3079
|
+
function lookupNativeRuntimeCacheEntry(request) {
|
|
3080
|
+
try {
|
|
3081
|
+
assertSafeCacheSegment(request.target, "target");
|
|
3082
|
+
assertSafeCacheSegment(request.packageVersion, "package version");
|
|
3083
|
+
const cacheRoot = request.cacheRoot ?? findProductionCacheRoot();
|
|
3084
|
+
if (!cacheRoot)
|
|
3085
|
+
return null;
|
|
3086
|
+
const sourceRealPath = fs3.realpathSync.native(request.sourcePath);
|
|
3087
|
+
const sourceStats = statOrNull(sourceRealPath);
|
|
3088
|
+
if (!sourceStats)
|
|
3089
|
+
return null;
|
|
3090
|
+
const runtime = currentRuntimeStamp();
|
|
3091
|
+
const resolvedCacheRoot = path3.resolve(cacheRoot);
|
|
3092
|
+
const targetPath = path3.join(resolvedCacheRoot, request.target);
|
|
3093
|
+
if (!isSafeExistingDirectory(resolvedCacheRoot) || !isSafeExistingDirectory(targetPath))
|
|
3094
|
+
return null;
|
|
3095
|
+
const prefix = `${request.packageVersion}-`;
|
|
3096
|
+
let entryNames;
|
|
3097
|
+
try {
|
|
3098
|
+
entryNames = fs3.readdirSync(targetPath);
|
|
3099
|
+
} catch {
|
|
3100
|
+
return null;
|
|
3101
|
+
}
|
|
3102
|
+
const now = request.now ?? Date.now();
|
|
3103
|
+
for (const entryName of entryNames) {
|
|
3104
|
+
if (!entryName.startsWith(prefix))
|
|
3105
|
+
continue;
|
|
3106
|
+
const entryPath = path3.join(targetPath, entryName);
|
|
3107
|
+
if (!isSafeExistingDirectory(entryPath))
|
|
3108
|
+
continue;
|
|
3109
|
+
const identity = readCacheIdentity(entryPath, sourceRealPath);
|
|
3110
|
+
if (!identity)
|
|
3111
|
+
continue;
|
|
3112
|
+
const expectedEntryName = `${request.packageVersion}-${identity.sha256}`;
|
|
3113
|
+
const expectedCacheKey = `${request.packageName}@${request.packageVersion}:${request.target}:${identity.sha256}`;
|
|
3114
|
+
const loadedPath = path3.resolve(identity.loadedPath);
|
|
3115
|
+
if (entryName !== expectedEntryName || identity.cacheKey !== expectedCacheKey || identity.loadedPath !== loadedPath || path3.dirname(loadedPath) !== entryPath || path3.basename(loadedPath) !== path3.basename(sourceRealPath)) {
|
|
3116
|
+
continue;
|
|
3117
|
+
}
|
|
3118
|
+
if (identity.sourcePath !== sourceRealPath)
|
|
3119
|
+
continue;
|
|
3120
|
+
if (identity.sourceSize !== sourceStats.size || identity.sourceMtimeMs !== sourceStats.mtimeMs)
|
|
3121
|
+
continue;
|
|
3122
|
+
if (identity.origin.packageName !== request.packageName || identity.origin.packageVersion !== request.packageVersion || identity.origin.target !== request.target || identity.origin.sourcePath === void 0 || identity.origin.loadedPath === void 0 || !pathsResolveEqual(identity.origin.sourcePath, sourceRealPath) || !pathsResolveEqual(identity.origin.loadedPath, identity.loadedPath) || identity.origin.cacheKey !== identity.cacheKey || identity.origin.sha256 !== identity.sha256) {
|
|
3123
|
+
continue;
|
|
3124
|
+
}
|
|
3125
|
+
if (identity.runtime.abi !== runtime.abi || identity.runtime.platform !== runtime.platform || identity.runtime.arch !== runtime.arch) {
|
|
3126
|
+
continue;
|
|
3127
|
+
}
|
|
3128
|
+
const cachedStats = lstatRegularFileOrNull(identity.loadedPath);
|
|
3129
|
+
if (!cachedStats)
|
|
3130
|
+
continue;
|
|
3131
|
+
if (identity.cachedSize !== cachedStats.size || identity.cachedMtimeMs !== cachedStats.mtimeMs)
|
|
3132
|
+
continue;
|
|
3133
|
+
const verifiedAt = Date.parse(identity.verifiedAt);
|
|
3134
|
+
if (!Number.isFinite(verifiedAt) || verifiedAt > now || now - verifiedAt >= IDENTITY_REVERIFY_INTERVAL_MS) {
|
|
3135
|
+
continue;
|
|
3136
|
+
}
|
|
3137
|
+
if (!isWithinDirectory(identity.loadedPath, resolvedCacheRoot))
|
|
3138
|
+
continue;
|
|
3139
|
+
return { entryPath, identity, revalidateAt: verifiedAt + IDENTITY_REVERIFY_INTERVAL_MS };
|
|
3140
|
+
}
|
|
3141
|
+
return null;
|
|
3142
|
+
} catch {
|
|
3143
|
+
return null;
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3146
|
+
function recordNativeRuntimeCacheIdentity(identity) {
|
|
3147
|
+
try {
|
|
3148
|
+
const sourceStats = statOrNull(identity.sourcePath);
|
|
3149
|
+
const cachedStats = lstatRegularFileOrNull(identity.loadedPath);
|
|
3150
|
+
if (!sourceStats || !cachedStats || sourceStats.size !== identity.sourceSize || sourceStats.mtimeMs !== identity.sourceMtimeMs || cachedStats.size !== identity.cachedSize || cachedStats.mtimeMs !== identity.cachedMtimeMs) {
|
|
3151
|
+
return;
|
|
3152
|
+
}
|
|
3153
|
+
const entryPath = path3.dirname(identity.loadedPath);
|
|
3154
|
+
const record = {
|
|
3155
|
+
version: IDENTITY_VERSION,
|
|
3156
|
+
runtime: currentRuntimeStamp(),
|
|
3157
|
+
...identity
|
|
3158
|
+
};
|
|
3159
|
+
const finalPath = identityFilePath(entryPath, identity.sourcePath);
|
|
3160
|
+
const temporaryPath = `${finalPath}.${randomSuffix()}.tmp`;
|
|
3161
|
+
try {
|
|
3162
|
+
const descriptor = fs3.openSync(temporaryPath, "wx");
|
|
3163
|
+
try {
|
|
3164
|
+
fs3.writeFileSync(descriptor, `${JSON.stringify(record, null, 2)}
|
|
3165
|
+
`, "utf8");
|
|
3166
|
+
fs3.fsyncSync(descriptor);
|
|
3167
|
+
} finally {
|
|
3168
|
+
fs3.closeSync(descriptor);
|
|
3169
|
+
}
|
|
3170
|
+
fs3.renameSync(temporaryPath, finalPath);
|
|
3171
|
+
} catch {
|
|
3172
|
+
removeRegularTemporaryFile(temporaryPath);
|
|
3173
|
+
}
|
|
3174
|
+
} catch {
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
function readEntrySummary(entryPath, now) {
|
|
3178
|
+
let packageVersion = null;
|
|
3179
|
+
let sourceFileName = null;
|
|
3180
|
+
let cachedAtMs = null;
|
|
3181
|
+
try {
|
|
3182
|
+
const parsed = JSON.parse(fs3.readFileSync(path3.join(entryPath, "manifest.json"), "utf8"));
|
|
3183
|
+
if (parsed && typeof parsed === "object") {
|
|
3184
|
+
const manifest = parsed;
|
|
3185
|
+
if (typeof manifest.packageVersion === "string" && manifest.packageVersion) {
|
|
3186
|
+
packageVersion = manifest.packageVersion;
|
|
3187
|
+
}
|
|
3188
|
+
if (typeof manifest.sourceFileName === "string" && manifest.sourceFileName && path3.basename(manifest.sourceFileName) === manifest.sourceFileName) {
|
|
3189
|
+
sourceFileName = manifest.sourceFileName;
|
|
3190
|
+
}
|
|
3191
|
+
const cachedAt = typeof manifest.cachedAt === "string" ? Date.parse(manifest.cachedAt) : Number.NaN;
|
|
3192
|
+
if (Number.isFinite(cachedAt))
|
|
3193
|
+
cachedAtMs = cachedAt;
|
|
3194
|
+
}
|
|
3195
|
+
} catch {
|
|
3196
|
+
return null;
|
|
3197
|
+
}
|
|
3198
|
+
if (!packageVersion || !sourceFileName)
|
|
3199
|
+
return null;
|
|
3200
|
+
const verifiedAt = latestCacheIdentityVerifiedAt(entryPath, now);
|
|
3201
|
+
const lastUsedMs = Number.isFinite(verifiedAt) ? verifiedAt : cachedAtMs;
|
|
3202
|
+
if (lastUsedMs === null)
|
|
3203
|
+
return null;
|
|
3204
|
+
return { packageVersion, lastUsedMs, sourceFileName };
|
|
3205
|
+
}
|
|
3206
|
+
function removeAbandonedEntry(entryPath, sourceFileName) {
|
|
3207
|
+
const cachedBinaryPath = path3.join(entryPath, sourceFileName);
|
|
3208
|
+
if (!isWithinDirectory(cachedBinaryPath, entryPath) || path3.dirname(cachedBinaryPath) !== entryPath) {
|
|
3209
|
+
throw new Error("invalid native cache binary path");
|
|
3210
|
+
}
|
|
3211
|
+
const stats = fs3.lstatSync(cachedBinaryPath);
|
|
3212
|
+
if (!stats.isFile() || stats.isSymbolicLink())
|
|
3213
|
+
throw new Error("unsafe native cache binary");
|
|
3214
|
+
fs3.unlinkSync(cachedBinaryPath);
|
|
3215
|
+
fs3.rmSync(entryPath, { recursive: true, force: true });
|
|
3216
|
+
}
|
|
3217
|
+
function pruneAbandonedEntries(targetPath, cacheRoot, keepEntryPath, keepVersion, now) {
|
|
3218
|
+
let entryNames;
|
|
3219
|
+
try {
|
|
3220
|
+
entryNames = fs3.readdirSync(targetPath);
|
|
3221
|
+
} catch {
|
|
3222
|
+
return;
|
|
3223
|
+
}
|
|
3224
|
+
for (const entryName of entryNames) {
|
|
3225
|
+
const entryPath = path3.join(targetPath, entryName);
|
|
3226
|
+
if (entryPath === keepEntryPath)
|
|
3227
|
+
continue;
|
|
3228
|
+
if (!isWithinDirectory(entryPath, cacheRoot))
|
|
3229
|
+
continue;
|
|
3230
|
+
try {
|
|
3231
|
+
if (!fs3.lstatSync(entryPath).isDirectory())
|
|
3232
|
+
continue;
|
|
3233
|
+
} catch {
|
|
3234
|
+
continue;
|
|
3235
|
+
}
|
|
3236
|
+
const summary = readEntrySummary(entryPath, now);
|
|
3237
|
+
if (!summary || summary.packageVersion === keepVersion)
|
|
3238
|
+
continue;
|
|
3239
|
+
if (now - summary.lastUsedMs < ABANDONED_ENTRY_RETENTION_MS)
|
|
3240
|
+
continue;
|
|
3241
|
+
try {
|
|
3242
|
+
removeAbandonedEntry(entryPath, summary.sourceFileName);
|
|
3243
|
+
} catch {
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
2954
3247
|
function prepareNativeRuntimeCache(request) {
|
|
2955
3248
|
const sourcePath = path3.resolve(request.sourcePath);
|
|
2956
3249
|
try {
|
|
2957
3250
|
assertSafeCacheSegment(request.target, "target");
|
|
2958
3251
|
assertSafeCacheSegment(request.packageVersion, "package version");
|
|
2959
|
-
const
|
|
3252
|
+
const hit = lookupNativeRuntimeCacheEntry({
|
|
3253
|
+
sourcePath,
|
|
3254
|
+
packageName: request.packageName,
|
|
3255
|
+
packageVersion: request.packageVersion,
|
|
3256
|
+
target: request.target,
|
|
3257
|
+
...request.cacheRoot !== void 0 ? { cacheRoot: request.cacheRoot } : {},
|
|
3258
|
+
...request.now !== void 0 ? { now: request.now } : {}
|
|
3259
|
+
});
|
|
3260
|
+
if (hit) {
|
|
3261
|
+
return {
|
|
3262
|
+
status: "reused",
|
|
3263
|
+
sourcePath: hit.identity.sourcePath,
|
|
3264
|
+
loadedPath: hit.identity.loadedPath,
|
|
3265
|
+
cacheKey: hit.identity.cacheKey,
|
|
3266
|
+
sha256: hit.identity.sha256,
|
|
3267
|
+
sourceSize: hit.identity.sourceSize,
|
|
3268
|
+
sourceMtimeMs: hit.identity.sourceMtimeMs,
|
|
3269
|
+
cachedSize: hit.identity.cachedSize,
|
|
3270
|
+
cachedMtimeMs: hit.identity.cachedMtimeMs,
|
|
3271
|
+
verified: false
|
|
3272
|
+
};
|
|
3273
|
+
}
|
|
3274
|
+
const sourceRealPath = fs3.realpathSync.native(sourcePath);
|
|
2960
3275
|
const source = hashFileStreaming(sourceRealPath);
|
|
2961
3276
|
const cacheRoot = prepareSafeDirectory(request.cacheRoot ?? resolveProductionCacheRoot());
|
|
2962
3277
|
const targetPath = prepareSafeDirectory(path3.join(cacheRoot, request.target));
|
|
@@ -2971,12 +3286,13 @@ function prepareNativeRuntimeCache(request) {
|
|
|
2971
3286
|
const sourceFileName = path3.basename(sourceRealPath);
|
|
2972
3287
|
const finalPath = path3.join(entryPath, sourceFileName);
|
|
2973
3288
|
let status = "reused";
|
|
2974
|
-
|
|
2975
|
-
if (!
|
|
2976
|
-
if (
|
|
3289
|
+
let cached = fs3.existsSync(finalPath) ? verifyFile(finalPath, source) : null;
|
|
3290
|
+
if (!cached) {
|
|
3291
|
+
if (fs3.existsSync(finalPath))
|
|
2977
3292
|
recoverCorruptFinal(finalPath);
|
|
2978
3293
|
status = populateBinary(sourceRealPath, finalPath, source) ? "cached" : "reused";
|
|
2979
|
-
|
|
3294
|
+
cached = verifyFile(finalPath, source);
|
|
3295
|
+
if (!cached) {
|
|
2980
3296
|
throw new Error("native cache winner failed integrity verification");
|
|
2981
3297
|
}
|
|
2982
3298
|
}
|
|
@@ -2990,12 +3306,18 @@ function prepareNativeRuntimeCache(request) {
|
|
|
2990
3306
|
sourceSha256: source.sha256,
|
|
2991
3307
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2992
3308
|
});
|
|
3309
|
+
pruneAbandonedEntries(targetPath, cacheRoot, entryPath, request.packageVersion, request.now ?? Date.now());
|
|
2993
3310
|
return {
|
|
2994
3311
|
status,
|
|
2995
3312
|
sourcePath: sourceRealPath,
|
|
2996
3313
|
loadedPath: finalPath,
|
|
2997
3314
|
cacheKey,
|
|
2998
|
-
sha256: source.sha256
|
|
3315
|
+
sha256: source.sha256,
|
|
3316
|
+
sourceSize: source.size,
|
|
3317
|
+
sourceMtimeMs: source.mtimeMs,
|
|
3318
|
+
cachedSize: cached.size,
|
|
3319
|
+
cachedMtimeMs: cached.mtimeMs,
|
|
3320
|
+
verified: true
|
|
2999
3321
|
};
|
|
3000
3322
|
} catch (error) {
|
|
3001
3323
|
return { status: "unavailable", sourcePath, error: asError(error) };
|
|
@@ -3054,7 +3376,7 @@ function findLocalNativeBinary(packageRoot) {
|
|
|
3054
3376
|
}
|
|
3055
3377
|
const expectedName = `index.${suffix}.node`;
|
|
3056
3378
|
try {
|
|
3057
|
-
const entries =
|
|
3379
|
+
const entries = fs4.readdirSync(packageRoot, { withFileTypes: true });
|
|
3058
3380
|
const binary = entries.find((entry) => entry.isFile() && entry.name === expectedName);
|
|
3059
3381
|
return binary ? path4.join(packageRoot, binary.name) : null;
|
|
3060
3382
|
} catch {
|
|
@@ -3068,13 +3390,13 @@ function readPlatformPackage(packageName, target, resolveFn) {
|
|
|
3068
3390
|
if (path4.basename(resolvedEntry) !== expectedFileName) {
|
|
3069
3391
|
throw new Error(`unexpected native platform entry for ${platformPackageName}: ${resolvedEntry}`);
|
|
3070
3392
|
}
|
|
3071
|
-
const sourcePath =
|
|
3072
|
-
const stats =
|
|
3393
|
+
const sourcePath = fs4.realpathSync.native(resolvedEntry);
|
|
3394
|
+
const stats = fs4.statSync(sourcePath);
|
|
3073
3395
|
if (!stats.isFile() || stats.size <= 0) {
|
|
3074
3396
|
throw new Error(`native platform entry is not a non-empty regular file: ${sourcePath}`);
|
|
3075
3397
|
}
|
|
3076
3398
|
const packageJsonPath = path4.join(path4.dirname(sourcePath), "package.json");
|
|
3077
|
-
const parsed = JSON.parse(
|
|
3399
|
+
const parsed = JSON.parse(fs4.readFileSync(packageJsonPath, "utf8"));
|
|
3078
3400
|
if (parsed.name !== platformPackageName || !parsed.version) {
|
|
3079
3401
|
throw new Error(`invalid native platform package metadata: ${packageJsonPath}`);
|
|
3080
3402
|
}
|
|
@@ -3160,6 +3482,17 @@ function loadNativeBinding(options) {
|
|
|
3160
3482
|
loadedPath: normalizePath(cached.loadedPath),
|
|
3161
3483
|
cacheKey: cached.cacheKey,
|
|
3162
3484
|
sha256: cached.sha256
|
|
3485
|
+
},
|
|
3486
|
+
cacheEntry: {
|
|
3487
|
+
sourcePath: cached.sourcePath,
|
|
3488
|
+
loadedPath: cached.loadedPath,
|
|
3489
|
+
cacheKey: cached.cacheKey,
|
|
3490
|
+
sha256: cached.sha256,
|
|
3491
|
+
sourceSize: cached.sourceSize,
|
|
3492
|
+
sourceMtimeMs: cached.sourceMtimeMs,
|
|
3493
|
+
cachedSize: cached.cachedSize,
|
|
3494
|
+
cachedMtimeMs: cached.cachedMtimeMs,
|
|
3495
|
+
verified: cached.verified
|
|
3163
3496
|
}
|
|
3164
3497
|
};
|
|
3165
3498
|
} catch (error) {
|
|
@@ -3202,6 +3535,7 @@ var require2 = createRequire(import.meta.url);
|
|
|
3202
3535
|
var localNativePackageRoot = path5.resolve(path5.dirname(fileURLToPath(import.meta.url)), "../../packages/codegraph-native");
|
|
3203
3536
|
var NATIVE_REQUIRED_ERROR_PREFIX = "native tree-sitter required by explicit option but unavailable";
|
|
3204
3537
|
var bindingState;
|
|
3538
|
+
var cachedRuntimeFingerprints = /* @__PURE__ */ new Map();
|
|
3205
3539
|
function isNativeTreeSitterDisabledByEnv(env = process.env) {
|
|
3206
3540
|
const rawValue = env.CODEGRAPH_DISABLE_NATIVE;
|
|
3207
3541
|
if (typeof rawValue !== "string") {
|
|
@@ -3216,6 +3550,7 @@ function normalizeNativeRuntimeMode(mode) {
|
|
|
3216
3550
|
function loadBinding() {
|
|
3217
3551
|
if (bindingState)
|
|
3218
3552
|
return bindingState;
|
|
3553
|
+
cachedRuntimeFingerprints.clear();
|
|
3219
3554
|
const loaded = loadNativeBinding({
|
|
3220
3555
|
packageName: "@lzehrung/codegraph-native",
|
|
3221
3556
|
localPackageRoot: localNativePackageRoot,
|
|
@@ -3223,12 +3558,28 @@ function loadBinding() {
|
|
|
3223
3558
|
resolveFn: require2.resolve
|
|
3224
3559
|
});
|
|
3225
3560
|
if (loaded.binding) {
|
|
3561
|
+
const supportedLanguageIds = new Set(loaded.binding.supportedLanguageIds());
|
|
3226
3562
|
bindingState = {
|
|
3227
3563
|
loaded: true,
|
|
3228
3564
|
binding: loaded.binding,
|
|
3229
|
-
supportedLanguageIds
|
|
3565
|
+
supportedLanguageIds,
|
|
3230
3566
|
origin: loaded.origin
|
|
3231
3567
|
};
|
|
3568
|
+
if (loaded.cacheEntry?.verified) {
|
|
3569
|
+
recordNativeRuntimeCacheIdentity({
|
|
3570
|
+
sourcePath: loaded.cacheEntry.sourcePath,
|
|
3571
|
+
loadedPath: loaded.cacheEntry.loadedPath,
|
|
3572
|
+
cacheKey: loaded.cacheEntry.cacheKey,
|
|
3573
|
+
sha256: loaded.cacheEntry.sha256,
|
|
3574
|
+
sourceSize: loaded.cacheEntry.sourceSize,
|
|
3575
|
+
sourceMtimeMs: loaded.cacheEntry.sourceMtimeMs,
|
|
3576
|
+
cachedSize: loaded.cacheEntry.cachedSize,
|
|
3577
|
+
cachedMtimeMs: loaded.cacheEntry.cachedMtimeMs,
|
|
3578
|
+
verifiedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3579
|
+
supportedLanguageIds: Array.from(supportedLanguageIds).sort(),
|
|
3580
|
+
origin: loaded.origin
|
|
3581
|
+
});
|
|
3582
|
+
}
|
|
3232
3583
|
return bindingState;
|
|
3233
3584
|
}
|
|
3234
3585
|
bindingState = {
|
|
@@ -3841,7 +4192,7 @@ function compressQueryText(text) {
|
|
|
3841
4192
|
});
|
|
3842
4193
|
}
|
|
3843
4194
|
function normalizeQuerySearchText(input) {
|
|
3844
|
-
return input.replace(/([
|
|
4195
|
+
return input.replace(/([\p{Ll}\p{Nd}])(\p{Lu})/gu, "$1 $2").replace(/(\p{Lu}+)(\p{Lu}\p{Ll})/gu, "$1 $2").toLowerCase().replace(/[^\p{L}\p{N}\p{M}_]+/gu, " ").trim();
|
|
3845
4196
|
}
|
|
3846
4197
|
function detectQueryIndexSurface(relativePath) {
|
|
3847
4198
|
const lower = relativePath.toLowerCase();
|
|
@@ -3891,7 +4242,7 @@ function buildQueryTextChunks(file, text) {
|
|
|
3891
4242
|
}
|
|
3892
4243
|
async function prepareQueryIndexFile(input) {
|
|
3893
4244
|
try {
|
|
3894
|
-
const stat = await
|
|
4245
|
+
const stat = await fs6.stat(input.absolutePath);
|
|
3895
4246
|
const support = supportForFile(input.absolutePath);
|
|
3896
4247
|
if (stat.size > MAX_QUERY_INDEX_TEXT_BYTES) {
|
|
3897
4248
|
return {
|
|
@@ -3906,7 +4257,7 @@ async function prepareQueryIndexFile(input) {
|
|
|
3906
4257
|
sourceRead: false
|
|
3907
4258
|
};
|
|
3908
4259
|
}
|
|
3909
|
-
const text = await
|
|
4260
|
+
const text = await fs6.readFile(input.absolutePath, "utf8");
|
|
3910
4261
|
return {
|
|
3911
4262
|
path: input.path,
|
|
3912
4263
|
sourceIdentity: input.sourceIdentity,
|