@wrongstack/tools 0.313.0 → 0.313.1

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 (134) hide show
  1. package/dist/audit.js +10 -4055
  2. package/dist/bash.js +9 -2308
  3. package/dist/batch-tool-use.js +2 -187
  4. package/dist/browser/index.js +25 -1339
  5. package/dist/builtin.js +69 -33949
  6. package/dist/chunk-2CTB3UK5.js +197 -0
  7. package/dist/chunk-2ME7ZWDD.js +1272 -0
  8. package/dist/chunk-2TFQDEPU.js +113 -0
  9. package/dist/chunk-2ZCJNKFE.js +315 -0
  10. package/dist/chunk-3PVYQFRQ.js +472 -0
  11. package/dist/chunk-3QMQBO5Z.js +89 -0
  12. package/dist/chunk-42AKKX7O.js +385 -0
  13. package/dist/chunk-42SKEETB.js +113 -0
  14. package/dist/chunk-4BHUSMNL.js +104 -0
  15. package/dist/chunk-4I4LWFOO.js +431 -0
  16. package/dist/chunk-553IQUMO.js +478 -0
  17. package/dist/chunk-55KF77OK.js +1944 -0
  18. package/dist/chunk-6HLZK37X.js +359 -0
  19. package/dist/chunk-6RNIFLG4.js +305 -0
  20. package/dist/chunk-A6BRWIXN.js +317 -0
  21. package/dist/chunk-AHHDWNXC.js +200 -0
  22. package/dist/chunk-B2CIOKWP.js +899 -0
  23. package/dist/chunk-BTSFTGIL.js +7 -0
  24. package/dist/chunk-D33S4RQG.js +222 -0
  25. package/dist/chunk-DIJKHSUO.js +134 -0
  26. package/dist/chunk-DPL47QGS.js +3515 -0
  27. package/dist/chunk-EMRGN4KM.js +170 -0
  28. package/dist/chunk-FGOABE4Z.js +955 -0
  29. package/dist/chunk-FW65TP4G.js +520 -0
  30. package/dist/chunk-GOIZNNOA.js +221 -0
  31. package/dist/chunk-H5MJUAA6.js +295 -0
  32. package/dist/chunk-H5OHH6F4.js +223 -0
  33. package/dist/chunk-HC5RM4WY.js +199 -0
  34. package/dist/chunk-HEQFMLZ7.js +190 -0
  35. package/dist/chunk-HFXSNKCV.js +196 -0
  36. package/dist/chunk-HXSBQ2SE.js +1723 -0
  37. package/dist/chunk-ILESNGNM.js +163 -0
  38. package/dist/chunk-INF5CGAO.js +137 -0
  39. package/dist/chunk-IWDFZ6XR.js +337 -0
  40. package/dist/chunk-IXMNTNW5.js +238 -0
  41. package/dist/chunk-J4SRJKBW.js +428 -0
  42. package/dist/chunk-J5SKD6LN.js +235 -0
  43. package/dist/chunk-JRJJX3L5.js +424 -0
  44. package/dist/chunk-KXNDHMUB.js +366 -0
  45. package/dist/chunk-LIJQMYYX.js +59 -0
  46. package/dist/chunk-MAN26PZ5.js +260 -0
  47. package/dist/chunk-MKRQMLZA.js +474 -0
  48. package/dist/chunk-NBDZMMG2.js +169 -0
  49. package/dist/chunk-NHA6BEIH.js +101 -0
  50. package/dist/chunk-OA6YJIWL.js +4412 -0
  51. package/dist/chunk-OZC255IC.js +2830 -0
  52. package/dist/chunk-PUR6WU2B.js +154 -0
  53. package/dist/chunk-Q5JPPCZC.js +12 -0
  54. package/dist/chunk-QBV725YG.js +128 -0
  55. package/dist/chunk-QHVW4AAM.js +892 -0
  56. package/dist/chunk-QNJ7AQ4B.js +1000 -0
  57. package/dist/chunk-RGISBZBD.js +231 -0
  58. package/dist/chunk-RJZQWEMS.js +84 -0
  59. package/dist/chunk-RP2ZA47V.js +15 -0
  60. package/dist/chunk-RXISBFR5.js +315 -0
  61. package/dist/chunk-S5CCLZL3.js +99 -0
  62. package/dist/chunk-TVTCSBJF.js +122 -0
  63. package/dist/chunk-U4D5S3VQ.js +21 -0
  64. package/dist/chunk-U4VAATKP.js +193 -0
  65. package/dist/chunk-UKU2ZX4C.js +203 -0
  66. package/dist/chunk-UNSKG6DC.js +159 -0
  67. package/dist/chunk-URFKEIHM.js +1091 -0
  68. package/dist/chunk-UTV7YAW7.js +178 -0
  69. package/dist/chunk-V43EQ6VR.js +68 -0
  70. package/dist/chunk-VB3MJGCV.js +610 -0
  71. package/dist/chunk-WHIIIREL.js +223 -0
  72. package/dist/chunk-XMIFYKUT.js +1371 -0
  73. package/dist/chunk-YF2RSV34.js +54 -0
  74. package/dist/chunk-Z6DAKQ3U.js +1 -0
  75. package/dist/chunk-ZIGAZFWE.js +522 -0
  76. package/dist/circuit-breaker.js +3 -191
  77. package/dist/codebase-index/index.js +84 -13688
  78. package/dist/codebase-index/parser-worker-script.js +8 -3995
  79. package/dist/codebase-index/project-server.js +60 -8548
  80. package/dist/codebase-index/worker.js +20 -8416
  81. package/dist/design.js +2 -299
  82. package/dist/diff.js +4 -256
  83. package/dist/document.js +4 -222
  84. package/dist/e2e.js +5 -476
  85. package/dist/edit.js +14 -10200
  86. package/dist/exec.js +16 -3131
  87. package/dist/fetch.js +8 -398
  88. package/dist/format.js +10 -3750
  89. package/dist/generic-parser-VUXDIAOZ.js +13 -0
  90. package/dist/git.js +4 -380
  91. package/dist/glob.js +6 -280
  92. package/dist/go-parser-6CA77WZ4.js +469 -0
  93. package/dist/grep.js +7 -604
  94. package/dist/index.js +318 -35387
  95. package/dist/install.js +10 -4091
  96. package/dist/json-parser-7YMDJSBJ.js +213 -0
  97. package/dist/json.js +4 -665
  98. package/dist/kanban.js +3 -2096
  99. package/dist/languages/index.js +23 -4664
  100. package/dist/legacy-bridge-7UKZT46G.js +18 -0
  101. package/dist/lint.js +10 -3706
  102. package/dist/logs.js +4 -287
  103. package/dist/memory.js +6 -215
  104. package/dist/mode.js +3 -99
  105. package/dist/outdated.js +4 -5170
  106. package/dist/pack.js +65 -33897
  107. package/dist/parser-dispatch-VPOFDO2U.js +14 -0
  108. package/dist/patch.js +13 -9935
  109. package/dist/plan.js +5 -3286
  110. package/dist/process-registry.js +8 -651
  111. package/dist/ps-slash.js +12 -1439
  112. package/dist/py-parser-GPM5VYRG.js +16 -0
  113. package/dist/read.js +13 -9816
  114. package/dist/replace.js +15 -10014
  115. package/dist/rs-parser-WVQ4KYCX.js +81 -0
  116. package/dist/scaffold.js +4 -253
  117. package/dist/search.js +5 -585
  118. package/dist/session-kanban.js +30 -972
  119. package/dist/skill.js +2 -215
  120. package/dist/task.js +5 -3410
  121. package/dist/test.js +10 -3773
  122. package/dist/todo.js +4 -2891
  123. package/dist/tool-help.js +3 -123
  124. package/dist/tool-search.js +3 -79
  125. package/dist/tool-tier.js +68 -33984
  126. package/dist/tool-use.js +2 -93
  127. package/dist/tree-sitter-parser-YCILHGZD.js +17 -0
  128. package/dist/tree.js +4 -288
  129. package/dist/ts-parser-YH4ZMWMH.js +232 -0
  130. package/dist/typecheck.js +10 -3753
  131. package/dist/win32.js +6 -60
  132. package/dist/write.js +14 -9882
  133. package/dist/yaml-parser-GFAOKV53.js +157 -0
  134. package/package.json +5 -5
@@ -0,0 +1,7 @@
1
+ // src/_env.ts
2
+ import { buildChildEnv } from "@wrongstack/core/utils";
3
+
4
+ export {
5
+ buildChildEnv
6
+ };
7
+ //# sourceMappingURL=chunk-BTSFTGIL.js.map
@@ -0,0 +1,222 @@
1
+ // src/_util.ts
2
+ import { createHash } from "node:crypto";
3
+ import * as fsp from "node:fs/promises";
4
+ import * as path from "node:path";
5
+ import * as Core from "@wrongstack/core/utils";
6
+ function sha256hex(content) {
7
+ return createHash("sha256").update(content, "utf8").digest("hex");
8
+ }
9
+ async function detectPackageManager(cwd, stopAt) {
10
+ let dir = path.resolve(cwd);
11
+ const stop = stopAt ? path.resolve(stopAt) : dir;
12
+ for (; ; ) {
13
+ const found = await detectPackageManagerInDir(dir);
14
+ if (found) return found;
15
+ if (dir === stop) break;
16
+ const parent = path.dirname(dir);
17
+ const relParent = path.relative(stop, parent);
18
+ if (parent === dir || relParent.startsWith("..") || path.isAbsolute(relParent)) break;
19
+ dir = parent;
20
+ }
21
+ return "npm";
22
+ }
23
+ async function detectPackageManagerInDir(dir) {
24
+ const fs = await import("node:fs/promises");
25
+ try {
26
+ const raw = await fs.readFile(path.join(dir, "package.json"), "utf8");
27
+ const declared = JSON.parse(raw).packageManager;
28
+ if (typeof declared === "string") {
29
+ const name = declared.split("@")[0] ?? "";
30
+ if (name === "pnpm" || name === "yarn") return name;
31
+ if (name === "npm" || name === "bun") return "npm";
32
+ }
33
+ } catch {
34
+ }
35
+ const lockfiles = [
36
+ ["pnpm-lock.yaml", "pnpm"],
37
+ ["yarn.lock", "yarn"],
38
+ ["bun.lockb", "npm"],
39
+ ["bun.lock", "npm"],
40
+ ["package-lock.json", "npm"],
41
+ ["npm-shrinkwrap.json", "npm"]
42
+ ];
43
+ for (const [file, manager] of lockfiles) {
44
+ try {
45
+ await fs.stat(`${dir}/${file}`);
46
+ return manager;
47
+ } catch {
48
+ }
49
+ }
50
+ return null;
51
+ }
52
+ function resolvePath(input, ctx) {
53
+ return path.isAbsolute(input) ? path.normalize(input) : path.resolve(ctx.workingDir ?? ctx.cwd, input);
54
+ }
55
+ function allowedRoots(ctx) {
56
+ return [path.resolve(ctx.projectRoot), path.resolve(Core.wstackGlobalRoot())];
57
+ }
58
+ function isInsideAny(target, roots) {
59
+ return roots.some((root) => {
60
+ const rel = path.relative(root, target);
61
+ return rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel);
62
+ });
63
+ }
64
+ function ensureInsideRoot(absPath, ctx) {
65
+ const target = path.resolve(absPath);
66
+ if (ctx.allowOutsideProjectRoot) return target;
67
+ if (isInsideAny(target, allowedRoots(ctx))) return target;
68
+ throw new Error(`Path "${absPath}" is outside project root "${path.resolve(ctx.projectRoot)}"`);
69
+ }
70
+ function safeResolve(input, ctx) {
71
+ return ensureInsideRoot(resolvePath(input, ctx), ctx);
72
+ }
73
+ async function assertRealInsideRoot(absPath, ctx) {
74
+ await resolveRealInsideRoot(absPath, ctx);
75
+ }
76
+ async function resolveRealInsideRoot(absPath, ctx) {
77
+ if (ctx.allowOutsideProjectRoot) return absPath;
78
+ const realRoots = await Promise.all(
79
+ allowedRoots(ctx).map((r) => fsp.realpath(r).catch(() => path.resolve(r)))
80
+ );
81
+ let probe = absPath;
82
+ const pendingTail = [];
83
+ for (; ; ) {
84
+ let real;
85
+ try {
86
+ real = await fsp.realpath(probe);
87
+ } catch (err) {
88
+ if (err.code === "ENOENT") {
89
+ const parent = path.dirname(probe);
90
+ if (parent === probe) return absPath;
91
+ pendingTail.unshift(path.basename(probe));
92
+ probe = parent;
93
+ continue;
94
+ }
95
+ throw err;
96
+ }
97
+ const candidate = pendingTail.length > 0 ? path.join(real, ...pendingTail) : real;
98
+ if (isInsideAny(candidate, realRoots)) {
99
+ return candidate;
100
+ }
101
+ throw new Error(
102
+ `Path "${absPath}" resolves through a symlink outside project root "${realRoots[0]}"`
103
+ );
104
+ }
105
+ }
106
+ async function safeResolveReal(input, ctx) {
107
+ const abs = safeResolve(input, ctx);
108
+ return await resolveRealInsideRoot(abs, ctx);
109
+ }
110
+ function truncateDiffPayload(diff, maxBytes) {
111
+ const total = Buffer.byteLength(diff, "utf8");
112
+ if (total <= maxBytes) return { text: diff, truncated: false };
113
+ const MARKER_RESERVE = 96;
114
+ let head = takeHeadBytes(diff, Math.max(0, maxBytes - MARKER_RESERVE));
115
+ const nl = head.lastIndexOf("\n");
116
+ if (nl > 0) head = head.slice(0, nl);
117
+ const kept = Buffer.byteLength(head, "utf8");
118
+ return {
119
+ text: `${head}
120
+ \u2026[diff truncated: ${total - kept} of ${total} bytes omitted]`,
121
+ truncated: true
122
+ };
123
+ }
124
+ function truncateMiddle(s, max) {
125
+ if (Buffer.byteLength(s, "utf8") <= max) return s;
126
+ const half = Math.floor(max / 2);
127
+ return s.slice(0, half) + `
128
+ \u2026[truncated ${Buffer.byteLength(s, "utf8") - max} bytes from middle]\u2026
129
+ ` + s.slice(-half);
130
+ }
131
+ function isBinaryBuffer(buf) {
132
+ const len = Math.min(buf.length, 8192);
133
+ for (let i = 0; i < len; i++) {
134
+ if (buf[i] === 0) return true;
135
+ }
136
+ return false;
137
+ }
138
+ var COMMAND_OUTPUT_MAX_BYTES = 32768;
139
+ var REPEAT_RUN_THRESHOLD = 3;
140
+ function collapseCarriageReturns(text) {
141
+ const lf = text.replace(/\r\n/g, "\n");
142
+ if (!lf.includes("\r")) return lf;
143
+ return lf.split("\n").map((line) => line.includes("\r") ? line.slice(line.lastIndexOf("\r") + 1) : line).join("\n");
144
+ }
145
+ function collapseConsecutiveDuplicates(text, minRun = REPEAT_RUN_THRESHOLD) {
146
+ const lines = text.split("\n");
147
+ const out = [];
148
+ let i = 0;
149
+ while (i < lines.length) {
150
+ let j = i + 1;
151
+ while (j < lines.length && lines[j] === lines[i]) j++;
152
+ const run = j - i;
153
+ if (run >= minRun) {
154
+ out.push(lines[i], `\u2026 \u27E8repeated ${run}\xD7\u27E9`);
155
+ } else {
156
+ for (let k = i; k < j; k++) out.push(lines[k]);
157
+ }
158
+ i = j;
159
+ }
160
+ return out.join("\n");
161
+ }
162
+ function takeHeadBytes(s, maxBytes) {
163
+ if (maxBytes <= 0) return "";
164
+ if (Buffer.byteLength(s, "utf8") <= maxBytes) return s;
165
+ let lo = 0;
166
+ let hi = s.length;
167
+ while (lo < hi) {
168
+ const mid = Math.ceil((lo + hi) / 2);
169
+ if (Buffer.byteLength(s.slice(0, mid), "utf8") <= maxBytes) lo = mid;
170
+ else hi = mid - 1;
171
+ }
172
+ return s.slice(0, lo);
173
+ }
174
+ function takeTailBytes(s, maxBytes) {
175
+ if (maxBytes <= 0) return "";
176
+ if (Buffer.byteLength(s, "utf8") <= maxBytes) return s;
177
+ let lo = 0;
178
+ let hi = s.length;
179
+ while (lo < hi) {
180
+ const mid = Math.ceil((lo + hi) / 2);
181
+ if (Buffer.byteLength(s.slice(s.length - mid), "utf8") <= maxBytes) lo = mid;
182
+ else hi = mid - 1;
183
+ }
184
+ return s.slice(s.length - lo);
185
+ }
186
+ function truncateHeadTail(s, maxBytes) {
187
+ const total = Buffer.byteLength(s, "utf8");
188
+ if (total <= maxBytes) return s;
189
+ const MARKER_RESERVE = 64;
190
+ const avail = Math.max(0, maxBytes - MARKER_RESERVE);
191
+ const headBudget = Math.floor(avail * 0.45);
192
+ const head = takeHeadBytes(s, headBudget);
193
+ const tail = takeTailBytes(s, avail - Buffer.byteLength(head, "utf8"));
194
+ const kept = Buffer.byteLength(head, "utf8") + Buffer.byteLength(tail, "utf8");
195
+ return `${head}
196
+ \u2026[truncated ${total - kept} bytes]\u2026
197
+ ${tail}`;
198
+ }
199
+ function normalizeCommandOutput(raw, opts = {}) {
200
+ if (!raw) return raw;
201
+ let text = Core.stripAnsi(raw);
202
+ text = collapseCarriageReturns(text);
203
+ text = text.replace(/[ \t]+$/gm, "");
204
+ text = collapseConsecutiveDuplicates(text);
205
+ text = text.replace(/\n{3,}/g, "\n\n");
206
+ return truncateHeadTail(text, opts.maxBytes ?? COMMAND_OUTPUT_MAX_BYTES);
207
+ }
208
+
209
+ export {
210
+ sha256hex,
211
+ detectPackageManager,
212
+ ensureInsideRoot,
213
+ assertRealInsideRoot,
214
+ resolveRealInsideRoot,
215
+ safeResolveReal,
216
+ truncateDiffPayload,
217
+ truncateMiddle,
218
+ isBinaryBuffer,
219
+ COMMAND_OUTPUT_MAX_BYTES,
220
+ normalizeCommandOutput
221
+ };
222
+ //# sourceMappingURL=chunk-D33S4RQG.js.map
@@ -0,0 +1,134 @@
1
+ import {
2
+ tryLegacyCodeOperation
3
+ } from "./chunk-NHA6BEIH.js";
4
+ import {
5
+ spawnStream
6
+ } from "./chunk-MAN26PZ5.js";
7
+ import {
8
+ normalizeCommandOutput,
9
+ safeResolveReal
10
+ } from "./chunk-D33S4RQG.js";
11
+
12
+ // src/lint.ts
13
+ var lintTool = {
14
+ name: "lint",
15
+ category: "Code Quality",
16
+ description: "Run the project linter (primarily Biome in this repo). Detects style violations, potential bugs, and formatting issues.",
17
+ usageHint: "RUN OFTEN DURING DEVELOPMENT:\n\n- `fix: true` will automatically correct what it can.\n- Target specific files or globs when you only want to check part of the project.\nThis is a fast and important quality gate. Use it before typecheck in most workflows.",
18
+ permission: "confirm",
19
+ mutating: false,
20
+ timeoutMs: 6e4,
21
+ capabilities: ["shell.restricted"],
22
+ icon: "code",
23
+ inputSchema: {
24
+ type: "object",
25
+ properties: {
26
+ files: {
27
+ type: "string",
28
+ description: 'Files/patterns: single path, comma-separated list, or glob (e.g. "src/**/*.ts")'
29
+ },
30
+ fix: { type: "boolean", description: "Auto-fix fixable issues (default: false)" },
31
+ linter: {
32
+ type: "string",
33
+ enum: ["biome", "eslint", "tslint", "auto"],
34
+ description: "Linter to use (default: auto-detect)"
35
+ },
36
+ cwd: { type: "string", description: "Working directory (default: cwd)" }
37
+ }
38
+ },
39
+ async execute(input, ctx, opts) {
40
+ let final;
41
+ const executeStream = lintTool.executeStream;
42
+ if (!executeStream) throw new Error("lintTool: stream execution unavailable");
43
+ for await (const ev of executeStream(input, ctx, opts)) {
44
+ if (ev.type === "final") final = ev.output;
45
+ }
46
+ if (!final) throw new Error("lint: stream ended without final event");
47
+ return final;
48
+ },
49
+ async *executeStream(input, ctx, opts) {
50
+ const cwd = input.cwd ? await safeResolveReal(input.cwd, ctx) : ctx.cwd;
51
+ const linter = input.linter ?? "auto";
52
+ if (linter === "auto" && !input.files) {
53
+ const bridge = await tryLegacyCodeOperation("lint", {
54
+ cwd,
55
+ projectRoot: ctx.projectRoot,
56
+ signal: opts.signal
57
+ });
58
+ if (bridge?.run) {
59
+ const run = bridge.run;
60
+ yield {
61
+ type: "final",
62
+ output: {
63
+ linter: bridge.language,
64
+ files_checked: 0,
65
+ errors: run.summary.errors,
66
+ warnings: run.summary.warnings,
67
+ output: normalizeCommandOutput(run.output || run.error || ""),
68
+ fix_applied: false,
69
+ truncated: run.truncated
70
+ }
71
+ };
72
+ return;
73
+ }
74
+ }
75
+ const detected = linter === "auto" ? await detectLinter(cwd) : linter;
76
+ if (!detected) {
77
+ yield {
78
+ type: "final",
79
+ output: {
80
+ linter: "none",
81
+ files_checked: 0,
82
+ errors: 0,
83
+ warnings: 0,
84
+ output: "No linter found (biome.json, .eslintrc, tslint.json)",
85
+ fix_applied: false,
86
+ truncated: false
87
+ }
88
+ };
89
+ return;
90
+ }
91
+ yield { type: "log", text: `Running ${detected}\u2026`, data: { linter: detected } };
92
+ const args = ["lint"];
93
+ if (input.fix) args.push("--write");
94
+ if (input.files) {
95
+ const files = Array.isArray(input.files) ? input.files : input.files.split(",");
96
+ args.push("--", ...files.map((f) => f.trim()));
97
+ }
98
+ const cmd = detected === "biome" ? "biome" : detected;
99
+ const result = yield* spawnStream({ cmd, args, cwd, signal: opts.signal, maxBytes: 1e5 });
100
+ const errors = [...result.stdout.matchAll(/\berror\b/gi)].length;
101
+ const warnings = [...result.stdout.matchAll(/\bwarning\b/gi)].length;
102
+ yield {
103
+ type: "final",
104
+ output: {
105
+ linter: detected,
106
+ files_checked: input.files ? Array.isArray(input.files) ? input.files.length : input.files.split(",").length : 0,
107
+ errors,
108
+ warnings,
109
+ output: normalizeCommandOutput(result.stdout),
110
+ fix_applied: input.fix ?? false,
111
+ truncated: result.truncated
112
+ }
113
+ };
114
+ }
115
+ };
116
+ async function detectLinter(cwd) {
117
+ const { stat } = await import("node:fs/promises");
118
+ const checks = ["biome.json", ".eslintrc.json", "tslint.json", ".eslintrc.js", "tsconfig.json"];
119
+ for (const f of checks) {
120
+ try {
121
+ await stat(`${cwd}/${f}`);
122
+ if (f.includes("biome")) return "biome";
123
+ if (f.includes("eslint")) return "eslint";
124
+ if (f.includes("tslint")) return "tslint";
125
+ } catch {
126
+ }
127
+ }
128
+ return "biome";
129
+ }
130
+
131
+ export {
132
+ lintTool
133
+ };
134
+ //# sourceMappingURL=chunk-DIJKHSUO.js.map