@wrongstack/tools 0.310.1 → 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.
- package/dist/_shell-pick.d.ts +5 -10
- package/dist/audit.js +10 -4055
- package/dist/bash.js +9 -2332
- package/dist/batch-tool-use.js +2 -187
- package/dist/browser/index.js +25 -1339
- package/dist/builtin.js +69 -33985
- package/dist/chunk-2CTB3UK5.js +197 -0
- package/dist/chunk-2ME7ZWDD.js +1272 -0
- package/dist/chunk-2TFQDEPU.js +113 -0
- package/dist/chunk-2ZCJNKFE.js +315 -0
- package/dist/chunk-3PVYQFRQ.js +472 -0
- package/dist/chunk-3QMQBO5Z.js +89 -0
- package/dist/chunk-42AKKX7O.js +385 -0
- package/dist/chunk-42SKEETB.js +113 -0
- package/dist/chunk-4BHUSMNL.js +104 -0
- package/dist/chunk-4I4LWFOO.js +431 -0
- package/dist/chunk-553IQUMO.js +478 -0
- package/dist/chunk-55KF77OK.js +1944 -0
- package/dist/chunk-6HLZK37X.js +359 -0
- package/dist/chunk-6RNIFLG4.js +305 -0
- package/dist/chunk-A6BRWIXN.js +317 -0
- package/dist/chunk-AHHDWNXC.js +200 -0
- package/dist/chunk-B2CIOKWP.js +899 -0
- package/dist/chunk-BTSFTGIL.js +7 -0
- package/dist/chunk-D33S4RQG.js +222 -0
- package/dist/chunk-DIJKHSUO.js +134 -0
- package/dist/chunk-DPL47QGS.js +3515 -0
- package/dist/chunk-EMRGN4KM.js +170 -0
- package/dist/chunk-FGOABE4Z.js +955 -0
- package/dist/chunk-FW65TP4G.js +520 -0
- package/dist/chunk-GOIZNNOA.js +221 -0
- package/dist/chunk-H5MJUAA6.js +295 -0
- package/dist/chunk-H5OHH6F4.js +223 -0
- package/dist/chunk-HC5RM4WY.js +199 -0
- package/dist/chunk-HEQFMLZ7.js +190 -0
- package/dist/chunk-HFXSNKCV.js +196 -0
- package/dist/chunk-HXSBQ2SE.js +1723 -0
- package/dist/chunk-ILESNGNM.js +163 -0
- package/dist/chunk-INF5CGAO.js +137 -0
- package/dist/chunk-IWDFZ6XR.js +337 -0
- package/dist/chunk-IXMNTNW5.js +238 -0
- package/dist/chunk-J4SRJKBW.js +428 -0
- package/dist/chunk-J5SKD6LN.js +235 -0
- package/dist/chunk-JRJJX3L5.js +424 -0
- package/dist/chunk-KXNDHMUB.js +366 -0
- package/dist/chunk-LIJQMYYX.js +59 -0
- package/dist/chunk-MAN26PZ5.js +260 -0
- package/dist/chunk-MKRQMLZA.js +474 -0
- package/dist/chunk-NBDZMMG2.js +169 -0
- package/dist/chunk-NHA6BEIH.js +101 -0
- package/dist/chunk-OA6YJIWL.js +4412 -0
- package/dist/chunk-OZC255IC.js +2830 -0
- package/dist/chunk-PUR6WU2B.js +154 -0
- package/dist/chunk-Q5JPPCZC.js +12 -0
- package/dist/chunk-QBV725YG.js +128 -0
- package/dist/chunk-QHVW4AAM.js +892 -0
- package/dist/chunk-QNJ7AQ4B.js +1000 -0
- package/dist/chunk-RGISBZBD.js +231 -0
- package/dist/chunk-RJZQWEMS.js +84 -0
- package/dist/chunk-RP2ZA47V.js +15 -0
- package/dist/chunk-RXISBFR5.js +315 -0
- package/dist/chunk-S5CCLZL3.js +99 -0
- package/dist/chunk-TVTCSBJF.js +122 -0
- package/dist/chunk-U4D5S3VQ.js +21 -0
- package/dist/chunk-U4VAATKP.js +193 -0
- package/dist/chunk-UKU2ZX4C.js +203 -0
- package/dist/chunk-UNSKG6DC.js +159 -0
- package/dist/chunk-URFKEIHM.js +1091 -0
- package/dist/chunk-UTV7YAW7.js +178 -0
- package/dist/chunk-V43EQ6VR.js +68 -0
- package/dist/chunk-VB3MJGCV.js +610 -0
- package/dist/chunk-WHIIIREL.js +223 -0
- package/dist/chunk-XMIFYKUT.js +1371 -0
- package/dist/chunk-YF2RSV34.js +54 -0
- package/dist/chunk-Z6DAKQ3U.js +1 -0
- package/dist/chunk-ZIGAZFWE.js +522 -0
- package/dist/circuit-breaker.js +3 -191
- package/dist/codebase-index/index.js +84 -13688
- package/dist/codebase-index/parser-worker-script.js +8 -3995
- package/dist/codebase-index/project-server.js +60 -8548
- package/dist/codebase-index/worker.js +20 -8416
- package/dist/design.js +2 -299
- package/dist/diff.js +4 -256
- package/dist/document.js +4 -222
- package/dist/e2e.js +5 -476
- package/dist/edit.js +14 -10200
- package/dist/exec.js +16 -3131
- package/dist/fetch.js +8 -398
- package/dist/format.js +10 -3750
- package/dist/generic-parser-VUXDIAOZ.js +13 -0
- package/dist/git.js +4 -380
- package/dist/glob.js +6 -280
- package/dist/go-parser-6CA77WZ4.js +469 -0
- package/dist/grep.js +7 -604
- package/dist/index.js +318 -35423
- package/dist/install.js +10 -4091
- package/dist/json-parser-7YMDJSBJ.js +213 -0
- package/dist/json.js +4 -665
- package/dist/kanban.js +3 -2096
- package/dist/languages/index.js +23 -4664
- package/dist/legacy-bridge-7UKZT46G.js +18 -0
- package/dist/lint.js +10 -3706
- package/dist/logs.js +4 -287
- package/dist/memory.js +6 -215
- package/dist/mode.js +3 -99
- package/dist/outdated.js +4 -5170
- package/dist/pack.js +65 -33933
- package/dist/parser-dispatch-VPOFDO2U.js +14 -0
- package/dist/patch.js +13 -9935
- package/dist/plan.js +5 -3286
- package/dist/process-registry.js +8 -651
- package/dist/ps-slash.js +12 -1439
- package/dist/py-parser-GPM5VYRG.js +16 -0
- package/dist/read.js +13 -9816
- package/dist/replace.js +15 -10014
- package/dist/rs-parser-WVQ4KYCX.js +81 -0
- package/dist/scaffold.js +4 -253
- package/dist/search.js +5 -585
- package/dist/session-kanban.js +30 -972
- package/dist/skill.js +2 -215
- package/dist/task.js +5 -3410
- package/dist/test.js +10 -3773
- package/dist/todo.js +4 -2891
- package/dist/tool-help.js +3 -123
- package/dist/tool-search.js +3 -79
- package/dist/tool-tier.js +68 -34020
- package/dist/tool-use.js +2 -93
- package/dist/tree-sitter-parser-YCILHGZD.js +17 -0
- package/dist/tree.js +4 -288
- package/dist/ts-parser-YH4ZMWMH.js +232 -0
- package/dist/typecheck.js +10 -3753
- package/dist/win32.js +6 -60
- package/dist/write.js +14 -9882
- package/dist/yaml-parser-GFAOKV53.js +157 -0
- package/package.json +5 -5
|
@@ -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
|