@saluzi/codegraph 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +885 -0
  3. package/package.json +42 -10
  4. package/scripts/add-lang/bench.sh +60 -0
  5. package/scripts/add-lang/check-grammar.mjs +75 -0
  6. package/scripts/add-lang/dump-ast.mjs +103 -0
  7. package/scripts/add-lang/verify-extraction.mjs +70 -0
  8. package/scripts/agent-eval/ab-adoption.sh +91 -0
  9. package/scripts/agent-eval/ab-hook.sh +86 -0
  10. package/scripts/agent-eval/ab-impl.sh +78 -0
  11. package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -0
  12. package/scripts/agent-eval/ab-sufficiency.sh +78 -0
  13. package/scripts/agent-eval/arms-F.sh +21 -0
  14. package/scripts/agent-eval/arms-matrix.sh +37 -0
  15. package/scripts/agent-eval/audit.sh +68 -0
  16. package/scripts/agent-eval/bench-readme.sh +28 -0
  17. package/scripts/agent-eval/bench-why-repo.sh +22 -0
  18. package/scripts/agent-eval/block-read-hook.sh +19 -0
  19. package/scripts/agent-eval/hook-settings.json +15 -0
  20. package/scripts/agent-eval/itrun.sh +120 -0
  21. package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
  22. package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
  23. package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
  24. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
  25. package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
  26. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
  27. package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
  28. package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
  29. package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
  30. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
  31. package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
  32. package/scripts/agent-eval/offload-eval-setup.sh +24 -0
  33. package/scripts/agent-eval/offload-eval-styles.sh +72 -0
  34. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
  35. package/scripts/agent-eval/offload-eval.md +76 -0
  36. package/scripts/agent-eval/parse-arms.mjs +116 -0
  37. package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
  38. package/scripts/agent-eval/parse-run.mjs +45 -0
  39. package/scripts/agent-eval/parse-session.mjs +93 -0
  40. package/scripts/agent-eval/probe-context.mjs +21 -0
  41. package/scripts/agent-eval/probe-explore.mjs +40 -0
  42. package/scripts/agent-eval/probe-node.mjs +20 -0
  43. package/scripts/agent-eval/probe-sweep.mjs +119 -0
  44. package/scripts/agent-eval/probe-trace.mjs +20 -0
  45. package/scripts/agent-eval/redirect-read-hook.sh +38 -0
  46. package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
  47. package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
  48. package/scripts/agent-eval/run-agent.sh +34 -0
  49. package/scripts/agent-eval/run-all.sh +75 -0
  50. package/scripts/agent-eval/run-arms.sh +56 -0
  51. package/scripts/agent-eval/seq-matrix.mjs +137 -0
  52. package/scripts/build-bundle.sh +123 -0
  53. package/scripts/extract-release-notes.mjs +130 -0
  54. package/scripts/local-install.sh +41 -0
  55. package/scripts/npm-sdk.js +75 -0
  56. package/scripts/npm-shim.js +275 -0
  57. package/scripts/pack-npm.sh +119 -0
  58. package/scripts/prepare-release.mjs +270 -0
  59. package/dist/bin/codegraph.d.ts +0 -25
  60. package/dist/bin/node-version-check.d.ts +0 -37
  61. package/dist/bin/uninstall.d.ts +0 -14
  62. package/dist/context/formatter.d.ts +0 -33
  63. package/dist/context/formatter.js +0 -244
  64. package/dist/context/index.d.ts +0 -117
  65. package/dist/context/index.js +0 -1050
  66. package/dist/db/index.d.ts +0 -101
  67. package/dist/db/index.js +0 -250
  68. package/dist/db/migrations.d.ts +0 -47
  69. package/dist/db/migrations.js +0 -131
  70. package/dist/db/queries.d.ts +0 -291
  71. package/dist/db/queries.js +0 -1349
  72. package/dist/db/schema.sql +0 -151
  73. package/dist/db/sqlite-adapter.d.ts +0 -49
  74. package/dist/db/sqlite-adapter.js +0 -141
  75. package/dist/directory.d.ts +0 -62
  76. package/dist/directory.js +0 -264
  77. package/dist/errors.d.ts +0 -149
  78. package/dist/errors.js +0 -219
  79. package/dist/extraction/dfm-extractor.d.ts +0 -31
  80. package/dist/extraction/dfm-extractor.js +0 -151
  81. package/dist/extraction/grammars.d.ts +0 -94
  82. package/dist/extraction/grammars.js +0 -357
  83. package/dist/extraction/index.d.ts +0 -148
  84. package/dist/extraction/index.js +0 -1286
  85. package/dist/extraction/languages/c-cpp.d.ts +0 -4
  86. package/dist/extraction/languages/c-cpp.js +0 -126
  87. package/dist/extraction/languages/csharp.d.ts +0 -3
  88. package/dist/extraction/languages/csharp.js +0 -72
  89. package/dist/extraction/languages/dart.d.ts +0 -3
  90. package/dist/extraction/languages/dart.js +0 -192
  91. package/dist/extraction/languages/go.d.ts +0 -3
  92. package/dist/extraction/languages/go.js +0 -58
  93. package/dist/extraction/languages/index.d.ts +0 -10
  94. package/dist/extraction/languages/index.js +0 -49
  95. package/dist/extraction/languages/java.d.ts +0 -3
  96. package/dist/extraction/languages/java.js +0 -64
  97. package/dist/extraction/languages/javascript.d.ts +0 -3
  98. package/dist/extraction/languages/javascript.js +0 -90
  99. package/dist/extraction/languages/kotlin.d.ts +0 -3
  100. package/dist/extraction/languages/kotlin.js +0 -253
  101. package/dist/extraction/languages/lua.d.ts +0 -3
  102. package/dist/extraction/languages/lua.js +0 -150
  103. package/dist/extraction/languages/luau.d.ts +0 -3
  104. package/dist/extraction/languages/luau.js +0 -37
  105. package/dist/extraction/languages/pascal.d.ts +0 -3
  106. package/dist/extraction/languages/pascal.js +0 -66
  107. package/dist/extraction/languages/php.d.ts +0 -3
  108. package/dist/extraction/languages/php.js +0 -107
  109. package/dist/extraction/languages/python.d.ts +0 -3
  110. package/dist/extraction/languages/python.js +0 -56
  111. package/dist/extraction/languages/ruby.d.ts +0 -3
  112. package/dist/extraction/languages/ruby.js +0 -114
  113. package/dist/extraction/languages/rust.d.ts +0 -3
  114. package/dist/extraction/languages/rust.js +0 -109
  115. package/dist/extraction/languages/scala.d.ts +0 -3
  116. package/dist/extraction/languages/scala.js +0 -139
  117. package/dist/extraction/languages/swift.d.ts +0 -3
  118. package/dist/extraction/languages/swift.js +0 -91
  119. package/dist/extraction/languages/typescript.d.ts +0 -3
  120. package/dist/extraction/languages/typescript.js +0 -129
  121. package/dist/extraction/liquid-extractor.d.ts +0 -52
  122. package/dist/extraction/liquid-extractor.js +0 -313
  123. package/dist/extraction/parse-worker.d.ts +0 -8
  124. package/dist/extraction/parse-worker.js +0 -94
  125. package/dist/extraction/svelte-extractor.d.ts +0 -56
  126. package/dist/extraction/svelte-extractor.js +0 -272
  127. package/dist/extraction/tree-sitter-helpers.d.ts +0 -39
  128. package/dist/extraction/tree-sitter-helpers.js +0 -103
  129. package/dist/extraction/tree-sitter-types.d.ts +0 -191
  130. package/dist/extraction/tree-sitter-types.js +0 -10
  131. package/dist/extraction/tree-sitter.d.ts +0 -238
  132. package/dist/extraction/tree-sitter.js +0 -2430
  133. package/dist/extraction/vue-extractor.d.ts +0 -36
  134. package/dist/extraction/vue-extractor.js +0 -163
  135. package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
  136. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  137. package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
  138. package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
  139. package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  140. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  141. package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  142. package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  143. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  144. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  145. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  146. package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
  147. package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  148. package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
  149. package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
  150. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  151. package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
  152. package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  153. package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  154. package/dist/extraction/wasm-runtime-flags.d.ts +0 -46
  155. package/dist/extraction/wasm-runtime-flags.js +0 -105
  156. package/dist/graph/index.d.ts +0 -8
  157. package/dist/graph/index.js +0 -13
  158. package/dist/graph/queries.d.ts +0 -109
  159. package/dist/graph/queries.js +0 -366
  160. package/dist/graph/traversal.d.ts +0 -137
  161. package/dist/graph/traversal.js +0 -528
  162. package/dist/index.d.ts +0 -509
  163. package/dist/index.js +0 -800
  164. package/dist/installer/claude-md-template.d.ts +0 -19
  165. package/dist/installer/config-writer.d.ts +0 -29
  166. package/dist/installer/index.d.ts +0 -140
  167. package/dist/installer/instructions-template.d.ts +0 -30
  168. package/dist/installer/targets/claude.d.ts +0 -55
  169. package/dist/installer/targets/codex.d.ts +0 -18
  170. package/dist/installer/targets/cursor.d.ts +0 -35
  171. package/dist/installer/targets/hermes.d.ts +0 -18
  172. package/dist/installer/targets/opencode.d.ts +0 -30
  173. package/dist/installer/targets/registry.d.ts +0 -38
  174. package/dist/installer/targets/shared.d.ts +0 -92
  175. package/dist/installer/targets/toml.d.ts +0 -64
  176. package/dist/installer/targets/types.d.ts +0 -122
  177. package/dist/mcp/index.d.ts +0 -98
  178. package/dist/mcp/server-instructions.d.ts +0 -20
  179. package/dist/mcp/tools.d.ts +0 -269
  180. package/dist/mcp/transport.d.ts +0 -117
  181. package/dist/resolution/frameworks/cargo-workspace.d.ts +0 -20
  182. package/dist/resolution/frameworks/cargo-workspace.js +0 -225
  183. package/dist/resolution/frameworks/csharp.d.ts +0 -8
  184. package/dist/resolution/frameworks/csharp.js +0 -213
  185. package/dist/resolution/frameworks/drupal.d.ts +0 -51
  186. package/dist/resolution/frameworks/drupal.js +0 -335
  187. package/dist/resolution/frameworks/express.d.ts +0 -8
  188. package/dist/resolution/frameworks/express.js +0 -225
  189. package/dist/resolution/frameworks/go.d.ts +0 -8
  190. package/dist/resolution/frameworks/go.js +0 -158
  191. package/dist/resolution/frameworks/index.d.ts +0 -52
  192. package/dist/resolution/frameworks/index.js +0 -137
  193. package/dist/resolution/frameworks/java.d.ts +0 -8
  194. package/dist/resolution/frameworks/java.js +0 -177
  195. package/dist/resolution/frameworks/laravel.d.ts +0 -13
  196. package/dist/resolution/frameworks/laravel.js +0 -248
  197. package/dist/resolution/frameworks/nestjs.d.ts +0 -26
  198. package/dist/resolution/frameworks/nestjs.js +0 -374
  199. package/dist/resolution/frameworks/python.d.ts +0 -10
  200. package/dist/resolution/frameworks/python.js +0 -278
  201. package/dist/resolution/frameworks/react.d.ts +0 -8
  202. package/dist/resolution/frameworks/react.js +0 -272
  203. package/dist/resolution/frameworks/ruby.d.ts +0 -8
  204. package/dist/resolution/frameworks/ruby.js +0 -198
  205. package/dist/resolution/frameworks/rust.d.ts +0 -8
  206. package/dist/resolution/frameworks/rust.js +0 -207
  207. package/dist/resolution/frameworks/svelte.d.ts +0 -9
  208. package/dist/resolution/frameworks/svelte.js +0 -249
  209. package/dist/resolution/frameworks/swift.d.ts +0 -10
  210. package/dist/resolution/frameworks/swift.js +0 -376
  211. package/dist/resolution/frameworks/vue.d.ts +0 -9
  212. package/dist/resolution/frameworks/vue.js +0 -306
  213. package/dist/resolution/import-resolver.d.ts +0 -61
  214. package/dist/resolution/import-resolver.js +0 -663
  215. package/dist/resolution/index.d.ts +0 -118
  216. package/dist/resolution/index.js +0 -744
  217. package/dist/resolution/lru-cache.d.ts +0 -24
  218. package/dist/resolution/lru-cache.js +0 -62
  219. package/dist/resolution/name-matcher.d.ts +0 -50
  220. package/dist/resolution/name-matcher.js +0 -384
  221. package/dist/resolution/path-aliases.d.ts +0 -72
  222. package/dist/resolution/path-aliases.js +0 -238
  223. package/dist/resolution/strip-comments.d.ts +0 -40
  224. package/dist/resolution/strip-comments.js +0 -441
  225. package/dist/resolution/types.d.ts +0 -181
  226. package/dist/resolution/types.js +0 -8
  227. package/dist/search/query-parser.d.ts +0 -61
  228. package/dist/search/query-parser.js +0 -177
  229. package/dist/search/query-utils.d.ts +0 -59
  230. package/dist/search/query-utils.js +0 -383
  231. package/dist/sync/git-hooks.d.ts +0 -54
  232. package/dist/sync/git-hooks.js +0 -223
  233. package/dist/sync/index.d.ts +0 -25
  234. package/dist/sync/index.js +0 -28
  235. package/dist/sync/watch-policy.d.ts +0 -51
  236. package/dist/sync/watch-policy.js +0 -124
  237. package/dist/sync/watcher.d.ts +0 -83
  238. package/dist/sync/watcher.js +0 -192
  239. package/dist/types.d.ts +0 -433
  240. package/dist/types.js +0 -75
  241. package/dist/ui/glyphs.d.ts +0 -42
  242. package/dist/ui/shimmer-progress.d.ts +0 -11
  243. package/dist/ui/shimmer-worker.d.ts +0 -2
  244. package/dist/ui/types.d.ts +0 -20
  245. package/dist/utils.d.ts +0 -231
  246. package/dist/utils.js +0 -549
@@ -1,36 +0,0 @@
1
- import { ExtractionResult } from '../types'
2
- /**
3
- * VueExtractor - Extracts code relationships from Vue Single-File Component files
4
- *
5
- * Vue SFCs are multi-language (script + template + style). Rather than
6
- * parsing the full Vue grammar, we extract the <script> block content
7
- * and delegate it to the TypeScript/JavaScript TreeSitterExtractor.
8
- *
9
- * Every .vue file produces a component node (Vue components are always importable).
10
- */
11
- export declare class VueExtractor {
12
- private filePath
13
- private source
14
- private nodes
15
- private edges
16
- private unresolvedReferences
17
- private errors
18
- constructor(filePath: string, source: string)
19
- /**
20
- * Extract from Vue source
21
- */
22
- extract(): ExtractionResult
23
- /**
24
- * Create a component node for the .vue file
25
- */
26
- private createComponentNode
27
- /**
28
- * Extract <script> and <script setup> blocks from the Vue source
29
- */
30
- private extractScriptBlocks
31
- /**
32
- * Process a script block by delegating to TreeSitterExtractor
33
- */
34
- private processScriptBlock
35
- }
36
- //# sourceMappingURL=vue-extractor.d.ts.map
@@ -1,163 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VueExtractor = 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
- * VueExtractor - Extracts code relationships from Vue Single-File Component files
9
- *
10
- * Vue SFCs are multi-language (script + template + style). Rather than
11
- * parsing the full Vue grammar, we extract the <script> block content
12
- * and delegate it to the TypeScript/JavaScript TreeSitterExtractor.
13
- *
14
- * Every .vue file produces a component node (Vue components are always importable).
15
- */
16
- class VueExtractor {
17
- filePath;
18
- source;
19
- nodes = [];
20
- edges = [];
21
- unresolvedReferences = [];
22
- errors = [];
23
- constructor(filePath, source) {
24
- this.filePath = filePath;
25
- this.source = source;
26
- }
27
- /**
28
- * Extract from Vue source
29
- */
30
- extract() {
31
- const startTime = Date.now();
32
- try {
33
- // Create component node for the .vue file itself
34
- const componentNode = this.createComponentNode();
35
- // Extract and process script blocks
36
- const scriptBlocks = this.extractScriptBlocks();
37
- for (const block of scriptBlocks) {
38
- this.processScriptBlock(block, componentNode.id);
39
- }
40
- }
41
- catch (error) {
42
- this.errors.push({
43
- message: `Vue extraction error: ${error instanceof Error ? error.message : String(error)}`,
44
- severity: 'error',
45
- });
46
- }
47
- return {
48
- nodes: this.nodes,
49
- edges: this.edges,
50
- unresolvedReferences: this.unresolvedReferences,
51
- errors: this.errors,
52
- durationMs: Date.now() - startTime,
53
- };
54
- }
55
- /**
56
- * Create a component node for the .vue file
57
- */
58
- createComponentNode() {
59
- const lines = this.source.split('\n');
60
- const fileName = this.filePath.split(/[/\\]/).pop() || this.filePath;
61
- const componentName = fileName.replace(/\.vue$/, '');
62
- const id = (0, tree_sitter_helpers_1.generateNodeId)(this.filePath, 'component', componentName, 1);
63
- const node = {
64
- id,
65
- kind: 'component',
66
- name: componentName,
67
- qualifiedName: `${this.filePath}::${componentName}`,
68
- filePath: this.filePath,
69
- language: 'vue',
70
- startLine: 1,
71
- endLine: lines.length,
72
- startColumn: 0,
73
- endColumn: lines[lines.length - 1]?.length || 0,
74
- isExported: true, // Vue components are always importable
75
- updatedAt: Date.now(),
76
- };
77
- this.nodes.push(node);
78
- return node;
79
- }
80
- /**
81
- * Extract <script> and <script setup> blocks from the Vue source
82
- */
83
- extractScriptBlocks() {
84
- const blocks = [];
85
- const scriptRegex = /<script(\s[^>]*)?>(?<content>[\s\S]*?)<\/script>/g;
86
- let match;
87
- while ((match = scriptRegex.exec(this.source)) !== null) {
88
- const attrs = match[1] || '';
89
- const content = match.groups?.content || match[2] || '';
90
- // Detect TypeScript from lang attribute
91
- const isTypeScript = /lang\s*=\s*["'](ts|typescript)["']/.test(attrs);
92
- // Detect <script setup>
93
- const isSetup = /\bsetup\b/.test(attrs);
94
- // Calculate start line of the script content (line after <script>)
95
- const beforeScript = this.source.substring(0, match.index);
96
- const scriptTagLine = (beforeScript.match(/\n/g) || []).length;
97
- // The content starts on the line after the opening <script> tag
98
- const openingTag = match[0].substring(0, match[0].indexOf('>') + 1);
99
- const openingTagLines = (openingTag.match(/\n/g) || []).length;
100
- const contentStartLine = scriptTagLine + openingTagLines + 1; // 0-indexed line
101
- blocks.push({
102
- content,
103
- startLine: contentStartLine,
104
- isSetup,
105
- isTypeScript,
106
- });
107
- }
108
- return blocks;
109
- }
110
- /**
111
- * Process a script block by delegating to TreeSitterExtractor
112
- */
113
- processScriptBlock(block, componentNodeId) {
114
- const scriptLanguage = block.isTypeScript ? 'typescript' : 'javascript';
115
- // Check if the script language parser is available
116
- if (!(0, grammars_1.isLanguageSupported)(scriptLanguage)) {
117
- this.errors.push({
118
- message: `Parser for ${scriptLanguage} not available, cannot parse Vue script block`,
119
- severity: 'warning',
120
- });
121
- return;
122
- }
123
- // Delegate to TreeSitterExtractor
124
- const extractor = new tree_sitter_1.TreeSitterExtractor(this.filePath, block.content, scriptLanguage);
125
- const result = extractor.extract();
126
- // Offset line numbers from script block back to .vue file positions
127
- for (const node of result.nodes) {
128
- node.startLine += block.startLine;
129
- node.endLine += block.startLine;
130
- node.language = 'vue'; // Mark as vue, not TS/JS
131
- this.nodes.push(node);
132
- // Add containment edge from component to this node
133
- this.edges.push({
134
- source: componentNodeId,
135
- target: node.id,
136
- kind: 'contains',
137
- });
138
- }
139
- // Offset edges (they reference line numbers)
140
- for (const edge of result.edges) {
141
- if (edge.line) {
142
- edge.line += block.startLine;
143
- }
144
- this.edges.push(edge);
145
- }
146
- // Offset unresolved references
147
- for (const ref of result.unresolvedReferences) {
148
- ref.line += block.startLine;
149
- ref.filePath = this.filePath;
150
- ref.language = 'vue';
151
- this.unresolvedReferences.push(ref);
152
- }
153
- // Carry over errors
154
- for (const error of result.errors) {
155
- if (error.line) {
156
- error.line += block.startLine;
157
- }
158
- this.errors.push(error);
159
- }
160
- }
161
- }
162
- exports.VueExtractor = VueExtractor;
163
- //# sourceMappingURL=vue-extractor.js.map
@@ -1,46 +0,0 @@
1
- /**
2
- * The V8 flag(s) that keep tree-sitter grammar compilation off the turboshaft
3
- * optimizing tier. Single source of truth: the relaunch guard and the test
4
- * suite both read this (a test asserts each is a real flag on the running
5
- * runtime, so a rename can't silently regress the fix).
6
- */
7
- export declare const WASM_RUNTIME_FLAGS: readonly string[]
8
- /**
9
- * Env var carrying the *host* PID (the relauncher's own parent) across the
10
- * re-exec. Without `--liftoff-only` the CLI re-execs itself once, inserting an
11
- * intermediate process between the MCP host and the server. That intermediate
12
- * stays alive (blocked in spawnSync) even after the host is killed, so the
13
- * server's PPID watchdog can't detect the host's death by watching its own
14
- * `process.ppid`. Passing the host PID through lets the watchdog poll it
15
- * directly. Unset on the no-re-exec path (bundled launcher / flag already
16
- * present), where the server is already a direct child of the host. See
17
- * src/mcp/index.ts (#277).
18
- */
19
- export declare const HOST_PPID_ENV = 'CODEGRAPH_HOST_PPID'
20
- /** True when every required WASM runtime flag is already present in `execArgv`. */
21
- export declare function processHasWasmRuntimeFlags(
22
- execArgv?: readonly string[],
23
- ): boolean
24
- /**
25
- * Build the argv for re-execing node with the WASM runtime flags: our flags
26
- * first, then any node flags already in `execArgv` (deduped), then the script
27
- * and its args. Pure — exported for unit testing.
28
- */
29
- export declare function buildRelaunchArgv(
30
- scriptPath: string,
31
- scriptArgs: readonly string[],
32
- execArgv?: readonly string[],
33
- ): string[]
34
- /**
35
- * If the current process is missing the WASM runtime flags, re-exec it once
36
- * with them and exit with the child's status. No-op when the flags are already
37
- * present (the normal bundled-launcher path), when already relaunched, or when
38
- * disabled via CODEGRAPH_NO_RELAUNCH.
39
- *
40
- * On spawn failure, returns so the caller runs in-process anyway — risking the
41
- * OOM is still better than refusing to start.
42
- */
43
- export declare function relaunchWithWasmRuntimeFlagsIfNeeded(
44
- scriptPath: string,
45
- ): void
46
- //# sourceMappingURL=wasm-runtime-flags.d.ts.map
@@ -1,105 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HOST_PPID_ENV = exports.WASM_RUNTIME_FLAGS = void 0;
4
- exports.processHasWasmRuntimeFlags = processHasWasmRuntimeFlags;
5
- exports.buildRelaunchArgv = buildRelaunchArgv;
6
- exports.relaunchWithWasmRuntimeFlagsIfNeeded = relaunchWithWasmRuntimeFlagsIfNeeded;
7
- /**
8
- * WASM runtime flags — workaround for the V8 turboshaft WASM Zone OOM.
9
- *
10
- * tree-sitter grammars are large WebAssembly modules. On Node >= 22 the V8
11
- * "turboshaft" optimizing WASM compiler can exhaust its per-compilation Zone
12
- * arena while compiling these grammars on a background thread, aborting the
13
- * whole process with `Fatal process out of memory: Zone` — even with tens of
14
- * GB of system memory free, because the Zone is a V8-internal arena, not the
15
- * JS heap. Reproduced on Node 22 and 24; Node 25 is already hard-blocked for
16
- * the same crash (see ../bin/node-version-check.ts). See issues #293 and #298.
17
- *
18
- * `--liftoff-only` forces every WASM module to the Liftoff baseline compiler
19
- * and never runs turboshaft, which eliminates the crash. Parsing stays fully
20
- * correct; we only forgo the (marginal, and for grammars rarely reached)
21
- * optimized-tier speedup.
22
- *
23
- * This flag MUST be on node's command line — it is read by V8 at engine init,
24
- * before any of our JS runs. Empirically (Node 24) none of these work:
25
- * - `v8.setFlagsFromString('--liftoff-only')` at runtime — too late.
26
- * - Worker `execArgv: ['--liftoff-only']` — rejected (ERR_WORKER_INVALID_EXEC_ARGV).
27
- * - `NODE_OPTIONS=--liftoff-only` — not on Node's NODE_OPTIONS allowlist.
28
- * Also empirically, `--no-wasm-tier-up` / `--no-wasm-dynamic-tiering` do NOT
29
- * prevent the crash — only disabling the optimizing tier entirely does.
30
- *
31
- * Delivery: the bundled launcher passes the flag directly (see
32
- * scripts/build-bundle.sh and scripts/npm-shim.js); for any other launch path
33
- * (running dist directly, from source, etc.) the CLI re-execs itself once with
34
- * the flag via {@link relaunchWithWasmRuntimeFlagsIfNeeded}. V8 flags are
35
- * PROCESS-global, and the parse worker is created with default (inherited)
36
- * execArgv, so flagging the main process governs the worker's WASM compilation
37
- * too.
38
- */
39
- const child_process_1 = require("child_process");
40
- /**
41
- * The V8 flag(s) that keep tree-sitter grammar compilation off the turboshaft
42
- * optimizing tier. Single source of truth: the relaunch guard and the test
43
- * suite both read this (a test asserts each is a real flag on the running
44
- * runtime, so a rename can't silently regress the fix).
45
- */
46
- exports.WASM_RUNTIME_FLAGS = ['--liftoff-only'];
47
- /**
48
- * Env var set on the relaunched child so a detection slip can never cause an
49
- * infinite re-exec loop. Also lets users force-disable the relaunch.
50
- */
51
- const RELAUNCH_GUARD_ENV = 'CODEGRAPH_WASM_RELAUNCHED';
52
- /**
53
- * Env var carrying the *host* PID (the relauncher's own parent) across the
54
- * re-exec. Without `--liftoff-only` the CLI re-execs itself once, inserting an
55
- * intermediate process between the MCP host and the server. That intermediate
56
- * stays alive (blocked in spawnSync) even after the host is killed, so the
57
- * server's PPID watchdog can't detect the host's death by watching its own
58
- * `process.ppid`. Passing the host PID through lets the watchdog poll it
59
- * directly. Unset on the no-re-exec path (bundled launcher / flag already
60
- * present), where the server is already a direct child of the host. See
61
- * src/mcp/index.ts (#277).
62
- */
63
- exports.HOST_PPID_ENV = 'CODEGRAPH_HOST_PPID';
64
- /** True when every required WASM runtime flag is already present in `execArgv`. */
65
- function processHasWasmRuntimeFlags(execArgv = process.execArgv) {
66
- return exports.WASM_RUNTIME_FLAGS.every((flag) => execArgv.includes(flag));
67
- }
68
- /**
69
- * Build the argv for re-execing node with the WASM runtime flags: our flags
70
- * first, then any node flags already in `execArgv` (deduped), then the script
71
- * and its args. Pure — exported for unit testing.
72
- */
73
- function buildRelaunchArgv(scriptPath, scriptArgs, execArgv = process.execArgv) {
74
- const preserved = execArgv.filter((arg) => !exports.WASM_RUNTIME_FLAGS.includes(arg));
75
- return [...exports.WASM_RUNTIME_FLAGS, ...preserved, scriptPath, ...scriptArgs];
76
- }
77
- /**
78
- * If the current process is missing the WASM runtime flags, re-exec it once
79
- * with them and exit with the child's status. No-op when the flags are already
80
- * present (the normal bundled-launcher path), when already relaunched, or when
81
- * disabled via CODEGRAPH_NO_RELAUNCH.
82
- *
83
- * On spawn failure, returns so the caller runs in-process anyway — risking the
84
- * OOM is still better than refusing to start.
85
- */
86
- function relaunchWithWasmRuntimeFlagsIfNeeded(scriptPath) {
87
- if (processHasWasmRuntimeFlags())
88
- return;
89
- if (process.env[RELAUNCH_GUARD_ENV])
90
- return;
91
- if (process.env.CODEGRAPH_NO_RELAUNCH)
92
- return;
93
- const argv = buildRelaunchArgv(scriptPath, process.argv.slice(2));
94
- const result = (0, child_process_1.spawnSync)(process.execPath, argv, {
95
- stdio: 'inherit',
96
- env: { ...process.env, [RELAUNCH_GUARD_ENV]: '1', [exports.HOST_PPID_ENV]: String(process.ppid) },
97
- });
98
- if (result.error) {
99
- // Couldn't relaunch (e.g. execPath unavailable) — fall through and run in
100
- // this process. Degraded (may OOM on huge repos) but not broken.
101
- return;
102
- }
103
- process.exit(result.status ?? (result.signal ? 1 : 0));
104
- }
105
- //# sourceMappingURL=wasm-runtime-flags.js.map
@@ -1,8 +0,0 @@
1
- /**
2
- * Graph Module
3
- *
4
- * Provides graph traversal and query functionality for the code knowledge graph.
5
- */
6
- export { GraphTraverser } from './traversal'
7
- export { GraphQueryManager } from './queries'
8
- //# sourceMappingURL=index.d.ts.map
@@ -1,13 +0,0 @@
1
- "use strict";
2
- /**
3
- * Graph Module
4
- *
5
- * Provides graph traversal and query functionality for the code knowledge graph.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.GraphQueryManager = exports.GraphTraverser = void 0;
9
- var traversal_1 = require("./traversal");
10
- Object.defineProperty(exports, "GraphTraverser", { enumerable: true, get: function () { return traversal_1.GraphTraverser; } });
11
- var queries_1 = require("./queries");
12
- Object.defineProperty(exports, "GraphQueryManager", { enumerable: true, get: function () { return queries_1.GraphQueryManager; } });
13
- //# sourceMappingURL=index.js.map
@@ -1,109 +0,0 @@
1
- /**
2
- * Graph Query Functions
3
- *
4
- * Higher-level query functions built on top of traversal algorithms.
5
- */
6
- import { Node, Context, Subgraph } from '../types'
7
- import { QueryBuilder } from '../db/queries'
8
- import { GraphTraverser } from './traversal'
9
- /**
10
- * Graph query manager for complex queries
11
- */
12
- export declare class GraphQueryManager {
13
- private queries
14
- private traverser
15
- constructor(queries: QueryBuilder)
16
- /**
17
- * Get full context for a node
18
- *
19
- * Returns the focal node along with its ancestors, children,
20
- * and both incoming and outgoing references.
21
- *
22
- * @param nodeId - ID of the focal node
23
- * @returns Context object with all related information
24
- */
25
- getContext(nodeId: string): Context
26
- /**
27
- * Get dependencies of a file
28
- *
29
- * Returns all files that this file imports from.
30
- *
31
- * @param filePath - Path to the file
32
- * @returns Array of file paths this file depends on
33
- */
34
- getFileDependencies(filePath: string): string[]
35
- /**
36
- * Get dependents of a file
37
- *
38
- * Returns all files that import from this file.
39
- *
40
- * @param filePath - Path to the file
41
- * @returns Array of file paths that depend on this file
42
- */
43
- getFileDependents(filePath: string): string[]
44
- /**
45
- * Get all symbols exported by a file
46
- *
47
- * @param filePath - Path to the file
48
- * @returns Array of exported nodes
49
- */
50
- getExportedSymbols(filePath: string): Node[]
51
- /**
52
- * Find symbols by qualified name pattern
53
- *
54
- * @param pattern - Pattern to match (supports * wildcard)
55
- * @returns Array of matching nodes
56
- */
57
- findByQualifiedName(pattern: string): Node[]
58
- /**
59
- * Get the module/package structure
60
- *
61
- * Returns a tree structure of files organized by directory.
62
- *
63
- * @returns Map of directory paths to contained files
64
- */
65
- getModuleStructure(): Map<string, string[]>
66
- /**
67
- * Find circular dependencies in the graph
68
- *
69
- * @returns Array of cycles, each cycle is an array of node IDs
70
- */
71
- findCircularDependencies(): string[][]
72
- /**
73
- * Get complexity metrics for a node
74
- *
75
- * @param nodeId - ID of the node
76
- * @returns Object containing various complexity metrics
77
- */
78
- getNodeMetrics(nodeId: string): {
79
- incomingEdgeCount: number
80
- outgoingEdgeCount: number
81
- callCount: number
82
- callerCount: number
83
- childCount: number
84
- depth: number
85
- }
86
- /**
87
- * Find dead code (nodes with no incoming references)
88
- *
89
- * @param kinds - Node kinds to check (default: functions, methods, classes)
90
- * @returns Array of unreferenced nodes
91
- */
92
- findDeadCode(kinds?: Node['kind'][]): Node[]
93
- /**
94
- * Get subgraph containing nodes matching a filter
95
- *
96
- * @param filter - Filter function to select nodes
97
- * @param includeEdges - Whether to include edges between matching nodes
98
- * @returns Subgraph containing matching nodes
99
- */
100
- getFilteredSubgraph(
101
- filter: (node: Node) => boolean,
102
- includeEdges?: boolean,
103
- ): Subgraph
104
- /**
105
- * Access the underlying traverser for direct traversal operations
106
- */
107
- getTraverser(): GraphTraverser
108
- }
109
- //# sourceMappingURL=queries.d.ts.map