@lzehrung/codegraph 2.1.2 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/codegraph-skill/codegraph/SKILL.md +21 -2
- package/dist/agent/explore.d.ts.map +1 -1
- package/dist/agent/explore.js +6 -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 +0 -16
- package/dist/agent/orient.js.map +1 -1
- package/dist/agent/query-index/store.d.ts +2 -0
- package/dist/agent/query-index/store.d.ts.map +1 -1
- package/dist/agent/query-index/store.js +4 -0
- package/dist/agent/query-index/store.js.map +1 -1
- package/dist/agent/session.js +3 -3
- package/dist/agent/session.js.map +1 -1
- package/dist/bin/cli.js +7306 -5661
- package/dist/bin/queryIndexWorker.js +357 -54
- package/dist/chunking/chunkSplit.js +0 -15
- package/dist/chunking/chunkSplit.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 +17 -0
- 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/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/options.d.ts +1 -1
- package/dist/cli/options.d.ts.map +1 -1
- package/dist/cli/options.js +31 -1
- package/dist/cli/options.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.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/documentLinks/check.d.ts.map +1 -1
- package/dist/documentLinks/check.js +4 -3
- 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/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 +2 -3
- package/dist/duplicates/units.js.map +1 -1
- package/dist/duplicates.d.ts.map +1 -1
- package/dist/duplicates.js +0 -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.map +1 -1
- package/dist/graphs/symbol-graph-detailed.js +0 -1
- package/dist/graphs/symbol-graph-detailed.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/module-cache.d.ts.map +1 -1
- package/dist/indexer/build-cache/module-cache.js +1 -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 +9 -1
- package/dist/indexer/build-cache/project-snapshot.d.ts.map +1 -1
- package/dist/indexer/build-cache/project-snapshot.js +1 -5
- package/dist/indexer/build-cache/project-snapshot.js.map +1 -1
- package/dist/indexer/build-index.d.ts.map +1 -1
- package/dist/indexer/build-index.js +59 -44
- package/dist/indexer/build-index.js.map +1 -1
- package/dist/indexer/build-workers.d.ts +29 -2
- package/dist/indexer/build-workers.d.ts.map +1 -1
- package/dist/indexer/build-workers.js +54 -3
- package/dist/indexer/build-workers.js.map +1 -1
- package/dist/indexer/call-hierarchy.d.ts.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/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 +2 -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 +1 -1
- package/dist/indexer/navigation-references.js.map +1 -1
- package/dist/indexer/navigation.d.ts.map +1 -1
- package/dist/indexer/navigation.js +2 -4
- package/dist/indexer/navigation.js.map +1 -1
- package/dist/indexer/parse-context.d.ts +1 -4
- package/dist/indexer/parse-context.d.ts.map +1 -1
- package/dist/indexer/parse-context.js +11 -6
- 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.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/registry.js +1 -27
- 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 -306
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +13 -1609
- package/dist/mcp/server.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/deleted.js +2 -2
- package/dist/review/deleted.js.map +1 -1
- 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/util/lazySymbols.js +1 -1
- package/dist/util/lazySymbols.js.map +1 -1
- package/dist/util/projectFiles.js +1 -1
- package/dist/util/projectFiles.js.map +1 -1
- package/dist/util/resolution/jvm.js +1 -1
- 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.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 +10 -4
- package/dist/worker/nativeExtractWorker.d.ts.map +1 -1
- package/dist/worker/nativeExtractWorker.js +55 -3
- 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 +16 -2
- 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";
|
|
@@ -2830,6 +2795,11 @@ import fs3 from "node:fs";
|
|
|
2830
2795
|
import path3 from "node:path";
|
|
2831
2796
|
var CACHE_SCHEMA_VERSION = 1;
|
|
2832
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;
|
|
2833
2803
|
function asError(error) {
|
|
2834
2804
|
return error instanceof Error ? error : new Error(String(error));
|
|
2835
2805
|
}
|
|
@@ -2851,7 +2821,7 @@ function assertSafePathComponent(componentPath) {
|
|
|
2851
2821
|
throw new Error(`unsafe native cache path component: ${componentPath}`);
|
|
2852
2822
|
}
|
|
2853
2823
|
}
|
|
2854
|
-
function prepareSafeDirectory(directoryPath) {
|
|
2824
|
+
function prepareSafeDirectory(directoryPath, create = true) {
|
|
2855
2825
|
const absolute = path3.resolve(directoryPath);
|
|
2856
2826
|
const parsed = path3.parse(absolute);
|
|
2857
2827
|
let current = parsed.root;
|
|
@@ -2862,7 +2832,7 @@ function prepareSafeDirectory(directoryPath) {
|
|
|
2862
2832
|
try {
|
|
2863
2833
|
assertSafePathComponent(current);
|
|
2864
2834
|
} catch (error) {
|
|
2865
|
-
if (error.code !== "ENOENT") {
|
|
2835
|
+
if (error.code !== "ENOENT" || !create) {
|
|
2866
2836
|
throw error;
|
|
2867
2837
|
}
|
|
2868
2838
|
try {
|
|
@@ -2876,12 +2846,18 @@ function prepareSafeDirectory(directoryPath) {
|
|
|
2876
2846
|
}
|
|
2877
2847
|
return fs3.realpathSync.native(absolute);
|
|
2878
2848
|
}
|
|
2879
|
-
function
|
|
2849
|
+
function findProductionCacheRoot() {
|
|
2880
2850
|
const localAppData = process.env.LOCALAPPDATA;
|
|
2881
|
-
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) {
|
|
2882
2858
|
throw new Error("LOCALAPPDATA is unavailable; cannot prepare the Windows native runtime cache");
|
|
2883
2859
|
}
|
|
2884
|
-
return
|
|
2860
|
+
return cacheRoot;
|
|
2885
2861
|
}
|
|
2886
2862
|
function hashFileStreaming(filePath, onChunk) {
|
|
2887
2863
|
const before = fs3.statSync(filePath);
|
|
@@ -2904,10 +2880,11 @@ function hashFileStreaming(filePath, onChunk) {
|
|
|
2904
2880
|
} finally {
|
|
2905
2881
|
fs3.closeSync(descriptor);
|
|
2906
2882
|
}
|
|
2907
|
-
|
|
2883
|
+
const after = fs3.statSync(filePath);
|
|
2884
|
+
if (!after.isFile() || size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs) {
|
|
2908
2885
|
throw new Error(`native binary changed while hashing: ${filePath}`);
|
|
2909
2886
|
}
|
|
2910
|
-
return { sha256: hash.digest("hex"), size };
|
|
2887
|
+
return { sha256: hash.digest("hex"), size, mtimeMs: before.mtimeMs };
|
|
2911
2888
|
}
|
|
2912
2889
|
function randomSuffix() {
|
|
2913
2890
|
return `${process.pid}.${randomBytes(8).toString("hex")}`;
|
|
@@ -2945,9 +2922,9 @@ function removeRegularTemporaryFile(filePath) {
|
|
|
2945
2922
|
function verifyFile(filePath, expected) {
|
|
2946
2923
|
try {
|
|
2947
2924
|
const actual = hashFileStreaming(filePath);
|
|
2948
|
-
return actual.size === expected.size && actual.sha256 === expected.sha256;
|
|
2925
|
+
return actual.size === expected.size && actual.sha256 === expected.sha256 ? actual : null;
|
|
2949
2926
|
} catch {
|
|
2950
|
-
return
|
|
2927
|
+
return null;
|
|
2951
2928
|
}
|
|
2952
2929
|
}
|
|
2953
2930
|
function publishExclusive(temporaryPath, finalPath) {
|
|
@@ -2999,11 +2976,301 @@ function writeManifest(entryPath, manifest) {
|
|
|
2999
2976
|
throw error;
|
|
3000
2977
|
}
|
|
3001
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
|
+
}
|
|
3002
3247
|
function prepareNativeRuntimeCache(request) {
|
|
3003
3248
|
const sourcePath = path3.resolve(request.sourcePath);
|
|
3004
3249
|
try {
|
|
3005
3250
|
assertSafeCacheSegment(request.target, "target");
|
|
3006
3251
|
assertSafeCacheSegment(request.packageVersion, "package version");
|
|
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
|
+
}
|
|
3007
3274
|
const sourceRealPath = fs3.realpathSync.native(sourcePath);
|
|
3008
3275
|
const source = hashFileStreaming(sourceRealPath);
|
|
3009
3276
|
const cacheRoot = prepareSafeDirectory(request.cacheRoot ?? resolveProductionCacheRoot());
|
|
@@ -3019,12 +3286,13 @@ function prepareNativeRuntimeCache(request) {
|
|
|
3019
3286
|
const sourceFileName = path3.basename(sourceRealPath);
|
|
3020
3287
|
const finalPath = path3.join(entryPath, sourceFileName);
|
|
3021
3288
|
let status = "reused";
|
|
3022
|
-
|
|
3023
|
-
if (!
|
|
3024
|
-
if (
|
|
3289
|
+
let cached = fs3.existsSync(finalPath) ? verifyFile(finalPath, source) : null;
|
|
3290
|
+
if (!cached) {
|
|
3291
|
+
if (fs3.existsSync(finalPath))
|
|
3025
3292
|
recoverCorruptFinal(finalPath);
|
|
3026
3293
|
status = populateBinary(sourceRealPath, finalPath, source) ? "cached" : "reused";
|
|
3027
|
-
|
|
3294
|
+
cached = verifyFile(finalPath, source);
|
|
3295
|
+
if (!cached) {
|
|
3028
3296
|
throw new Error("native cache winner failed integrity verification");
|
|
3029
3297
|
}
|
|
3030
3298
|
}
|
|
@@ -3038,12 +3306,18 @@ function prepareNativeRuntimeCache(request) {
|
|
|
3038
3306
|
sourceSha256: source.sha256,
|
|
3039
3307
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3040
3308
|
});
|
|
3309
|
+
pruneAbandonedEntries(targetPath, cacheRoot, entryPath, request.packageVersion, request.now ?? Date.now());
|
|
3041
3310
|
return {
|
|
3042
3311
|
status,
|
|
3043
3312
|
sourcePath: sourceRealPath,
|
|
3044
3313
|
loadedPath: finalPath,
|
|
3045
3314
|
cacheKey,
|
|
3046
|
-
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
|
|
3047
3321
|
};
|
|
3048
3322
|
} catch (error) {
|
|
3049
3323
|
return { status: "unavailable", sourcePath, error: asError(error) };
|
|
@@ -3208,6 +3482,17 @@ function loadNativeBinding(options) {
|
|
|
3208
3482
|
loadedPath: normalizePath(cached.loadedPath),
|
|
3209
3483
|
cacheKey: cached.cacheKey,
|
|
3210
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
|
|
3211
3496
|
}
|
|
3212
3497
|
};
|
|
3213
3498
|
} catch (error) {
|
|
@@ -3250,6 +3535,7 @@ var require2 = createRequire(import.meta.url);
|
|
|
3250
3535
|
var localNativePackageRoot = path5.resolve(path5.dirname(fileURLToPath(import.meta.url)), "../../packages/codegraph-native");
|
|
3251
3536
|
var NATIVE_REQUIRED_ERROR_PREFIX = "native tree-sitter required by explicit option but unavailable";
|
|
3252
3537
|
var bindingState;
|
|
3538
|
+
var cachedRuntimeFingerprints = /* @__PURE__ */ new Map();
|
|
3253
3539
|
function isNativeTreeSitterDisabledByEnv(env = process.env) {
|
|
3254
3540
|
const rawValue = env.CODEGRAPH_DISABLE_NATIVE;
|
|
3255
3541
|
if (typeof rawValue !== "string") {
|
|
@@ -3264,6 +3550,7 @@ function normalizeNativeRuntimeMode(mode) {
|
|
|
3264
3550
|
function loadBinding() {
|
|
3265
3551
|
if (bindingState)
|
|
3266
3552
|
return bindingState;
|
|
3553
|
+
cachedRuntimeFingerprints.clear();
|
|
3267
3554
|
const loaded = loadNativeBinding({
|
|
3268
3555
|
packageName: "@lzehrung/codegraph-native",
|
|
3269
3556
|
localPackageRoot: localNativePackageRoot,
|
|
@@ -3271,12 +3558,28 @@ function loadBinding() {
|
|
|
3271
3558
|
resolveFn: require2.resolve
|
|
3272
3559
|
});
|
|
3273
3560
|
if (loaded.binding) {
|
|
3561
|
+
const supportedLanguageIds = new Set(loaded.binding.supportedLanguageIds());
|
|
3274
3562
|
bindingState = {
|
|
3275
3563
|
loaded: true,
|
|
3276
3564
|
binding: loaded.binding,
|
|
3277
|
-
supportedLanguageIds
|
|
3565
|
+
supportedLanguageIds,
|
|
3278
3566
|
origin: loaded.origin
|
|
3279
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
|
+
}
|
|
3280
3583
|
return bindingState;
|
|
3281
3584
|
}
|
|
3282
3585
|
bindingState = {
|
|
@@ -3939,7 +4242,7 @@ function buildQueryTextChunks(file, text) {
|
|
|
3939
4242
|
}
|
|
3940
4243
|
async function prepareQueryIndexFile(input) {
|
|
3941
4244
|
try {
|
|
3942
|
-
const stat = await
|
|
4245
|
+
const stat = await fs6.stat(input.absolutePath);
|
|
3943
4246
|
const support = supportForFile(input.absolutePath);
|
|
3944
4247
|
if (stat.size > MAX_QUERY_INDEX_TEXT_BYTES) {
|
|
3945
4248
|
return {
|
|
@@ -3954,7 +4257,7 @@ async function prepareQueryIndexFile(input) {
|
|
|
3954
4257
|
sourceRead: false
|
|
3955
4258
|
};
|
|
3956
4259
|
}
|
|
3957
|
-
const text = await
|
|
4260
|
+
const text = await fs6.readFile(input.absolutePath, "utf8");
|
|
3958
4261
|
return {
|
|
3959
4262
|
path: input.path,
|
|
3960
4263
|
sourceIdentity: input.sourceIdentity,
|