@saluzi/codegraph 0.1.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 (189) hide show
  1. package/dist/bin/codegraph.d.ts +25 -0
  2. package/dist/bin/node-version-check.d.ts +37 -0
  3. package/dist/bin/uninstall.d.ts +14 -0
  4. package/dist/context/formatter.d.ts +33 -0
  5. package/dist/context/formatter.js +244 -0
  6. package/dist/context/index.d.ts +117 -0
  7. package/dist/context/index.js +1050 -0
  8. package/dist/db/index.d.ts +101 -0
  9. package/dist/db/index.js +250 -0
  10. package/dist/db/migrations.d.ts +47 -0
  11. package/dist/db/migrations.js +131 -0
  12. package/dist/db/queries.d.ts +291 -0
  13. package/dist/db/queries.js +1349 -0
  14. package/dist/db/schema.sql +151 -0
  15. package/dist/db/sqlite-adapter.d.ts +49 -0
  16. package/dist/db/sqlite-adapter.js +141 -0
  17. package/dist/directory.d.ts +62 -0
  18. package/dist/directory.js +264 -0
  19. package/dist/errors.d.ts +149 -0
  20. package/dist/errors.js +219 -0
  21. package/dist/extraction/dfm-extractor.d.ts +31 -0
  22. package/dist/extraction/dfm-extractor.js +151 -0
  23. package/dist/extraction/grammars.d.ts +94 -0
  24. package/dist/extraction/grammars.js +357 -0
  25. package/dist/extraction/index.d.ts +148 -0
  26. package/dist/extraction/index.js +1286 -0
  27. package/dist/extraction/languages/c-cpp.d.ts +4 -0
  28. package/dist/extraction/languages/c-cpp.js +126 -0
  29. package/dist/extraction/languages/csharp.d.ts +3 -0
  30. package/dist/extraction/languages/csharp.js +72 -0
  31. package/dist/extraction/languages/dart.d.ts +3 -0
  32. package/dist/extraction/languages/dart.js +192 -0
  33. package/dist/extraction/languages/go.d.ts +3 -0
  34. package/dist/extraction/languages/go.js +58 -0
  35. package/dist/extraction/languages/index.d.ts +10 -0
  36. package/dist/extraction/languages/index.js +49 -0
  37. package/dist/extraction/languages/java.d.ts +3 -0
  38. package/dist/extraction/languages/java.js +64 -0
  39. package/dist/extraction/languages/javascript.d.ts +3 -0
  40. package/dist/extraction/languages/javascript.js +90 -0
  41. package/dist/extraction/languages/kotlin.d.ts +3 -0
  42. package/dist/extraction/languages/kotlin.js +253 -0
  43. package/dist/extraction/languages/lua.d.ts +3 -0
  44. package/dist/extraction/languages/lua.js +150 -0
  45. package/dist/extraction/languages/luau.d.ts +3 -0
  46. package/dist/extraction/languages/luau.js +37 -0
  47. package/dist/extraction/languages/pascal.d.ts +3 -0
  48. package/dist/extraction/languages/pascal.js +66 -0
  49. package/dist/extraction/languages/php.d.ts +3 -0
  50. package/dist/extraction/languages/php.js +107 -0
  51. package/dist/extraction/languages/python.d.ts +3 -0
  52. package/dist/extraction/languages/python.js +56 -0
  53. package/dist/extraction/languages/ruby.d.ts +3 -0
  54. package/dist/extraction/languages/ruby.js +114 -0
  55. package/dist/extraction/languages/rust.d.ts +3 -0
  56. package/dist/extraction/languages/rust.js +109 -0
  57. package/dist/extraction/languages/scala.d.ts +3 -0
  58. package/dist/extraction/languages/scala.js +139 -0
  59. package/dist/extraction/languages/swift.d.ts +3 -0
  60. package/dist/extraction/languages/swift.js +91 -0
  61. package/dist/extraction/languages/typescript.d.ts +3 -0
  62. package/dist/extraction/languages/typescript.js +129 -0
  63. package/dist/extraction/liquid-extractor.d.ts +52 -0
  64. package/dist/extraction/liquid-extractor.js +313 -0
  65. package/dist/extraction/parse-worker.d.ts +8 -0
  66. package/dist/extraction/parse-worker.js +94 -0
  67. package/dist/extraction/svelte-extractor.d.ts +56 -0
  68. package/dist/extraction/svelte-extractor.js +272 -0
  69. package/dist/extraction/tree-sitter-helpers.d.ts +39 -0
  70. package/dist/extraction/tree-sitter-helpers.js +103 -0
  71. package/dist/extraction/tree-sitter-types.d.ts +191 -0
  72. package/dist/extraction/tree-sitter-types.js +10 -0
  73. package/dist/extraction/tree-sitter.d.ts +238 -0
  74. package/dist/extraction/tree-sitter.js +2430 -0
  75. package/dist/extraction/vue-extractor.d.ts +36 -0
  76. package/dist/extraction/vue-extractor.js +163 -0
  77. package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
  78. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  79. package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
  80. package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
  81. package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  82. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  83. package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  84. package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  85. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  86. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  87. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  88. package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
  89. package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  90. package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
  91. package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
  92. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  93. package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
  94. package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  95. package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  96. package/dist/extraction/wasm-runtime-flags.d.ts +46 -0
  97. package/dist/extraction/wasm-runtime-flags.js +105 -0
  98. package/dist/graph/index.d.ts +8 -0
  99. package/dist/graph/index.js +13 -0
  100. package/dist/graph/queries.d.ts +109 -0
  101. package/dist/graph/queries.js +366 -0
  102. package/dist/graph/traversal.d.ts +137 -0
  103. package/dist/graph/traversal.js +528 -0
  104. package/dist/index.d.ts +509 -0
  105. package/dist/index.js +800 -0
  106. package/dist/installer/claude-md-template.d.ts +19 -0
  107. package/dist/installer/config-writer.d.ts +29 -0
  108. package/dist/installer/index.d.ts +140 -0
  109. package/dist/installer/instructions-template.d.ts +30 -0
  110. package/dist/installer/targets/claude.d.ts +55 -0
  111. package/dist/installer/targets/codex.d.ts +18 -0
  112. package/dist/installer/targets/cursor.d.ts +35 -0
  113. package/dist/installer/targets/hermes.d.ts +18 -0
  114. package/dist/installer/targets/opencode.d.ts +30 -0
  115. package/dist/installer/targets/registry.d.ts +38 -0
  116. package/dist/installer/targets/shared.d.ts +92 -0
  117. package/dist/installer/targets/toml.d.ts +64 -0
  118. package/dist/installer/targets/types.d.ts +122 -0
  119. package/dist/mcp/index.d.ts +98 -0
  120. package/dist/mcp/server-instructions.d.ts +20 -0
  121. package/dist/mcp/tools.d.ts +269 -0
  122. package/dist/mcp/transport.d.ts +117 -0
  123. package/dist/resolution/frameworks/cargo-workspace.d.ts +20 -0
  124. package/dist/resolution/frameworks/cargo-workspace.js +225 -0
  125. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  126. package/dist/resolution/frameworks/csharp.js +213 -0
  127. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  128. package/dist/resolution/frameworks/drupal.js +335 -0
  129. package/dist/resolution/frameworks/express.d.ts +8 -0
  130. package/dist/resolution/frameworks/express.js +225 -0
  131. package/dist/resolution/frameworks/go.d.ts +8 -0
  132. package/dist/resolution/frameworks/go.js +158 -0
  133. package/dist/resolution/frameworks/index.d.ts +52 -0
  134. package/dist/resolution/frameworks/index.js +137 -0
  135. package/dist/resolution/frameworks/java.d.ts +8 -0
  136. package/dist/resolution/frameworks/java.js +177 -0
  137. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  138. package/dist/resolution/frameworks/laravel.js +248 -0
  139. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  140. package/dist/resolution/frameworks/nestjs.js +374 -0
  141. package/dist/resolution/frameworks/python.d.ts +10 -0
  142. package/dist/resolution/frameworks/python.js +278 -0
  143. package/dist/resolution/frameworks/react.d.ts +8 -0
  144. package/dist/resolution/frameworks/react.js +272 -0
  145. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  146. package/dist/resolution/frameworks/ruby.js +198 -0
  147. package/dist/resolution/frameworks/rust.d.ts +8 -0
  148. package/dist/resolution/frameworks/rust.js +207 -0
  149. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  150. package/dist/resolution/frameworks/svelte.js +249 -0
  151. package/dist/resolution/frameworks/swift.d.ts +10 -0
  152. package/dist/resolution/frameworks/swift.js +376 -0
  153. package/dist/resolution/frameworks/vue.d.ts +9 -0
  154. package/dist/resolution/frameworks/vue.js +306 -0
  155. package/dist/resolution/import-resolver.d.ts +61 -0
  156. package/dist/resolution/import-resolver.js +663 -0
  157. package/dist/resolution/index.d.ts +118 -0
  158. package/dist/resolution/index.js +744 -0
  159. package/dist/resolution/lru-cache.d.ts +24 -0
  160. package/dist/resolution/lru-cache.js +62 -0
  161. package/dist/resolution/name-matcher.d.ts +50 -0
  162. package/dist/resolution/name-matcher.js +384 -0
  163. package/dist/resolution/path-aliases.d.ts +72 -0
  164. package/dist/resolution/path-aliases.js +238 -0
  165. package/dist/resolution/strip-comments.d.ts +40 -0
  166. package/dist/resolution/strip-comments.js +441 -0
  167. package/dist/resolution/types.d.ts +181 -0
  168. package/dist/resolution/types.js +8 -0
  169. package/dist/search/query-parser.d.ts +61 -0
  170. package/dist/search/query-parser.js +177 -0
  171. package/dist/search/query-utils.d.ts +59 -0
  172. package/dist/search/query-utils.js +383 -0
  173. package/dist/sync/git-hooks.d.ts +54 -0
  174. package/dist/sync/git-hooks.js +223 -0
  175. package/dist/sync/index.d.ts +25 -0
  176. package/dist/sync/index.js +28 -0
  177. package/dist/sync/watch-policy.d.ts +51 -0
  178. package/dist/sync/watch-policy.js +124 -0
  179. package/dist/sync/watcher.d.ts +83 -0
  180. package/dist/sync/watcher.js +192 -0
  181. package/dist/types.d.ts +433 -0
  182. package/dist/types.js +75 -0
  183. package/dist/ui/glyphs.d.ts +42 -0
  184. package/dist/ui/shimmer-progress.d.ts +11 -0
  185. package/dist/ui/shimmer-worker.d.ts +2 -0
  186. package/dist/ui/types.d.ts +20 -0
  187. package/dist/utils.d.ts +231 -0
  188. package/dist/utils.js +549 -0
  189. package/package.json +24 -0
@@ -0,0 +1,441 @@
1
+ "use strict";
2
+ /**
3
+ * Per-language comment stripper for framework route extractors.
4
+ *
5
+ * Replaces comment characters and string-literal contents that hide
6
+ * routing-shaped text with spaces (NOT removal) so that source offsets
7
+ * are preserved. This means `match.index` from a regex run on the
8
+ * stripped output still maps to the same line in the original source.
9
+ *
10
+ * Example:
11
+ * Input: "x = 1 # path('/fake/', V)\n real = 2"
12
+ * Output: "x = 1 \n real = 2"
13
+ *
14
+ * Why strip strings/docstrings as well as comments? Python module/class
15
+ * docstrings are a common source of false positives — they often contain
16
+ * `path('/example/', View)` examples in usage docs. We treat triple-quoted
17
+ * strings the same as comments. Single-line strings stay intact (a `#`
18
+ * inside a Python string is NOT a comment).
19
+ *
20
+ * Scope: this is a pragmatic, regex-supporting helper, not a full parser.
21
+ * It does NOT try to detect JS regex literals, Python f-string expressions,
22
+ * or shell-style heredocs. Those edge cases are not load-bearing for the
23
+ * `path(...)`, `Route::get(...)`, `app.get(...)` style patterns that
24
+ * framework extractors scan for.
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.stripCommentsForRegex = stripCommentsForRegex;
28
+ function stripCommentsForRegex(content, lang) {
29
+ switch (lang) {
30
+ case 'python':
31
+ return stripPython(content);
32
+ case 'ruby':
33
+ return stripRuby(content);
34
+ case 'rust':
35
+ return stripRust(content);
36
+ case 'php':
37
+ return stripPhp(content);
38
+ case 'go':
39
+ return stripGo(content);
40
+ case 'javascript':
41
+ case 'typescript':
42
+ case 'java':
43
+ case 'csharp':
44
+ case 'swift':
45
+ return stripCStyle(content, /* allowSingleQuoteStrings */ lang === 'javascript' || lang === 'typescript');
46
+ default:
47
+ return content;
48
+ }
49
+ }
50
+ /**
51
+ * Replace every char in a slice with spaces, but keep newlines so line
52
+ * numbers computed downstream remain valid.
53
+ */
54
+ function blankRange(buf, start, end, src) {
55
+ for (let i = start; i < end; i++) {
56
+ buf[i] = src[i] === '\n' ? '\n' : ' ';
57
+ }
58
+ }
59
+ // ---------- Python ----------
60
+ function stripPython(src) {
61
+ const out = src.split('');
62
+ let i = 0;
63
+ const n = src.length;
64
+ while (i < n) {
65
+ const c = src[i];
66
+ const c2 = src[i + 1] ?? '';
67
+ const c3 = src[i + 2] ?? '';
68
+ // Triple-quoted string: """...""" or '''...'''
69
+ if ((c === '"' || c === "'") && c2 === c && c3 === c) {
70
+ const quote = c;
71
+ const start = i;
72
+ i += 3;
73
+ while (i < n) {
74
+ if (src[i] === '\\' && i + 1 < n) {
75
+ i += 2;
76
+ continue;
77
+ }
78
+ if (src[i] === quote && src[i + 1] === quote && src[i + 2] === quote) {
79
+ i += 3;
80
+ break;
81
+ }
82
+ i++;
83
+ }
84
+ blankRange(out, start, i, src);
85
+ continue;
86
+ }
87
+ // Single-line string: '...' or "..."
88
+ if (c === '"' || c === "'") {
89
+ const quote = c;
90
+ i++;
91
+ while (i < n && src[i] !== quote) {
92
+ if (src[i] === '\\' && i + 1 < n) {
93
+ i += 2;
94
+ continue;
95
+ }
96
+ if (src[i] === '\n')
97
+ break; // unterminated
98
+ i++;
99
+ }
100
+ if (i < n && src[i] === quote)
101
+ i++;
102
+ continue;
103
+ }
104
+ // Line comment
105
+ if (c === '#') {
106
+ const start = i;
107
+ while (i < n && src[i] !== '\n')
108
+ i++;
109
+ blankRange(out, start, i, src);
110
+ continue;
111
+ }
112
+ i++;
113
+ }
114
+ return out.join('');
115
+ }
116
+ // ---------- Ruby ----------
117
+ function stripRuby(src) {
118
+ const out = src.split('');
119
+ let i = 0;
120
+ const n = src.length;
121
+ let atLineStart = true;
122
+ while (i < n) {
123
+ const c = src[i];
124
+ // =begin / =end block comments must be at start of line (after optional whitespace)
125
+ if (atLineStart && c === '=' && src.startsWith('=begin', i)) {
126
+ const start = i;
127
+ // consume to matching =end at line start
128
+ i += '=begin'.length;
129
+ while (i < n) {
130
+ if (src[i] === '\n') {
131
+ // check next line for =end
132
+ let j = i + 1;
133
+ while (j < n && (src[j] === ' ' || src[j] === '\t'))
134
+ j++;
135
+ if (src.startsWith('=end', j)) {
136
+ i = j + '=end'.length;
137
+ // consume rest of that line
138
+ while (i < n && src[i] !== '\n')
139
+ i++;
140
+ break;
141
+ }
142
+ }
143
+ i++;
144
+ }
145
+ blankRange(out, start, i, src);
146
+ atLineStart = i > 0 && src[i - 1] === '\n';
147
+ continue;
148
+ }
149
+ // String literals
150
+ if (c === '"' || c === "'") {
151
+ const quote = c;
152
+ i++;
153
+ while (i < n && src[i] !== quote) {
154
+ if (src[i] === '\\' && i + 1 < n) {
155
+ i += 2;
156
+ continue;
157
+ }
158
+ if (src[i] === '\n')
159
+ break;
160
+ i++;
161
+ }
162
+ if (i < n && src[i] === quote)
163
+ i++;
164
+ atLineStart = false;
165
+ continue;
166
+ }
167
+ // Line comment
168
+ if (c === '#') {
169
+ const start = i;
170
+ while (i < n && src[i] !== '\n')
171
+ i++;
172
+ blankRange(out, start, i, src);
173
+ atLineStart = false;
174
+ continue;
175
+ }
176
+ if (c === '\n') {
177
+ atLineStart = true;
178
+ i++;
179
+ continue;
180
+ }
181
+ if (c === ' ' || c === '\t') {
182
+ // whitespace doesn't change atLineStart
183
+ i++;
184
+ continue;
185
+ }
186
+ atLineStart = false;
187
+ i++;
188
+ }
189
+ return out.join('');
190
+ }
191
+ // ---------- C-style (JS/TS/Java/C#/Swift) ----------
192
+ function stripCStyle(src, allowSingleQuoteStrings) {
193
+ const out = src.split('');
194
+ let i = 0;
195
+ const n = src.length;
196
+ while (i < n) {
197
+ const c = src[i];
198
+ const c2 = src[i + 1] ?? '';
199
+ // Block comment
200
+ if (c === '/' && c2 === '*') {
201
+ const start = i;
202
+ i += 2;
203
+ while (i < n && !(src[i] === '*' && src[i + 1] === '/'))
204
+ i++;
205
+ if (i < n)
206
+ i += 2;
207
+ blankRange(out, start, i, src);
208
+ continue;
209
+ }
210
+ // Line comment
211
+ if (c === '/' && c2 === '/') {
212
+ const start = i;
213
+ while (i < n && src[i] !== '\n')
214
+ i++;
215
+ blankRange(out, start, i, src);
216
+ continue;
217
+ }
218
+ // String literals
219
+ if (c === '"' || (allowSingleQuoteStrings && c === "'") || c === '`') {
220
+ const quote = c;
221
+ i++;
222
+ while (i < n && src[i] !== quote) {
223
+ if (src[i] === '\\' && i + 1 < n) {
224
+ i += 2;
225
+ continue;
226
+ }
227
+ // Template literal can span lines; regular strings break on newline (treat as unterminated)
228
+ if (quote !== '`' && src[i] === '\n')
229
+ break;
230
+ i++;
231
+ }
232
+ if (i < n && src[i] === quote)
233
+ i++;
234
+ continue;
235
+ }
236
+ i++;
237
+ }
238
+ return out.join('');
239
+ }
240
+ // ---------- PHP ----------
241
+ function stripPhp(src) {
242
+ const out = src.split('');
243
+ let i = 0;
244
+ const n = src.length;
245
+ while (i < n) {
246
+ const c = src[i];
247
+ const c2 = src[i + 1] ?? '';
248
+ // Block comment
249
+ if (c === '/' && c2 === '*') {
250
+ const start = i;
251
+ i += 2;
252
+ while (i < n && !(src[i] === '*' && src[i + 1] === '/'))
253
+ i++;
254
+ if (i < n)
255
+ i += 2;
256
+ blankRange(out, start, i, src);
257
+ continue;
258
+ }
259
+ // // line comment
260
+ if (c === '/' && c2 === '/') {
261
+ const start = i;
262
+ while (i < n && src[i] !== '\n')
263
+ i++;
264
+ blankRange(out, start, i, src);
265
+ continue;
266
+ }
267
+ // # line comment (PHP supports both)
268
+ if (c === '#') {
269
+ const start = i;
270
+ while (i < n && src[i] !== '\n')
271
+ i++;
272
+ blankRange(out, start, i, src);
273
+ continue;
274
+ }
275
+ // String literals: ', ", ` (PHP doesn't really use backticks for strings,
276
+ // but it does have shell-exec backticks; treating as a string is fine here)
277
+ if (c === '"' || c === "'" || c === '`') {
278
+ const quote = c;
279
+ i++;
280
+ while (i < n && src[i] !== quote) {
281
+ if (src[i] === '\\' && i + 1 < n) {
282
+ i += 2;
283
+ continue;
284
+ }
285
+ if (src[i] === '\n')
286
+ break;
287
+ i++;
288
+ }
289
+ if (i < n && src[i] === quote)
290
+ i++;
291
+ continue;
292
+ }
293
+ i++;
294
+ }
295
+ return out.join('');
296
+ }
297
+ // ---------- Go ----------
298
+ function stripGo(src) {
299
+ const out = src.split('');
300
+ let i = 0;
301
+ const n = src.length;
302
+ while (i < n) {
303
+ const c = src[i];
304
+ const c2 = src[i + 1] ?? '';
305
+ // Block comment
306
+ if (c === '/' && c2 === '*') {
307
+ const start = i;
308
+ i += 2;
309
+ while (i < n && !(src[i] === '*' && src[i + 1] === '/'))
310
+ i++;
311
+ if (i < n)
312
+ i += 2;
313
+ blankRange(out, start, i, src);
314
+ continue;
315
+ }
316
+ // Line comment
317
+ if (c === '/' && c2 === '/') {
318
+ const start = i;
319
+ while (i < n && src[i] !== '\n')
320
+ i++;
321
+ blankRange(out, start, i, src);
322
+ continue;
323
+ }
324
+ // Raw string with backticks (no escapes, can span lines)
325
+ if (c === '`') {
326
+ i++;
327
+ while (i < n && src[i] !== '`')
328
+ i++;
329
+ if (i < n)
330
+ i++;
331
+ continue;
332
+ }
333
+ // Interpreted string with double quotes
334
+ if (c === '"') {
335
+ i++;
336
+ while (i < n && src[i] !== '"') {
337
+ if (src[i] === '\\' && i + 1 < n) {
338
+ i += 2;
339
+ continue;
340
+ }
341
+ if (src[i] === '\n')
342
+ break;
343
+ i++;
344
+ }
345
+ if (i < n && src[i] === '"')
346
+ i++;
347
+ continue;
348
+ }
349
+ // Rune literal with single quotes (handle as a tiny string)
350
+ if (c === "'") {
351
+ i++;
352
+ while (i < n && src[i] !== "'") {
353
+ if (src[i] === '\\' && i + 1 < n) {
354
+ i += 2;
355
+ continue;
356
+ }
357
+ if (src[i] === '\n')
358
+ break;
359
+ i++;
360
+ }
361
+ if (i < n && src[i] === "'")
362
+ i++;
363
+ continue;
364
+ }
365
+ i++;
366
+ }
367
+ return out.join('');
368
+ }
369
+ // ---------- Rust ----------
370
+ function stripRust(src) {
371
+ const out = src.split('');
372
+ let i = 0;
373
+ const n = src.length;
374
+ while (i < n) {
375
+ const c = src[i];
376
+ const c2 = src[i + 1] ?? '';
377
+ // Nested block comment /* ... /* ... */ ... */
378
+ if (c === '/' && c2 === '*') {
379
+ const start = i;
380
+ i += 2;
381
+ let depth = 1;
382
+ while (i < n && depth > 0) {
383
+ if (src[i] === '/' && src[i + 1] === '*') {
384
+ depth++;
385
+ i += 2;
386
+ }
387
+ else if (src[i] === '*' && src[i + 1] === '/') {
388
+ depth--;
389
+ i += 2;
390
+ }
391
+ else {
392
+ i++;
393
+ }
394
+ }
395
+ blankRange(out, start, i, src);
396
+ continue;
397
+ }
398
+ // Line comment
399
+ if (c === '/' && c2 === '/') {
400
+ const start = i;
401
+ while (i < n && src[i] !== '\n')
402
+ i++;
403
+ blankRange(out, start, i, src);
404
+ continue;
405
+ }
406
+ // String literals
407
+ if (c === '"') {
408
+ i++;
409
+ while (i < n && src[i] !== '"') {
410
+ if (src[i] === '\\' && i + 1 < n) {
411
+ i += 2;
412
+ continue;
413
+ }
414
+ i++;
415
+ }
416
+ if (i < n && src[i] === '"')
417
+ i++;
418
+ continue;
419
+ }
420
+ // Char literal — keep simple: skip 'x' or '\x'
421
+ if (c === "'") {
422
+ // Could be a lifetime, e.g. 'a, but those don't contain routing text
423
+ i++;
424
+ while (i < n && src[i] !== "'") {
425
+ if (src[i] === '\\' && i + 1 < n) {
426
+ i += 2;
427
+ continue;
428
+ }
429
+ if (src[i] === '\n')
430
+ break;
431
+ i++;
432
+ }
433
+ if (i < n && src[i] === "'")
434
+ i++;
435
+ continue;
436
+ }
437
+ i++;
438
+ }
439
+ return out.join('');
440
+ }
441
+ //# sourceMappingURL=strip-comments.js.map
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Reference Resolution Types
3
+ *
4
+ * Types for the reference resolution system.
5
+ */
6
+ import { EdgeKind, Language, Node } from '../types'
7
+ /**
8
+ * An unresolved reference from extraction
9
+ */
10
+ export interface UnresolvedRef {
11
+ /** ID of the source node containing the reference */
12
+ fromNodeId: string
13
+ /** The name being referenced */
14
+ referenceName: string
15
+ /** Type of reference */
16
+ referenceKind: EdgeKind
17
+ /** Line where reference occurs */
18
+ line: number
19
+ /** Column where reference occurs */
20
+ column: number
21
+ /** File path where reference occurs */
22
+ filePath: string
23
+ /** Language of the source file */
24
+ language: Language
25
+ /** Possible qualified names it might resolve to */
26
+ candidates?: string[]
27
+ }
28
+ /**
29
+ * A resolved reference
30
+ */
31
+ export interface ResolvedRef {
32
+ /** Original unresolved reference */
33
+ original: UnresolvedRef
34
+ /** ID of the target node */
35
+ targetNodeId: string
36
+ /** Confidence score (0-1) */
37
+ confidence: number
38
+ /** How it was resolved */
39
+ resolvedBy:
40
+ | 'exact-match'
41
+ | 'import'
42
+ | 'qualified-name'
43
+ | 'framework'
44
+ | 'fuzzy'
45
+ | 'instance-method'
46
+ | 'file-path'
47
+ }
48
+ /**
49
+ * Result of resolution attempt
50
+ */
51
+ export interface ResolutionResult {
52
+ /** Successfully resolved references */
53
+ resolved: ResolvedRef[]
54
+ /** References that couldn't be resolved */
55
+ unresolved: UnresolvedRef[]
56
+ /** Statistics */
57
+ stats: {
58
+ total: number
59
+ resolved: number
60
+ unresolved: number
61
+ byMethod: Record<string, number>
62
+ }
63
+ }
64
+ /**
65
+ * Context for resolution - provides access to the graph
66
+ */
67
+ export interface ResolutionContext {
68
+ /** Get all nodes in a file */
69
+ getNodesInFile(filePath: string): Node[]
70
+ /** Get all nodes by name */
71
+ getNodesByName(name: string): Node[]
72
+ /** Get all nodes by qualified name */
73
+ getNodesByQualifiedName(qualifiedName: string): Node[]
74
+ /** Get all nodes of a kind */
75
+ getNodesByKind(kind: Node['kind']): Node[]
76
+ /** Check if a file exists */
77
+ fileExists(filePath: string): boolean
78
+ /** Read file content */
79
+ readFile(filePath: string): string | null
80
+ /** Get project root */
81
+ getProjectRoot(): string
82
+ /** Get all files */
83
+ getAllFiles(): string[]
84
+ /** Get nodes by lowercase name (O(1) lookup for fuzzy matching) */
85
+ getNodesByLowerName(lowerName: string): Node[]
86
+ /** Get cached import mappings for a file */
87
+ getImportMappings(filePath: string, language: Language): ImportMapping[]
88
+ /**
89
+ * Project import-path aliases (tsconfig/jsconfig `paths`). Returns
90
+ * `null` when the project doesn't define any. Cached per resolver
91
+ * instance — safe to call from any resolver code path. Optional so
92
+ * existing test fixtures and external context implementations
93
+ * compile without modification; production resolver implements it.
94
+ */
95
+ getProjectAliases?(): import('./path-aliases').AliasMap | null
96
+ /**
97
+ * Re-exports declared by a file (`export { x } from './other'`,
98
+ * `export * from './other'`). Empty array when the file has none.
99
+ * Optional so older callers compile; the import resolver follows
100
+ * re-export chains when this is provided.
101
+ */
102
+ getReExports?(filePath: string, language: Language): ReExport[]
103
+ /**
104
+ * List immediate subdirectories of `relativePath` (relative to the
105
+ * project root). Returns an empty array when the path doesn't exist
106
+ * or isn't a directory. Used by framework resolvers that need to
107
+ * walk build-system metadata (e.g. Cargo workspace globs). Optional
108
+ * so external context implementations and test fixtures compile
109
+ * without modification.
110
+ */
111
+ listDirectories?(relativePath: string): string[]
112
+ }
113
+ /**
114
+ * Result of framework-specific file extraction.
115
+ */
116
+ export interface FrameworkExtractionResult {
117
+ /** Framework-specific nodes (e.g. routes) */
118
+ nodes: Node[]
119
+ /** Framework-specific unresolved references (e.g. route -> handler) */
120
+ references: UnresolvedRef[]
121
+ }
122
+ /**
123
+ * Framework-specific resolver
124
+ */
125
+ export interface FrameworkResolver {
126
+ /** Framework name */
127
+ name: string
128
+ /** Languages this framework applies to. If omitted, applies to all languages. */
129
+ languages?: Language[]
130
+ /** Detect if project uses this framework (project-level, called once at startup) */
131
+ detect(context: ResolutionContext): boolean
132
+ /** Resolve a reference using framework-specific patterns */
133
+ resolve(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null
134
+ /**
135
+ * Extract framework-specific nodes and references from a file.
136
+ *
137
+ * Returns route nodes, middleware nodes, etc., plus unresolved references
138
+ * that link those nodes to handlers (view classes, controller methods,
139
+ * included modules). Unresolved references flow into the normal resolution
140
+ * pipeline; the framework's own `resolve()` is one of the strategies tried.
141
+ */
142
+ extract?(filePath: string, content: string): FrameworkExtractionResult
143
+ }
144
+ /**
145
+ * Import mapping from a file
146
+ */
147
+ export interface ImportMapping {
148
+ /** Local name used in the file */
149
+ localName: string
150
+ /** Original exported name (may differ due to aliasing) */
151
+ exportedName: string
152
+ /** Source module/path */
153
+ source: string
154
+ /** Whether it's a default import */
155
+ isDefault: boolean
156
+ /** Whether it's a namespace import (import * as X) */
157
+ isNamespace: boolean
158
+ /** Resolved file path (if local) */
159
+ resolvedPath?: string
160
+ }
161
+ /**
162
+ * Re-export from a file: `export { x } from './other'` or
163
+ * `export * from './other'`. Used by the resolver to chase
164
+ * symbols through barrel files.
165
+ */
166
+ export type ReExport =
167
+ | {
168
+ kind: 'named'
169
+ /** Name as exported by THIS file. */
170
+ exportedName: string
171
+ /** Name in the upstream module (differs when renamed: `as`). */
172
+ originalName: string
173
+ /** Module specifier of the upstream module. */
174
+ source: string
175
+ }
176
+ | {
177
+ kind: 'wildcard'
178
+ /** Module specifier of the upstream module. */
179
+ source: string
180
+ }
181
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * Reference Resolution Types
4
+ *
5
+ * Types for the reference resolution system.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Field-qualified search query parser.
3
+ *
4
+ * Splits a raw query like
5
+ *
6
+ * kind:function name:auth path:src/api authenticate
7
+ *
8
+ * into structured filters (kind=function, name="auth", path prefix
9
+ * "src/api") plus the free-text portion ("authenticate") that goes
10
+ * to FTS. Free-text and filters compose: filters narrow the result
11
+ * set, FTS scores within the narrowed set.
12
+ *
13
+ * Recognised fields (case-insensitive, value is the rest until
14
+ * whitespace):
15
+ *
16
+ * kind: one of function|method|class|interface|struct|...
17
+ * lang: one of typescript|python|go|... (alias: language:)
18
+ * path: case-insensitive substring of file_path
19
+ * name: case-insensitive substring of the symbol's name
20
+ *
21
+ * Unknown field prefixes (e.g. `foo:bar`) are passed through to FTS
22
+ * as plain text — that's how someone searching for `TODO:` gets a
23
+ * result instead of a parse error.
24
+ *
25
+ * Quoting:
26
+ * kind:function path:"src/some path/with spaces" → handled by stripping
27
+ * the surrounding double quotes from the value (single token only,
28
+ * no nested escapes).
29
+ */
30
+ import type { NodeKind, Language } from '../types'
31
+ export interface ParsedQuery {
32
+ /** Free-text portion to feed to FTS / LIKE. May be empty. */
33
+ text: string
34
+ /** kind: filters (OR'd). Empty when none specified. */
35
+ kinds: NodeKind[]
36
+ /** lang:/language: filters (OR'd). Empty when none specified. */
37
+ languages: Language[]
38
+ /** path: filters (OR'd, case-insensitive substring of file_path). Empty when none. */
39
+ pathFilters: string[]
40
+ /** name: filters (OR'd, case-insensitive substring of node.name). */
41
+ nameFilters: string[]
42
+ }
43
+ /**
44
+ * Parse a raw query into structured filters + remaining text.
45
+ * Always returns a value; never throws.
46
+ */
47
+ export declare function parseQuery(raw: string): ParsedQuery
48
+ /**
49
+ * Damerau-Levenshtein-ish bounded edit distance. Returns `maxDist + 1`
50
+ * as soon as the distance is known to exceed `maxDist`; that early-exit
51
+ * makes the fuzzy fallback cheap even over tens of thousands of names.
52
+ *
53
+ * Pure DP, O(min(len(a), len(b))) memory. Compares case-folded inputs;
54
+ * callers should pass `lowercase(name)` strings.
55
+ */
56
+ export declare function boundedEditDistance(
57
+ a: string,
58
+ b: string,
59
+ maxDist: number,
60
+ ): number
61
+ //# sourceMappingURL=query-parser.d.ts.map