@wrongstack/tools 0.3.4 → 0.3.7
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/bash.js +33 -3
- package/dist/bash.js.map +1 -1
- package/dist/builtin.js +46 -9
- package/dist/builtin.js.map +1 -1
- package/dist/index.js +46 -9
- package/dist/index.js.map +1 -1
- package/dist/pack.js +46 -9
- package/dist/pack.js.map +1 -1
- package/dist/patch.js +2 -1
- package/dist/patch.js.map +1 -1
- package/dist/read.js +8 -1
- package/dist/read.js.map +1 -1
- package/dist/write.js +4 -4
- package/dist/write.js.map +1 -1
- package/package.json +2 -2
package/dist/pack.js
CHANGED
|
@@ -284,12 +284,41 @@ var bashTool = {
|
|
|
284
284
|
signal: opts.signal
|
|
285
285
|
});
|
|
286
286
|
if (input.background) {
|
|
287
|
-
|
|
288
|
-
|
|
287
|
+
let buf2 = "";
|
|
288
|
+
let truncated = false;
|
|
289
|
+
const child2 = spawn(shell, args, {
|
|
290
|
+
cwd: ctx.projectRoot,
|
|
291
|
+
env,
|
|
292
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
293
|
+
detached: true,
|
|
294
|
+
signal: opts.signal
|
|
295
|
+
});
|
|
296
|
+
const pid = child2.pid;
|
|
297
|
+
child2.stdout?.on("data", (chunk) => {
|
|
298
|
+
if (!truncated) {
|
|
299
|
+
const remain = MAX_OUTPUT - buf2.length;
|
|
300
|
+
if (remain > 0) {
|
|
301
|
+
buf2 += chunk.toString().slice(0, remain);
|
|
302
|
+
}
|
|
303
|
+
if (buf2.length >= MAX_OUTPUT) truncated = true;
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
child2.stderr?.on("data", (chunk) => {
|
|
307
|
+
if (!truncated) {
|
|
308
|
+
const remain = MAX_OUTPUT - buf2.length;
|
|
309
|
+
if (remain > 0) {
|
|
310
|
+
buf2 += chunk.toString().slice(0, remain);
|
|
311
|
+
}
|
|
312
|
+
if (buf2.length >= MAX_OUTPUT) truncated = true;
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
child2.on("close", () => {
|
|
316
|
+
});
|
|
317
|
+
if (typeof pid === "number") child2.unref();
|
|
289
318
|
yield {
|
|
290
319
|
type: "final",
|
|
291
320
|
output: {
|
|
292
|
-
output:
|
|
321
|
+
output: truncated ? buf2.slice(0, MAX_OUTPUT) + "\u2026[truncated]" : buf2,
|
|
293
322
|
exit_code: null,
|
|
294
323
|
timed_out: false,
|
|
295
324
|
pid
|
|
@@ -334,6 +363,7 @@ var bashTool = {
|
|
|
334
363
|
}
|
|
335
364
|
}, 2e3);
|
|
336
365
|
timers.push(killTimer);
|
|
366
|
+
killTimer.unref?.();
|
|
337
367
|
} catch {
|
|
338
368
|
}
|
|
339
369
|
}
|
|
@@ -2681,7 +2711,7 @@ var patchTool = {
|
|
|
2681
2711
|
};
|
|
2682
2712
|
}
|
|
2683
2713
|
}
|
|
2684
|
-
const tmpDir = await fs9.mkdtemp(path.join(
|
|
2714
|
+
const tmpDir = await fs9.mkdtemp(path.join(os.tmpdir(), ".wstack_patch_"));
|
|
2685
2715
|
try {
|
|
2686
2716
|
await fs9.chmod(tmpDir, 448).catch(() => {
|
|
2687
2717
|
});
|
|
@@ -2871,7 +2901,14 @@ var readTool = {
|
|
|
2871
2901
|
async execute(input, ctx) {
|
|
2872
2902
|
if (!input?.path) throw new Error("read: path is required");
|
|
2873
2903
|
const absPath = safeResolve(input.path, ctx);
|
|
2874
|
-
|
|
2904
|
+
let stat9;
|
|
2905
|
+
try {
|
|
2906
|
+
stat9 = await fs9.stat(absPath);
|
|
2907
|
+
} catch (err) {
|
|
2908
|
+
const code = err.code;
|
|
2909
|
+
if (code === "ENOENT") throw new Error(`read: file not found "${input.path}"`);
|
|
2910
|
+
throw new Error(`read: failed to stat "${input.path}": ${err instanceof Error ? err.message : String(err)}`);
|
|
2911
|
+
}
|
|
2875
2912
|
if (!stat9.isFile()) throw new Error(`read: "${input.path}" is not a regular file`);
|
|
2876
2913
|
if (stat9.size > MAX_BYTES2) {
|
|
2877
2914
|
throw new Error(`read: file too large (${stat9.size} bytes, limit ${MAX_BYTES2})`);
|
|
@@ -4215,11 +4252,11 @@ var writeTool = {
|
|
|
4215
4252
|
existed = stat10.isFile();
|
|
4216
4253
|
if (existed) {
|
|
4217
4254
|
if (!ctx.hasRead(absPath)) {
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4255
|
+
prev = await fs9.readFile(absPath, "utf8");
|
|
4256
|
+
ctx.recordRead(absPath, stat10.mtimeMs);
|
|
4257
|
+
} else {
|
|
4258
|
+
prev = await fs9.readFile(absPath, "utf8");
|
|
4221
4259
|
}
|
|
4222
|
-
prev = await fs9.readFile(absPath, "utf8");
|
|
4223
4260
|
}
|
|
4224
4261
|
} catch (err) {
|
|
4225
4262
|
if (err.code !== "ENOENT") {
|