@wrongstack/tools 1.0.8 → 1.0.10

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 (136) hide show
  1. package/dist/_win32-resolve.d.ts +5 -0
  2. package/dist/audit.js +5 -5
  3. package/dist/bash-kill-guard.d.ts +6 -4
  4. package/dist/bash.js +2 -2
  5. package/dist/browser/index.js +1 -1
  6. package/dist/builtin.js +41 -41
  7. package/dist/{chunk-N3OTTQNC.js → chunk-2OCAAFAT.js} +44 -25
  8. package/dist/{chunk-5MP76C72.js → chunk-2UVAIS5O.js} +24 -29
  9. package/dist/{chunk-SIIOHBNY.js → chunk-3RRK33YM.js} +2 -2
  10. package/dist/{chunk-M2W36JT7.js → chunk-4CE3RKEP.js} +6 -3
  11. package/dist/{chunk-QJARSK2G.js → chunk-4SUGLJLO.js} +11 -3
  12. package/dist/{chunk-AH7J5HWL.js → chunk-5RBUYFRV.js} +15 -7
  13. package/dist/{chunk-GNLHBDFO.js → chunk-6I6RXQFG.js} +127 -196
  14. package/dist/{chunk-WKLUOXR4.js → chunk-7GOE2ZTZ.js} +2 -2
  15. package/dist/{chunk-O6AGFJBO.js → chunk-7V33PHT6.js} +49 -77
  16. package/dist/{chunk-CAF4L6KN.js → chunk-C3WP6ZOT.js} +36 -48
  17. package/dist/{chunk-KMXPP32M.js → chunk-C6ZOXNXV.js} +13 -3
  18. package/dist/{chunk-EGT5QLCB.js → chunk-D6RQZMZS.js} +123 -255
  19. package/dist/{chunk-S6CGSFLX.js → chunk-DBG7UQGK.js} +10 -3
  20. package/dist/{chunk-FI6SOIVE.js → chunk-DLZCOEVG.js} +21 -3
  21. package/dist/{chunk-NL45OWEO.js → chunk-DOAHONOS.js} +7 -12
  22. package/dist/{chunk-3LQJXJDM.js → chunk-E7A4SLKR.js} +2 -2
  23. package/dist/{chunk-JB5JLY7V.js → chunk-ENE22I5W.js} +387 -394
  24. package/dist/{chunk-5KRKL3WD.js → chunk-FCSUBTUJ.js} +112 -119
  25. package/dist/{chunk-YUK3WLHJ.js → chunk-FVSMTEO3.js} +2 -2
  26. package/dist/{chunk-SEONDNLN.js → chunk-G7CYW5EP.js} +2 -2
  27. package/dist/{chunk-TU6UVATU.js → chunk-HYHE4VNA.js} +3 -3
  28. package/dist/{chunk-HIRVCXLP.js → chunk-IE4KDAOB.js} +3 -3
  29. package/dist/{chunk-YA2ZYCJY.js → chunk-JPK2HHBK.js} +1 -1
  30. package/dist/{chunk-7E55DAFW.js → chunk-KHUCKLOR.js} +12 -7
  31. package/dist/{chunk-R3HIZVFS.js → chunk-KPDCKSN5.js} +23 -3
  32. package/dist/{chunk-B3MGJBFI.js → chunk-KS2OEZWV.js} +23 -47
  33. package/dist/{chunk-UI3ZJIG3.js → chunk-LKLIQUCW.js} +14 -8
  34. package/dist/{chunk-62OAECEQ.js → chunk-LLSFOUZF.js} +8 -8
  35. package/dist/{chunk-YZQSUL5G.js → chunk-M4ZHHCCW.js} +14 -6
  36. package/dist/{chunk-IXIS7RSG.js → chunk-MRXWOOOR.js} +29 -47
  37. package/dist/{chunk-C4DSQBTT.js → chunk-NEYUPZL6.js} +3 -3
  38. package/dist/{chunk-6XYFYLN7.js → chunk-O2MHULBO.js} +13 -8
  39. package/dist/{chunk-B62LKMWQ.js → chunk-OKZJJDOG.js} +86 -188
  40. package/dist/{chunk-HOFVYIPI.js → chunk-ON6ET5ER.js} +16 -1
  41. package/dist/{chunk-KF7GMVNU.js → chunk-OUERRFEM.js} +32 -11
  42. package/dist/{chunk-GF4JHLCO.js → chunk-PWZUHZP7.js} +2 -2
  43. package/dist/{chunk-OGQMPX3J.js → chunk-QAWI3RSK.js} +37 -81
  44. package/dist/{chunk-ZMCV3XOV.js → chunk-SPNXDTCJ.js} +29 -63
  45. package/dist/{chunk-H2VB7GCR.js → chunk-ULI2J6TX.js} +27 -14
  46. package/dist/{chunk-EMA2XENR.js → chunk-UVYRQKPZ.js} +4 -3
  47. package/dist/{chunk-MF6ZUBI7.js → chunk-V25Q6TQ7.js} +3 -3
  48. package/dist/{chunk-2NTHMZV3.js → chunk-VMJY6FYJ.js} +693 -276
  49. package/dist/{chunk-ZOUG3KKS.js → chunk-XPVYZ2S6.js} +2 -2
  50. package/dist/{chunk-5U5ULQX2.js → chunk-XZLVJD56.js} +5 -1
  51. package/dist/{chunk-HCPSVK7J.js → chunk-YKSOSI2N.js} +47 -31
  52. package/dist/codebase-index/codebase-ast-replace-tool.d.ts +5 -6
  53. package/dist/codebase-index/codebase-context-tool.d.ts +4 -6
  54. package/dist/codebase-index/codebase-impact-analysis-tool.d.ts +1 -2
  55. package/dist/codebase-index/codebase-incoming-calls-tool.d.ts +0 -2
  56. package/dist/codebase-index/codebase-index-tool.d.ts +0 -2
  57. package/dist/codebase-index/codebase-invariant-check-tool.d.ts +1 -2
  58. package/dist/codebase-index/codebase-outgoing-calls-tool.d.ts +0 -2
  59. package/dist/codebase-index/codebase-repo-map-tool.d.ts +1 -2
  60. package/dist/codebase-index/codebase-search-tool.d.ts +1 -1
  61. package/dist/codebase-index/codebase-targeted-test-tool.d.ts +1 -2
  62. package/dist/codebase-index/index.js +8 -8
  63. package/dist/codebase-index/parser-worker-script.js +3 -3
  64. package/dist/codebase-index/project-server.js +5 -5
  65. package/dist/codebase-index/worker.js +4 -4
  66. package/dist/design.js +1 -1
  67. package/dist/diff.js +1 -1
  68. package/dist/edit.js +7 -7
  69. package/dist/exec.d.ts +7 -7
  70. package/dist/exec.js +2 -2
  71. package/dist/format.js +5 -5
  72. package/dist/git.js +1 -1
  73. package/dist/glob.js +1 -1
  74. package/dist/{go-parser-VDPRQEGM.js → go-parser-Z4H6SR3R.js} +6 -3
  75. package/dist/grep.js +1 -1
  76. package/dist/index.js +45 -45
  77. package/dist/install.js +5 -5
  78. package/dist/json.d.ts +0 -1
  79. package/dist/json.js +1 -1
  80. package/dist/kanban-presence.d.ts +6 -0
  81. package/dist/kanban-serializer.d.ts +9 -1
  82. package/dist/kanban-split-task-handler.d.ts +1 -1
  83. package/dist/kanban-tool-results.d.ts +57 -2
  84. package/dist/kanban-tool-types.d.ts +16 -5
  85. package/dist/kanban.d.ts +14 -0
  86. package/dist/kanban.js +9 -1
  87. package/dist/languages/index.js +3 -3
  88. package/dist/{legacy-bridge-4T4OTSQP.js → legacy-bridge-BPT2S2F4.js} +5 -5
  89. package/dist/lint.js +5 -5
  90. package/dist/logs.js +1 -1
  91. package/dist/mode.d.ts +3 -2
  92. package/dist/mode.js +1 -1
  93. package/dist/outdated.js +2 -2
  94. package/dist/pack.js +42 -42
  95. package/dist/{parser-dispatch-4E2SDQUO.js → parser-dispatch-WG4DNBHH.js} +4 -4
  96. package/dist/patch.js +7 -7
  97. package/dist/plan.d.ts +2 -1
  98. package/dist/plan.js +3 -3
  99. package/dist/{py-parser-MAW6DHFE.js → py-parser-4PFZYAJ7.js} +3 -3
  100. package/dist/read.js +7 -7
  101. package/dist/replace.js +7 -7
  102. package/dist/search.d.ts +0 -6
  103. package/dist/search.js +1 -1
  104. package/dist/security-ast-scan-tool.d.ts +1 -2
  105. package/dist/session-shell.js +2 -2
  106. package/dist/task.d.ts +2 -1
  107. package/dist/task.js +3 -3
  108. package/dist/test.d.ts +8 -1
  109. package/dist/test.js +5 -5
  110. package/dist/todo.js +2 -2
  111. package/dist/tool-search.d.ts +2 -0
  112. package/dist/tool-search.js +1 -1
  113. package/dist/tool-tier.js +43 -43
  114. package/dist/tool-use.d.ts +2 -2
  115. package/dist/tool-use.js +1 -1
  116. package/dist/tree.js +1 -1
  117. package/dist/typecheck.js +5 -5
  118. package/dist/wasm/bash/tree-sitter-bash.wasm +0 -0
  119. package/dist/wasm/c/tree-sitter-c.wasm +0 -0
  120. package/dist/wasm/c_sharp/tree-sitter-c_sharp.wasm +0 -0
  121. package/dist/wasm/checksums.json +16 -0
  122. package/dist/wasm/cpp/tree-sitter-cpp.wasm +0 -0
  123. package/dist/wasm/elixir/tree-sitter-elixir.wasm +0 -0
  124. package/dist/wasm/go/tree-sitter-go.wasm +0 -0
  125. package/dist/wasm/java/tree-sitter-java.wasm +0 -0
  126. package/dist/wasm/kotlin/tree-sitter-kotlin.wasm +0 -0
  127. package/dist/wasm/php/tree-sitter-php.wasm +0 -0
  128. package/dist/wasm/python/tree-sitter-python.wasm +0 -0
  129. package/dist/wasm/ruby/tree-sitter-ruby.wasm +0 -0
  130. package/dist/wasm/rust/tree-sitter-rust.wasm +0 -0
  131. package/dist/wasm/swift/tree-sitter-swift.wasm +0 -0
  132. package/dist/wasm/tree-sitter-runtime.wasm +0 -0
  133. package/dist/win32.d.ts +1 -1
  134. package/dist/win32.js +3 -1
  135. package/dist/write.js +7 -7
  136. package/package.json +10 -10
@@ -15,85 +15,85 @@ import {
15
15
  codebaseStatsTool,
16
16
  codebaseTargetedTestTool,
17
17
  deadCodeScanTool
18
- } from "./chunk-JB5JLY7V.js";
18
+ } from "./chunk-ENE22I5W.js";
19
19
  import {
20
20
  designTool
21
- } from "./chunk-IXIS7RSG.js";
21
+ } from "./chunk-MRXWOOOR.js";
22
22
  import {
23
23
  planTool
24
- } from "./chunk-O6AGFJBO.js";
24
+ } from "./chunk-7V33PHT6.js";
25
25
  import {
26
26
  taskTool
27
- } from "./chunk-B62LKMWQ.js";
27
+ } from "./chunk-OKZJJDOG.js";
28
28
  import {
29
29
  testTool
30
- } from "./chunk-KF7GMVNU.js";
30
+ } from "./chunk-OUERRFEM.js";
31
31
  import {
32
32
  installTool
33
- } from "./chunk-H2VB7GCR.js";
33
+ } from "./chunk-ULI2J6TX.js";
34
34
  import {
35
35
  auditTool
36
- } from "./chunk-HCPSVK7J.js";
36
+ } from "./chunk-YKSOSI2N.js";
37
37
  import {
38
38
  outdatedTool
39
- } from "./chunk-NL45OWEO.js";
39
+ } from "./chunk-DOAHONOS.js";
40
40
  import {
41
41
  logsTool
42
- } from "./chunk-CAF4L6KN.js";
42
+ } from "./chunk-C3WP6ZOT.js";
43
43
  import {
44
44
  toolSearchTool
45
- } from "./chunk-YA2ZYCJY.js";
45
+ } from "./chunk-JPK2HHBK.js";
46
46
  import {
47
47
  toolUseTool
48
- } from "./chunk-B3MGJBFI.js";
48
+ } from "./chunk-KS2OEZWV.js";
49
49
  import {
50
50
  gitTool
51
- } from "./chunk-ZMCV3XOV.js";
51
+ } from "./chunk-SPNXDTCJ.js";
52
52
  import {
53
53
  patchTool
54
- } from "./chunk-5MP76C72.js";
54
+ } from "./chunk-2UVAIS5O.js";
55
55
  import {
56
56
  jsonTool
57
- } from "./chunk-EGT5QLCB.js";
57
+ } from "./chunk-D6RQZMZS.js";
58
58
  import {
59
59
  diffTool
60
- } from "./chunk-N3OTTQNC.js";
60
+ } from "./chunk-2OCAAFAT.js";
61
61
  import {
62
62
  treeTool
63
- } from "./chunk-YZQSUL5G.js";
63
+ } from "./chunk-M4ZHHCCW.js";
64
64
  import {
65
65
  lintTool
66
- } from "./chunk-R3HIZVFS.js";
66
+ } from "./chunk-KPDCKSN5.js";
67
67
  import {
68
68
  formatTool
69
- } from "./chunk-QJARSK2G.js";
69
+ } from "./chunk-4SUGLJLO.js";
70
70
  import {
71
71
  typecheckTool
72
- } from "./chunk-AH7J5HWL.js";
72
+ } from "./chunk-5RBUYFRV.js";
73
73
  import {
74
74
  languageInfoTool,
75
75
  languagePackageTool,
76
76
  languageTool
77
- } from "./chunk-SEONDNLN.js";
77
+ } from "./chunk-G7CYW5EP.js";
78
78
  import {
79
79
  replaceTool
80
- } from "./chunk-KMXPP32M.js";
80
+ } from "./chunk-C6ZOXNXV.js";
81
81
  import {
82
82
  globTool
83
- } from "./chunk-HOFVYIPI.js";
83
+ } from "./chunk-ON6ET5ER.js";
84
84
  import {
85
85
  grepTool
86
- } from "./chunk-FI6SOIVE.js";
86
+ } from "./chunk-DLZCOEVG.js";
87
87
  import {
88
88
  bashTool,
89
89
  checkAndBlockKillCommand,
90
90
  diagnoseBashism,
91
91
  shellArgs
92
- } from "./chunk-5KRKL3WD.js";
92
+ } from "./chunk-FCSUBTUJ.js";
93
93
  import {
94
94
  detectDanger,
95
95
  execTool
96
- } from "./chunk-OGQMPX3J.js";
96
+ } from "./chunk-QAWI3RSK.js";
97
97
  import {
98
98
  buildChildEnv
99
99
  } from "./chunk-BTSFTGIL.js";
@@ -110,31 +110,31 @@ import {
110
110
  } from "./chunk-4SW6BXUR.js";
111
111
  import {
112
112
  searchTool
113
- } from "./chunk-62OAECEQ.js";
113
+ } from "./chunk-LLSFOUZF.js";
114
114
  import {
115
115
  guardedFetch
116
116
  } from "./chunk-NBDZMMG2.js";
117
117
  import {
118
118
  todoTool
119
- } from "./chunk-S6CGSFLX.js";
119
+ } from "./chunk-DBG7UQGK.js";
120
120
  import {
121
121
  kanbanTool
122
- } from "./chunk-2NTHMZV3.js";
122
+ } from "./chunk-VMJY6FYJ.js";
123
123
  import {
124
124
  browserTools
125
- } from "./chunk-6XYFYLN7.js";
125
+ } from "./chunk-O2MHULBO.js";
126
126
  import {
127
127
  readTool
128
- } from "./chunk-HIRVCXLP.js";
128
+ } from "./chunk-IE4KDAOB.js";
129
129
  import {
130
130
  writeTool
131
- } from "./chunk-GF4JHLCO.js";
131
+ } from "./chunk-PWZUHZP7.js";
132
132
  import {
133
133
  editTool
134
- } from "./chunk-WKLUOXR4.js";
134
+ } from "./chunk-7GOE2ZTZ.js";
135
135
  import {
136
136
  resolvePowerShell
137
- } from "./chunk-5U5ULQX2.js";
137
+ } from "./chunk-XZLVJD56.js";
138
138
  import {
139
139
  normalizeCommandOutput,
140
140
  safeResolveProjectPath,
@@ -143,6 +143,7 @@ import {
143
143
 
144
144
  // src/clarify.ts
145
145
  import { randomUUID } from "node:crypto";
146
+ import { ToolValidationError } from "@wrongstack/core/types";
146
147
  import { toErrorMessage } from "@wrongstack/core/utils";
147
148
  var clarifyTool = {
148
149
  name: "clarify",
@@ -192,40 +193,41 @@ var clarifyTool = {
192
193
  additionalProperties: false
193
194
  },
194
195
  async execute(input, ctx, opts) {
196
+ const signal = opts?.signal ?? ctx.signal;
197
+ signal?.throwIfAborted();
198
+ let request;
195
199
  try {
196
- const signal = opts?.signal ?? ctx.signal;
197
- signal.throwIfAborted();
198
- const request = normalizeRequest(input);
199
- let response;
200
- if (typeof ctx.requestUserInput === "function")
201
- response = await ctx.requestUserInput(request, signal);
202
- else response = await legacyHostResponse(ctx, request);
203
- const autoDecided = response === void 0;
204
- const resolved = response ?? recommendedResponse(request);
205
- if (resolved.status === "cancelled")
206
- return skipped(request, "User cancelled the clarification form.");
207
- const answers = materializeAnswers(request, resolved.answers);
208
- const primary = answers[0];
209
- const decisionSummary = `${autoDecided ? "Auto-selected recommended answers in non-interactive mode" : "User clarified"}: ${answers.map((answer) => {
210
- if (answer.delegatedToModel)
211
- return `"${answer.question}": model should decide (user delegated)`;
212
- const values = [
213
- ...answer.selectedOptions,
214
- ...answer.customResponse ? [answer.customResponse] : []
215
- ];
216
- return `"${answer.question}": ${values.join(", ") || "(blank)"}`;
217
- }).join("; ")}`;
218
- return {
219
- status: autoDecided ? "auto_decided" : "answered",
220
- question: primary.question,
221
- selectedOptions: primary.selectedOptions,
222
- customResponse: primary.customResponse,
223
- answers,
224
- decisionSummary
225
- };
200
+ request = normalizeRequest(input);
226
201
  } catch (error) {
227
- return skippedFromInput(input, toErrorMessage(error));
202
+ throw new ToolValidationError({ message: `clarify: ${toErrorMessage(error)}`, cause: error });
228
203
  }
204
+ let response;
205
+ if (typeof ctx.requestUserInput === "function")
206
+ response = await ctx.requestUserInput(request, signal);
207
+ else response = await legacyHostResponse(ctx, request);
208
+ const autoDecided = response === void 0;
209
+ const resolved = response ?? recommendedResponse(request);
210
+ if (resolved.status === "cancelled")
211
+ return skipped(request, "User cancelled the clarification form.");
212
+ const answers = materializeAnswers(request, resolved.answers);
213
+ const primary = answers[0];
214
+ const decisionSummary = `${autoDecided ? "Auto-selected recommended answers in non-interactive mode" : "User clarified"}: ${answers.map((answer) => {
215
+ if (answer.delegatedToModel)
216
+ return `"${answer.question}": model should decide (user delegated)`;
217
+ const values = [
218
+ ...answer.selectedOptions,
219
+ ...answer.customResponse ? [answer.customResponse] : []
220
+ ];
221
+ return `"${answer.question}": ${values.join(", ") || "(blank)"}`;
222
+ }).join("; ")}`;
223
+ return {
224
+ status: autoDecided ? "auto_decided" : "answered",
225
+ question: primary.question,
226
+ selectedOptions: primary.selectedOptions,
227
+ customResponse: primary.customResponse,
228
+ answers,
229
+ decisionSummary
230
+ };
229
231
  }
230
232
  };
231
233
  function optionArraySchema() {
@@ -476,15 +478,6 @@ function skipped(request, error) {
476
478
  error
477
479
  };
478
480
  }
479
- function skippedFromInput(input, error) {
480
- return {
481
- status: "skipped",
482
- question: input.question ?? input.questions?.[0]?.question ?? input.tabs?.[0]?.questions[0]?.question ?? "",
483
- selectedOptions: [],
484
- decisionSummary: "",
485
- error
486
- };
487
- }
488
481
 
489
482
  // src/pwsh.ts
490
483
  import { spawn } from "node:child_process";
@@ -495,7 +488,7 @@ import {
495
488
  emitProcessOutput,
496
489
  emitProcessStarted
497
490
  } from "@wrongstack/core/observability";
498
- import { ToolValidationError } from "@wrongstack/core/types";
491
+ import { ToolValidationError as ToolValidationError2 } from "@wrongstack/core/types";
499
492
  var MAX_OUTPUT = 32768;
500
493
  var DEFAULT_TIMEOUT_MS = 3e5;
501
494
  var STREAM_FLUSH_INTERVAL_MS = 200;
@@ -654,7 +647,7 @@ var pwshTool = {
654
647
  },
655
648
  async *executeStream(input, ctx, opts) {
656
649
  if (!input?.command || typeof input.command !== "string" || !input.command.trim()) {
657
- throw new ToolValidationError({
650
+ throw new ToolValidationError2({
658
651
  message: "pwsh: command is required and cannot be empty",
659
652
  field: "command"
660
653
  });
@@ -676,31 +669,13 @@ var pwshTool = {
676
669
  const isBackground = !!(input.run_in_background || input.background);
677
670
  const registry = getProcessRegistry();
678
671
  if (!registry.beforeCall(isBackground)) {
679
- yield {
680
- type: "final",
681
- output: {
682
- output: "",
683
- exit_code: 1,
684
- timed_out: false,
685
- pid: null,
686
- error: "pwsh: circuit breaker open \u2014 too many consecutive failures or slow calls. Use /kill to inspect or /kill reset to recover."
687
- }
688
- };
689
- return;
672
+ throw new Error(
673
+ "pwsh: circuit breaker open \u2014 too many consecutive failures or slow calls. Use /kill to inspect or /kill reset to recover."
674
+ );
690
675
  }
691
676
  const killCheck = await checkAndBlockKillCommand(input.command);
692
677
  if (killCheck.blocked) {
693
- yield {
694
- type: "final",
695
- output: {
696
- output: "",
697
- exit_code: 1,
698
- timed_out: false,
699
- pid: null,
700
- error: `pwsh: ${killCheck.reason}`
701
- }
702
- };
703
- return;
678
+ throw new Error(`pwsh: ${killCheck.reason}`);
704
679
  }
705
680
  const isWin = os.platform() === "win32";
706
681
  const bin = isWin ? resolvePowerShell("pwsh.exe") : "pwsh";
@@ -713,17 +688,7 @@ var pwshTool = {
713
688
  try {
714
689
  targetCwd = await safeResolveReal(input.workdir ?? ctx.workingDir ?? ctx.projectRoot, ctx);
715
690
  } catch (err) {
716
- yield {
717
- type: "final",
718
- output: {
719
- output: "",
720
- exit_code: 1,
721
- timed_out: false,
722
- pid: null,
723
- error: `pwsh: ${err.message}`
724
- }
725
- };
726
- return;
691
+ throw new Error(`pwsh: ${err.message}`, { cause: err });
727
692
  }
728
693
  const startedAt = Date.now();
729
694
  const detached = !isWin;
@@ -755,17 +720,9 @@ var pwshTool = {
755
720
  timedOut: false,
756
721
  endedAt: (/* @__PURE__ */ new Date()).toISOString()
757
722
  });
758
- yield {
759
- type: "final",
760
- output: {
761
- output: "",
762
- exit_code: 1,
763
- timed_out: false,
764
- pid: null,
765
- error: `pwsh: spawn failed: ${err instanceof Error ? err.message : String(err)}`
766
- }
767
- };
768
- return;
723
+ throw new Error(`pwsh: spawn failed: ${err instanceof Error ? err.message : String(err)}`, {
724
+ cause: err
725
+ });
769
726
  }
770
727
  const pid2 = child2.pid;
771
728
  let bgTelemetryCompleted = false;
@@ -843,17 +800,7 @@ Working directory: ${targetCwd}`,
843
800
  return;
844
801
  }
845
802
  completeBackground(1);
846
- yield {
847
- type: "final",
848
- output: {
849
- output: "",
850
- exit_code: 1,
851
- timed_out: false,
852
- pid: null,
853
- error: "pwsh: failed to obtain PID for background process"
854
- }
855
- };
856
- return;
803
+ throw new Error("pwsh: failed to obtain PID for background process");
857
804
  }
858
805
  const spool = createOutputSpool({ tool: "pwsh", thresholdBytes: MAX_OUTPUT });
859
806
  let child;
@@ -884,17 +831,9 @@ Working directory: ${targetCwd}`,
884
831
  timedOut: false,
885
832
  endedAt: (/* @__PURE__ */ new Date()).toISOString()
886
833
  });
887
- yield {
888
- type: "final",
889
- output: {
890
- output: "",
891
- exit_code: 1,
892
- timed_out: false,
893
- pid: null,
894
- error: `pwsh: spawn failed: ${err instanceof Error ? err.message : String(err)}`
895
- }
896
- };
897
- return;
834
+ throw new Error(`pwsh: spawn failed: ${err instanceof Error ? err.message : String(err)}`, {
835
+ cause: err
836
+ });
898
837
  }
899
838
  const pid = child.pid;
900
839
  let stdoutBytes = 0;
@@ -1083,16 +1022,6 @@ Working directory: ${targetCwd}`,
1083
1022
  yield { type: "partial_output", text: remainder };
1084
1023
  }
1085
1024
  const spooled = spool.finalize();
1086
- yield {
1087
- type: "final",
1088
- output: {
1089
- output: normalizeCommandOutput(buf) + (spooled ? spoolNote(spooled) : ""),
1090
- exit_code: isAbort ? 124 : 1,
1091
- timed_out: isAbort,
1092
- pid: pid ?? null,
1093
- error: isAbort ? "Command aborted by user or signal" : c.err.message
1094
- }
1095
- };
1096
1025
  ctx.recordSideEffect?.({
1097
1026
  toolUseId: `pwsh-${Date.now()}`,
1098
1027
  toolName: "pwsh",
@@ -1101,6 +1030,19 @@ Working directory: ${targetCwd}`,
1101
1030
  outcome: isAbort ? "aborted" : `error (${c.err.message})`,
1102
1031
  risk: "shell"
1103
1032
  });
1033
+ if (!isAbort) {
1034
+ throw new Error(`pwsh: process error: ${c.err.message}`, { cause: c.err });
1035
+ }
1036
+ yield {
1037
+ type: "final",
1038
+ output: {
1039
+ output: normalizeCommandOutput(buf) + (spooled ? spoolNote(spooled) : ""),
1040
+ exit_code: 124,
1041
+ timed_out: true,
1042
+ pid: pid ?? null,
1043
+ error: "Command aborted by user or signal"
1044
+ }
1045
+ };
1104
1046
  return;
1105
1047
  }
1106
1048
  if (c.kind === "end") {
@@ -1261,7 +1203,6 @@ var readUrlContentTool = {
1261
1203
  // src/security-ast-scan-tool.ts
1262
1204
  import * as fs from "node:fs/promises";
1263
1205
  import * as path from "node:path";
1264
- import { toErrorMessage as toErrorMessage2 } from "@wrongstack/core/utils";
1265
1206
  var SECRET_PATTERNS = [
1266
1207
  { name: "AWS Access Key", regex: /\b(AKIA[0-9A-Z]{16})\b/ },
1267
1208
  { name: "GitHub Token", regex: /\b(gh[pousr]_[A-Za-z0-9_]{36,255})\b/ },
@@ -1421,58 +1362,48 @@ var securityAstScanTool = {
1421
1362
  },
1422
1363
  additionalProperties: false
1423
1364
  },
1365
+ // Failures THROW so the executor marks the call is_error. The old catch
1366
+ // returned `status: 'error'`, which the executor recorded as a successful
1367
+ // call — for a scanner that reads as "ran fine", the worst possible lie.
1424
1368
  async execute(input, ctx) {
1425
- try {
1426
- const projectRoot = ctx.projectRoot ?? ctx.cwd ?? process.cwd();
1427
- let targetFile = input.file ?? "inline-code.ts";
1428
- let content = input.content;
1429
- if (!content && input.file) {
1430
- const absPath = await safeResolveProjectPath(input.file, ctx);
1431
- targetFile = path.relative(projectRoot, absPath).replace(/\\/g, "/");
1432
- content = await fs.readFile(absPath, "utf8");
1433
- }
1434
- if (!content) {
1435
- return {
1436
- status: "clean",
1437
- filesScanned: 0,
1438
- totalFindings: 0,
1439
- criticalCount: 0,
1440
- warningCount: 0,
1441
- findings: [],
1442
- summary: "No content or file provided to scan."
1443
- };
1444
- }
1445
- let findings = analyzeSecurityAndPerformance(targetFile, content);
1446
- if (input.rules && input.rules.length > 0) {
1447
- const ruleSet = new Set(input.rules);
1448
- findings = findings.filter((f) => ruleSet.has(f.ruleId));
1449
- }
1450
- const criticalCount = findings.filter((f) => f.severity === "critical").length;
1451
- const warningCount = findings.filter((f) => f.severity === "warning").length;
1452
- const totalFindings = findings.length;
1453
- const status = totalFindings === 0 ? "clean" : "findings_detected";
1454
- const summary = totalFindings === 0 ? `Security & Performance AST Scan: CLEAN (${targetFile})` : `Security & Performance AST Scan: ${totalFindings} issue(s) detected (${criticalCount} critical, ${warningCount} warning).`;
1455
- return {
1456
- status,
1457
- filesScanned: 1,
1458
- totalFindings,
1459
- criticalCount,
1460
- warningCount,
1461
- findings,
1462
- summary
1463
- };
1464
- } catch (err) {
1369
+ const projectRoot = ctx.projectRoot ?? ctx.cwd ?? process.cwd();
1370
+ let targetFile = input.file ?? "inline-code.ts";
1371
+ let content = input.content;
1372
+ if (!content && input.file) {
1373
+ const absPath = await safeResolveProjectPath(input.file, ctx);
1374
+ targetFile = path.relative(projectRoot, absPath).replace(/\\/g, "/");
1375
+ content = await fs.readFile(absPath, "utf8");
1376
+ }
1377
+ if (!content) {
1465
1378
  return {
1466
- status: "error",
1379
+ status: "clean",
1467
1380
  filesScanned: 0,
1468
1381
  totalFindings: 0,
1469
1382
  criticalCount: 0,
1470
1383
  warningCount: 0,
1471
1384
  findings: [],
1472
- summary: "",
1473
- error: toErrorMessage2(err)
1385
+ summary: "No content or file provided to scan."
1474
1386
  };
1475
1387
  }
1388
+ let findings = analyzeSecurityAndPerformance(targetFile, content);
1389
+ if (input.rules && input.rules.length > 0) {
1390
+ const ruleSet = new Set(input.rules);
1391
+ findings = findings.filter((f) => ruleSet.has(f.ruleId));
1392
+ }
1393
+ const criticalCount = findings.filter((f) => f.severity === "critical").length;
1394
+ const warningCount = findings.filter((f) => f.severity === "warning").length;
1395
+ const totalFindings = findings.length;
1396
+ const status = totalFindings === 0 ? "clean" : "findings_detected";
1397
+ const summary = totalFindings === 0 ? `Security & Performance AST Scan: CLEAN (${targetFile})` : `Security & Performance AST Scan: ${totalFindings} issue(s) detected (${criticalCount} critical, ${warningCount} warning).`;
1398
+ return {
1399
+ status,
1400
+ filesScanned: 1,
1401
+ totalFindings,
1402
+ criticalCount,
1403
+ warningCount,
1404
+ findings,
1405
+ summary
1406
+ };
1476
1407
  }
1477
1408
  };
1478
1409
 
@@ -1692,4 +1623,4 @@ export {
1692
1623
  TIER3_TOOLS,
1693
1624
  builtinTools
1694
1625
  };
1695
- //# sourceMappingURL=chunk-GNLHBDFO.js.map
1626
+ //# sourceMappingURL=chunk-6I6RXQFG.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-MSOAX3GC.js";
4
4
  import {
5
5
  enqueueReindex
6
- } from "./chunk-TU6UVATU.js";
6
+ } from "./chunk-HYHE4VNA.js";
7
7
  import {
8
8
  safeResolveReal,
9
9
  sha256hex,
@@ -518,4 +518,4 @@ Compare this against your old_string and retry with the file's actual text.` : "
518
518
  export {
519
519
  editTool
520
520
  };
521
- //# sourceMappingURL=chunk-WKLUOXR4.js.map
521
+ //# sourceMappingURL=chunk-7GOE2ZTZ.js.map