@wrongstack/tools 0.317.0 → 0.318.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.
Files changed (110) hide show
  1. package/dist/_spawn-stream.d.ts +1 -1
  2. package/dist/audit.d.ts +37 -2
  3. package/dist/audit.js +4 -4
  4. package/dist/bash.js +1 -1
  5. package/dist/batch-tool-use.js +1 -1
  6. package/dist/browser/index.js +1 -1
  7. package/dist/browser/tools.d.ts +16 -1
  8. package/dist/builtin.js +43 -43
  9. package/dist/{chunk-SDLVH5RZ.js → chunk-3QQSBUXR.js} +6 -5
  10. package/dist/{chunk-YGG6X57C.js → chunk-3U4H6ZRF.js} +12 -9
  11. package/dist/{chunk-K3WNSHUF.js → chunk-45JPRMC2.js} +62 -36
  12. package/dist/{chunk-EJWSCQ6D.js → chunk-4AEZIFOW.js} +6 -5
  13. package/dist/{chunk-PQKK5JH7.js → chunk-4E42D7UF.js} +2 -2
  14. package/dist/{chunk-JRJJX3L5.js → chunk-5WNDJHT6.js} +3 -2
  15. package/dist/{chunk-7EY5DCRO.js → chunk-5ZYEGP2P.js} +4 -4
  16. package/dist/{chunk-VGBUDLW4.js → chunk-6GVXZCQV.js} +7 -6
  17. package/dist/{chunk-UNSKG6DC.js → chunk-6GZPSWP3.js} +10 -15
  18. package/dist/{chunk-5OAOKALG.js → chunk-AGUSOFNI.js} +4 -3
  19. package/dist/{chunk-TRDX25UH.js → chunk-BLCSYKNN.js} +293 -86
  20. package/dist/{chunk-U6DZWHBA.js → chunk-CIFAIIHI.js} +9 -7
  21. package/dist/{chunk-HPEO4EA7.js → chunk-CISOLTOP.js} +35 -17
  22. package/dist/{chunk-RGISBZBD.js → chunk-CPSAF2AU.js} +3 -2
  23. package/dist/{chunk-BSLVR56S.js → chunk-CPVLVQYT.js} +6 -5
  24. package/dist/{chunk-VJNHFZ7J.js → chunk-CVALEVGA.js} +6 -5
  25. package/dist/{chunk-PY2IOS7C.js → chunk-CWALNI6K.js} +5 -5
  26. package/dist/{chunk-LIJQMYYX.js → chunk-DTQ75VBC.js} +8 -3
  27. package/dist/{chunk-553IQUMO.js → chunk-EOOFNYIT.js} +7 -6
  28. package/dist/{chunk-JNNVRHMV.js → chunk-FJEQZHZN.js} +8 -8
  29. package/dist/{chunk-S5CCLZL3.js → chunk-FRN7TIAA.js} +2 -2
  30. package/dist/{chunk-NKJW5GFO.js → chunk-H6AWAZ2Y.js} +3 -3
  31. package/dist/{chunk-IVWV2UM6.js → chunk-HTYEO67J.js} +6 -5
  32. package/dist/{chunk-IYK7XGDZ.js → chunk-JJQB6R7Y.js} +7 -7
  33. package/dist/{chunk-DSEANA2W.js → chunk-K23JNFE3.js} +37 -36
  34. package/dist/{chunk-LWKUTMD5.js → chunk-MRZOVQ5D.js} +6 -5
  35. package/dist/{chunk-PCHQ6YRR.js → chunk-MX25MTDJ.js} +2 -2
  36. package/dist/{chunk-U4D5S3VQ.js → chunk-NWZ6XGBJ.js} +2 -1
  37. package/dist/{chunk-UKU2ZX4C.js → chunk-P7ZQ2FAJ.js} +27 -17
  38. package/dist/{chunk-4I4LWFOO.js → chunk-PQTONQ4P.js} +16 -11
  39. package/dist/{chunk-P7FYFZ6M.js → chunk-S2GBLQ5S.js} +11 -7
  40. package/dist/{chunk-OUBDL3WH.js → chunk-SOG7XIRF.js} +11 -8
  41. package/dist/{chunk-AHHDWNXC.js → chunk-TKA4VEX2.js} +2 -2
  42. package/dist/{chunk-5H4GSJAI.js → chunk-UE3UBMCP.js} +7 -6
  43. package/dist/{chunk-IXMNTNW5.js → chunk-UKGMDCXT.js} +4 -3
  44. package/dist/{chunk-QDQY7NQ2.js → chunk-VZLX2JZG.js} +5 -5
  45. package/dist/{chunk-T2F4S7U4.js → chunk-WI3VDXHD.js} +18 -8
  46. package/dist/{chunk-O4MBV4AX.js → chunk-WJYXMB2R.js} +6 -5
  47. package/dist/{chunk-U4VAATKP.js → chunk-WXJY3BKV.js} +16 -6
  48. package/dist/{chunk-DR7JOQTC.js → chunk-X5K3U6GI.js} +3 -3
  49. package/dist/{chunk-JQRIR762.js → chunk-YF3D5INN.js} +27 -19
  50. package/dist/{chunk-TEBQ4VPZ.js → chunk-YOHO4DVT.js} +6 -5
  51. package/dist/{chunk-RXISBFR5.js → chunk-ZE6KLBUO.js} +5 -4
  52. package/dist/{chunk-22B7GE5T.js → chunk-ZHH3BEWU.js} +13 -12
  53. package/dist/{chunk-XGHMUZ77.js → chunk-ZZT45EHF.js} +3 -3
  54. package/dist/codebase-index/bm25.d.ts +14 -1
  55. package/dist/codebase-index/index.d.ts +1 -0
  56. package/dist/codebase-index/index.js +13 -8
  57. package/dist/codebase-index/json-parser.d.ts +4 -0
  58. package/dist/codebase-index/parser-worker-script.js +2 -2
  59. package/dist/codebase-index/project-server.js +48 -9
  60. package/dist/codebase-index/worker.js +4 -4
  61. package/dist/codebase-index/writer-bulk-insert.d.ts +0 -1
  62. package/dist/codebase-index/writer-schema.d.ts +1 -1
  63. package/dist/codebase-index/writer.d.ts +38 -0
  64. package/dist/diff.js +1 -1
  65. package/dist/e2e.d.ts +40 -1
  66. package/dist/e2e.js +1 -1
  67. package/dist/edit.js +7 -7
  68. package/dist/exec.js +1 -1
  69. package/dist/fetch.js +1 -1
  70. package/dist/format.d.ts +42 -2
  71. package/dist/format.js +4 -4
  72. package/dist/git.d.ts +70 -1
  73. package/dist/git.js +1 -1
  74. package/dist/glob.js +3 -3
  75. package/dist/{go-parser-JXYKJHRC.js → go-parser-IKHW67WE.js} +2 -2
  76. package/dist/grep.js +3 -3
  77. package/dist/index.js +45 -45
  78. package/dist/install.d.ts +51 -2
  79. package/dist/install.js +4 -4
  80. package/dist/{json-parser-IBHZ4BZC.js → json-parser-2EOVP5MR.js} +81 -15
  81. package/dist/kanban.d.ts +19 -1
  82. package/dist/kanban.js +2 -2
  83. package/dist/languages/index.js +2 -2
  84. package/dist/{legacy-bridge-7M6QLUQN.js → legacy-bridge-SFNXIRAP.js} +4 -4
  85. package/dist/lint.js +4 -4
  86. package/dist/logs.js +1 -1
  87. package/dist/outdated.d.ts +25 -1
  88. package/dist/outdated.js +1 -1
  89. package/dist/pack.js +44 -44
  90. package/dist/{parser-dispatch-QH4XPGG6.js → parser-dispatch-X62UWXJS.js} +3 -3
  91. package/dist/patch.js +7 -7
  92. package/dist/plan.js +4 -4
  93. package/dist/{py-parser-IS4HKYMF.js → py-parser-TDXSQZBC.js} +2 -2
  94. package/dist/read.js +7 -7
  95. package/dist/replace.js +7 -7
  96. package/dist/{rs-parser-XHUUO2KZ.js → rs-parser-GIWPUA3T.js} +2 -2
  97. package/dist/scaffold.js +1 -1
  98. package/dist/search.js +1 -1
  99. package/dist/session-kanban.js +1 -1
  100. package/dist/task.js +4 -4
  101. package/dist/test.js +4 -4
  102. package/dist/todo.js +3 -3
  103. package/dist/tool-diff.js +1 -1
  104. package/dist/tool-tier.js +45 -45
  105. package/dist/tool-use.js +1 -1
  106. package/dist/{ts-parser-RCTYKSVI.js → ts-parser-7W26YB26.js} +2 -2
  107. package/dist/typecheck.js +4 -4
  108. package/dist/write.js +7 -7
  109. package/dist/{yaml-parser-4SAXV3PL.js → yaml-parser-RGBXEZE4.js} +2 -2
  110. package/package.json +5 -5
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  e2ePlanTool
3
- } from "./chunk-JRJJX3L5.js";
3
+ } from "./chunk-5WNDJHT6.js";
4
4
  import {
5
5
  codebaseAstReplaceTool,
6
6
  codebaseImpactAnalysisTool,
@@ -14,22 +14,22 @@ import {
14
14
  codebaseStatsTool,
15
15
  codebaseTargetedTestTool,
16
16
  deadCodeScanTool
17
- } from "./chunk-JQRIR762.js";
17
+ } from "./chunk-YF3D5INN.js";
18
18
  import {
19
19
  planTool
20
- } from "./chunk-NKJW5GFO.js";
20
+ } from "./chunk-H6AWAZ2Y.js";
21
21
  import {
22
22
  taskTool
23
- } from "./chunk-DR7JOQTC.js";
23
+ } from "./chunk-X5K3U6GI.js";
24
24
  import {
25
25
  toolSearchTool
26
26
  } from "./chunk-RJZQWEMS.js";
27
27
  import {
28
28
  toolUseTool
29
- } from "./chunk-S5CCLZL3.js";
29
+ } from "./chunk-FRN7TIAA.js";
30
30
  import {
31
31
  batchToolUseTool
32
- } from "./chunk-U4VAATKP.js";
32
+ } from "./chunk-WXJY3BKV.js";
33
33
  import {
34
34
  toolHelpTool
35
35
  } from "./chunk-QBV725YG.js";
@@ -38,73 +38,73 @@ import {
38
38
  } from "./chunk-6RNIFLG4.js";
39
39
  import {
40
40
  testTool
41
- } from "./chunk-BSLVR56S.js";
41
+ } from "./chunk-CPVLVQYT.js";
42
42
  import {
43
43
  installTool
44
- } from "./chunk-5H4GSJAI.js";
44
+ } from "./chunk-UE3UBMCP.js";
45
45
  import {
46
46
  auditTool
47
- } from "./chunk-VJNHFZ7J.js";
47
+ } from "./chunk-CVALEVGA.js";
48
48
  import {
49
49
  outdatedTool
50
- } from "./chunk-LWKUTMD5.js";
50
+ } from "./chunk-MRZOVQ5D.js";
51
51
  import {
52
52
  logsTool
53
- } from "./chunk-RGISBZBD.js";
53
+ } from "./chunk-CPSAF2AU.js";
54
54
  import {
55
55
  documentTool
56
56
  } from "./chunk-EMRGN4KM.js";
57
57
  import {
58
58
  scaffoldTool
59
- } from "./chunk-AHHDWNXC.js";
59
+ } from "./chunk-TKA4VEX2.js";
60
60
  import {
61
61
  gitTool
62
- } from "./chunk-RXISBFR5.js";
62
+ } from "./chunk-ZE6KLBUO.js";
63
63
  import {
64
64
  patchTool
65
- } from "./chunk-5OAOKALG.js";
65
+ } from "./chunk-AGUSOFNI.js";
66
66
  import {
67
67
  jsonTool
68
68
  } from "./chunk-VB3MJGCV.js";
69
69
  import {
70
70
  diffTool
71
- } from "./chunk-UKU2ZX4C.js";
71
+ } from "./chunk-P7ZQ2FAJ.js";
72
72
  import {
73
73
  treeTool
74
74
  } from "./chunk-J5SKD6LN.js";
75
75
  import {
76
76
  lintTool
77
- } from "./chunk-O4MBV4AX.js";
77
+ } from "./chunk-WJYXMB2R.js";
78
78
  import {
79
79
  formatTool
80
- } from "./chunk-SDLVH5RZ.js";
80
+ } from "./chunk-3QQSBUXR.js";
81
81
  import {
82
82
  typecheckTool
83
- } from "./chunk-EJWSCQ6D.js";
83
+ } from "./chunk-4AEZIFOW.js";
84
84
  import {
85
85
  languageInfoTool,
86
86
  languagePackageTool,
87
87
  languageTool
88
- } from "./chunk-OUBDL3WH.js";
88
+ } from "./chunk-SOG7XIRF.js";
89
89
  import {
90
90
  replaceTool
91
- } from "./chunk-HPEO4EA7.js";
91
+ } from "./chunk-CISOLTOP.js";
92
92
  import {
93
93
  globTool
94
- } from "./chunk-UNSKG6DC.js";
94
+ } from "./chunk-6GZPSWP3.js";
95
95
  import {
96
96
  grepTool
97
- } from "./chunk-553IQUMO.js";
97
+ } from "./chunk-EOOFNYIT.js";
98
98
  import {
99
99
  bashTool,
100
100
  checkAndBlockKillCommand,
101
101
  diagnoseBashism,
102
102
  shellArgs
103
- } from "./chunk-IVWV2UM6.js";
103
+ } from "./chunk-HTYEO67J.js";
104
104
  import {
105
105
  detectDanger,
106
106
  execTool
107
- } from "./chunk-T2F4S7U4.js";
107
+ } from "./chunk-WI3VDXHD.js";
108
108
  import {
109
109
  buildChildEnv
110
110
  } from "./chunk-BTSFTGIL.js";
@@ -118,28 +118,28 @@ import {
118
118
  } from "./chunk-3PVYQFRQ.js";
119
119
  import {
120
120
  fetchTool
121
- } from "./chunk-IXMNTNW5.js";
121
+ } from "./chunk-UKGMDCXT.js";
122
122
  import {
123
123
  searchTool
124
- } from "./chunk-4I4LWFOO.js";
124
+ } from "./chunk-PQTONQ4P.js";
125
125
  import {
126
126
  todoTool
127
- } from "./chunk-7EY5DCRO.js";
127
+ } from "./chunk-5ZYEGP2P.js";
128
128
  import {
129
129
  kanbanTool
130
- } from "./chunk-JNNVRHMV.js";
130
+ } from "./chunk-FJEQZHZN.js";
131
131
  import {
132
132
  browserTools
133
- } from "./chunk-K3WNSHUF.js";
133
+ } from "./chunk-45JPRMC2.js";
134
134
  import {
135
135
  readTool
136
- } from "./chunk-YGG6X57C.js";
136
+ } from "./chunk-3U4H6ZRF.js";
137
137
  import {
138
138
  writeTool
139
- } from "./chunk-P7FYFZ6M.js";
139
+ } from "./chunk-S2GBLQ5S.js";
140
140
  import {
141
141
  editTool
142
- } from "./chunk-U6DZWHBA.js";
142
+ } from "./chunk-CIFAIIHI.js";
143
143
  import {
144
144
  resolvePowerShell
145
145
  } from "./chunk-V43EQ6VR.js";
@@ -368,6 +368,7 @@ var pwshTool = {
368
368
  return;
369
369
  }
370
370
  const startedAt = Date.now();
371
+ const callerSignal = opts?.signal ?? ctx.signal ?? new AbortController().signal;
371
372
  const detached = !isWin;
372
373
  if (isBackground) {
373
374
  const child2 = spawn(bin, args, {
@@ -525,8 +526,8 @@ Working directory: ${targetCwd}`,
525
526
  }, timeoutMs);
526
527
  timers.push(timer);
527
528
  const onAbort = () => killWithTimeout(2e3);
528
- if (opts.signal.aborted) onAbort();
529
- else opts.signal.addEventListener("abort", onAbort, { once: true });
529
+ if (callerSignal.aborted) onAbort();
530
+ else callerSignal.addEventListener("abort", onAbort, { once: true });
530
531
  const queue = [];
531
532
  let resolveNext = null;
532
533
  const push = (c) => {
@@ -825,7 +826,7 @@ var securityAstScanTool = {
825
826
  },
826
827
  async execute(input, ctx) {
827
828
  try {
828
- const projectRoot = ctx.projectRoot;
829
+ const projectRoot = ctx.projectRoot ?? ctx.cwd ?? process.cwd();
829
830
  let targetFile = input.file ?? "inline-code.ts";
830
831
  let content = input.content;
831
832
  if (!content && input.file) {
@@ -1088,4 +1089,4 @@ export {
1088
1089
  TIER3_TOOLS,
1089
1090
  builtinTools
1090
1091
  };
1091
- //# sourceMappingURL=chunk-DSEANA2W.js.map
1092
+ //# sourceMappingURL=chunk-K23JNFE3.js.map
@@ -49,10 +49,11 @@ var outdatedTool = {
49
49
  },
50
50
  async execute(input, ctx, opts) {
51
51
  const cwd = input.cwd ? await safeResolveReal(input.cwd, ctx) : ctx.cwd;
52
+ const signal = opts?.signal ?? ctx.signal ?? new AbortController().signal;
52
53
  const manager = await detectPackageManager(cwd, ctx.projectRoot);
53
54
  if (manager === "npm") {
54
55
  try {
55
- const { detectNonJsEcosystem } = await import("./legacy-bridge-7M6QLUQN.js");
56
+ const { detectNonJsEcosystem } = await import("./legacy-bridge-SFNXIRAP.js");
56
57
  const nonJs = await detectNonJsEcosystem(cwd, ctx.projectRoot);
57
58
  if (nonJs) {
58
59
  const { planLanguageOperation, executePackagePlan } = await import("./languages/index.js");
@@ -61,7 +62,7 @@ var outdatedTool = {
61
62
  cwd,
62
63
  operation: "package-outdated",
63
64
  language: nonJs,
64
- signal: opts.signal
65
+ signal
65
66
  });
66
67
  if (planResult.status === "planned") {
67
68
  const runner = executePackagePlan({
@@ -69,7 +70,7 @@ var outdatedTool = {
69
70
  workspace: planResult.workspace,
70
71
  plan: planResult.plan,
71
72
  packages: [],
72
- signal: opts.signal
73
+ signal
73
74
  });
74
75
  let outcome = null;
75
76
  for (; ; ) {
@@ -102,7 +103,7 @@ var outdatedTool = {
102
103
  }
103
104
  }
104
105
  const args = ["outdated", "--json"];
105
- return runOutdated(manager, args, cwd, opts.signal);
106
+ return runOutdated(manager, args, cwd, signal);
106
107
  }
107
108
  };
108
109
  function runOutdated(manager, args, cwd, signal) {
@@ -194,4 +195,4 @@ Note: exit code 1 from \`outdated\` means outdated packages were found (expected
194
195
  export {
195
196
  outdatedTool
196
197
  };
197
- //# sourceMappingURL=chunk-LWKUTMD5.js.map
198
+ //# sourceMappingURL=chunk-MRZOVQ5D.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  builtinTools
3
- } from "./chunk-DSEANA2W.js";
3
+ } from "./chunk-K23JNFE3.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-PCHQ6YRR.js.map
15
+ //# sourceMappingURL=chunk-MX25MTDJ.js.map
@@ -1,6 +1,7 @@
1
1
  // src/_concurrency.ts
2
2
  async function mapWithConcurrency(items, limit, fn) {
3
3
  if (items.length === 0) return [];
4
+ if (items.length === 1) return [await fn(items[0])];
4
5
  const effectiveLimit = Math.max(1, Math.min(limit | 0, items.length));
5
6
  const results = new Array(items.length);
6
7
  let nextIndex = 0;
@@ -18,4 +19,4 @@ async function mapWithConcurrency(items, limit, fn) {
18
19
  export {
19
20
  mapWithConcurrency
20
21
  };
21
- //# sourceMappingURL=chunk-U4D5S3VQ.js.map
22
+ //# sourceMappingURL=chunk-NWZ6XGBJ.js.map
@@ -58,10 +58,11 @@ var diffTool = {
58
58
  }
59
59
  },
60
60
  async execute(input, ctx, opts) {
61
+ const signal = opts?.signal ?? ctx.signal ?? new AbortController().signal;
61
62
  if (input.a !== void 0 || input.b !== void 0) {
62
- return await gitDiff(input, ctx, opts.signal);
63
+ return await gitDiff(input, ctx, signal);
63
64
  }
64
- return await fileDiff(input, ctx, opts.signal);
65
+ return await fileDiff(input, ctx, signal);
65
66
  }
66
67
  };
67
68
  async function gitDiff(input, ctx, signal) {
@@ -163,22 +164,31 @@ async function fileDiff(input, ctx, _signal) {
163
164
  mode: "dump"
164
165
  };
165
166
  }
167
+ const fileEntries = await Promise.all(
168
+ files.map(async (file) => {
169
+ const absPath = await safeResolveReal(file, ctx);
170
+ const stat2 = await fs.stat(absPath).catch(() => null);
171
+ if (!stat2?.isFile()) return null;
172
+ if (stat2.size > MAX_FILE_DUMP_BYTES) {
173
+ return {
174
+ truncated: true,
175
+ output: `--- ${file} (skipped: ${stat2.size} bytes exceeds the ${MAX_FILE_DUMP_BYTES} limit; use the read tool with offset/limit) ---`
176
+ };
177
+ }
178
+ const content = await fs.readFile(absPath, "utf8");
179
+ const lines = content.split(/\r?\n/);
180
+ return {
181
+ truncated: false,
182
+ output: formatWithLineNumbers(file, lines)
183
+ };
184
+ })
185
+ );
166
186
  const results = [];
167
187
  let truncated = false;
168
- for (const file of files) {
169
- const absPath = await safeResolveReal(file, ctx);
170
- const stat2 = await fs.stat(absPath).catch(() => null);
171
- if (!stat2?.isFile()) continue;
172
- if (stat2.size > MAX_FILE_DUMP_BYTES) {
173
- truncated = true;
174
- results.push(
175
- `--- ${file} (skipped: ${stat2.size} bytes exceeds the ${MAX_FILE_DUMP_BYTES} limit; use the read tool with offset/limit) ---`
176
- );
177
- continue;
178
- }
179
- const content = await fs.readFile(absPath, "utf8");
180
- const lines = content.split(/\r?\n/);
181
- results.push(formatWithLineNumbers(file, lines));
188
+ for (const entry of fileEntries) {
189
+ if (!entry) continue;
190
+ if (entry.truncated) truncated = true;
191
+ results.push(entry.output);
182
192
  }
183
193
  return {
184
194
  diff: results.join("\n\n"),
@@ -200,4 +210,4 @@ ${numbered}`;
200
210
  export {
201
211
  diffTool
202
212
  };
203
- //# sourceMappingURL=chunk-UKU2ZX4C.js.map
213
+ //# sourceMappingURL=chunk-P7ZQ2FAJ.js.map
@@ -55,13 +55,14 @@ var searchTool = {
55
55
  if (!final) throw new Error("search: stream ended without final event");
56
56
  return final;
57
57
  },
58
- async *executeStream(input, _ctx, opts) {
58
+ async *executeStream(input, ctx, opts) {
59
59
  if (!input?.query || input.query.trim() === "") {
60
60
  throw new ToolValidationError({
61
61
  message: "search: query is required and must be a non-empty string",
62
62
  field: "query"
63
63
  });
64
64
  }
65
+ const signal = opts?.signal ?? ctx?.signal ?? new AbortController().signal;
65
66
  const num = Math.max(1, Math.min(input.num_results ?? DEFAULT_NUM, MAX_RESULTS));
66
67
  const source = input.source ?? "duckduckgo";
67
68
  const skipCache = input.skip_cache ?? false;
@@ -106,13 +107,13 @@ var searchTool = {
106
107
  let effectiveSource = source;
107
108
  switch (source) {
108
109
  case "duckduckgo":
109
- engine = await duckduckgoSearch(input.query, opts.signal);
110
+ engine = await duckduckgoSearch(input.query, signal);
110
111
  break;
111
112
  case "google":
112
- engine = await googleSearch(input.query, opts.signal);
113
+ engine = await googleSearch(input.query, signal);
113
114
  break;
114
115
  case "bing":
115
- engine = await bingSearch(input.query, opts.signal);
116
+ engine = await bingSearch(input.query, signal);
116
117
  break;
117
118
  default:
118
119
  throw new ToolValidationError({
@@ -128,7 +129,7 @@ var searchTool = {
128
129
  text: `${source} returned no relevant static results; falling back to duckduckgo`,
129
130
  data: { source, fallback: "duckduckgo", query: input.query }
130
131
  };
131
- const fallback = await duckduckgoSearch(input.query, opts.signal);
132
+ const fallback = await duckduckgoSearch(input.query, signal);
132
133
  ranked = rankSearchResults(fallback.results, input.query);
133
134
  engineError = fallback.error;
134
135
  effectiveSource = "duckduckgo";
@@ -161,14 +162,18 @@ var searchTool = {
161
162
  }
162
163
  };
163
164
  function pruneCacheEntries() {
165
+ if (cache.size <= CACHE_MAX_ENTRIES) return;
164
166
  const cutoff = Date.now() - CACHE_TTL_MS * 2;
165
167
  for (const [key, entry] of cache.entries()) {
166
- if (entry.timestamp < cutoff) cache.delete(key);
168
+ if (entry.timestamp < cutoff) {
169
+ cache.delete(key);
170
+ }
167
171
  }
168
- while (cache.size > CACHE_MAX_ENTRIES) {
169
- const oldestKey = cache.keys().next().value;
170
- if (oldestKey === void 0) break;
171
- cache.delete(oldestKey);
172
+ if (cache.size > CACHE_MAX_ENTRIES) {
173
+ for (const key of cache.keys()) {
174
+ cache.delete(key);
175
+ if (cache.size <= CACHE_MAX_ENTRIES) break;
176
+ }
172
177
  }
173
178
  }
174
179
  function __clearSearchCache() {
@@ -428,4 +433,4 @@ export {
428
433
  searchTool,
429
434
  __clearSearchCache
430
435
  };
431
- //# sourceMappingURL=chunk-4I4LWFOO.js.map
436
+ //# sourceMappingURL=chunk-PQTONQ4P.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-FQZOHLG3.js";
4
4
  import {
5
5
  enqueueReindex
6
- } from "./chunk-QDQY7NQ2.js";
6
+ } from "./chunk-VZLX2JZG.js";
7
7
  import {
8
8
  safeResolveReal,
9
9
  sha256hex,
@@ -54,20 +54,26 @@ var writeTool = {
54
54
  required: ["path", "content"]
55
55
  },
56
56
  async execute(input, ctx, opts) {
57
- return writeFile(input, ctx, opts?.signal);
57
+ const signal = opts?.signal ?? ctx?.signal;
58
+ return writeFile(input, ctx, signal);
58
59
  },
59
60
  async *executeStream(input, ctx, opts) {
61
+ const signal = opts?.signal ?? ctx?.signal;
62
+ signal?.throwIfAborted();
60
63
  const prepared = await prepareWrite(input, ctx);
64
+ signal?.throwIfAborted();
61
65
  if (!prepared.existed) {
62
66
  for (const line of input.content.split("\n")) {
67
+ signal?.throwIfAborted();
63
68
  yield { type: "partial_output", text: `${line}
64
69
  `, data: { livePreview: true } };
65
70
  }
66
71
  }
67
- yield { type: "final", output: await finishWrite(input, ctx, prepared, opts?.signal) };
72
+ yield { type: "final", output: await finishWrite(input, ctx, prepared, signal) };
68
73
  }
69
74
  };
70
75
  async function writeFile(input, ctx, signal) {
76
+ signal?.throwIfAborted();
71
77
  return finishWrite(input, ctx, await prepareWrite(input, ctx), signal);
72
78
  }
73
79
  async function prepareWrite(input, ctx) {
@@ -90,11 +96,9 @@ async function prepareWrite(input, ctx) {
90
96
  const stat2 = await fs.stat(absPath);
91
97
  existed = stat2.isFile();
92
98
  if (existed) {
99
+ prev = await fs.readFile(absPath, "utf8");
93
100
  if (!ctx.hasRead(absPath)) {
94
- prev = await fs.readFile(absPath, "utf8");
95
101
  ctx.recordRead(absPath, stat2.mtimeMs, "write", sha256hex(prev));
96
- } else {
97
- prev = await fs.readFile(absPath, "utf8");
98
102
  }
99
103
  }
100
104
  } catch (err) {
@@ -151,4 +155,4 @@ async function finishWrite(input, ctx, prepared, signal) {
151
155
  export {
152
156
  writeTool
153
157
  };
154
- //# sourceMappingURL=chunk-P7FYFZ6M.js.map
158
+ //# sourceMappingURL=chunk-S2GBLQ5S.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  spawnStream
3
- } from "./chunk-22B7GE5T.js";
3
+ } from "./chunk-ZHH3BEWU.js";
4
4
  import {
5
5
  normalizeCommandOutput,
6
6
  safeResolveReal
@@ -2929,11 +2929,12 @@ var languageTool = {
2929
2929
  },
2930
2930
  async *executeStream(input, ctx, opts) {
2931
2931
  const cwd = input.cwd ? await safeResolveReal(input.cwd, ctx) : ctx.workingDir ?? ctx.cwd;
2932
+ const signal = opts?.signal ?? ctx.signal ?? new AbortController().signal;
2932
2933
  const operations = operationsFor(input);
2933
2934
  const runs = [];
2934
2935
  const unavailableReasons = [];
2935
2936
  for (const operation of operations) {
2936
- opts.signal.throwIfAborted();
2937
+ signal.throwIfAborted();
2937
2938
  const planResult = await planLanguageOperation({
2938
2939
  projectRoot: ctx.projectRoot,
2939
2940
  cwd,
@@ -2943,7 +2944,7 @@ var languageTool = {
2943
2944
  ...input.workspace ? { workspace: input.workspace } : {},
2944
2945
  ...input.mode ? { mode: input.mode } : {},
2945
2946
  operationOptions: operationOptions(input),
2946
- signal: opts.signal
2947
+ signal
2947
2948
  });
2948
2949
  if (planResult.status !== "planned") {
2949
2950
  const reason = planResult.status === "unavailable" ? planResult.unavailable.reason : planResult.reason;
@@ -2961,7 +2962,7 @@ var languageTool = {
2961
2962
  projectRoot: ctx.projectRoot,
2962
2963
  workspace: planResult.workspace,
2963
2964
  plan: planResult.plan,
2964
- signal: opts.signal
2965
+ signal
2965
2966
  });
2966
2967
  for (; ; ) {
2967
2968
  const next = await runner.next();
@@ -3196,6 +3197,7 @@ var languagePackageTool = {
3196
3197
  },
3197
3198
  async *executeStream(input, ctx, opts) {
3198
3199
  const cwd = input.cwd ? await safeResolveReal(input.cwd, ctx) : ctx.workingDir ?? ctx.cwd;
3200
+ const signal = opts?.signal ?? ctx.signal ?? new AbortController().signal;
3199
3201
  const planOperation = OPERATION_TO_PLAN[input.operation];
3200
3202
  const operationOptions2 = {
3201
3203
  ...input.names ? { packages: input.names } : {},
@@ -3209,7 +3211,7 @@ var languagePackageTool = {
3209
3211
  ...input.language ? { language: input.language } : {},
3210
3212
  ...input.workspace ? { workspace: input.workspace } : {},
3211
3213
  operationOptions: operationOptions2,
3212
- signal: opts.signal
3214
+ signal
3213
3215
  });
3214
3216
  if (planResult.status !== "planned") {
3215
3217
  const reason = planResult.status === "unavailable" ? planResult.unavailable.reason : planResult.reason;
@@ -3251,7 +3253,7 @@ var languagePackageTool = {
3251
3253
  workspace: planResult.workspace,
3252
3254
  plan: planResult.plan,
3253
3255
  packages: input.names ?? [],
3254
- signal: opts.signal
3256
+ signal
3255
3257
  });
3256
3258
  let outcome;
3257
3259
  for (; ; ) {
@@ -3473,12 +3475,13 @@ var languageInfoTool = {
3473
3475
  };
3474
3476
  }
3475
3477
  const cwd = input.cwd ? await safeResolveReal(input.cwd, ctx) : ctx.workingDir ?? ctx.cwd;
3478
+ const signal = opts?.signal ?? ctx.signal ?? new AbortController().signal;
3476
3479
  const common = {
3477
3480
  projectRoot: ctx.projectRoot,
3478
3481
  cwd,
3479
3482
  ...input.target ? { target: input.target } : {},
3480
3483
  ...input.language ? { language: input.language } : {},
3481
- signal: opts.signal
3484
+ signal
3482
3485
  };
3483
3486
  if (input.action === "detect") {
3484
3487
  return { action: "detect", ...await detectLanguageWorkspaces(common) };
@@ -3512,4 +3515,4 @@ export {
3512
3515
  languagePackageTool,
3513
3516
  languageInfoTool
3514
3517
  };
3515
- //# sourceMappingURL=chunk-OUBDL3WH.js.map
3518
+ //# sourceMappingURL=chunk-SOG7XIRF.js.map
@@ -156,7 +156,7 @@ async function handleBuiltIn(name, templateFiles, cwd, ctx, dryRun, vars) {
156
156
  for (const [filePath, content] of Object.entries(templateFiles)) {
157
157
  const resolvedPath = substituteVars(filePath, name, vars);
158
158
  const joinedPath = path.join(cwd, resolvedPath);
159
- const root = path.resolve(ctx.projectRoot);
159
+ const root = path.resolve(ctx.projectRoot ?? ctx.cwd ?? process.cwd());
160
160
  const target = path.resolve(joinedPath);
161
161
  const rel = path.relative(root, target);
162
162
  if (rel.startsWith("..") || path.isAbsolute(rel)) {
@@ -197,4 +197,4 @@ function substituteVars(content, name, vars) {
197
197
  export {
198
198
  scaffoldTool
199
199
  };
200
- //# sourceMappingURL=chunk-AHHDWNXC.js.map
200
+ //# sourceMappingURL=chunk-TKA4VEX2.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  tryLegacyPackageOperation
3
- } from "./chunk-PQKK5JH7.js";
3
+ } from "./chunk-4E42D7UF.js";
4
4
  import {
5
5
  spawnStream
6
- } from "./chunk-22B7GE5T.js";
6
+ } from "./chunk-ZHH3BEWU.js";
7
7
  import {
8
8
  detectPackageManager,
9
9
  normalizeCommandOutput,
@@ -73,6 +73,7 @@ var installTool = {
73
73
  },
74
74
  async *executeStream(input, ctx, opts) {
75
75
  const cwd = input.cwd ? await safeResolveReal(input.cwd, ctx) : ctx.cwd;
76
+ const signal = opts?.signal ?? ctx.signal ?? new AbortController().signal;
76
77
  if (!input.global) {
77
78
  const pkgList2 = input.packages ? Array.isArray(input.packages) ? input.packages : input.packages.split(",").map((p) => p.trim()) : [];
78
79
  const bridge = await tryLegacyPackageOperation(
@@ -80,7 +81,7 @@ var installTool = {
80
81
  {
81
82
  cwd,
82
83
  projectRoot: ctx.projectRoot,
83
- signal: opts.signal
84
+ signal
84
85
  },
85
86
  pkgList2
86
87
  );
@@ -162,7 +163,7 @@ var installTool = {
162
163
  cmd: pkgManager,
163
164
  args,
164
165
  cwd,
165
- signal: opts.signal,
166
+ signal,
166
167
  maxBytes: 1e5
167
168
  });
168
169
  const output = {
@@ -187,7 +188,7 @@ var installTool = {
187
188
  ecosystem: detectPackageEcosystem(manifestPath),
188
189
  agentId: ctx.agentId,
189
190
  agentName: ctx.agentName,
190
- sessionId: ctx.session.id
191
+ sessionId: ctx.session?.id
191
192
  });
192
193
  } catch {
193
194
  }
@@ -220,4 +221,4 @@ function resolveManifestPath(cwd, pkgManager) {
220
221
  export {
221
222
  installTool
222
223
  };
223
- //# sourceMappingURL=chunk-5H4GSJAI.js.map
224
+ //# sourceMappingURL=chunk-UE3UBMCP.js.map
@@ -106,6 +106,7 @@ var fetchTool = {
106
106
  }
107
107
  await assertNotPrivate(u.hostname);
108
108
  yield { type: "log", text: `GET ${input.url}` };
109
+ const signal = opts?.signal ?? ctx.signal ?? new AbortController().signal;
109
110
  const ctrl = new AbortController();
110
111
  const timer = setTimeout(
111
112
  () => ctrl.abort(
@@ -117,13 +118,13 @@ var fetchTool = {
117
118
  ),
118
119
  TIMEOUT_MS
119
120
  );
120
- const combined = combineSignals([opts.signal, ctrl.signal]);
121
+ const combined = combineSignals([signal, ctrl.signal]);
121
122
  try {
122
123
  let res;
123
124
  try {
124
125
  res = await guardedFetch(input.url, 5, combined);
125
126
  } catch (err) {
126
- if (opts.signal.aborted) throw err;
127
+ if (signal.aborted) throw err;
127
128
  throw describeFetchError(err, input.url, ctrl.signal.aborted);
128
129
  }
129
130
  const ct = res.headers.get("content-type") ?? "application/octet-stream";
@@ -235,4 +236,4 @@ function prettyJson(s) {
235
236
  export {
236
237
  fetchTool
237
238
  };
238
- //# sourceMappingURL=chunk-IXMNTNW5.js.map
239
+ //# sourceMappingURL=chunk-UKGMDCXT.js.map
@@ -9,7 +9,7 @@ import {
9
9
  projectIndexServerBuildId,
10
10
  projectIndexServerEndpoint,
11
11
  projectIndexServerMetadataPath
12
- } from "./chunk-VGBUDLW4.js";
12
+ } from "./chunk-6GVXZCQV.js";
13
13
  import {
14
14
  CircuitOpenError,
15
15
  IndexTimeoutError,
@@ -24,15 +24,15 @@ import {
24
24
  searchService,
25
25
  statsService,
26
26
  symbolGraphService
27
- } from "./chunk-TRDX25UH.js";
27
+ } from "./chunk-BLCSYKNN.js";
28
28
  import {
29
29
  isIndexablePath
30
- } from "./chunk-TEBQ4VPZ.js";
30
+ } from "./chunk-YOHO4DVT.js";
31
31
 
32
32
  // src/codebase-index/project-server-client-state.ts
33
33
  import * as fs from "node:fs";
34
34
  import { fileURLToPath } from "node:url";
35
- import { checkUnixSocketPath } from "@wrongstack/core/utils";
35
+ import { checkUnixSocketPath } from "@wrongstack/persistence";
36
36
  var CONNECT_ATTEMPT_TIMEOUT_MS = 750;
37
37
  var SERVER_START_TIMEOUT_MS = 1e4;
38
38
  var SERVER_CONTROL_TIMEOUT_MS = 5e3;
@@ -1269,4 +1269,4 @@ export {
1269
1269
  checkCodebaseIndexServerHealth,
1270
1270
  ensureCodebaseIndexServer
1271
1271
  };
1272
- //# sourceMappingURL=chunk-QDQY7NQ2.js.map
1272
+ //# sourceMappingURL=chunk-VZLX2JZG.js.map