@wrongstack/tools 1.0.7 → 1.0.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  bashTool
3
- } from "./chunk-CLJXKFVS.js";
3
+ } from "./chunk-5KRKL3WD.js";
4
4
  import "./chunk-BTSFTGIL.js";
5
5
  import "./chunk-PVCB7RUZ.js";
6
6
  import "./chunk-SCMRM6NL.js";
package/dist/builtin.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  TIER2_TOOLS,
7
7
  TIER3_TOOLS,
8
8
  builtinTools
9
- } from "./chunk-4DK5WZGR.js";
9
+ } from "./chunk-GNLHBDFO.js";
10
10
  import "./chunk-BVHKBBGA.js";
11
11
  import "./chunk-JB5JLY7V.js";
12
12
  import "./chunk-XRNN44QY.js";
@@ -32,12 +32,12 @@ import "./chunk-3LQJXJDM.js";
32
32
  import "./chunk-SEONDNLN.js";
33
33
  import "./chunk-EMA2XENR.js";
34
34
  import "./chunk-KMXPP32M.js";
35
- import "./chunk-JKFIDWQG.js";
36
- import "./chunk-2W4XTULI.js";
35
+ import "./chunk-HOFVYIPI.js";
36
+ import "./chunk-FI6SOIVE.js";
37
37
  import "./chunk-YJTXRH5Y.js";
38
38
  import "./chunk-ZBMANLYH.js";
39
- import "./chunk-CLJXKFVS.js";
40
- import "./chunk-A3LNNBYO.js";
39
+ import "./chunk-5KRKL3WD.js";
40
+ import "./chunk-OGQMPX3J.js";
41
41
  import "./chunk-BTSFTGIL.js";
42
42
  import "./chunk-PVCB7RUZ.js";
43
43
  import "./chunk-SCMRM6NL.js";
@@ -575,7 +575,7 @@ var bashTool = {
575
575
  };
576
576
  return;
577
577
  }
578
- const PIPE_TO_SHELL_PATTERN = /\|\s*(sh|bash|ksh|zsh|fish|cmd|powershell|pwsh)/i;
578
+ const PIPE_TO_SHELL_PATTERN = /\|\s*(?:sudo\s+)?(sh|bash|ksh|zsh|fish|cmd|powershell|pwsh)(?:\.exe)?\b/i;
579
579
  const pipeToShellNote = PIPE_TO_SHELL_PATTERN.test(input.command) ? "\n\n[wrongstack] Caution: this command pipes output into a shell interpreter (pipe-to-shell). Piped content executes as arbitrary code \u2014 review the source before trusting the result, and prefer downloading to a file and inspecting it first." : "";
580
580
  const rawTimeout = typeof input.timeout_ms === "number" && !Number.isNaN(input.timeout_ms) ? input.timeout_ms : DEFAULT_TIMEOUT_MS;
581
581
  const timeoutMs = Math.max(1, Math.min(rawTimeout, 6e5));
@@ -1093,4 +1093,4 @@ export {
1093
1093
  checkAndBlockKillCommand,
1094
1094
  bashTool
1095
1095
  };
1096
- //# sourceMappingURL=chunk-CLJXKFVS.js.map
1096
+ //# sourceMappingURL=chunk-5KRKL3WD.js.map
@@ -18,6 +18,7 @@ import {
18
18
  import { spawn } from "node:child_process";
19
19
  import * as fs from "node:fs/promises";
20
20
  import * as path from "node:path";
21
+ import { StringDecoder } from "node:string_decoder";
21
22
  import { ToolValidationError } from "@wrongstack/core/types";
22
23
  import {
23
24
  buildChildEnv,
@@ -31,6 +32,13 @@ var NATIVE_READ_CHUNK_BYTES = 64 * 1024;
31
32
  var NATIVE_MAX_FILE_BYTES = 1e6;
32
33
  var RG_MAX_QUEUE_CHUNKS = 128;
33
34
  var RG_MAX_QUEUE_CHARS = 8 * 1024 * 1024;
35
+ function isInsideDefaultIgnoredDirectory(target, root) {
36
+ const relative2 = path.relative(root, target);
37
+ if (!relative2 || relative2 === ".." || relative2.startsWith(`..${path.sep}`) || path.isAbsolute(relative2)) {
38
+ return false;
39
+ }
40
+ return relative2.split(path.sep).some((segment) => DEFAULT_IGNORE.has(segment));
41
+ }
34
42
  var grepTool = {
35
43
  name: "grep",
36
44
  category: "Search",
@@ -99,6 +107,8 @@ var grepTool = {
99
107
  });
100
108
  }
101
109
  const base = input.path ? await safeResolveReal(input.path, ctx) : ctx.cwd;
110
+ const ignoreRoot = await fs.realpath(ctx.projectRoot ?? ctx.cwd).catch(() => path.resolve(ctx.projectRoot ?? ctx.cwd));
111
+ const ignoreTarget = await fs.realpath(base).catch(() => path.resolve(base));
102
112
  const mode = input.output_mode ?? "content";
103
113
  const rawLimit = typeof input.limit === "number" && Number.isFinite(input.limit) ? input.limit : 200;
104
114
  const limit = Math.max(1, Math.min(Math.floor(rawLimit), 2e3));
@@ -112,6 +122,18 @@ var grepTool = {
112
122
  const signal = opts?.signal ?? ctx.signal ?? new AbortController().signal;
113
123
  const relativize = makeRootRelativizer(ctx.cwd);
114
124
  const rgAvailable = await detectRg();
125
+ if (isInsideDefaultIgnoredDirectory(ignoreTarget, ignoreRoot)) {
126
+ yield {
127
+ type: "final",
128
+ output: {
129
+ matches: [],
130
+ count: 0,
131
+ truncated: false,
132
+ used: rgAvailable ? "rg" : "native"
133
+ }
134
+ };
135
+ return;
136
+ }
115
137
  if (rgAvailable) {
116
138
  try {
117
139
  yield* runRgStream(input, base, mode, limit, signal, relativize);
@@ -132,7 +154,7 @@ function __setRgAvailableForTests(available) {
132
154
  rgAvailabilityCache = available !== void 0 ? Promise.resolve(available) : void 0;
133
155
  }
134
156
  function detectRg() {
135
- rgAvailabilityCache ??= new Promise((resolve) => {
157
+ rgAvailabilityCache ??= new Promise((resolve2) => {
136
158
  try {
137
159
  const p = spawn("rg", ["--version"], {
138
160
  env: buildChildEnv(),
@@ -140,10 +162,10 @@ function detectRg() {
140
162
  signal: AbortSignal.timeout(1e4),
141
163
  windowsHide: true
142
164
  });
143
- p.on("error", () => resolve(false));
144
- p.on("close", (code) => resolve(code === 0));
165
+ p.on("error", () => resolve2(false));
166
+ p.on("close", (code) => resolve2(code === 0));
145
167
  } catch {
146
- resolve(false);
168
+ resolve2(false);
147
169
  }
148
170
  });
149
171
  return rgAvailabilityCache;
@@ -398,6 +420,7 @@ async function runNative(input, base, mode, limit, signal, relativize) {
398
420
  let lineNumber = 0;
399
421
  let fileHits = 0;
400
422
  let leftover = "";
423
+ const decoder = new StringDecoder("utf8");
401
424
  let binaryChecked = false;
402
425
  const buffer = Buffer.allocUnsafe(Math.min(NATIVE_READ_CHUNK_BYTES, maxBytes));
403
426
  while (!stopped && !signal.aborted && bytesReadTotal < maxBytes) {
@@ -415,7 +438,7 @@ async function runNative(input, base, mode, limit, signal, relativize) {
415
438
  if (isBinaryBuffer(chunk)) return;
416
439
  }
417
440
  bytesReadTotal += bytesRead;
418
- const text = leftover + chunk.toString("utf8");
441
+ const text = leftover + decoder.write(chunk);
419
442
  const lines = text.split(/\r?\n/);
420
443
  leftover = lines.pop() ?? "";
421
444
  for (const rawLine of lines) {
@@ -439,6 +462,7 @@ async function runNative(input, base, mode, limit, signal, relativize) {
439
462
  }
440
463
  if (mode === "files_with_matches" && fileHits > 0) break;
441
464
  }
465
+ leftover += decoder.end();
442
466
  if (!stopped && !signal.aborted && leftover.length > 0) {
443
467
  lineNumber++;
444
468
  const ln = leftover.length > 4096 ? capSubject(leftover) : leftover;
@@ -526,4 +550,4 @@ export {
526
550
  __resetRgDetectionForTests,
527
551
  __setRgAvailableForTests
528
552
  };
529
- //# sourceMappingURL=chunk-2W4XTULI.js.map
553
+ //# sourceMappingURL=chunk-FI6SOIVE.js.map
@@ -80,20 +80,20 @@ import {
80
80
  } from "./chunk-KMXPP32M.js";
81
81
  import {
82
82
  globTool
83
- } from "./chunk-JKFIDWQG.js";
83
+ } from "./chunk-HOFVYIPI.js";
84
84
  import {
85
85
  grepTool
86
- } from "./chunk-2W4XTULI.js";
86
+ } from "./chunk-FI6SOIVE.js";
87
87
  import {
88
88
  bashTool,
89
89
  checkAndBlockKillCommand,
90
90
  diagnoseBashism,
91
91
  shellArgs
92
- } from "./chunk-CLJXKFVS.js";
92
+ } from "./chunk-5KRKL3WD.js";
93
93
  import {
94
94
  detectDanger,
95
95
  execTool
96
- } from "./chunk-A3LNNBYO.js";
96
+ } from "./chunk-OGQMPX3J.js";
97
97
  import {
98
98
  buildChildEnv
99
99
  } from "./chunk-BTSFTGIL.js";
@@ -1692,4 +1692,4 @@ export {
1692
1692
  TIER3_TOOLS,
1693
1693
  builtinTools
1694
1694
  };
1695
- //# sourceMappingURL=chunk-4DK5WZGR.js.map
1695
+ //# sourceMappingURL=chunk-GNLHBDFO.js.map
@@ -71,6 +71,36 @@ var globTool = {
71
71
  const results = [];
72
72
  const visitedRealDirs = /* @__PURE__ */ new Set();
73
73
  let truncated = false;
74
+ const siftUp = (start) => {
75
+ let i = start;
76
+ while (i > 0) {
77
+ const parent = i - 1 >> 1;
78
+ if (results[parent].mtime <= results[i].mtime) return;
79
+ const tmp = results[i];
80
+ results[i] = results[parent];
81
+ results[parent] = tmp;
82
+ i = parent;
83
+ }
84
+ };
85
+ const siftDown = (start) => {
86
+ let i = start;
87
+ for (; ; ) {
88
+ const left = i * 2 + 1;
89
+ const right = left + 1;
90
+ let smallest = i;
91
+ if (left < results.length && results[left].mtime < results[smallest].mtime) {
92
+ smallest = left;
93
+ }
94
+ if (right < results.length && results[right].mtime < results[smallest].mtime) {
95
+ smallest = right;
96
+ }
97
+ if (smallest === i) return;
98
+ const tmp = results[i];
99
+ results[i] = results[smallest];
100
+ results[smallest] = tmp;
101
+ i = smallest;
102
+ }
103
+ };
74
104
  const pushResult = async (full) => {
75
105
  if (signal?.aborted) {
76
106
  truncated = true;
@@ -82,18 +112,16 @@ var globTool = {
82
112
  truncated = true;
83
113
  return;
84
114
  }
115
+ const entry = { rel: full, mtime: st.mtimeMs };
85
116
  if (results.length < limit) {
86
- results.push({ rel: full, mtime: st.mtimeMs });
117
+ results.push(entry);
118
+ siftUp(results.length - 1);
87
119
  return;
88
120
  }
89
121
  truncated = true;
90
- let oldestIndex = 0;
91
- for (let i = 1; i < results.length; i++) {
92
- if (results[i].mtime < results[oldestIndex].mtime) oldestIndex = i;
93
- }
94
- if (st.mtimeMs > results[oldestIndex].mtime) {
95
- results[oldestIndex] = { rel: full, mtime: st.mtimeMs };
96
- }
122
+ if (st.mtimeMs <= results[0].mtime) return;
123
+ results[0] = entry;
124
+ siftDown(0);
97
125
  } catch {
98
126
  }
99
127
  };
@@ -160,4 +188,4 @@ var globTool = {
160
188
  export {
161
189
  globTool
162
190
  };
163
- //# sourceMappingURL=chunk-JKFIDWQG.js.map
191
+ //# sourceMappingURL=chunk-HOFVYIPI.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  builtinToolsPack
3
- } from "./chunk-KPR53VKZ.js";
3
+ } from "./chunk-YUK3WLHJ.js";
4
4
  import {
5
5
  TIER1_TOOLS,
6
6
  TIER2_TOOLS
7
- } from "./chunk-4DK5WZGR.js";
7
+ } from "./chunk-GNLHBDFO.js";
8
8
 
9
9
  // src/tool-tier.ts
10
10
  function toolNameSet(tools) {
@@ -54,4 +54,4 @@ export {
54
54
  selectBuiltinToolsForTier,
55
55
  registerBuiltinToolTier
56
56
  };
57
- //# sourceMappingURL=chunk-YPSIG23D.js.map
57
+ //# sourceMappingURL=chunk-MF6ZUBI7.js.map
@@ -272,8 +272,10 @@ var RULES = [
272
272
  if (cmd !== "git") return false;
273
273
  const cleanIdx = args.indexOf("clean");
274
274
  if (cleanIdx < 0) return false;
275
- return args.slice(cleanIdx + 1).some(
276
- (a) => a === "-f" || a === "--force" || a.startsWith("-f") || a.startsWith("--force=")
275
+ const after = args.slice(cleanIdx + 1);
276
+ if (after.some((a) => a === "--dry-run" || /^-[a-z]*n[a-z]*$/i.test(a))) return false;
277
+ return after.some(
278
+ (a) => a === "--force" || a.startsWith("--force=") || /^-[a-z]+$/i.test(a) && a.toLowerCase().includes("f")
277
279
  );
278
280
  },
279
281
  reason: "git clean -f (deletes untracked files)"
@@ -1844,4 +1846,4 @@ export {
1844
1846
  getExecAllowlist,
1845
1847
  execTool
1846
1848
  };
1847
- //# sourceMappingURL=chunk-A3LNNBYO.js.map
1849
+ //# sourceMappingURL=chunk-OGQMPX3J.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  builtinTools
3
- } from "./chunk-4DK5WZGR.js";
3
+ } from "./chunk-GNLHBDFO.js";
4
4
 
5
5
  // src/pack.ts
6
6
  var builtinToolsPack = {
@@ -12,4 +12,4 @@ var builtinToolsPack = {
12
12
  export {
13
13
  builtinToolsPack
14
14
  };
15
- //# sourceMappingURL=chunk-KPR53VKZ.js.map
15
+ //# sourceMappingURL=chunk-YUK3WLHJ.js.map
package/dist/exec.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  isExecCommandAllowed,
8
8
  resetDangerBypass,
9
9
  resetExecPolicy
10
- } from "./chunk-A3LNNBYO.js";
10
+ } from "./chunk-OGQMPX3J.js";
11
11
  import "./chunk-BTSFTGIL.js";
12
12
  import "./chunk-PVCB7RUZ.js";
13
13
  import "./chunk-SCMRM6NL.js";
package/dist/glob.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  globTool
3
- } from "./chunk-JKFIDWQG.js";
3
+ } from "./chunk-HOFVYIPI.js";
4
4
  import "./chunk-ZBMANLYH.js";
5
5
  import "./chunk-XHSHNOAF.js";
6
6
  import "./chunk-2IAEJRLT.js";
package/dist/grep.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  __resetRgDetectionForTests,
3
3
  __setRgAvailableForTests,
4
4
  grepTool
5
- } from "./chunk-2W4XTULI.js";
5
+ } from "./chunk-FI6SOIVE.js";
6
6
  import "./chunk-YJTXRH5Y.js";
7
7
  import "./chunk-ZBMANLYH.js";
8
8
  import "./chunk-XHSHNOAF.js";
package/dist/index.js CHANGED
@@ -46,10 +46,10 @@ import "./chunk-Z6DAKQ3U.js";
46
46
  import {
47
47
  registerBuiltinToolTier,
48
48
  selectBuiltinToolsForTier
49
- } from "./chunk-YPSIG23D.js";
49
+ } from "./chunk-MF6ZUBI7.js";
50
50
  import {
51
51
  builtinToolsPack
52
- } from "./chunk-KPR53VKZ.js";
52
+ } from "./chunk-YUK3WLHJ.js";
53
53
  import {
54
54
  OFF_ONLY_TOOLS,
55
55
  OPTIONAL_TOOLS,
@@ -64,7 +64,7 @@ import {
64
64
  pwshTool,
65
65
  readUrlContentTool,
66
66
  securityAstScanTool
67
- } from "./chunk-4DK5WZGR.js";
67
+ } from "./chunk-GNLHBDFO.js";
68
68
  import {
69
69
  discoverE2EProjects,
70
70
  e2ePlanTool
@@ -177,10 +177,10 @@ import {
177
177
  } from "./chunk-KMXPP32M.js";
178
178
  import {
179
179
  globTool
180
- } from "./chunk-JKFIDWQG.js";
180
+ } from "./chunk-HOFVYIPI.js";
181
181
  import {
182
182
  grepTool
183
- } from "./chunk-2W4XTULI.js";
183
+ } from "./chunk-FI6SOIVE.js";
184
184
  import {
185
185
  MAX_SUBJECT_LEN,
186
186
  capSubject,
@@ -192,7 +192,7 @@ import {
192
192
  import {
193
193
  bashTool,
194
194
  checkAndBlockKillCommand
195
- } from "./chunk-CLJXKFVS.js";
195
+ } from "./chunk-5KRKL3WD.js";
196
196
  import {
197
197
  checkExecKillCommand,
198
198
  configureDangerBypass,
@@ -204,7 +204,7 @@ import {
204
204
  isExecCommandAllowed,
205
205
  resetDangerBypass,
206
206
  resetExecPolicy
207
- } from "./chunk-A3LNNBYO.js";
207
+ } from "./chunk-OGQMPX3J.js";
208
208
  import "./chunk-BTSFTGIL.js";
209
209
  import {
210
210
  getPersistentProcessRegistry,
package/dist/pack.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  builtinToolsPack
3
- } from "./chunk-KPR53VKZ.js";
4
- import "./chunk-4DK5WZGR.js";
3
+ } from "./chunk-YUK3WLHJ.js";
4
+ import "./chunk-GNLHBDFO.js";
5
5
  import "./chunk-BVHKBBGA.js";
6
6
  import "./chunk-JB5JLY7V.js";
7
7
  import "./chunk-XRNN44QY.js";
@@ -27,12 +27,12 @@ import "./chunk-3LQJXJDM.js";
27
27
  import "./chunk-SEONDNLN.js";
28
28
  import "./chunk-EMA2XENR.js";
29
29
  import "./chunk-KMXPP32M.js";
30
- import "./chunk-JKFIDWQG.js";
31
- import "./chunk-2W4XTULI.js";
30
+ import "./chunk-HOFVYIPI.js";
31
+ import "./chunk-FI6SOIVE.js";
32
32
  import "./chunk-YJTXRH5Y.js";
33
33
  import "./chunk-ZBMANLYH.js";
34
- import "./chunk-CLJXKFVS.js";
35
- import "./chunk-A3LNNBYO.js";
34
+ import "./chunk-5KRKL3WD.js";
35
+ import "./chunk-OGQMPX3J.js";
36
36
  import "./chunk-BTSFTGIL.js";
37
37
  import "./chunk-PVCB7RUZ.js";
38
38
  import "./chunk-SCMRM6NL.js";
package/dist/tool-tier.js CHANGED
@@ -2,9 +2,9 @@ import {
2
2
  BUILTIN_TIER_COUNTS,
3
3
  registerBuiltinToolTier,
4
4
  selectBuiltinToolsForTier
5
- } from "./chunk-YPSIG23D.js";
6
- import "./chunk-KPR53VKZ.js";
7
- import "./chunk-4DK5WZGR.js";
5
+ } from "./chunk-MF6ZUBI7.js";
6
+ import "./chunk-YUK3WLHJ.js";
7
+ import "./chunk-GNLHBDFO.js";
8
8
  import "./chunk-BVHKBBGA.js";
9
9
  import "./chunk-JB5JLY7V.js";
10
10
  import "./chunk-XRNN44QY.js";
@@ -30,12 +30,12 @@ import "./chunk-3LQJXJDM.js";
30
30
  import "./chunk-SEONDNLN.js";
31
31
  import "./chunk-EMA2XENR.js";
32
32
  import "./chunk-KMXPP32M.js";
33
- import "./chunk-JKFIDWQG.js";
34
- import "./chunk-2W4XTULI.js";
33
+ import "./chunk-HOFVYIPI.js";
34
+ import "./chunk-FI6SOIVE.js";
35
35
  import "./chunk-YJTXRH5Y.js";
36
36
  import "./chunk-ZBMANLYH.js";
37
- import "./chunk-CLJXKFVS.js";
38
- import "./chunk-A3LNNBYO.js";
37
+ import "./chunk-5KRKL3WD.js";
38
+ import "./chunk-OGQMPX3J.js";
39
39
  import "./chunk-BTSFTGIL.js";
40
40
  import "./chunk-PVCB7RUZ.js";
41
41
  import "./chunk-SCMRM6NL.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/tools",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "license": "MIT",
5
5
  "description": "WrongStack built-in tools: read/write/edit, bash/exec, grep/glob, git, fetch, test, lint, and more.",
6
6
  "repository": {
@@ -237,10 +237,10 @@
237
237
  "@msgpack/msgpack": "^3.1.3",
238
238
  "@playwright/test": "^1.62.1",
239
239
  "@typescript/typescript6": "^6.0.2",
240
- "@wrongstack/core": "1.0.7",
241
- "@wrongstack/kanban": "1.0.7",
242
- "@wrongstack/persistence": "1.0.7",
243
- "@wrongstack/primitives": "1.0.7",
240
+ "@wrongstack/core": "1.0.8",
241
+ "@wrongstack/kanban": "1.0.8",
242
+ "@wrongstack/persistence": "1.0.8",
243
+ "@wrongstack/primitives": "1.0.8",
244
244
  "tree-sitter-wasm": "1.1.4",
245
245
  "turndown": "^7.2.4",
246
246
  "undici": "^8.10.0",