@colbymchenry/codegraph-darwin-x64 0.9.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dist/bin/codegraph.d.ts +1 -0
- package/lib/dist/bin/codegraph.d.ts.map +1 -1
- package/lib/dist/bin/codegraph.js +247 -39
- package/lib/dist/bin/codegraph.js.map +1 -1
- package/lib/dist/context/index.d.ts +9 -0
- package/lib/dist/context/index.d.ts.map +1 -1
- package/lib/dist/context/index.js +102 -6
- package/lib/dist/context/index.js.map +1 -1
- package/lib/dist/context/markers.d.ts +19 -0
- package/lib/dist/context/markers.d.ts.map +1 -0
- package/lib/dist/context/markers.js +22 -0
- package/lib/dist/context/markers.js.map +1 -0
- package/lib/dist/db/index.d.ts.map +1 -1
- package/lib/dist/db/index.js +2 -1
- package/lib/dist/db/index.js.map +1 -1
- package/lib/dist/db/migrations.d.ts +1 -1
- package/lib/dist/db/migrations.d.ts.map +1 -1
- package/lib/dist/db/migrations.js +10 -1
- package/lib/dist/db/migrations.js.map +1 -1
- package/lib/dist/db/queries.d.ts +43 -0
- package/lib/dist/db/queries.d.ts.map +1 -1
- package/lib/dist/db/queries.js +103 -7
- package/lib/dist/db/queries.js.map +1 -1
- package/lib/dist/db/schema.sql +1 -0
- package/lib/dist/db/sqlite-adapter.d.ts +7 -0
- package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
- package/lib/dist/db/sqlite-adapter.js +3 -0
- package/lib/dist/db/sqlite-adapter.js.map +1 -1
- package/lib/dist/directory.d.ts +34 -2
- package/lib/dist/directory.d.ts.map +1 -1
- package/lib/dist/directory.js +129 -35
- package/lib/dist/directory.js.map +1 -1
- package/lib/dist/extraction/astro-extractor.d.ts +79 -0
- package/lib/dist/extraction/astro-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/astro-extractor.js +320 -0
- package/lib/dist/extraction/astro-extractor.js.map +1 -0
- package/lib/dist/extraction/extraction-version.d.ts +25 -0
- package/lib/dist/extraction/extraction-version.d.ts.map +1 -0
- package/lib/dist/extraction/extraction-version.js +28 -0
- package/lib/dist/extraction/extraction-version.js.map +1 -0
- package/lib/dist/extraction/function-ref.d.ts +118 -0
- package/lib/dist/extraction/function-ref.d.ts.map +1 -0
- package/lib/dist/extraction/function-ref.js +727 -0
- package/lib/dist/extraction/function-ref.js.map +1 -0
- package/lib/dist/extraction/generated-detection.d.ts.map +1 -1
- package/lib/dist/extraction/generated-detection.js +3 -0
- package/lib/dist/extraction/generated-detection.js.map +1 -1
- package/lib/dist/extraction/grammars.d.ts +7 -1
- package/lib/dist/extraction/grammars.d.ts.map +1 -1
- package/lib/dist/extraction/grammars.js +52 -4
- package/lib/dist/extraction/grammars.js.map +1 -1
- package/lib/dist/extraction/index.d.ts +34 -0
- package/lib/dist/extraction/index.d.ts.map +1 -1
- package/lib/dist/extraction/index.js +346 -62
- package/lib/dist/extraction/index.js.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.d.ts +8 -0
- package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.js +87 -28
- package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
- package/lib/dist/extraction/languages/csharp.d.ts +22 -0
- package/lib/dist/extraction/languages/csharp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/csharp.js +84 -2
- package/lib/dist/extraction/languages/csharp.js.map +1 -1
- package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
- package/lib/dist/extraction/languages/dart.js +161 -1
- package/lib/dist/extraction/languages/dart.js.map +1 -1
- package/lib/dist/extraction/languages/go.d.ts.map +1 -1
- package/lib/dist/extraction/languages/go.js +43 -2
- package/lib/dist/extraction/languages/go.js.map +1 -1
- package/lib/dist/extraction/languages/index.d.ts.map +1 -1
- package/lib/dist/extraction/languages/index.js +2 -0
- package/lib/dist/extraction/languages/index.js.map +1 -1
- package/lib/dist/extraction/languages/java.d.ts.map +1 -1
- package/lib/dist/extraction/languages/java.js +42 -1
- package/lib/dist/extraction/languages/java.js.map +1 -1
- package/lib/dist/extraction/languages/javascript.d.ts.map +1 -1
- package/lib/dist/extraction/languages/javascript.js +16 -0
- package/lib/dist/extraction/languages/javascript.js.map +1 -1
- package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
- package/lib/dist/extraction/languages/kotlin.js +69 -0
- package/lib/dist/extraction/languages/kotlin.js.map +1 -1
- package/lib/dist/extraction/languages/objc.d.ts.map +1 -1
- package/lib/dist/extraction/languages/objc.js +42 -0
- package/lib/dist/extraction/languages/objc.js.map +1 -1
- package/lib/dist/extraction/languages/pascal.d.ts.map +1 -1
- package/lib/dist/extraction/languages/pascal.js +11 -0
- package/lib/dist/extraction/languages/pascal.js.map +1 -1
- package/lib/dist/extraction/languages/php.d.ts.map +1 -1
- package/lib/dist/extraction/languages/php.js +90 -1
- package/lib/dist/extraction/languages/php.js.map +1 -1
- package/lib/dist/extraction/languages/r.d.ts +3 -0
- package/lib/dist/extraction/languages/r.d.ts.map +1 -0
- package/lib/dist/extraction/languages/r.js +314 -0
- package/lib/dist/extraction/languages/r.js.map +1 -0
- package/lib/dist/extraction/languages/ruby.d.ts.map +1 -1
- package/lib/dist/extraction/languages/ruby.js +35 -0
- package/lib/dist/extraction/languages/ruby.js.map +1 -1
- package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
- package/lib/dist/extraction/languages/rust.js +35 -2
- package/lib/dist/extraction/languages/rust.js.map +1 -1
- package/lib/dist/extraction/languages/scala.d.ts.map +1 -1
- package/lib/dist/extraction/languages/scala.js +61 -1
- package/lib/dist/extraction/languages/scala.js.map +1 -1
- package/lib/dist/extraction/languages/swift.d.ts.map +1 -1
- package/lib/dist/extraction/languages/swift.js +61 -0
- package/lib/dist/extraction/languages/swift.js.map +1 -1
- package/lib/dist/extraction/languages/typescript.d.ts +13 -0
- package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
- package/lib/dist/extraction/languages/typescript.js +38 -0
- package/lib/dist/extraction/languages/typescript.js.map +1 -1
- package/lib/dist/extraction/liquid-extractor.d.ts +7 -0
- package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/liquid-extractor.js +53 -9
- package/lib/dist/extraction/liquid-extractor.js.map +1 -1
- package/lib/dist/extraction/razor-extractor.d.ts +42 -0
- package/lib/dist/extraction/razor-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/razor-extractor.js +285 -0
- package/lib/dist/extraction/razor-extractor.js.map +1 -0
- package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/svelte-extractor.js +6 -3
- package/lib/dist/extraction/svelte-extractor.js.map +1 -1
- package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter-helpers.js +59 -10
- package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
- package/lib/dist/extraction/tree-sitter-types.d.ts +33 -0
- package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.d.ts +237 -0
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.js +1820 -68
- package/lib/dist/extraction/tree-sitter.js.map +1 -1
- package/lib/dist/extraction/vue-extractor.d.ts +15 -0
- package/lib/dist/extraction/vue-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/vue-extractor.js +94 -3
- package/lib/dist/extraction/vue-extractor.js.map +1 -1
- package/lib/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
- package/lib/dist/graph/queries.d.ts.map +1 -1
- package/lib/dist/graph/queries.js +13 -40
- package/lib/dist/graph/queries.js.map +1 -1
- package/lib/dist/graph/traversal.d.ts.map +1 -1
- package/lib/dist/graph/traversal.js +16 -4
- package/lib/dist/graph/traversal.js.map +1 -1
- package/lib/dist/index.d.ts +41 -3
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +99 -9
- package/lib/dist/index.js.map +1 -1
- package/lib/dist/installer/index.d.ts.map +1 -1
- package/lib/dist/installer/index.js +52 -2
- package/lib/dist/installer/index.js.map +1 -1
- package/lib/dist/installer/instructions-template.d.ts +34 -11
- package/lib/dist/installer/instructions-template.d.ts.map +1 -1
- package/lib/dist/installer/instructions-template.js +44 -12
- package/lib/dist/installer/instructions-template.js.map +1 -1
- package/lib/dist/installer/targets/claude.d.ts.map +1 -1
- package/lib/dist/installer/targets/claude.js +6 -10
- package/lib/dist/installer/targets/claude.js.map +1 -1
- package/lib/dist/installer/targets/codex.js +4 -6
- package/lib/dist/installer/targets/codex.js.map +1 -1
- package/lib/dist/installer/targets/gemini.js +4 -6
- package/lib/dist/installer/targets/gemini.js.map +1 -1
- package/lib/dist/installer/targets/opencode.d.ts +9 -1
- package/lib/dist/installer/targets/opencode.d.ts.map +1 -1
- package/lib/dist/installer/targets/opencode.js +91 -40
- package/lib/dist/installer/targets/opencode.js.map +1 -1
- package/lib/dist/installer/targets/shared.d.ts +14 -0
- package/lib/dist/installer/targets/shared.d.ts.map +1 -1
- package/lib/dist/installer/targets/shared.js +19 -2
- package/lib/dist/installer/targets/shared.js.map +1 -1
- package/lib/dist/mcp/daemon.d.ts +60 -1
- package/lib/dist/mcp/daemon.d.ts.map +1 -1
- package/lib/dist/mcp/daemon.js +221 -8
- package/lib/dist/mcp/daemon.js.map +1 -1
- package/lib/dist/mcp/dynamic-boundaries.d.ts +41 -0
- package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
- package/lib/dist/mcp/dynamic-boundaries.js +359 -0
- package/lib/dist/mcp/dynamic-boundaries.js.map +1 -0
- package/lib/dist/mcp/index.d.ts.map +1 -1
- package/lib/dist/mcp/index.js +18 -9
- package/lib/dist/mcp/index.js.map +1 -1
- package/lib/dist/mcp/ppid-watchdog.d.ts +44 -0
- package/lib/dist/mcp/ppid-watchdog.d.ts.map +1 -0
- package/lib/dist/mcp/ppid-watchdog.js +27 -0
- package/lib/dist/mcp/ppid-watchdog.js.map +1 -0
- package/lib/dist/mcp/proxy.d.ts +6 -0
- package/lib/dist/mcp/proxy.d.ts.map +1 -1
- package/lib/dist/mcp/proxy.js +153 -24
- package/lib/dist/mcp/proxy.js.map +1 -1
- package/lib/dist/mcp/server-instructions.d.ts +12 -1
- package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
- package/lib/dist/mcp/server-instructions.js +58 -32
- package/lib/dist/mcp/server-instructions.js.map +1 -1
- package/lib/dist/mcp/session.d.ts +2 -0
- package/lib/dist/mcp/session.d.ts.map +1 -1
- package/lib/dist/mcp/session.js +49 -2
- package/lib/dist/mcp/session.js.map +1 -1
- package/lib/dist/mcp/stdin-teardown.d.ts +27 -0
- package/lib/dist/mcp/stdin-teardown.d.ts.map +1 -0
- package/lib/dist/mcp/stdin-teardown.js +49 -0
- package/lib/dist/mcp/stdin-teardown.js.map +1 -0
- package/lib/dist/mcp/tools.d.ts +110 -49
- package/lib/dist/mcp/tools.d.ts.map +1 -1
- package/lib/dist/mcp/tools.js +1222 -972
- package/lib/dist/mcp/tools.js.map +1 -1
- package/lib/dist/mcp/transport.d.ts.map +1 -1
- package/lib/dist/mcp/transport.js +18 -2
- package/lib/dist/mcp/transport.js.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.d.ts +3 -3
- package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.js +549 -21
- package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
- package/lib/dist/resolution/frameworks/astro.d.ts +9 -0
- package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/astro.js +169 -0
- package/lib/dist/resolution/frameworks/astro.js.map +1 -0
- package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/expo-modules.js +6 -1
- package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -1
- package/lib/dist/resolution/frameworks/index.d.ts +1 -0
- package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/index.js +5 -1
- package/lib/dist/resolution/frameworks/index.js.map +1 -1
- package/lib/dist/resolution/frameworks/java.js +6 -1
- package/lib/dist/resolution/frameworks/java.js.map +1 -1
- package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/python.js +7 -3
- package/lib/dist/resolution/frameworks/python.js.map +1 -1
- package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react-native.js +53 -3
- package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
- package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react.js +15 -3
- package/lib/dist/resolution/frameworks/react.js.map +1 -1
- package/lib/dist/resolution/frameworks/svelte.js +5 -1
- package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
- package/lib/dist/resolution/frameworks/vue.js +24 -27
- package/lib/dist/resolution/frameworks/vue.js.map +1 -1
- package/lib/dist/resolution/import-resolver.d.ts +10 -0
- package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
- package/lib/dist/resolution/import-resolver.js +564 -2
- package/lib/dist/resolution/import-resolver.js.map +1 -1
- package/lib/dist/resolution/index.d.ts +80 -0
- package/lib/dist/resolution/index.d.ts.map +1 -1
- package/lib/dist/resolution/index.js +457 -7
- package/lib/dist/resolution/index.js.map +1 -1
- package/lib/dist/resolution/name-matcher.d.ts +61 -0
- package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
- package/lib/dist/resolution/name-matcher.js +590 -14
- package/lib/dist/resolution/name-matcher.js.map +1 -1
- package/lib/dist/resolution/types.d.ts +27 -3
- package/lib/dist/resolution/types.d.ts.map +1 -1
- package/lib/dist/resolution/workspace-packages.d.ts +48 -0
- package/lib/dist/resolution/workspace-packages.d.ts.map +1 -0
- package/lib/dist/resolution/workspace-packages.js +208 -0
- package/lib/dist/resolution/workspace-packages.js.map +1 -0
- package/lib/dist/search/query-utils.d.ts +35 -1
- package/lib/dist/search/query-utils.d.ts.map +1 -1
- package/lib/dist/search/query-utils.js +109 -10
- package/lib/dist/search/query-utils.js.map +1 -1
- package/lib/dist/sync/watcher.d.ts +124 -32
- package/lib/dist/sync/watcher.d.ts.map +1 -1
- package/lib/dist/sync/watcher.js +326 -111
- package/lib/dist/sync/watcher.js.map +1 -1
- package/lib/dist/telemetry/index.d.ts +146 -0
- package/lib/dist/telemetry/index.d.ts.map +1 -0
- package/lib/dist/telemetry/index.js +544 -0
- package/lib/dist/telemetry/index.js.map +1 -0
- package/lib/dist/types.d.ts +25 -2
- package/lib/dist/types.d.ts.map +1 -1
- package/lib/dist/types.js +3 -0
- package/lib/dist/types.js.map +1 -1
- package/lib/dist/upgrade/index.d.ts +132 -0
- package/lib/dist/upgrade/index.d.ts.map +1 -0
- package/lib/dist/upgrade/index.js +462 -0
- package/lib/dist/upgrade/index.js.map +1 -0
- package/lib/dist/utils.d.ts +30 -24
- package/lib/dist/utils.d.ts.map +1 -1
- package/lib/dist/utils.js +64 -48
- package/lib/dist/utils.js.map +1 -1
- package/lib/node_modules/.package-lock.json +1 -29
- package/lib/package.json +1 -2
- package/package.json +1 -1
- package/lib/node_modules/chokidar/LICENSE +0 -21
- package/lib/node_modules/chokidar/README.md +0 -305
- package/lib/node_modules/chokidar/esm/handler.d.ts +0 -90
- package/lib/node_modules/chokidar/esm/handler.js +0 -629
- package/lib/node_modules/chokidar/esm/index.d.ts +0 -215
- package/lib/node_modules/chokidar/esm/index.js +0 -798
- package/lib/node_modules/chokidar/esm/package.json +0 -1
- package/lib/node_modules/chokidar/handler.d.ts +0 -90
- package/lib/node_modules/chokidar/handler.js +0 -635
- package/lib/node_modules/chokidar/index.d.ts +0 -215
- package/lib/node_modules/chokidar/index.js +0 -804
- package/lib/node_modules/chokidar/package.json +0 -69
- package/lib/node_modules/readdirp/LICENSE +0 -21
- package/lib/node_modules/readdirp/README.md +0 -120
- package/lib/node_modules/readdirp/esm/index.d.ts +0 -108
- package/lib/node_modules/readdirp/esm/index.js +0 -257
- package/lib/node_modules/readdirp/esm/package.json +0 -1
- package/lib/node_modules/readdirp/index.d.ts +0 -108
- package/lib/node_modules/readdirp/index.js +0 -263
- package/lib/node_modules/readdirp/package.json +0 -70
package/lib/dist/directory.js
CHANGED
|
@@ -39,6 +39,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
39
39
|
})();
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.CODEGRAPH_DIR = void 0;
|
|
42
|
+
exports.codeGraphDirName = codeGraphDirName;
|
|
43
|
+
exports.isCodeGraphDataDir = isCodeGraphDataDir;
|
|
42
44
|
exports.getCodeGraphDir = getCodeGraphDir;
|
|
43
45
|
exports.isInitialized = isInitialized;
|
|
44
46
|
exports.findNearestCodeGraphRoot = findNearestCodeGraphRoot;
|
|
@@ -50,15 +52,73 @@ exports.ensureSubdirectory = ensureSubdirectory;
|
|
|
50
52
|
exports.validateDirectory = validateDirectory;
|
|
51
53
|
const fs = __importStar(require("fs"));
|
|
52
54
|
const path = __importStar(require("path"));
|
|
55
|
+
/** The default per-project data directory name. */
|
|
56
|
+
const DEFAULT_CODEGRAPH_DIR = '.codegraph';
|
|
57
|
+
let warnedBadDirName = false;
|
|
53
58
|
/**
|
|
54
|
-
*
|
|
59
|
+
* Resolve the per-project data directory name, honoring the `CODEGRAPH_DIR`
|
|
60
|
+
* environment override (default `.codegraph`). The override is a single path
|
|
61
|
+
* segment that lives in the project root.
|
|
62
|
+
*
|
|
63
|
+
* Why this exists: two environments that share one working tree must NOT share
|
|
64
|
+
* one `.codegraph/` — most concretely Windows-native and WSL (issue #636). The
|
|
65
|
+
* daemon lockfile (`.codegraph/daemon.pid`) records a platform-specific pid and
|
|
66
|
+
* socket path (a Windows named pipe vs a WSL Unix socket), and SQLite file
|
|
67
|
+
* locking across the WSL2 ↔ Windows filesystem boundary is unreliable, so two
|
|
68
|
+
* daemons sharing one index risks corruption. Setting `CODEGRAPH_DIR=.codegraph-win`
|
|
69
|
+
* on one side gives each environment its own index in the same tree.
|
|
70
|
+
*
|
|
71
|
+
* Read live (not captured at load) so it is both process-accurate and testable.
|
|
72
|
+
* An override that isn't a plain directory name — empty, containing a path
|
|
73
|
+
* separator, `.`, `..`/traversal, or absolute — is ignored (we keep the
|
|
74
|
+
* default) rather than risk writing the index outside the project or into the
|
|
75
|
+
* project root itself; we warn once to stderr so the misconfiguration is seen.
|
|
76
|
+
*/
|
|
77
|
+
function codeGraphDirName() {
|
|
78
|
+
const raw = process.env.CODEGRAPH_DIR?.trim();
|
|
79
|
+
if (!raw)
|
|
80
|
+
return DEFAULT_CODEGRAPH_DIR;
|
|
81
|
+
const invalid = raw === '.' ||
|
|
82
|
+
raw.includes('..') ||
|
|
83
|
+
raw.includes('/') ||
|
|
84
|
+
raw.includes('\\') ||
|
|
85
|
+
path.isAbsolute(raw);
|
|
86
|
+
if (invalid) {
|
|
87
|
+
if (!warnedBadDirName) {
|
|
88
|
+
warnedBadDirName = true;
|
|
89
|
+
// stderr only — stdout is the MCP protocol channel.
|
|
90
|
+
console.warn(`[codegraph] Ignoring invalid CODEGRAPH_DIR="${raw}" — it must be a plain ` +
|
|
91
|
+
`directory name (no path separators, no "..", not absolute). Using "${DEFAULT_CODEGRAPH_DIR}".`);
|
|
92
|
+
}
|
|
93
|
+
return DEFAULT_CODEGRAPH_DIR;
|
|
94
|
+
}
|
|
95
|
+
return raw;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* CodeGraph directory name — a load-time snapshot of {@link codeGraphDirName}.
|
|
99
|
+
* A running process's environment is fixed, so this equals the live value;
|
|
100
|
+
* it's kept as a stable string export for backward compatibility. Internal code
|
|
101
|
+
* resolves the name through {@link codeGraphDirName} / {@link getCodeGraphDir}
|
|
102
|
+
* so the `CODEGRAPH_DIR` override always applies.
|
|
55
103
|
*/
|
|
56
|
-
exports.CODEGRAPH_DIR =
|
|
104
|
+
exports.CODEGRAPH_DIR = codeGraphDirName();
|
|
105
|
+
/**
|
|
106
|
+
* Is `name` (a single path segment) a CodeGraph data directory? Matches the
|
|
107
|
+
* default `.codegraph`, the active `CODEGRAPH_DIR` override, and any
|
|
108
|
+
* `.codegraph-*` sibling. File-watching and the indexer skip ALL of these, so
|
|
109
|
+
* when two environments share one working tree (Windows + WSL, issue #636)
|
|
110
|
+
* neither indexes or watches the other's index directory.
|
|
111
|
+
*/
|
|
112
|
+
function isCodeGraphDataDir(name) {
|
|
113
|
+
return (name === DEFAULT_CODEGRAPH_DIR ||
|
|
114
|
+
name === codeGraphDirName() ||
|
|
115
|
+
name.startsWith(DEFAULT_CODEGRAPH_DIR + '-'));
|
|
116
|
+
}
|
|
57
117
|
/**
|
|
58
118
|
* Get the .codegraph directory path for a project
|
|
59
119
|
*/
|
|
60
120
|
function getCodeGraphDir(projectRoot) {
|
|
61
|
-
return path.join(projectRoot,
|
|
121
|
+
return path.join(projectRoot, codeGraphDirName());
|
|
62
122
|
}
|
|
63
123
|
/**
|
|
64
124
|
* Check if a project has been initialized with CodeGraph
|
|
@@ -100,6 +160,61 @@ function findNearestCodeGraphRoot(startPath) {
|
|
|
100
160
|
}
|
|
101
161
|
return null;
|
|
102
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Contents of `.codegraph/.gitignore`. A single wildcard ignore keeps every
|
|
165
|
+
* transient file in the index dir — the database, `daemon.pid`, the socket,
|
|
166
|
+
* logs, cache, and anything future versions add — out of git, without having
|
|
167
|
+
* to enumerate each name (issues #788, #492, #484). Older versions wrote an
|
|
168
|
+
* explicit allowlist that never listed `daemon.pid` or the socket, so those
|
|
169
|
+
* runtime files were silently committed.
|
|
170
|
+
*/
|
|
171
|
+
const GITIGNORE_CONTENT = `# CodeGraph data files — local to each machine, not for committing.
|
|
172
|
+
# Ignore everything in .codegraph/ except this file itself, so transient
|
|
173
|
+
# files (the database, daemon.pid, sockets, logs) never show up in git.
|
|
174
|
+
*
|
|
175
|
+
!.gitignore
|
|
176
|
+
`;
|
|
177
|
+
/** Header line that prefixes every .gitignore CodeGraph has auto-generated. */
|
|
178
|
+
const GITIGNORE_MARKER = '# CodeGraph data files';
|
|
179
|
+
/**
|
|
180
|
+
* Is `content` a stale CodeGraph-generated `.gitignore` that should be
|
|
181
|
+
* regenerated in place? True when it carries our header but predates the
|
|
182
|
+
* wildcard ignore (it has no bare `*` line) — i.e. one of the old explicit
|
|
183
|
+
* allowlists (`*.db`, `cache/`, `.dirty`, …) that never ignored `daemon.pid`
|
|
184
|
+
* or the socket (issue #788). A file WITHOUT our header is user-authored and
|
|
185
|
+
* is left untouched; one that already has the wildcard is current. Matching
|
|
186
|
+
* on the header (not a byte-exact list of past defaults) heals every old
|
|
187
|
+
* variant — v0.7.x through 0.9.9 — and is idempotent once upgraded.
|
|
188
|
+
*/
|
|
189
|
+
function isStaleDefaultGitignore(content) {
|
|
190
|
+
if (!content.trimStart().startsWith(GITIGNORE_MARKER))
|
|
191
|
+
return false;
|
|
192
|
+
return !content.split('\n').some((line) => line.trim() === '*');
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Write `.codegraph/.gitignore` if it's absent, or upgrade a stale
|
|
196
|
+
* CodeGraph-generated default in place; a user-customized file is left alone.
|
|
197
|
+
* Best-effort — returns `false` only if a needed write failed.
|
|
198
|
+
*/
|
|
199
|
+
function ensureGitignore(gitignorePath) {
|
|
200
|
+
let existing;
|
|
201
|
+
try {
|
|
202
|
+
existing = fs.readFileSync(gitignorePath, 'utf-8');
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
existing = null; // absent (ENOENT) or unreadable — (re)create below
|
|
206
|
+
}
|
|
207
|
+
// Current default or a user-authored file: nothing to do.
|
|
208
|
+
if (existing !== null && !isStaleDefaultGitignore(existing))
|
|
209
|
+
return true;
|
|
210
|
+
try {
|
|
211
|
+
fs.writeFileSync(gitignorePath, GITIGNORE_CONTENT, 'utf-8');
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
103
218
|
/**
|
|
104
219
|
* Create the .codegraph directory structure
|
|
105
220
|
* Note: Only throws if codegraph.db already exists, not just if .codegraph/ exists.
|
|
@@ -114,28 +229,9 @@ function createDirectory(projectRoot) {
|
|
|
114
229
|
}
|
|
115
230
|
// Create main directory (if it doesn't exist)
|
|
116
231
|
fs.mkdirSync(codegraphDir, { recursive: true });
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const gitignoreContent = `# CodeGraph data files
|
|
121
|
-
# These are local to each machine and should not be committed
|
|
122
|
-
|
|
123
|
-
# Database
|
|
124
|
-
*.db
|
|
125
|
-
*.db-wal
|
|
126
|
-
*.db-shm
|
|
127
|
-
|
|
128
|
-
# Cache
|
|
129
|
-
cache/
|
|
130
|
-
|
|
131
|
-
# Logs
|
|
132
|
-
*.log
|
|
133
|
-
|
|
134
|
-
# Hook markers
|
|
135
|
-
.dirty
|
|
136
|
-
`;
|
|
137
|
-
fs.writeFileSync(gitignorePath, gitignoreContent, 'utf-8');
|
|
138
|
-
}
|
|
232
|
+
// Write .gitignore inside .codegraph (create if absent, upgrade a stale
|
|
233
|
+
// pre-wildcard default left by an older version — issue #788).
|
|
234
|
+
ensureGitignore(path.join(codegraphDir, '.gitignore'));
|
|
139
235
|
}
|
|
140
236
|
/**
|
|
141
237
|
* Remove the .codegraph directory
|
|
@@ -244,17 +340,15 @@ function validateDirectory(projectRoot) {
|
|
|
244
340
|
errors.push('.codegraph exists but is not a directory');
|
|
245
341
|
return { valid: false, errors };
|
|
246
342
|
}
|
|
247
|
-
// Auto-repair
|
|
343
|
+
// Auto-repair / upgrade .gitignore (non-critical file). A missing one is
|
|
344
|
+
// recreated; a stale pre-wildcard default that never ignored daemon.pid is
|
|
345
|
+
// regenerated in place (issue #788); a user-authored file is left alone.
|
|
248
346
|
const gitignorePath = path.join(codegraphDir, '.gitignore');
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
catch {
|
|
255
|
-
// Non-fatal: warn but don't block
|
|
256
|
-
errors.push('.gitignore missing in .codegraph directory and could not be created');
|
|
257
|
-
}
|
|
347
|
+
const existedBefore = fs.existsSync(gitignorePath);
|
|
348
|
+
if (!ensureGitignore(gitignorePath) && !existedBefore) {
|
|
349
|
+
// Only a missing-and-uncreatable file is surfaced; a failed in-place
|
|
350
|
+
// upgrade of an existing file is non-fatal — the index still works.
|
|
351
|
+
errors.push('.gitignore missing in .codegraph directory and could not be created');
|
|
258
352
|
}
|
|
259
353
|
return {
|
|
260
354
|
valid: errors.length === 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BH,4CAqBC;AAkBD,gDAMC;AAKD,0CAEC;AAMD,sCAQC;AAWD,4DAmBC;AA6DD,0CAgBC;AAKD,0CAuBC;AAKD,sDA8BC;AAKD,4CA+BC;AAKD,gDAYC;AAKD,8CAgCC;AAjWD,uCAAyB;AACzB,2CAA6B;AAE7B,mDAAmD;AACnD,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAE3C,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAE7B;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,gBAAgB;IAC9B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC;IAC9C,IAAI,CAAC,GAAG;QAAE,OAAO,qBAAqB,CAAC;IACvC,MAAM,OAAO,GACX,GAAG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ACnD,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QACtD,qEAAqE;QACrE,oEAAoE;QACpE,MAAM,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC;IACrF,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ExtractionResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* AstroExtractor - Extracts code relationships from Astro component files
|
|
4
|
+
*
|
|
5
|
+
* Astro files are multi-language: a TypeScript frontmatter block fenced by
|
|
6
|
+
* `---` lines, a JSX-like HTML template, and optional <script>/<style> blocks.
|
|
7
|
+
* Rather than parsing a full Astro grammar, we extract the frontmatter and
|
|
8
|
+
* <script> contents and delegate them to the TypeScript TreeSitterExtractor
|
|
9
|
+
* (Astro processes both as TypeScript by default — no `lang` attr needed).
|
|
10
|
+
*
|
|
11
|
+
* Also extracts function calls from template expressions (`{fn(...)}`) and
|
|
12
|
+
* component usages (`<PascalCase>`) so cross-file edges are captured even
|
|
13
|
+
* when the only reference lives in markup.
|
|
14
|
+
*
|
|
15
|
+
* Every .astro file produces a component node (Astro components are always
|
|
16
|
+
* importable).
|
|
17
|
+
*/
|
|
18
|
+
export declare class AstroExtractor {
|
|
19
|
+
private filePath;
|
|
20
|
+
private source;
|
|
21
|
+
private nodes;
|
|
22
|
+
private edges;
|
|
23
|
+
private unresolvedReferences;
|
|
24
|
+
private errors;
|
|
25
|
+
constructor(filePath: string, source: string);
|
|
26
|
+
/**
|
|
27
|
+
* Extract from Astro source
|
|
28
|
+
*/
|
|
29
|
+
extract(): ExtractionResult;
|
|
30
|
+
/**
|
|
31
|
+
* Create a component node for the .astro file
|
|
32
|
+
*/
|
|
33
|
+
private createComponentNode;
|
|
34
|
+
/**
|
|
35
|
+
* Extract the frontmatter block: the content between the opening `---`
|
|
36
|
+
* fence (first non-blank line of the file) and the closing `---` fence.
|
|
37
|
+
* An unclosed fence is treated as "no frontmatter" rather than swallowing
|
|
38
|
+
* the whole template as TypeScript.
|
|
39
|
+
*
|
|
40
|
+
* Returns the content plus its 0-indexed start line, or null.
|
|
41
|
+
*/
|
|
42
|
+
private extractFrontmatter;
|
|
43
|
+
/**
|
|
44
|
+
* Extract <script> blocks from the template portion
|
|
45
|
+
*/
|
|
46
|
+
private extractScriptBlocks;
|
|
47
|
+
/**
|
|
48
|
+
* Process frontmatter / script content by delegating to TreeSitterExtractor.
|
|
49
|
+
* Astro treats both as TypeScript by default.
|
|
50
|
+
*/
|
|
51
|
+
private processScriptContent;
|
|
52
|
+
/**
|
|
53
|
+
* Line ranges (0-indexed, inclusive) the template scans must skip:
|
|
54
|
+
* the frontmatter block and <script>/<style> blocks.
|
|
55
|
+
*/
|
|
56
|
+
private getCoveredRanges;
|
|
57
|
+
/**
|
|
58
|
+
* Extract function calls from Astro template expressions.
|
|
59
|
+
*
|
|
60
|
+
* Astro templates embed JSX-like expressions (`{formatDate(post.date)}`,
|
|
61
|
+
* `class:list={cn(...)}`), so calls frequently live in markup rather than
|
|
62
|
+
* the frontmatter. We scan template lines for `{expression}` groups and
|
|
63
|
+
* extract call patterns from them. A `{` group left open at end-of-line
|
|
64
|
+
* (the pervasive `{posts.map((post) => (` pattern) contributes the calls
|
|
65
|
+
* on its opening line.
|
|
66
|
+
*/
|
|
67
|
+
private extractTemplateCalls;
|
|
68
|
+
/**
|
|
69
|
+
* Extract component usages from the Astro template.
|
|
70
|
+
*
|
|
71
|
+
* PascalCase tags like <Layout>, <PostCard /> represent component
|
|
72
|
+
* instantiations — analogous to function calls in imperative code.
|
|
73
|
+
* Lowercase tags are native HTML (Astro does not register kebab-case
|
|
74
|
+
* components the way Vue does, so those are real custom elements and
|
|
75
|
+
* are skipped).
|
|
76
|
+
*/
|
|
77
|
+
private extractTemplateComponents;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=astro-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro-extractor.d.ts","sourceRoot":"","sources":["../../src/extraction/astro-extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,gBAAgB,EAAwC,MAAM,UAAU,CAAC;AAW9F;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,oBAAoB,CAA6B;IACzD,OAAO,CAAC,MAAM,CAAyB;gBAE3B,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK5C;;OAEG;IACH,OAAO,IAAI,gBAAgB;IA2C3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAyB3B;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;IA8B1B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAyB3B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IA0D5B;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAqBxB;;;;;;;;;OASG;IACH,OAAO,CAAC,oBAAoB;IAiD5B;;;;;;;;OAQG;IACH,OAAO,CAAC,yBAAyB;CA6BlC"}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AstroExtractor = void 0;
|
|
4
|
+
const tree_sitter_helpers_1 = require("./tree-sitter-helpers");
|
|
5
|
+
const tree_sitter_1 = require("./tree-sitter");
|
|
6
|
+
const grammars_1 = require("./grammars");
|
|
7
|
+
/**
|
|
8
|
+
* Astro built-in components — compiler-provided (`<Fragment>`) or shipped by
|
|
9
|
+
* `astro:components` (`<Code>`, `<Debug>`), not user code.
|
|
10
|
+
*/
|
|
11
|
+
const ASTRO_BUILTIN_COMPONENTS = new Set(['Fragment', 'Code', 'Debug']);
|
|
12
|
+
/**
|
|
13
|
+
* AstroExtractor - Extracts code relationships from Astro component files
|
|
14
|
+
*
|
|
15
|
+
* Astro files are multi-language: a TypeScript frontmatter block fenced by
|
|
16
|
+
* `---` lines, a JSX-like HTML template, and optional <script>/<style> blocks.
|
|
17
|
+
* Rather than parsing a full Astro grammar, we extract the frontmatter and
|
|
18
|
+
* <script> contents and delegate them to the TypeScript TreeSitterExtractor
|
|
19
|
+
* (Astro processes both as TypeScript by default — no `lang` attr needed).
|
|
20
|
+
*
|
|
21
|
+
* Also extracts function calls from template expressions (`{fn(...)}`) and
|
|
22
|
+
* component usages (`<PascalCase>`) so cross-file edges are captured even
|
|
23
|
+
* when the only reference lives in markup.
|
|
24
|
+
*
|
|
25
|
+
* Every .astro file produces a component node (Astro components are always
|
|
26
|
+
* importable).
|
|
27
|
+
*/
|
|
28
|
+
class AstroExtractor {
|
|
29
|
+
filePath;
|
|
30
|
+
source;
|
|
31
|
+
nodes = [];
|
|
32
|
+
edges = [];
|
|
33
|
+
unresolvedReferences = [];
|
|
34
|
+
errors = [];
|
|
35
|
+
constructor(filePath, source) {
|
|
36
|
+
this.filePath = filePath;
|
|
37
|
+
this.source = source;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Extract from Astro source
|
|
41
|
+
*/
|
|
42
|
+
extract() {
|
|
43
|
+
const startTime = Date.now();
|
|
44
|
+
try {
|
|
45
|
+
// Create component node for the .astro file itself
|
|
46
|
+
const componentNode = this.createComponentNode();
|
|
47
|
+
// Extract and process the frontmatter block (--- fenced, TypeScript)
|
|
48
|
+
const frontmatter = this.extractFrontmatter();
|
|
49
|
+
if (frontmatter) {
|
|
50
|
+
this.processScriptContent(frontmatter, componentNode.id, 'frontmatter');
|
|
51
|
+
}
|
|
52
|
+
// Extract and process <script> blocks (client-side, TypeScript-capable)
|
|
53
|
+
for (const block of this.extractScriptBlocks()) {
|
|
54
|
+
this.processScriptContent(block, componentNode.id, 'script');
|
|
55
|
+
}
|
|
56
|
+
// Ranges the template scans must skip: frontmatter + <script>/<style>
|
|
57
|
+
const coveredRanges = this.getCoveredRanges(frontmatter);
|
|
58
|
+
// Extract function calls from template expressions ({fn(...)})
|
|
59
|
+
this.extractTemplateCalls(componentNode.id, coveredRanges);
|
|
60
|
+
// Extract component usages from template (<ComponentName>)
|
|
61
|
+
this.extractTemplateComponents(componentNode.id, coveredRanges);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
this.errors.push({
|
|
65
|
+
message: `Astro extraction error: ${error instanceof Error ? error.message : String(error)}`,
|
|
66
|
+
severity: 'error',
|
|
67
|
+
code: 'parse_error',
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
nodes: this.nodes,
|
|
72
|
+
edges: this.edges,
|
|
73
|
+
unresolvedReferences: this.unresolvedReferences,
|
|
74
|
+
errors: this.errors,
|
|
75
|
+
durationMs: Date.now() - startTime,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create a component node for the .astro file
|
|
80
|
+
*/
|
|
81
|
+
createComponentNode() {
|
|
82
|
+
const lines = this.source.split('\n');
|
|
83
|
+
const fileName = this.filePath.split(/[/\\]/).pop() || this.filePath;
|
|
84
|
+
const componentName = fileName.replace(/\.astro$/, '');
|
|
85
|
+
const id = (0, tree_sitter_helpers_1.generateNodeId)(this.filePath, 'component', componentName, 1);
|
|
86
|
+
const node = {
|
|
87
|
+
id,
|
|
88
|
+
kind: 'component',
|
|
89
|
+
name: componentName,
|
|
90
|
+
qualifiedName: `${this.filePath}::${componentName}`,
|
|
91
|
+
filePath: this.filePath,
|
|
92
|
+
language: 'astro',
|
|
93
|
+
startLine: 1,
|
|
94
|
+
endLine: lines.length,
|
|
95
|
+
startColumn: 0,
|
|
96
|
+
endColumn: lines[lines.length - 1]?.length || 0,
|
|
97
|
+
isExported: true, // Astro components are always importable
|
|
98
|
+
updatedAt: Date.now(),
|
|
99
|
+
};
|
|
100
|
+
this.nodes.push(node);
|
|
101
|
+
return node;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Extract the frontmatter block: the content between the opening `---`
|
|
105
|
+
* fence (first non-blank line of the file) and the closing `---` fence.
|
|
106
|
+
* An unclosed fence is treated as "no frontmatter" rather than swallowing
|
|
107
|
+
* the whole template as TypeScript.
|
|
108
|
+
*
|
|
109
|
+
* Returns the content plus its 0-indexed start line, or null.
|
|
110
|
+
*/
|
|
111
|
+
extractFrontmatter() {
|
|
112
|
+
const lines = this.source.split('\n');
|
|
113
|
+
// Opening fence must be the first non-blank line
|
|
114
|
+
let openIdx = -1;
|
|
115
|
+
for (let i = 0; i < lines.length; i++) {
|
|
116
|
+
const trimmed = lines[i].trim();
|
|
117
|
+
if (trimmed === '')
|
|
118
|
+
continue;
|
|
119
|
+
if (trimmed === '---')
|
|
120
|
+
openIdx = i;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
if (openIdx === -1)
|
|
124
|
+
return null;
|
|
125
|
+
// Closing fence
|
|
126
|
+
let closeIdx = -1;
|
|
127
|
+
for (let i = openIdx + 1; i < lines.length; i++) {
|
|
128
|
+
if (lines[i].trim() === '---') {
|
|
129
|
+
closeIdx = i;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (closeIdx === -1)
|
|
134
|
+
return null;
|
|
135
|
+
return {
|
|
136
|
+
content: lines.slice(openIdx + 1, closeIdx).join('\n'),
|
|
137
|
+
startLine: openIdx + 1, // 0-indexed line where content starts
|
|
138
|
+
endLine: closeIdx, // 0-indexed line of the closing fence
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Extract <script> blocks from the template portion
|
|
143
|
+
*/
|
|
144
|
+
extractScriptBlocks() {
|
|
145
|
+
const blocks = [];
|
|
146
|
+
const scriptRegex = /<script(\s[^>]*)?>(?<content>[\s\S]*?)<\/script>/g;
|
|
147
|
+
let match;
|
|
148
|
+
while ((match = scriptRegex.exec(this.source)) !== null) {
|
|
149
|
+
const content = match.groups?.content || match[2] || '';
|
|
150
|
+
// Calculate the 0-indexed line where the content begins. The content
|
|
151
|
+
// starts right after the opening tag's `>` — its leading `\n` is part
|
|
152
|
+
// of the content, so relative line 1 sits ON the tag's closing line
|
|
153
|
+
// (do not add 1 here; that double-counts the embedded newline).
|
|
154
|
+
const beforeScript = this.source.substring(0, match.index);
|
|
155
|
+
const scriptTagLine = (beforeScript.match(/\n/g) || []).length;
|
|
156
|
+
const openingTag = match[0].substring(0, match[0].indexOf('>') + 1);
|
|
157
|
+
const openingTagLines = (openingTag.match(/\n/g) || []).length;
|
|
158
|
+
const contentStartLine = scriptTagLine + openingTagLines; // 0-indexed
|
|
159
|
+
blocks.push({ content, startLine: contentStartLine });
|
|
160
|
+
}
|
|
161
|
+
return blocks;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Process frontmatter / script content by delegating to TreeSitterExtractor.
|
|
165
|
+
* Astro treats both as TypeScript by default.
|
|
166
|
+
*/
|
|
167
|
+
processScriptContent(block, componentNodeId, label) {
|
|
168
|
+
if (!(0, grammars_1.isLanguageSupported)('typescript')) {
|
|
169
|
+
this.errors.push({
|
|
170
|
+
message: `Parser for typescript not available, cannot parse Astro ${label} block`,
|
|
171
|
+
severity: 'warning',
|
|
172
|
+
});
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
// Delegate to TreeSitterExtractor
|
|
176
|
+
const extractor = new tree_sitter_1.TreeSitterExtractor(this.filePath, block.content, 'typescript');
|
|
177
|
+
const result = extractor.extract();
|
|
178
|
+
// Offset line numbers from the block back to .astro file positions
|
|
179
|
+
for (const node of result.nodes) {
|
|
180
|
+
node.startLine += block.startLine;
|
|
181
|
+
node.endLine += block.startLine;
|
|
182
|
+
node.language = 'astro'; // Mark as astro, not TS
|
|
183
|
+
this.nodes.push(node);
|
|
184
|
+
// Add containment edge from component to this node
|
|
185
|
+
this.edges.push({
|
|
186
|
+
source: componentNodeId,
|
|
187
|
+
target: node.id,
|
|
188
|
+
kind: 'contains',
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
// Offset edges (they reference line numbers)
|
|
192
|
+
for (const edge of result.edges) {
|
|
193
|
+
if (edge.line) {
|
|
194
|
+
edge.line += block.startLine;
|
|
195
|
+
}
|
|
196
|
+
this.edges.push(edge);
|
|
197
|
+
}
|
|
198
|
+
// Offset unresolved references
|
|
199
|
+
for (const ref of result.unresolvedReferences) {
|
|
200
|
+
ref.line += block.startLine;
|
|
201
|
+
ref.filePath = this.filePath;
|
|
202
|
+
ref.language = 'astro';
|
|
203
|
+
this.unresolvedReferences.push(ref);
|
|
204
|
+
}
|
|
205
|
+
// Carry over errors
|
|
206
|
+
for (const error of result.errors) {
|
|
207
|
+
if (error.line) {
|
|
208
|
+
error.line += block.startLine;
|
|
209
|
+
}
|
|
210
|
+
this.errors.push(error);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Line ranges (0-indexed, inclusive) the template scans must skip:
|
|
215
|
+
* the frontmatter block and <script>/<style> blocks.
|
|
216
|
+
*/
|
|
217
|
+
getCoveredRanges(frontmatter) {
|
|
218
|
+
const coveredRanges = [];
|
|
219
|
+
if (frontmatter) {
|
|
220
|
+
// Cover from the opening fence line through the closing fence line
|
|
221
|
+
coveredRanges.push([frontmatter.startLine - 1, frontmatter.endLine]);
|
|
222
|
+
}
|
|
223
|
+
const tagRegex = /<(script|style)(\s[^>]*)?>[\s\S]*?<\/\1>/g;
|
|
224
|
+
let tagMatch;
|
|
225
|
+
while ((tagMatch = tagRegex.exec(this.source)) !== null) {
|
|
226
|
+
const startLine = (this.source.substring(0, tagMatch.index).match(/\n/g) || []).length;
|
|
227
|
+
const endLine = startLine + (tagMatch[0].match(/\n/g) || []).length;
|
|
228
|
+
coveredRanges.push([startLine, endLine]);
|
|
229
|
+
}
|
|
230
|
+
return coveredRanges;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Extract function calls from Astro template expressions.
|
|
234
|
+
*
|
|
235
|
+
* Astro templates embed JSX-like expressions (`{formatDate(post.date)}`,
|
|
236
|
+
* `class:list={cn(...)}`), so calls frequently live in markup rather than
|
|
237
|
+
* the frontmatter. We scan template lines for `{expression}` groups and
|
|
238
|
+
* extract call patterns from them. A `{` group left open at end-of-line
|
|
239
|
+
* (the pervasive `{posts.map((post) => (` pattern) contributes the calls
|
|
240
|
+
* on its opening line.
|
|
241
|
+
*/
|
|
242
|
+
extractTemplateCalls(componentNodeId, coveredRanges) {
|
|
243
|
+
const lines = this.source.split('\n');
|
|
244
|
+
// Complete groups: {...} — excluding JSX comments ({/* ... */})
|
|
245
|
+
const exprRegex = /\{([^}/][^}]*)\}/g;
|
|
246
|
+
// A group opened but not closed on this line
|
|
247
|
+
const openExprRegex = /\{([^}/][^}]*)$/;
|
|
248
|
+
for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
|
|
249
|
+
if (coveredRanges.some(([start, end]) => lineIdx >= start && lineIdx <= end))
|
|
250
|
+
continue;
|
|
251
|
+
const line = lines[lineIdx];
|
|
252
|
+
const exprs = [];
|
|
253
|
+
let exprMatch;
|
|
254
|
+
while ((exprMatch = exprRegex.exec(line)) !== null) {
|
|
255
|
+
exprs.push({ text: exprMatch[1], offset: exprMatch.index });
|
|
256
|
+
}
|
|
257
|
+
const openMatch = openExprRegex.exec(line.replace(exprRegex, ''));
|
|
258
|
+
if (openMatch) {
|
|
259
|
+
exprs.push({ text: openMatch[1], offset: line.lastIndexOf('{') });
|
|
260
|
+
}
|
|
261
|
+
for (const expr of exprs) {
|
|
262
|
+
// Extract function calls: identifiers followed by (
|
|
263
|
+
// Matches: cn(...), formatDate(...), obj.method(...)
|
|
264
|
+
const callRegex = /\b([a-zA-Z_$][\w$.]*)\s*\(/g;
|
|
265
|
+
let callMatch;
|
|
266
|
+
while ((callMatch = callRegex.exec(expr.text)) !== null) {
|
|
267
|
+
const calleeName = callMatch[1];
|
|
268
|
+
// Skip control-flow keywords valid inside expressions
|
|
269
|
+
if (calleeName === 'if' || calleeName === 'await' || calleeName === 'function')
|
|
270
|
+
continue;
|
|
271
|
+
this.unresolvedReferences.push({
|
|
272
|
+
fromNodeId: componentNodeId,
|
|
273
|
+
referenceName: calleeName,
|
|
274
|
+
referenceKind: 'calls',
|
|
275
|
+
line: lineIdx + 1, // 1-indexed
|
|
276
|
+
column: expr.offset + callMatch.index,
|
|
277
|
+
filePath: this.filePath,
|
|
278
|
+
language: 'astro',
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Extract component usages from the Astro template.
|
|
286
|
+
*
|
|
287
|
+
* PascalCase tags like <Layout>, <PostCard /> represent component
|
|
288
|
+
* instantiations — analogous to function calls in imperative code.
|
|
289
|
+
* Lowercase tags are native HTML (Astro does not register kebab-case
|
|
290
|
+
* components the way Vue does, so those are real custom elements and
|
|
291
|
+
* are skipped).
|
|
292
|
+
*/
|
|
293
|
+
extractTemplateComponents(componentNodeId, coveredRanges) {
|
|
294
|
+
const lines = this.source.split('\n');
|
|
295
|
+
// Opening/self-closing tags (closing tags </Foo> start with </ so won't match)
|
|
296
|
+
const componentTagRegex = /<([A-Z][a-zA-Z0-9_$]*)\b/g;
|
|
297
|
+
for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
|
|
298
|
+
if (coveredRanges.some(([start, end]) => lineIdx >= start && lineIdx <= end))
|
|
299
|
+
continue;
|
|
300
|
+
const line = lines[lineIdx];
|
|
301
|
+
let match;
|
|
302
|
+
while ((match = componentTagRegex.exec(line)) !== null) {
|
|
303
|
+
const componentName = match[1];
|
|
304
|
+
if (ASTRO_BUILTIN_COMPONENTS.has(componentName))
|
|
305
|
+
continue;
|
|
306
|
+
this.unresolvedReferences.push({
|
|
307
|
+
fromNodeId: componentNodeId,
|
|
308
|
+
referenceName: componentName,
|
|
309
|
+
referenceKind: 'references',
|
|
310
|
+
line: lineIdx + 1, // 1-indexed
|
|
311
|
+
column: match.index + 1,
|
|
312
|
+
filePath: this.filePath,
|
|
313
|
+
language: 'astro',
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
exports.AstroExtractor = AstroExtractor;
|
|
320
|
+
//# sourceMappingURL=astro-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro-extractor.js","sourceRoot":"","sources":["../../src/extraction/astro-extractor.ts"],"names":[],"mappings":";;;AACA,+DAAuD;AACvD,+CAAoD;AACpD,yCAAiD;AAEjD;;;GAGG;AACH,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAExE;;;;;;;;;;;;;;;GAeG;AACH,MAAa,cAAc;IACjB,QAAQ,CAAS;IACjB,MAAM,CAAS;IACf,KAAK,GAAW,EAAE,CAAC;IACnB,KAAK,GAAW,EAAE,CAAC;IACnB,oBAAoB,GAA0B,EAAE,CAAC;IACjD,MAAM,GAAsB,EAAE,CAAC;IAEvC,YAAY,QAAgB,EAAE,MAAc;QAC1C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,IAAI,CAAC;YACH,mDAAmD;YACnD,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAEjD,qEAAqE;YACrE,MAAM,WAAW,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC9C,IAAI,WAAW,EAAE,CAAC;gBAChB,IAAI,CAAC,oBAAoB,CAAC,WAAW,EAAE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