@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,238 +0,0 @@
1
- "use strict";
2
- /**
3
- * Project-level import-path alias loading.
4
- *
5
- * Reads `compilerOptions.paths` from `tsconfig.json` / `jsconfig.json`
6
- * at the project root and converts the patterns into a form the
7
- * import-resolver can consult.
8
- *
9
- * This is the single biggest blocker to accurate resolution on modern
10
- * JS/TS codebases: aliases like `@/components/Foo` (Next, Nuxt, Nest,
11
- * Vite scaffolds) point into a `paths` map the resolver previously
12
- * ignored — every import through an alias was treated as unresolvable
13
- * unless it happened to match the small hard-coded fallback list.
14
- *
15
- * Scope deliberately small for v1:
16
- * - reads tsconfig.json, then jsconfig.json
17
- * - honours top-level `compilerOptions.baseUrl` and `compilerOptions.paths`
18
- * - supports `*` wildcard (the only TS-supported wildcard)
19
- * - does NOT follow `extends` chains yet (most projects don't need it)
20
- * - does NOT read Vite/webpack/Rollup configs (separate follow-up)
21
- *
22
- * The file is parsed as JSON-with-comments-tolerant — tsconfigs in the
23
- * wild routinely contain `//` and `/* *\/` comments and trailing
24
- * commas, which JSON.parse rejects. We strip those before parsing.
25
- */
26
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
27
- if (k2 === undefined) k2 = k;
28
- var desc = Object.getOwnPropertyDescriptor(m, k);
29
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
30
- desc = { enumerable: true, get: function() { return m[k]; } };
31
- }
32
- Object.defineProperty(o, k2, desc);
33
- }) : (function(o, m, k, k2) {
34
- if (k2 === undefined) k2 = k;
35
- o[k2] = m[k];
36
- }));
37
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
38
- Object.defineProperty(o, "default", { enumerable: true, value: v });
39
- }) : function(o, v) {
40
- o["default"] = v;
41
- });
42
- var __importStar = (this && this.__importStar) || (function () {
43
- var ownKeys = function(o) {
44
- ownKeys = Object.getOwnPropertyNames || function (o) {
45
- var ar = [];
46
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
47
- return ar;
48
- };
49
- return ownKeys(o);
50
- };
51
- return function (mod) {
52
- if (mod && mod.__esModule) return mod;
53
- var result = {};
54
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
55
- __setModuleDefault(result, mod);
56
- return result;
57
- };
58
- })();
59
- Object.defineProperty(exports, "__esModule", { value: true });
60
- exports.loadProjectAliases = loadProjectAliases;
61
- exports.applyAliases = applyAliases;
62
- const fs = __importStar(require("fs"));
63
- const path = __importStar(require("path"));
64
- const errors_1 = require("../errors");
65
- /**
66
- * Strip JSONC comments + trailing commas so a tsconfig with the usual
67
- * VS Code-style annotations parses cleanly. Walks the source as a
68
- * tiny state machine that tracks string context — the previous
69
- * regex-only version corrupted any URL inside a string value
70
- * (`"baseUrl": "https://cdn.example.com"` had everything after `//`
71
- * truncated).
72
- */
73
- function stripJsonc(src) {
74
- let out = '';
75
- let i = 0;
76
- let inString = false;
77
- while (i < src.length) {
78
- const ch = src[i];
79
- if (inString) {
80
- out += ch;
81
- if (ch === '\\' && i + 1 < src.length) {
82
- out += src[i + 1];
83
- i += 2;
84
- continue;
85
- }
86
- if (ch === '"')
87
- inString = false;
88
- i++;
89
- continue;
90
- }
91
- if (ch === '"') {
92
- inString = true;
93
- out += ch;
94
- i++;
95
- continue;
96
- }
97
- if (ch === '/' && src[i + 1] === '/') {
98
- while (i < src.length && src[i] !== '\n')
99
- i++;
100
- continue;
101
- }
102
- if (ch === '/' && src[i + 1] === '*') {
103
- i += 2;
104
- while (i < src.length && !(src[i] === '*' && src[i + 1] === '/'))
105
- i++;
106
- i += 2;
107
- continue;
108
- }
109
- out += ch;
110
- i++;
111
- }
112
- // Trailing commas before } or ] — outside strings, so safe to
113
- // run on the comment-stripped output.
114
- return out.replace(/,(\s*[}\]])/g, '$1');
115
- }
116
- function readTsconfigLike(filePath) {
117
- try {
118
- const raw = fs.readFileSync(filePath, 'utf-8');
119
- const parsed = JSON.parse(stripJsonc(raw));
120
- return parsed && typeof parsed === 'object' ? parsed : null;
121
- }
122
- catch (err) {
123
- (0, errors_1.logDebug)('path-aliases: failed to parse', { filePath, err: String(err) });
124
- return null;
125
- }
126
- }
127
- function splitWildcard(pattern) {
128
- const star = pattern.indexOf('*');
129
- if (star === -1)
130
- return { prefix: pattern, suffix: '', hasWildcard: false };
131
- return {
132
- prefix: pattern.slice(0, star),
133
- suffix: pattern.slice(star + 1),
134
- hasWildcard: true,
135
- };
136
- }
137
- /**
138
- * Load aliases for `projectRoot`. Returns `null` when no tsconfig /
139
- * jsconfig is present or when the file has no usable `paths`.
140
- *
141
- * Cheap to call repeatedly — caching is the caller's job (the
142
- * resolver does it via {@link aliasCache}).
143
- */
144
- function loadProjectAliases(projectRoot) {
145
- const candidates = ['tsconfig.json', 'jsconfig.json'];
146
- let raw = null;
147
- let usedFile = null;
148
- for (const name of candidates) {
149
- const p = path.join(projectRoot, name);
150
- if (fs.existsSync(p)) {
151
- raw = readTsconfigLike(p);
152
- if (raw) {
153
- usedFile = name;
154
- break;
155
- }
156
- }
157
- }
158
- if (!raw)
159
- return null;
160
- const co = raw.compilerOptions ?? {};
161
- const baseUrlRel = co.baseUrl ?? '.';
162
- const baseUrl = path.resolve(projectRoot, baseUrlRel);
163
- const paths = co.paths;
164
- if (!paths || typeof paths !== 'object') {
165
- // baseUrl alone isn't an "alias" per se; with no paths we'd just
166
- // be redirecting the whole tree. Skip — the existing resolver
167
- // already handles relative imports.
168
- return null;
169
- }
170
- const patterns = [];
171
- for (const [pattern, targets] of Object.entries(paths)) {
172
- if (!Array.isArray(targets) || targets.length === 0)
173
- continue;
174
- const filtered = targets.filter((t) => typeof t === 'string');
175
- if (filtered.length === 0)
176
- continue;
177
- const { prefix, suffix, hasWildcard } = splitWildcard(pattern);
178
- patterns.push({ prefix, suffix, hasWildcard, replacements: filtered });
179
- }
180
- if (patterns.length === 0)
181
- return null;
182
- // Specificity sort: longer prefix first; literal patterns before
183
- // wildcard patterns of the same prefix length. TypeScript itself
184
- // uses a similar "most specific match wins" rule.
185
- patterns.sort((a, b) => {
186
- if (a.prefix.length !== b.prefix.length)
187
- return b.prefix.length - a.prefix.length;
188
- if (a.hasWildcard !== b.hasWildcard)
189
- return a.hasWildcard ? 1 : -1;
190
- return 0;
191
- });
192
- (0, errors_1.logDebug)('path-aliases loaded', {
193
- file: usedFile,
194
- baseUrl,
195
- patternCount: patterns.length,
196
- });
197
- return { baseUrl, patterns };
198
- }
199
- /**
200
- * Resolve an import path through an {@link AliasMap}. Returns the list
201
- * of candidate filesystem paths (relative to `projectRoot`), in the
202
- * priority order defined by tsconfig (multiple replacements per alias
203
- * are tried in order). Returns `[]` when no alias matches.
204
- *
205
- * Callers still need to try each candidate with the language's
206
- * extension list — this function only does the alias rewrite.
207
- */
208
- function applyAliases(importPath, aliases, projectRoot) {
209
- for (const pat of aliases.patterns) {
210
- if (!importPath.startsWith(pat.prefix))
211
- continue;
212
- if (pat.suffix && !importPath.endsWith(pat.suffix))
213
- continue;
214
- let captured = '';
215
- if (pat.hasWildcard) {
216
- captured = importPath.slice(pat.prefix.length, importPath.length - pat.suffix.length);
217
- }
218
- else if (importPath !== pat.prefix) {
219
- // Literal pattern must match exactly.
220
- continue;
221
- }
222
- const out = [];
223
- for (const target of pat.replacements) {
224
- const filled = pat.hasWildcard ? target.replace('*', captured) : target;
225
- // baseUrl is absolute; produce a path relative to projectRoot
226
- const absolute = path.resolve(aliases.baseUrl, filled);
227
- const relative = path.relative(projectRoot, absolute);
228
- // Skip if the rewrite escapes the project root (unsafe + can't
229
- // be looked up via the file index anyway).
230
- if (relative.startsWith('..'))
231
- continue;
232
- out.push(relative.replace(/\\/g, '/'));
233
- }
234
- return out;
235
- }
236
- return [];
237
- }
238
- //# sourceMappingURL=path-aliases.js.map
@@ -1,40 +0,0 @@
1
- /**
2
- * Per-language comment stripper for framework route extractors.
3
- *
4
- * Replaces comment characters and string-literal contents that hide
5
- * routing-shaped text with spaces (NOT removal) so that source offsets
6
- * are preserved. This means `match.index` from a regex run on the
7
- * stripped output still maps to the same line in the original source.
8
- *
9
- * Example:
10
- * Input: "x = 1 # path('/fake/', V)\n real = 2"
11
- * Output: "x = 1 \n real = 2"
12
- *
13
- * Why strip strings/docstrings as well as comments? Python module/class
14
- * docstrings are a common source of false positives — they often contain
15
- * `path('/example/', View)` examples in usage docs. We treat triple-quoted
16
- * strings the same as comments. Single-line strings stay intact (a `#`
17
- * inside a Python string is NOT a comment).
18
- *
19
- * Scope: this is a pragmatic, regex-supporting helper, not a full parser.
20
- * It does NOT try to detect JS regex literals, Python f-string expressions,
21
- * or shell-style heredocs. Those edge cases are not load-bearing for the
22
- * `path(...)`, `Route::get(...)`, `app.get(...)` style patterns that
23
- * framework extractors scan for.
24
- */
25
- export type CommentLang =
26
- | 'python'
27
- | 'javascript'
28
- | 'typescript'
29
- | 'php'
30
- | 'ruby'
31
- | 'java'
32
- | 'csharp'
33
- | 'swift'
34
- | 'go'
35
- | 'rust'
36
- export declare function stripCommentsForRegex(
37
- content: string,
38
- lang: CommentLang,
39
- ): string
40
- //# sourceMappingURL=strip-comments.d.ts.map