@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
@@ -1,256 +0,0 @@
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 regexParse({ file, content, lang, maxSymbols: opts.maxSymbols });
13
- } catch {
14
- return { file, lang, symbols: [], mtimeMs: Date.now() };
15
- }
16
- }
17
- function topLevelKeys(content) {
18
- const keys = [];
19
- const stack = [];
20
- let inString = false;
21
- for (let i = 0; i < content.length; i++) {
22
- const ch = content[i];
23
- if (inString) {
24
- if (ch === "\\") {
25
- i++;
26
- } else if (ch === '"') {
27
- inString = false;
28
- }
29
- continue;
30
- }
31
- if (ch === "/" && content[i + 1] === "/") {
32
- while (i < content.length && content[i] !== "\n") i++;
33
- continue;
34
- }
35
- if (ch === "/" && content[i + 1] === "*") {
36
- i += 2;
37
- while (i < content.length && !(content[i] === "*" && content[i + 1] === "/")) i++;
38
- i++;
39
- continue;
40
- }
41
- if (ch === '"') {
42
- inString = true;
43
- if (stack.length === 1 && stack[0] === "{") {
44
- let j = i + 1;
45
- while (j < content.length && content[j] !== '"') {
46
- if (content[j] === "\\") j++;
47
- j++;
48
- }
49
- if (j < content.length) {
50
- const key = content.slice(i + 1, j);
51
- let k = j + 1;
52
- while (k < content.length && /\s/.test(content[k] ?? "")) k++;
53
- if (content[k] === ":") keys.push({ key, offset: i });
54
- i = j;
55
- inString = false;
56
- }
57
- }
58
- continue;
59
- }
60
- if (ch === "{" || ch === "[") stack.push(ch);
61
- else if (ch === "}" || ch === "]") stack.pop();
62
- }
63
- return keys;
64
- }
65
- function regexParse(opts) {
66
- const { file, content, lang } = opts;
67
- const maxSymbols = opts.maxSymbols ?? JSON_MAX_SYMBOLS_DEFAULT;
68
- const symbols = [];
69
- const pushSymbol = (symbol) => {
70
- if (symbols.length < maxSymbols) symbols.push(symbol);
71
- };
72
- const basename2 = path.basename(file).toLowerCase();
73
- const isPackageJson = basename2 === "package.json";
74
- const isTsconfig = basename2 === "tsconfig.json" || basename2 === "tsconfig.build.json";
75
- const isJsonSchema = content.includes("$schema") || content.includes("$id") || content.includes("$ref");
76
- const isOpenApi = content.includes("openapi") || content.includes("swagger");
77
- const lines = content.split("\n");
78
- const lineOffsets = [0];
79
- for (let i = 0; i < lines.length; i++) {
80
- lineOffsets.push((lineOffsets[i] ?? 0) + (lines[i]?.length ?? 0) + 1);
81
- }
82
- function lineFromOffset(offset) {
83
- let lo = 0;
84
- let hi = lineOffsets.length - 1;
85
- while (lo < hi) {
86
- const mid = lo + hi + 1 >>> 1;
87
- if (expectDefined(lineOffsets[mid]) <= offset) lo = mid;
88
- else hi = mid - 1;
89
- }
90
- return lo + 1;
91
- }
92
- const rootMatch = content.match(/^\s*\{/m);
93
- if (rootMatch) {
94
- const offset = expectDefined(rootMatch.index);
95
- const line = lineFromOffset(offset);
96
- pushSymbol(
97
- makeSymbol({
98
- name: path.basename(file),
99
- kind: "object",
100
- line,
101
- col: 0,
102
- signature: `"${path.basename(file)}" = { ... }`,
103
- file,
104
- lang
105
- })
106
- );
107
- }
108
- for (const { key, offset } of topLevelKeys(content)) {
109
- if (symbols.length >= maxSymbols) break;
110
- const line = lineFromOffset(offset);
111
- const col = offset - (lineOffsets[line - 1] ?? 0);
112
- let kind = "property";
113
- let signature = `"${key}": ..."`;
114
- if (isPackageJson) {
115
- if (key === "scripts" || key === "dependencies" || key === "devDependencies" || key === "peerDependencies" || key === "optionalDependencies") {
116
- kind = "const";
117
- signature = `"${key}": { ... }`;
118
- }
119
- } else if (isTsconfig) {
120
- if (key === "compilerOptions") {
121
- kind = "property";
122
- signature = `"compilerOptions": { ... }`;
123
- }
124
- }
125
- if (isJsonSchema || isOpenApi) {
126
- if (key === "$schema" || key === "$id") {
127
- kind = "schema";
128
- signature = `"${key}": "..."`;
129
- } else if (key === "$ref") {
130
- kind = "schema";
131
- signature = `"$ref": "..."`;
132
- }
133
- }
134
- pushSymbol(
135
- makeSymbol({
136
- name: key,
137
- kind,
138
- line,
139
- col,
140
- signature,
141
- file,
142
- lang
143
- })
144
- );
145
- if (isPackageJson && key === "scripts") {
146
- extractPackageScripts(content, symbols, file, lang, lineOffsets, lineFromOffset, maxSymbols);
147
- }
148
- if (isTsconfig && key === "compilerOptions") {
149
- extractCompilerOptions(content, symbols, file, lang, lineOffsets, lineFromOffset, maxSymbols);
150
- }
151
- }
152
- const defsPatterns = [
153
- /"\$defs"\s*:/g,
154
- /"definitions"\s*:/g,
155
- /"components"\s*:/g,
156
- /"schemas"\s*:/g
157
- ];
158
- for (const pat of defsPatterns) {
159
- pat.lastIndex = 0;
160
- for (let match = pat.exec(content); match !== null; match = pat.exec(content)) {
161
- if (symbols.length >= maxSymbols) break;
162
- const offset = match.index ?? 0;
163
- const line = lineFromOffset(offset);
164
- const key = match[0]?.match(/"([^"]+)"/)?.[1] ?? expectDefined(match[0]);
165
- pushSymbol(
166
- makeSymbol({
167
- name: key,
168
- kind: "property",
169
- line,
170
- col: offset - (lineOffsets[line - 1] ?? 0),
171
- signature: `"${key}": { ... }`,
172
- file,
173
- lang
174
- })
175
- );
176
- }
177
- }
178
- return { file, lang, symbols, mtimeMs: Date.now() };
179
- }
180
- function extractPackageScripts(content, symbols, file, lang, lineOffsets, lineFromOffset, maxSymbols) {
181
- const scriptsBlockRegex = /"scripts"\s*:\s*\{([^}]+)\}/g;
182
- for (let match = scriptsBlockRegex.exec(content); match !== null; match = scriptsBlockRegex.exec(content)) {
183
- if (symbols.length >= maxSymbols) return;
184
- const scriptInner = expectDefined(match[1]);
185
- const scriptFull = expectDefined(match[0]);
186
- const blockContent = scriptInner;
187
- const blockOffset = (match.index ?? 0) + (scriptFull.length - scriptInner.length - 1);
188
- const scriptKeyRegex = /"(\w[\w-]*)"\s*:/g;
189
- for (let scriptMatch = scriptKeyRegex.exec(blockContent); scriptMatch !== null; scriptMatch = scriptKeyRegex.exec(blockContent)) {
190
- if (symbols.length >= maxSymbols) return;
191
- const key = expectDefined(scriptMatch[1]);
192
- const keyOffset = blockOffset + expectDefined(scriptMatch.index);
193
- const line = lineFromOffset(keyOffset);
194
- symbols.push(
195
- makeSymbol({
196
- name: key,
197
- kind: "function",
198
- line,
199
- col: keyOffset - (lineOffsets[line - 1] ?? 0),
200
- signature: `"${key}": "..."`,
201
- file,
202
- lang
203
- })
204
- );
205
- }
206
- }
207
- }
208
- function extractCompilerOptions(content, symbols, file, lang, lineOffsets, lineFromOffset, maxSymbols) {
209
- const optsBlockRegex = /"compilerOptions"\s*:\s*\{([^}]+)\}/g;
210
- for (let match = optsBlockRegex.exec(content); match !== null; match = optsBlockRegex.exec(content)) {
211
- if (symbols.length >= maxSymbols) return;
212
- const optsInner = expectDefined(match[1]);
213
- const optsFull = expectDefined(match[0]);
214
- const blockContent = optsInner;
215
- const blockOffset = (match.index ?? 0) + (optsFull.length - optsInner.length - 1);
216
- const optKeyRegex = /"(\w[\w]*)"\s*:/g;
217
- for (let optMatch = optKeyRegex.exec(blockContent); optMatch !== null; optMatch = optKeyRegex.exec(blockContent)) {
218
- if (symbols.length >= maxSymbols) return;
219
- const key = expectDefined(optMatch[1]);
220
- const keyOffset = blockOffset + expectDefined(optMatch.index);
221
- const line = lineFromOffset(keyOffset);
222
- symbols.push(
223
- makeSymbol({
224
- name: key,
225
- kind: "property",
226
- line,
227
- col: keyOffset - (lineOffsets[line - 1] ?? 0),
228
- signature: `"${key}": ...`,
229
- file,
230
- lang
231
- })
232
- );
233
- }
234
- }
235
- }
236
- function makeSymbol(opts) {
237
- return {
238
- id: 0,
239
- lang: opts.lang,
240
- kind: opts.kind,
241
- name: opts.name,
242
- file: opts.file,
243
- line: opts.line,
244
- col: opts.col,
245
- signature: opts.signature,
246
- docComment: "",
247
- scope: "",
248
- text: `${opts.name} ${opts.signature}`.trim()
249
- };
250
- }
251
- export {
252
- JSON_MAX_SYMBOLS_DEFAULT,
253
- detectLang,
254
- parseSymbols
255
- };
256
- //# sourceMappingURL=json-parser-IJD77VL4.js.map
@@ -1,14 +0,0 @@
1
- import {
2
- parseFileContent,
3
- parseFilesContent
4
- } from "./chunk-KHUCKLOR.js";
5
- import "./chunk-4CE3RKEP.js";
6
- import "./chunk-SKRMUHTU.js";
7
- import "./chunk-ZKC5UNGD.js";
8
- import "./chunk-YOHO4DVT.js";
9
- import "./chunk-XZLVJD56.js";
10
- export {
11
- parseFileContent,
12
- parseFilesContent
13
- };
14
- //# sourceMappingURL=parser-dispatch-WG4DNBHH.js.map
@@ -1,81 +0,0 @@
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: /fn\s+(\w+)\s*\([^)]*\)/g, kind: "function" },
13
- { regex: /struct\s+(\w+)/g, kind: "struct" },
14
- { regex: /enum\s+(\w+)/g, kind: "enum" },
15
- { regex: /trait\s+(\w+)/g, kind: "trait" },
16
- { regex: /impl\s+(?:<[^>]+>)?(\w+)/g, kind: "impl" },
17
- { regex: /type\s+(\w+)\s*=/g, kind: "type" },
18
- { regex: /const\s+(\w+)/g, kind: "const" },
19
- { regex: /static\s+(\w+)/g, kind: "static" },
20
- { regex: /mod\s+(\w+)/g, kind: "mod" }
21
- ];
22
- function regexParse(opts) {
23
- const { file, content, lang } = opts;
24
- const symbols = [];
25
- const lines = content.split("\n");
26
- const lineOffsets = [0];
27
- for (let i = 0; i < lines.length; i++) {
28
- lineOffsets.push((lineOffsets[i] ?? 0) + (lines[i]?.length ?? 0) + 1);
29
- }
30
- function lineFromOffset(offset) {
31
- let lo = 0;
32
- let hi = lineOffsets.length - 1;
33
- while (lo < hi) {
34
- const mid = lo + hi + 1 >>> 1;
35
- if (expectDefined(lineOffsets[mid]) <= offset) lo = mid;
36
- else hi = mid - 1;
37
- }
38
- return lo + 1;
39
- }
40
- function extractDeclaration(lineIdx, _match) {
41
- const line = lines[lineIdx] ?? "";
42
- return line.trim().slice(0, 500);
43
- }
44
- for (const pattern of RS_PATTERNS) {
45
- pattern.regex.lastIndex = 0;
46
- for (let match = pattern.regex.exec(content); match !== null; match = pattern.regex.exec(content)) {
47
- const name = expectDefined(match[1]);
48
- const offset = match.index ?? 0;
49
- const line = lineFromOffset(offset);
50
- const col = offset - (lineOffsets[line - 1] ?? 0);
51
- const lineIdx = line - 1;
52
- const signature = extractDeclaration(lineIdx, match);
53
- symbols.push({
54
- id: 0,
55
- lang,
56
- kind: pattern.kind,
57
- name,
58
- file,
59
- line,
60
- col,
61
- signature,
62
- docComment: "",
63
- scope: "",
64
- text: `${name} ${signature}`.trim()
65
- });
66
- }
67
- }
68
- const seen = /* @__PURE__ */ new Set();
69
- const deduped = symbols.filter((s) => {
70
- const key = `${s.name}:${s.line}`;
71
- if (seen.has(key)) return false;
72
- seen.add(key);
73
- return true;
74
- });
75
- return { file, lang, symbols: deduped, mtimeMs: Date.now() };
76
- }
77
- export {
78
- detectLang,
79
- parseSymbols
80
- };
81
- //# sourceMappingURL=rs-parser-GIWPUA3T.js.map