@wrongstack/tools 1.0.11 → 1.0.12

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 (75) hide show
  1. package/dist/builtin.js +15 -15
  2. package/dist/{chunk-GU7TZE6Z.js → chunk-2BCRQAIW.js} +7 -7
  3. package/dist/{chunk-XRNN44QY.js → chunk-2IRHFHZY.js} +235 -71
  4. package/dist/{chunk-NEYUPZL6.js → chunk-6D3UIQMF.js} +651 -303
  5. package/dist/chunk-BJ5LXLKE.js +351 -0
  6. package/dist/{chunk-C6ZOXNXV.js → chunk-CSS42GRP.js} +2 -2
  7. package/dist/{chunk-SKRMUHTU.js → chunk-HSLDY55L.js} +41 -8
  8. package/dist/{chunk-ENE22I5W.js → chunk-K37AKCTN.js} +884 -362
  9. package/dist/{chunk-DKXMDO5F.js → chunk-K3VX6V5P.js} +3 -3
  10. package/dist/chunk-OIFY4XNP.js +855 -0
  11. package/dist/{chunk-7GOE2ZTZ.js → chunk-OMWC2OGT.js} +2 -2
  12. package/dist/{chunk-IE4KDAOB.js → chunk-OYQE2UNT.js} +3 -3
  13. package/dist/chunk-R3HR3QI3.js +97 -0
  14. package/dist/{chunk-XPVYZ2S6.js → chunk-RYLMSGR5.js} +2 -2
  15. package/dist/{chunk-HYHE4VNA.js → chunk-UMOP3VGK.js} +79 -45
  16. package/dist/{chunk-6OIEYJM4.js → chunk-VMNWQI4V.js} +2 -2
  17. package/dist/{chunk-2UVAIS5O.js → chunk-YPSVPCIE.js} +2 -2
  18. package/dist/{chunk-PWZUHZP7.js → chunk-Z77XMU3U.js} +2 -2
  19. package/dist/codebase-index/ast-invariant-engine.d.ts +19 -2
  20. package/dist/codebase-index/atlas-projection.d.ts +19 -0
  21. package/dist/codebase-index/background-indexer.d.ts +14 -0
  22. package/dist/codebase-index/circuit-breaker.d.ts +7 -0
  23. package/dist/codebase-index/codebase-ast-replace-tool.d.ts +1 -1
  24. package/dist/codebase-index/codebase-impact-analysis-tool.d.ts +6 -0
  25. package/dist/codebase-index/codebase-invariant-check-tool.d.ts +2 -0
  26. package/dist/codebase-index/codebase-targeted-test-tool.d.ts +26 -0
  27. package/dist/codebase-index/dead-code-scan.d.ts +4 -0
  28. package/dist/codebase-index/go-parser.d.ts +23 -3
  29. package/dist/codebase-index/graph-rank-pass.d.ts +10 -0
  30. package/dist/codebase-index/graph-rank.d.ts +8 -0
  31. package/dist/codebase-index/index.d.ts +1 -1
  32. package/dist/codebase-index/index.js +9 -9
  33. package/dist/codebase-index/lsp-kind.d.ts +3 -1
  34. package/dist/codebase-index/module-resolver.d.ts +21 -1
  35. package/dist/codebase-index/parser-batch.d.ts +6 -8
  36. package/dist/codebase-index/parser-output.d.ts +5 -1
  37. package/dist/codebase-index/parser-worker-script.js +4 -4
  38. package/dist/codebase-index/project-server-framing.d.ts +1 -17
  39. package/dist/codebase-index/project-server-watcher.d.ts +6 -0
  40. package/dist/codebase-index/project-server.js +72 -26
  41. package/dist/codebase-index/py-parser.d.ts +4 -4
  42. package/dist/codebase-index/rs-parser.d.ts +7 -0
  43. package/dist/codebase-index/toolchain-scripts.d.ts +64 -0
  44. package/dist/codebase-index/tree-sitter/queries.d.ts +14 -0
  45. package/dist/codebase-index/tree-sitter/util.d.ts +6 -1
  46. package/dist/codebase-index/tree-sitter-parser.d.ts +7 -0
  47. package/dist/codebase-index/worker.js +23 -16
  48. package/dist/codebase-index/writer-refs.d.ts +17 -2
  49. package/dist/codebase-index/writer-search-helpers.d.ts +9 -0
  50. package/dist/codebase-index/writer.d.ts +20 -1
  51. package/dist/edit.js +8 -8
  52. package/dist/{generic-parser-N2PLGBC2.js → generic-parser-IVWLFKMR.js} +2 -2
  53. package/dist/go-parser-LWV3L5V7.js +197 -0
  54. package/dist/index.js +17 -17
  55. package/dist/json-parser-PERV2JHX.js +204 -0
  56. package/dist/pack.js +16 -16
  57. package/dist/parser-dispatch-ZSWCQB6M.js +14 -0
  58. package/dist/patch.js +8 -8
  59. package/dist/{py-parser-4PFZYAJ7.js → py-parser-B6D6RGH7.js} +4 -4
  60. package/dist/read.js +8 -8
  61. package/dist/replace.js +8 -8
  62. package/dist/rs-parser-L7SP4GWJ.js +182 -0
  63. package/dist/tool-tier.js +17 -17
  64. package/dist/{tree-sitter-parser-GILYQLS4.js → tree-sitter-parser-KU6JF3ZC.js} +6 -4
  65. package/dist/{ts-parser-7W26YB26.js → ts-parser-PML6QIH7.js} +55 -23
  66. package/dist/write.js +8 -8
  67. package/dist/{yaml-parser-DFBC5FWH.js → yaml-parser-7BJN544B.js} +41 -6
  68. package/package.json +5 -5
  69. package/dist/chunk-4CE3RKEP.js +0 -390
  70. package/dist/chunk-KHUCKLOR.js +0 -899
  71. package/dist/chunk-ZKC5UNGD.js +0 -167
  72. package/dist/go-parser-Z4H6SR3R.js +0 -474
  73. package/dist/json-parser-IJD77VL4.js +0 -256
  74. package/dist/parser-dispatch-WG4DNBHH.js +0 -14
  75. package/dist/rs-parser-GIWPUA3T.js +0 -81
@@ -0,0 +1,204 @@
1
+ import {
2
+ detectLang
3
+ } from "./chunk-YOHO4DVT.js";
4
+
5
+ // src/codebase-index/json-parser.ts
6
+ import { expectDefined } from "@wrongstack/core/utils";
7
+ import * as path from "node:path";
8
+ var JSON_MAX_SYMBOLS_DEFAULT = 1e3;
9
+ function parseSymbols(opts) {
10
+ const { file, content, lang } = opts;
11
+ try {
12
+ return scanParse({ file, content, lang, maxSymbols: opts.maxSymbols });
13
+ } catch {
14
+ return { file, lang, symbols: [], mtimeMs: Date.now() };
15
+ }
16
+ }
17
+ function skipTrivia(content, from) {
18
+ let i = from;
19
+ while (i < content.length) {
20
+ const ch = content[i];
21
+ if (ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\uFEFF") {
22
+ i++;
23
+ continue;
24
+ }
25
+ if (ch === "/" && content[i + 1] === "/") {
26
+ const newline = content.indexOf("\n", i);
27
+ i = newline === -1 ? content.length : newline + 1;
28
+ continue;
29
+ }
30
+ if (ch === "/" && content[i + 1] === "*") {
31
+ const end = content.indexOf("*/", i + 2);
32
+ i = end === -1 ? content.length : end + 2;
33
+ continue;
34
+ }
35
+ break;
36
+ }
37
+ return i;
38
+ }
39
+ function objectKeys(content, open) {
40
+ const keys = [];
41
+ let depth = 0;
42
+ for (let i = open; i < content.length; i++) {
43
+ const ch = content[i];
44
+ if (ch === '"') {
45
+ let j = i + 1;
46
+ while (j < content.length && content[j] !== '"') {
47
+ if (content[j] === "\\") j++;
48
+ j++;
49
+ }
50
+ if (j >= content.length) break;
51
+ if (depth === 1) {
52
+ const colon = skipTrivia(content, j + 1);
53
+ if (content[colon] === ":") {
54
+ keys.push({
55
+ key: content.slice(i + 1, j),
56
+ offset: i,
57
+ valueStart: skipTrivia(content, colon + 1)
58
+ });
59
+ }
60
+ }
61
+ i = j;
62
+ continue;
63
+ }
64
+ if (ch === "/" && (content[i + 1] === "/" || content[i + 1] === "*")) {
65
+ i = skipTrivia(content, i) - 1;
66
+ continue;
67
+ }
68
+ if (ch === "{" || ch === "[") {
69
+ depth++;
70
+ } else if (ch === "}" || ch === "]") {
71
+ depth--;
72
+ if (depth === 0) break;
73
+ }
74
+ }
75
+ return keys;
76
+ }
77
+ var DEFINITION_CONTAINERS = /* @__PURE__ */ new Set(["$defs", "definitions", "schemas"]);
78
+ var BLOCK_CONTAINERS = /* @__PURE__ */ new Set([...DEFINITION_CONTAINERS, "components"]);
79
+ var DEFINITION_SEARCH_DEPTH = 4;
80
+ function scanParse(opts) {
81
+ const { file, content, lang } = opts;
82
+ const maxSymbols = opts.maxSymbols ?? JSON_MAX_SYMBOLS_DEFAULT;
83
+ const symbols = [];
84
+ const basename2 = path.basename(file).toLowerCase();
85
+ const isPackageJson = basename2 === "package.json";
86
+ const isTsconfig = basename2 === "tsconfig.json" || basename2 === "tsconfig.build.json";
87
+ const isJsonSchema = content.includes("$schema") || content.includes("$id") || content.includes("$ref") || content.includes("$defs");
88
+ const isOpenApi = content.includes("openapi") || content.includes("swagger");
89
+ const lines = content.split("\n");
90
+ const lineOffsets = [0];
91
+ for (let i = 0; i < lines.length; i++) {
92
+ lineOffsets.push((lineOffsets[i] ?? 0) + (lines[i]?.length ?? 0) + 1);
93
+ }
94
+ function lineFromOffset(offset) {
95
+ let lo = 0;
96
+ let hi = lineOffsets.length - 1;
97
+ while (lo < hi) {
98
+ const mid = lo + hi + 1 >>> 1;
99
+ if (expectDefined(lineOffsets[mid]) <= offset) lo = mid;
100
+ else hi = mid - 1;
101
+ }
102
+ return lo + 1;
103
+ }
104
+ const push = (name, kind, offset, signature) => {
105
+ if (symbols.length >= maxSymbols) return;
106
+ const line = lineFromOffset(offset);
107
+ symbols.push(
108
+ makeSymbol({
109
+ name,
110
+ kind,
111
+ line,
112
+ col: offset - (lineOffsets[line - 1] ?? 0),
113
+ signature,
114
+ file,
115
+ lang
116
+ })
117
+ );
118
+ };
119
+ const rootOpen = skipTrivia(content, 0);
120
+ if (content[rootOpen] !== "{") {
121
+ return { file, lang, symbols, mtimeMs: Date.now() };
122
+ }
123
+ const rootLine = lineFromOffset(rootOpen);
124
+ symbols.push(
125
+ makeSymbol({
126
+ name: path.basename(file),
127
+ kind: "object",
128
+ line: rootLine,
129
+ col: 0,
130
+ signature: `"${path.basename(file)}" = { ... }`,
131
+ file,
132
+ lang
133
+ })
134
+ );
135
+ for (const { key, offset, valueStart } of objectKeys(content, rootOpen)) {
136
+ if (symbols.length >= maxSymbols) break;
137
+ let kind = "property";
138
+ let signature = `"${key}": ...`;
139
+ if (isPackageJson) {
140
+ if (key === "scripts" || key === "dependencies" || key === "devDependencies" || key === "peerDependencies" || key === "optionalDependencies") {
141
+ kind = "const";
142
+ signature = `"${key}": { ... }`;
143
+ }
144
+ } else if (isTsconfig && key === "compilerOptions") {
145
+ signature = `"compilerOptions": { ... }`;
146
+ }
147
+ if ((isJsonSchema || isOpenApi) && (key === "$schema" || key === "$id" || key === "$ref")) {
148
+ kind = "schema";
149
+ signature = `"${key}": "..."`;
150
+ }
151
+ push(key, kind, offset, signature);
152
+ const objectValue = content[valueStart] === "{";
153
+ if (isPackageJson && key === "scripts" && objectValue) {
154
+ for (const script of objectKeys(content, valueStart)) {
155
+ push(script.key, "function", script.offset, `"${script.key}": "..."`);
156
+ }
157
+ }
158
+ if (isTsconfig && key === "compilerOptions" && objectValue) {
159
+ for (const option of objectKeys(content, valueStart)) {
160
+ push(option.key, "property", option.offset, `"${option.key}": ...`);
161
+ }
162
+ }
163
+ }
164
+ if (isJsonSchema || isOpenApi) {
165
+ const visit = (open, depth) => {
166
+ for (const entry of objectKeys(content, open)) {
167
+ if (symbols.length >= maxSymbols) return;
168
+ if (content[entry.valueStart] !== "{") continue;
169
+ if (BLOCK_CONTAINERS.has(entry.key)) {
170
+ push(entry.key, "property", entry.offset, `"${entry.key}": { ... }`);
171
+ }
172
+ if (DEFINITION_CONTAINERS.has(entry.key)) {
173
+ for (const definition of objectKeys(content, entry.valueStart)) {
174
+ push(definition.key, "schema", definition.offset, `"${definition.key}": { ... }`);
175
+ }
176
+ }
177
+ if (depth < DEFINITION_SEARCH_DEPTH) visit(entry.valueStart, depth + 1);
178
+ }
179
+ };
180
+ visit(rootOpen, 0);
181
+ }
182
+ return { file, lang, symbols, mtimeMs: Date.now() };
183
+ }
184
+ function makeSymbol(opts) {
185
+ return {
186
+ id: 0,
187
+ lang: opts.lang,
188
+ kind: opts.kind,
189
+ name: opts.name,
190
+ file: opts.file,
191
+ line: opts.line,
192
+ col: opts.col,
193
+ signature: opts.signature,
194
+ docComment: "",
195
+ scope: "",
196
+ text: `${opts.name} ${opts.signature}`.trim()
197
+ };
198
+ }
199
+ export {
200
+ JSON_MAX_SYMBOLS_DEFAULT,
201
+ detectLang,
202
+ parseSymbols
203
+ };
204
+ //# sourceMappingURL=json-parser-PERV2JHX.js.map
package/dist/pack.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  builtinToolsPack
3
- } from "./chunk-6OIEYJM4.js";
4
- import "./chunk-GU7TZE6Z.js";
3
+ } from "./chunk-VMNWQI4V.js";
4
+ import "./chunk-2BCRQAIW.js";
5
5
  import "./chunk-BVHKBBGA.js";
6
- import "./chunk-ENE22I5W.js";
7
- import "./chunk-XRNN44QY.js";
6
+ import "./chunk-K37AKCTN.js";
7
+ import "./chunk-2IRHFHZY.js";
8
8
  import "./chunk-MRXWOOOR.js";
9
9
  import "./chunk-7V33PHT6.js";
10
10
  import "./chunk-OKZJJDOG.js";
@@ -16,7 +16,7 @@ import "./chunk-C3WP6ZOT.js";
16
16
  import "./chunk-JPK2HHBK.js";
17
17
  import "./chunk-KS2OEZWV.js";
18
18
  import "./chunk-SPNXDTCJ.js";
19
- import "./chunk-2UVAIS5O.js";
19
+ import "./chunk-YPSVPCIE.js";
20
20
  import "./chunk-D6RQZMZS.js";
21
21
  import "./chunk-2OCAAFAT.js";
22
22
  import "./chunk-M4ZHHCCW.js";
@@ -26,7 +26,7 @@ import "./chunk-4IMNVQRB.js";
26
26
  import "./chunk-E7A4SLKR.js";
27
27
  import "./chunk-G7CYW5EP.js";
28
28
  import "./chunk-UVYRQKPZ.js";
29
- import "./chunk-C6ZOXNXV.js";
29
+ import "./chunk-CSS42GRP.js";
30
30
  import "./chunk-ON6ET5ER.js";
31
31
  import "./chunk-DLZCOEVG.js";
32
32
  import "./chunk-YJTXRH5Y.js";
@@ -45,17 +45,17 @@ import "./chunk-DBG7UQGK.js";
45
45
  import "./chunk-VMJY6FYJ.js";
46
46
  import "./chunk-YZECCW3F.js";
47
47
  import "./chunk-O2MHULBO.js";
48
- import "./chunk-IE4KDAOB.js";
49
- import "./chunk-PWZUHZP7.js";
50
- import "./chunk-7GOE2ZTZ.js";
48
+ import "./chunk-OYQE2UNT.js";
49
+ import "./chunk-Z77XMU3U.js";
50
+ import "./chunk-OMWC2OGT.js";
51
51
  import "./chunk-MSOAX3GC.js";
52
- import "./chunk-HYHE4VNA.js";
53
- import "./chunk-XPVYZ2S6.js";
54
- import "./chunk-NEYUPZL6.js";
55
- import "./chunk-KHUCKLOR.js";
56
- import "./chunk-4CE3RKEP.js";
57
- import "./chunk-SKRMUHTU.js";
58
- import "./chunk-ZKC5UNGD.js";
52
+ import "./chunk-UMOP3VGK.js";
53
+ import "./chunk-RYLMSGR5.js";
54
+ import "./chunk-6D3UIQMF.js";
55
+ import "./chunk-BJ5LXLKE.js";
56
+ import "./chunk-R3HR3QI3.js";
57
+ import "./chunk-HSLDY55L.js";
58
+ import "./chunk-OIFY4XNP.js";
59
59
  import "./chunk-YOHO4DVT.js";
60
60
  import "./chunk-XHSHNOAF.js";
61
61
  import "./chunk-XZLVJD56.js";
@@ -0,0 +1,14 @@
1
+ import {
2
+ parseFileContent,
3
+ parseFilesContent
4
+ } from "./chunk-BJ5LXLKE.js";
5
+ import "./chunk-R3HR3QI3.js";
6
+ import "./chunk-HSLDY55L.js";
7
+ import "./chunk-OIFY4XNP.js";
8
+ import "./chunk-YOHO4DVT.js";
9
+ import "./chunk-XZLVJD56.js";
10
+ export {
11
+ parseFileContent,
12
+ parseFilesContent
13
+ };
14
+ //# sourceMappingURL=parser-dispatch-ZSWCQB6M.js.map
package/dist/patch.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  patchTool
3
- } from "./chunk-2UVAIS5O.js";
4
- import "./chunk-HYHE4VNA.js";
5
- import "./chunk-XPVYZ2S6.js";
6
- import "./chunk-NEYUPZL6.js";
7
- import "./chunk-KHUCKLOR.js";
8
- import "./chunk-4CE3RKEP.js";
9
- import "./chunk-SKRMUHTU.js";
10
- import "./chunk-ZKC5UNGD.js";
3
+ } from "./chunk-YPSVPCIE.js";
4
+ import "./chunk-UMOP3VGK.js";
5
+ import "./chunk-RYLMSGR5.js";
6
+ import "./chunk-6D3UIQMF.js";
7
+ import "./chunk-BJ5LXLKE.js";
8
+ import "./chunk-R3HR3QI3.js";
9
+ import "./chunk-HSLDY55L.js";
10
+ import "./chunk-OIFY4XNP.js";
11
11
  import "./chunk-YOHO4DVT.js";
12
12
  import "./chunk-XHSHNOAF.js";
13
13
  import "./chunk-XZLVJD56.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  parseSymbols,
3
3
  resolvePythonBinary
4
- } from "./chunk-4CE3RKEP.js";
5
- import "./chunk-SKRMUHTU.js";
6
- import "./chunk-ZKC5UNGD.js";
4
+ } from "./chunk-R3HR3QI3.js";
5
+ import "./chunk-HSLDY55L.js";
6
+ import "./chunk-OIFY4XNP.js";
7
7
  import {
8
8
  detectLang
9
9
  } from "./chunk-YOHO4DVT.js";
@@ -13,4 +13,4 @@ export {
13
13
  parseSymbols,
14
14
  resolvePythonBinary
15
15
  };
16
- //# sourceMappingURL=py-parser-4PFZYAJ7.js.map
16
+ //# sourceMappingURL=py-parser-B6D6RGH7.js.map
package/dist/read.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  readTool
3
- } from "./chunk-IE4KDAOB.js";
4
- import "./chunk-HYHE4VNA.js";
5
- import "./chunk-XPVYZ2S6.js";
6
- import "./chunk-NEYUPZL6.js";
7
- import "./chunk-KHUCKLOR.js";
8
- import "./chunk-4CE3RKEP.js";
9
- import "./chunk-SKRMUHTU.js";
10
- import "./chunk-ZKC5UNGD.js";
3
+ } from "./chunk-OYQE2UNT.js";
4
+ import "./chunk-UMOP3VGK.js";
5
+ import "./chunk-RYLMSGR5.js";
6
+ import "./chunk-6D3UIQMF.js";
7
+ import "./chunk-BJ5LXLKE.js";
8
+ import "./chunk-R3HR3QI3.js";
9
+ import "./chunk-HSLDY55L.js";
10
+ import "./chunk-OIFY4XNP.js";
11
11
  import "./chunk-YOHO4DVT.js";
12
12
  import "./chunk-XHSHNOAF.js";
13
13
  import "./chunk-XZLVJD56.js";
package/dist/replace.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  __resetRgDetectionForTests,
3
3
  replaceTool
4
- } from "./chunk-C6ZOXNXV.js";
4
+ } from "./chunk-CSS42GRP.js";
5
5
  import "./chunk-YJTXRH5Y.js";
6
6
  import "./chunk-ZBMANLYH.js";
7
- import "./chunk-HYHE4VNA.js";
8
- import "./chunk-XPVYZ2S6.js";
9
- import "./chunk-NEYUPZL6.js";
10
- import "./chunk-KHUCKLOR.js";
11
- import "./chunk-4CE3RKEP.js";
12
- import "./chunk-SKRMUHTU.js";
13
- import "./chunk-ZKC5UNGD.js";
7
+ import "./chunk-UMOP3VGK.js";
8
+ import "./chunk-RYLMSGR5.js";
9
+ import "./chunk-6D3UIQMF.js";
10
+ import "./chunk-BJ5LXLKE.js";
11
+ import "./chunk-R3HR3QI3.js";
12
+ import "./chunk-HSLDY55L.js";
13
+ import "./chunk-OIFY4XNP.js";
14
14
  import "./chunk-YOHO4DVT.js";
15
15
  import "./chunk-XHSHNOAF.js";
16
16
  import "./chunk-XZLVJD56.js";
@@ -0,0 +1,182 @@
1
+ import {
2
+ detectLang
3
+ } from "./chunk-YOHO4DVT.js";
4
+
5
+ // src/codebase-index/rs-parser.ts
6
+ import { expectDefined } from "@wrongstack/core/utils";
7
+ async function parseSymbols(opts) {
8
+ const { file, content, lang } = opts;
9
+ return regexParse({ file, content, lang });
10
+ }
11
+ var RS_PATTERNS = [
12
+ { regex: /\bfn\s+(\w+)\s*[<(]/dg, kind: "function" },
13
+ { regex: /\bstruct\s+(\w+)/dg, kind: "struct" },
14
+ { regex: /\benum\s+(\w+)/dg, kind: "enum" },
15
+ { regex: /\btrait\s+(\w+)/dg, kind: "trait" },
16
+ {
17
+ // Item position only (line start, optional `unsafe`); generic parameter
18
+ // lists may nest one level (`impl<T: Into<String>> Foo`).
19
+ regex: /^[ \t]*(?:unsafe\s+)?impl\b\s*(?:<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?\s*(?:[\w]+::)*(\w+)/dgm,
20
+ kind: "impl"
21
+ },
22
+ { regex: /\btype\s+(\w+)\s*(?:<[^=;]*>)?\s*=/dg, kind: "type" },
23
+ { regex: /(?<![\w'])const\s+(?!(?:fn|unsafe|extern|async)\b)(\w+)\s*:/dg, kind: "const" },
24
+ { regex: /(?<![\w'])static\s+(?:mut\s+)?(\w+)\s*:/dg, kind: "static" },
25
+ { regex: /\bmod\s+(\w+)\s*[;{]/dg, kind: "mod" }
26
+ ];
27
+ function maskRustNonCode(src) {
28
+ const blank = (text) => text.replace(/[^\n]/g, " ");
29
+ let out = "";
30
+ let i = 0;
31
+ const n = src.length;
32
+ while (i < n) {
33
+ const c = src[i];
34
+ const next = src[i + 1];
35
+ if (c === "/" && next === "/") {
36
+ const newline = src.indexOf("\n", i);
37
+ const stop = newline === -1 ? n : newline;
38
+ out += blank(src.slice(i, stop));
39
+ i = stop;
40
+ continue;
41
+ }
42
+ if (c === "/" && next === "*") {
43
+ let depth = 1;
44
+ let j = i + 2;
45
+ while (j < n && depth > 0) {
46
+ if (src[j] === "/" && src[j + 1] === "*") {
47
+ depth++;
48
+ j += 2;
49
+ } else if (src[j] === "*" && src[j + 1] === "/") {
50
+ depth--;
51
+ j += 2;
52
+ } else {
53
+ j++;
54
+ }
55
+ }
56
+ out += blank(src.slice(i, j));
57
+ i = j;
58
+ continue;
59
+ }
60
+ const prev = src[i - 1] ?? "";
61
+ const rawPrefixOk = !/\w/.test(prev) || prev === "b" && !/\w/.test(src[i - 2] ?? "");
62
+ if (c === "r" && (next === '"' || next === "#") && rawPrefixOk) {
63
+ let j = i + 1;
64
+ let hashes = 0;
65
+ while (src[j] === "#") {
66
+ hashes++;
67
+ j++;
68
+ }
69
+ if (src[j] === '"') {
70
+ const closer = `"${"#".repeat(hashes)}`;
71
+ const end = src.indexOf(closer, j + 1);
72
+ const stop = end === -1 ? n : end + closer.length;
73
+ out += `r${blank(src.slice(i + 1, stop))}`;
74
+ i = stop;
75
+ continue;
76
+ }
77
+ }
78
+ if (c === '"') {
79
+ let j = i + 1;
80
+ while (j < n && src[j] !== '"') j += src[j] === "\\" ? 2 : 1;
81
+ if (j >= n) {
82
+ out += `"${blank(src.slice(i + 1, n))}`;
83
+ i = n;
84
+ } else {
85
+ out += `"${blank(src.slice(i + 1, j))}"`;
86
+ i = j + 1;
87
+ }
88
+ continue;
89
+ }
90
+ if (c === "'") {
91
+ let end = -1;
92
+ if (next === "\\") {
93
+ const close = src.indexOf("'", i + 2);
94
+ if (close !== -1 && close - i <= 12) end = close;
95
+ } else if (next !== void 0) {
96
+ const width = (src.codePointAt(i + 1) ?? 0) > 65535 ? 2 : 1;
97
+ if (src[i + 1 + width] === "'") end = i + 1 + width;
98
+ }
99
+ if (end !== -1) {
100
+ out += `'${blank(src.slice(i + 1, end))}'`;
101
+ i = end + 1;
102
+ continue;
103
+ }
104
+ }
105
+ out += c;
106
+ i++;
107
+ }
108
+ return out;
109
+ }
110
+ function rustDocAbove(lines, lineIdx) {
111
+ const doc = [];
112
+ for (let i = lineIdx - 1; i >= 0; i--) {
113
+ const trimmed = (lines[i] ?? "").trim();
114
+ if (trimmed.startsWith("///")) doc.unshift(trimmed.slice(3).trim());
115
+ else if (trimmed.startsWith("#[")) continue;
116
+ else break;
117
+ }
118
+ return (doc.find((line) => line.length > 0) ?? "").slice(0, 200);
119
+ }
120
+ function regexParse(opts) {
121
+ const { file, content, lang } = opts;
122
+ const symbols = [];
123
+ const lines = content.split("\n");
124
+ const code = maskRustNonCode(content);
125
+ const lineOffsets = [0];
126
+ for (let i = 0; i < lines.length; i++) {
127
+ lineOffsets.push((lineOffsets[i] ?? 0) + (lines[i]?.length ?? 0) + 1);
128
+ }
129
+ function lineFromOffset(offset) {
130
+ let lo = 0;
131
+ let hi = lineOffsets.length - 1;
132
+ while (lo < hi) {
133
+ const mid = lo + hi + 1 >>> 1;
134
+ if (expectDefined(lineOffsets[mid]) <= offset) lo = mid;
135
+ else hi = mid - 1;
136
+ }
137
+ return lo + 1;
138
+ }
139
+ function extractDeclaration(lineIdx, _match) {
140
+ const line = lines[lineIdx] ?? "";
141
+ return line.trim().slice(0, 500);
142
+ }
143
+ for (const pattern of RS_PATTERNS) {
144
+ pattern.regex.lastIndex = 0;
145
+ for (let match = pattern.regex.exec(code); match !== null; match = pattern.regex.exec(code)) {
146
+ const name = expectDefined(match[1]);
147
+ const offset = match.indices?.[1]?.[0] ?? match.index ?? 0;
148
+ const line = lineFromOffset(offset);
149
+ const col = offset - (lineOffsets[line - 1] ?? 0);
150
+ const lineIdx = line - 1;
151
+ const signature = extractDeclaration(lineIdx, match);
152
+ const docComment = rustDocAbove(lines, lineIdx);
153
+ symbols.push({
154
+ id: 0,
155
+ lang,
156
+ kind: pattern.kind,
157
+ name,
158
+ file,
159
+ line,
160
+ col,
161
+ signature,
162
+ docComment,
163
+ scope: "",
164
+ text: [name, signature, docComment].filter(Boolean).join(" ").trim()
165
+ });
166
+ }
167
+ }
168
+ const seen = /* @__PURE__ */ new Set();
169
+ const deduped = symbols.filter((s) => {
170
+ const key = `${s.name}:${s.line}`;
171
+ if (seen.has(key)) return false;
172
+ seen.add(key);
173
+ return true;
174
+ });
175
+ return { file, lang, symbols: deduped, mtimeMs: Date.now() };
176
+ }
177
+ export {
178
+ detectLang,
179
+ maskRustNonCode,
180
+ parseSymbols
181
+ };
182
+ //# sourceMappingURL=rs-parser-L7SP4GWJ.js.map
package/dist/tool-tier.js CHANGED
@@ -2,12 +2,12 @@ import {
2
2
  BUILTIN_TIER_COUNTS,
3
3
  registerBuiltinToolTier,
4
4
  selectBuiltinToolsForTier
5
- } from "./chunk-DKXMDO5F.js";
6
- import "./chunk-6OIEYJM4.js";
7
- import "./chunk-GU7TZE6Z.js";
5
+ } from "./chunk-K3VX6V5P.js";
6
+ import "./chunk-VMNWQI4V.js";
7
+ import "./chunk-2BCRQAIW.js";
8
8
  import "./chunk-BVHKBBGA.js";
9
- import "./chunk-ENE22I5W.js";
10
- import "./chunk-XRNN44QY.js";
9
+ import "./chunk-K37AKCTN.js";
10
+ import "./chunk-2IRHFHZY.js";
11
11
  import "./chunk-MRXWOOOR.js";
12
12
  import "./chunk-7V33PHT6.js";
13
13
  import "./chunk-OKZJJDOG.js";
@@ -19,7 +19,7 @@ import "./chunk-C3WP6ZOT.js";
19
19
  import "./chunk-JPK2HHBK.js";
20
20
  import "./chunk-KS2OEZWV.js";
21
21
  import "./chunk-SPNXDTCJ.js";
22
- import "./chunk-2UVAIS5O.js";
22
+ import "./chunk-YPSVPCIE.js";
23
23
  import "./chunk-D6RQZMZS.js";
24
24
  import "./chunk-2OCAAFAT.js";
25
25
  import "./chunk-M4ZHHCCW.js";
@@ -29,7 +29,7 @@ import "./chunk-4IMNVQRB.js";
29
29
  import "./chunk-E7A4SLKR.js";
30
30
  import "./chunk-G7CYW5EP.js";
31
31
  import "./chunk-UVYRQKPZ.js";
32
- import "./chunk-C6ZOXNXV.js";
32
+ import "./chunk-CSS42GRP.js";
33
33
  import "./chunk-ON6ET5ER.js";
34
34
  import "./chunk-DLZCOEVG.js";
35
35
  import "./chunk-YJTXRH5Y.js";
@@ -48,17 +48,17 @@ import "./chunk-DBG7UQGK.js";
48
48
  import "./chunk-VMJY6FYJ.js";
49
49
  import "./chunk-YZECCW3F.js";
50
50
  import "./chunk-O2MHULBO.js";
51
- import "./chunk-IE4KDAOB.js";
52
- import "./chunk-PWZUHZP7.js";
53
- import "./chunk-7GOE2ZTZ.js";
51
+ import "./chunk-OYQE2UNT.js";
52
+ import "./chunk-Z77XMU3U.js";
53
+ import "./chunk-OMWC2OGT.js";
54
54
  import "./chunk-MSOAX3GC.js";
55
- import "./chunk-HYHE4VNA.js";
56
- import "./chunk-XPVYZ2S6.js";
57
- import "./chunk-NEYUPZL6.js";
58
- import "./chunk-KHUCKLOR.js";
59
- import "./chunk-4CE3RKEP.js";
60
- import "./chunk-SKRMUHTU.js";
61
- import "./chunk-ZKC5UNGD.js";
55
+ import "./chunk-UMOP3VGK.js";
56
+ import "./chunk-RYLMSGR5.js";
57
+ import "./chunk-6D3UIQMF.js";
58
+ import "./chunk-BJ5LXLKE.js";
59
+ import "./chunk-R3HR3QI3.js";
60
+ import "./chunk-HSLDY55L.js";
61
+ import "./chunk-OIFY4XNP.js";
62
62
  import "./chunk-YOHO4DVT.js";
63
63
  import "./chunk-XHSHNOAF.js";
64
64
  import "./chunk-XZLVJD56.js";
@@ -3,13 +3,15 @@ import {
3
3
  getGrammarWasmPath,
4
4
  loadTreeSitterLanguage,
5
5
  parseSymbols,
6
- parseTreeSitterAst
7
- } from "./chunk-XRNN44QY.js";
6
+ parseTreeSitterAst,
7
+ treeSitterDeclarationName
8
+ } from "./chunk-2IRHFHZY.js";
8
9
  export {
9
10
  __smokeRootType,
10
11
  getGrammarWasmPath,
11
12
  loadTreeSitterLanguage,
12
13
  parseSymbols,
13
- parseTreeSitterAst
14
+ parseTreeSitterAst,
15
+ treeSitterDeclarationName
14
16
  };
15
- //# sourceMappingURL=tree-sitter-parser-GILYQLS4.js.map
17
+ //# sourceMappingURL=tree-sitter-parser-KU6JF3ZC.js.map