@wrongstack/tools 0.119.1 → 0.141.0

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/builtin.js CHANGED
@@ -1,6 +1,6 @@
1
+ import { spawn, execFileSync, spawnSync } from 'node:child_process';
1
2
  import * as Core from '@wrongstack/core';
2
3
  import { buildChildEnv, expectDefined, detectNewlineStyle, normalizeToLf, toStyle, atomicWrite, unifiedDiff, compileGlob, loadPlan, emptyPlan, clearPlan, savePlan, getPlanTemplate, addPlanItem, deriveTodosFromPlanItem, removePlanItem, setPlanItemStatus, formatPlan, loadTasks, emptyTaskFile, saveTasks, computeTaskItemProgress, formatTaskList, resolveWstackPaths } from '@wrongstack/core';
3
- import { spawn, execFileSync, spawnSync } from 'node:child_process';
4
4
  import * as fs12 from 'node:fs/promises';
5
5
  import * as path from 'node:path';
6
6
  import { resolve, sep, dirname } from 'node:path';
@@ -65,7 +65,7 @@ async function* spawnStream(opts) {
65
65
  waiter = resolve7;
66
66
  });
67
67
  }
68
- const chunk = expectDefined(queue.shift());
68
+ const chunk = queue.shift();
69
69
  if (chunk.kind === "close") {
70
70
  if (!spawnFailed) exitCode = chunk.code ?? 0;
71
71
  break;
@@ -181,9 +181,9 @@ function collapseConsecutiveDuplicates(text, minRun = REPEAT_RUN_THRESHOLD) {
181
181
  while (j < lines.length && lines[j] === lines[i]) j++;
182
182
  const run = j - i;
183
183
  if (run >= minRun) {
184
- out.push(expectDefined(lines[i]), `\u2026 \u27E8repeated ${run}\xD7\u27E9`);
184
+ out.push(lines[i], `\u2026 \u27E8repeated ${run}\xD7\u27E9`);
185
185
  } else {
186
- for (let k = i; k < j; k++) out.push(expectDefined(lines[k]));
186
+ for (let k = i; k < j; k++) out.push(lines[k]);
187
187
  }
188
188
  i = j;
189
189
  }
@@ -838,44 +838,46 @@ var bashTool = {
838
838
  let pending = "";
839
839
  let timedOut = false;
840
840
  const timers = [];
841
- const timer = setTimeout(() => {
842
- timedOut = true;
841
+ function killWithTimeout(child2, timeoutMs2) {
843
842
  if (isWin) {
844
843
  try {
845
- child.kill();
844
+ child2.kill();
846
845
  } catch {
847
846
  }
848
- } else {
847
+ return;
848
+ }
849
+ try {
850
+ if (typeof child2.pid === "number") {
851
+ try {
852
+ process.kill(-child2.pid, "SIGTERM");
853
+ } catch {
854
+ child2.kill("SIGTERM");
855
+ }
856
+ } else {
857
+ child2.kill("SIGTERM");
858
+ }
859
+ } catch {
860
+ }
861
+ const killTimer = setTimeout(() => {
849
862
  try {
850
- if (typeof child.pid === "number") {
863
+ if (typeof child2.pid === "number") {
851
864
  try {
852
- process.kill(-child.pid, "SIGTERM");
865
+ process.kill(-child2.pid, "SIGKILL");
853
866
  } catch {
854
- child.kill("SIGTERM");
867
+ child2.kill("SIGKILL");
855
868
  }
856
869
  } else {
857
- child.kill("SIGTERM");
870
+ child2.kill("SIGKILL");
858
871
  }
859
- const killTimer = setTimeout(() => {
860
- try {
861
- if (typeof child.pid === "number") {
862
- try {
863
- process.kill(-child.pid, "SIGKILL");
864
- } catch {
865
- child.kill("SIGKILL");
866
- }
867
- } else {
868
- child.kill("SIGKILL");
869
- }
870
- } catch {
871
- } finally {
872
- killTimer.unref?.();
873
- }
874
- }, 2e3);
875
- timers.push(killTimer);
876
872
  } catch {
877
873
  }
878
- }
874
+ }, timeoutMs2);
875
+ timers.push(killTimer);
876
+ killTimer.unref?.();
877
+ }
878
+ const timer = setTimeout(() => {
879
+ timedOut = true;
880
+ killWithTimeout(child, 2e3);
879
881
  }, timeoutMs);
880
882
  timers.push(timer);
881
883
  timer.unref?.();
@@ -3891,19 +3893,7 @@ if (ALLOW_PRIVATE && !process.env["CI"]) {
3891
3893
  "[WrongStack] WARNING: WRONGSTACK_FETCH_ALLOW_PRIVATE=1 is active \u2014\n fetch tool can now access private IPs (10.x, 192.168.x, 169.254.x),\n cloud metadata endpoints, and plaintext HTTP. Use only on isolated networks."
3892
3894
  );
3893
3895
  }
3894
- function combineSignals(signals) {
3895
- const anyFn = AbortSignal.any;
3896
- if (typeof anyFn === "function") return anyFn(signals);
3897
- const ctrl = new AbortController();
3898
- for (const sig of signals) {
3899
- if (sig.aborted) {
3900
- ctrl.abort(sig.reason);
3901
- return ctrl.signal;
3902
- }
3903
- sig.addEventListener("abort", () => ctrl.abort(sig.reason), { once: true });
3904
- }
3905
- return ctrl.signal;
3906
- }
3896
+ var combineSignals = (signals) => AbortSignal.any(signals);
3907
3897
  function guardedLookup(hostname, options, callback) {
3908
3898
  dns.lookup(hostname, { all: true }).then((records) => {
3909
3899
  const family = options?.family;
@@ -6117,7 +6107,11 @@ function checkRg() {
6117
6107
  }
6118
6108
  function spawnRgFind(pattern, base) {
6119
6109
  const args = ["--files", "--glob", pattern, base];
6120
- const child = spawn("rg", args, { env: buildChildEnv(), stdio: ["ignore", "pipe", "pipe"] });
6110
+ const child = spawn("rg", args, {
6111
+ signal: AbortSignal.timeout(3e4),
6112
+ env: buildChildEnv(),
6113
+ stdio: ["ignore", "pipe", "pipe"]
6114
+ });
6121
6115
  let buf = "";
6122
6116
  child.stdout?.on("data", (chunk) => {
6123
6117
  buf += chunk.toString();