@wrongstack/tools 0.320.1 → 1.0.1

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 (192) hide show
  1. package/dist/_danger-detect.d.ts +8 -0
  2. package/dist/_syntax-check.d.ts +1 -2
  3. package/dist/audit.d.ts +4 -5
  4. package/dist/audit.js +6 -6
  5. package/dist/auto-proceed-loop-guard.d.ts +1 -1
  6. package/dist/auto-proceed-loop-guard.js +9 -160
  7. package/dist/bash-kill-guard.d.ts +2 -3
  8. package/dist/bash.d.ts +2 -3
  9. package/dist/bash.js +4 -4
  10. package/dist/batch-tool-use.d.ts +2 -3
  11. package/dist/batch-tool-use.js +1 -1
  12. package/dist/browser/index.d.ts +1 -1
  13. package/dist/browser/index.js +1 -1
  14. package/dist/browser/tools.d.ts +56 -45
  15. package/dist/builtin.js +50 -50
  16. package/dist/{chunk-T77XOX7E.js → chunk-24T5XIJU.js} +1 -1
  17. package/dist/{chunk-DTQ75VBC.js → chunk-2CTZW6JQ.js} +2 -2
  18. package/dist/{chunk-KWXIKGE3.js → chunk-3D5DJWOE.js} +3 -3
  19. package/dist/{chunk-XSSFBS5I.js → chunk-4ERMPDHV.js} +11 -6
  20. package/dist/{chunk-QSNVDHOZ.js → chunk-4WPBS45A.js} +4 -5
  21. package/dist/{chunk-4CQWNZ62.js → chunk-5ITQPCLC.js} +2 -2
  22. package/dist/{chunk-B4HTSV6Z.js → chunk-5KS24LTS.js} +11 -11
  23. package/dist/{chunk-QPNYDH5B.js → chunk-62OAECEQ.js} +29 -7
  24. package/dist/{chunk-DFQDJT22.js → chunk-6GOZTS6F.js} +3 -3
  25. package/dist/{chunk-5UFVCIUB.js → chunk-6H4ERJP7.js} +140 -24
  26. package/dist/{chunk-34VLZ35Z.js → chunk-7HL23T3T.js} +63 -10
  27. package/dist/{chunk-HFXSNKCV.js → chunk-7JJFC6CT.js} +1 -1
  28. package/dist/{chunk-23EX5WDO.js → chunk-7LQCT3LT.js} +3 -3
  29. package/dist/{chunk-NDIT3SBZ.js → chunk-7N5U2RAU.js} +2 -2
  30. package/dist/{chunk-QBV725YG.js → chunk-7ODZTPCU.js} +2 -2
  31. package/dist/{chunk-6AAOT4PW.js → chunk-AQ5YBURX.js} +16 -4
  32. package/dist/{chunk-ZMW6WJFT.js → chunk-ASEXQRA7.js} +3 -3
  33. package/dist/{chunk-FRN7TIAA.js → chunk-B3MGJBFI.js} +1 -1
  34. package/dist/{chunk-JLYA4X7K.js → chunk-CGXTR34H.js} +21 -6
  35. package/dist/{chunk-IU4DV2PA.js → chunk-CHEK3ASV.js} +6 -3
  36. package/dist/{chunk-GOIZNNOA.js → chunk-DJYLI7EW.js} +1 -1
  37. package/dist/{chunk-Z6IHMJMC.js → chunk-DK4J2WMH.js} +11 -11
  38. package/dist/{chunk-OYP27E3I.js → chunk-DRRY6SCM.js} +47 -20
  39. package/dist/{chunk-JVRLTEO7.js → chunk-E7JE3UEX.js} +2 -2
  40. package/dist/{chunk-BK732J7I.js → chunk-FBUP524S.js} +4 -4
  41. package/dist/{chunk-NYRLWDT5.js → chunk-FVM3O4JQ.js} +1 -1
  42. package/dist/chunk-FYDBUVQD.js +244 -0
  43. package/dist/{chunk-PV6HIZQD.js → chunk-GDDXX27P.js} +50 -50
  44. package/dist/{chunk-3GIKYHLA.js → chunk-GKSG5CPH.js} +6 -6
  45. package/dist/{chunk-ESLPBT5A.js → chunk-HDYUBRMF.js} +4 -3
  46. package/dist/{chunk-4BABEJC2.js → chunk-IAYMTTR2.js} +236 -79
  47. package/dist/{chunk-ELRRTWNP.js → chunk-IXIS7RSG.js} +2 -2
  48. package/dist/{chunk-HR67OWEP.js → chunk-IYH4OHBP.js} +5 -5
  49. package/dist/{chunk-W232EFEM.js → chunk-JDOO4P6Z.js} +7 -4
  50. package/dist/{chunk-2OXHS3KZ.js → chunk-KLJZ4WV4.js} +4 -3
  51. package/dist/{chunk-3M7LLN7W.js → chunk-LQSOU63Z.js} +12 -11
  52. package/dist/{chunk-OTPTQBYE.js → chunk-MGPR7VG3.js} +279 -265
  53. package/dist/{chunk-C2DQKVLO.js → chunk-MJSJWXBF.js} +1 -1
  54. package/dist/{chunk-NSPNFOJ7.js → chunk-MK2JK35J.js} +25 -10
  55. package/dist/{chunk-JSNSMG5R.js → chunk-MSOAX3GC.js} +1 -1
  56. package/dist/{chunk-J43O3BOX.js → chunk-N3K2SFEI.js} +532 -492
  57. package/dist/{chunk-J74TMK4M.js → chunk-NJX2RXKJ.js} +50 -7
  58. package/dist/chunk-NL2S2CXD.js +171 -0
  59. package/dist/{chunk-WAQASTXB.js → chunk-O6BY43ZB.js} +29 -8
  60. package/dist/{chunk-QGF2C7TF.js → chunk-PVCB7RUZ.js} +2 -2
  61. package/dist/{chunk-YTKSNTT4.js → chunk-QA6IASYX.js} +8 -8
  62. package/dist/{chunk-VPALDFYM.js → chunk-RV7BVTDG.js} +1 -1
  63. package/dist/chunk-S57CDR2H.js +288 -0
  64. package/dist/{chunk-W2CECGTG.js → chunk-SMARDKAC.js} +1 -1
  65. package/dist/{chunk-QWKSKFKZ.js → chunk-SOR7OCYP.js} +1 -1
  66. package/dist/{chunk-I7FBZOEP.js → chunk-T3SMFF5Q.js} +11 -5
  67. package/dist/{chunk-4BHUSMNL.js → chunk-UI3ZJIG3.js} +1 -1
  68. package/dist/{chunk-WXJY3BKV.js → chunk-VBF2YXUW.js} +2 -2
  69. package/dist/{chunk-FQNXYA6W.js → chunk-VU3QBYL4.js} +36 -5
  70. package/dist/{chunk-VD2LV5WO.js → chunk-VZGPASGD.js} +37 -12
  71. package/dist/{chunk-UZFY3CKD.js → chunk-WEEVSWQB.js} +17 -6
  72. package/dist/chunk-XXRMF2BC.js +186 -0
  73. package/dist/{chunk-LRDIRJJL.js → chunk-YEISRT4S.js} +5 -11
  74. package/dist/{chunk-Q5JPPCZC.js → chunk-YJTXRH5Y.js} +3 -2
  75. package/dist/{chunk-Z5Q3TXRY.js → chunk-ZTCJCYLN.js} +3 -3
  76. package/dist/circuit-breaker.d.ts +1 -0
  77. package/dist/circuit-breaker.js +1 -1
  78. package/dist/clarify.d.ts +1 -0
  79. package/dist/codebase-index/codebase-ast-replace-tool.d.ts +2 -3
  80. package/dist/codebase-index/codebase-impact-analysis-tool.d.ts +5 -4
  81. package/dist/codebase-index/codebase-incoming-calls-tool.d.ts +4 -3
  82. package/dist/codebase-index/codebase-index-tool.d.ts +2 -3
  83. package/dist/codebase-index/codebase-invariant-check-tool.d.ts +2 -3
  84. package/dist/codebase-index/codebase-outgoing-calls-tool.d.ts +4 -3
  85. package/dist/codebase-index/codebase-repo-map-tool.d.ts +2 -3
  86. package/dist/codebase-index/codebase-search-tool.d.ts +2 -3
  87. package/dist/codebase-index/codebase-skeleton-tool.d.ts +2 -3
  88. package/dist/codebase-index/codebase-stats-tool.d.ts +9 -3
  89. package/dist/codebase-index/codebase-targeted-test-tool.d.ts +4 -3
  90. package/dist/codebase-index/index.d.ts +11 -11
  91. package/dist/codebase-index/index.js +8 -8
  92. package/dist/codebase-index/project-server-framing.d.ts +29 -0
  93. package/dist/codebase-index/project-server-lifecycle.d.ts +20 -0
  94. package/dist/codebase-index/project-server-operations.d.ts +37 -0
  95. package/dist/codebase-index/project-server-types.d.ts +30 -0
  96. package/dist/codebase-index/project-server-watcher.d.ts +25 -0
  97. package/dist/codebase-index/project-server.js +448 -391
  98. package/dist/codebase-index/worker.js +2 -2
  99. package/dist/codebase-index/writer-init.d.ts +13 -0
  100. package/dist/codebase-index/writer-maintenance.d.ts +14 -0
  101. package/dist/codebase-index/writer.d.ts +0 -15
  102. package/dist/design.d.ts +2 -2
  103. package/dist/design.js +1 -1
  104. package/dist/diff.d.ts +4 -4
  105. package/dist/diff.js +1 -1
  106. package/dist/document.d.ts +3 -4
  107. package/dist/document.js +1 -1
  108. package/dist/e2e.d.ts +1 -1
  109. package/dist/e2e.js +1 -1
  110. package/dist/edit.d.ts +3 -3
  111. package/dist/edit.js +6 -6
  112. package/dist/exec.d.ts +2 -3
  113. package/dist/exec.js +4 -4
  114. package/dist/fetch.d.ts +4 -3
  115. package/dist/fetch.js +1 -1
  116. package/dist/format.d.ts +17 -45
  117. package/dist/format.js +12 -8
  118. package/dist/git.d.ts +3 -3
  119. package/dist/git.js +1 -1
  120. package/dist/glob.d.ts +2 -3
  121. package/dist/glob.js +2 -2
  122. package/dist/grep.d.ts +7 -5
  123. package/dist/grep.js +3 -3
  124. package/dist/index.d.ts +54 -45
  125. package/dist/index.js +118 -59
  126. package/dist/install.d.ts +7 -55
  127. package/dist/install.js +6 -6
  128. package/dist/json.d.ts +3 -4
  129. package/dist/json.js +2 -2
  130. package/dist/kanban-tool-types.d.ts +1 -2
  131. package/dist/kanban.d.ts +3 -19
  132. package/dist/kanban.js +1 -1
  133. package/dist/languages/execute-tool.d.ts +2 -3
  134. package/dist/languages/index.d.ts +2 -2
  135. package/dist/languages/index.js +4 -4
  136. package/dist/languages/tool.d.ts +3 -4
  137. package/dist/{legacy-bridge-FOV5ODDI.js → legacy-bridge-YXANP5QB.js} +6 -6
  138. package/dist/lint.d.ts +5 -4
  139. package/dist/lint.js +6 -6
  140. package/dist/logs.d.ts +3 -4
  141. package/dist/logs.js +2 -2
  142. package/dist/memory.d.ts +7 -8
  143. package/dist/memory.js +1 -1
  144. package/dist/mode.d.ts +3 -4
  145. package/dist/mode.js +1 -1
  146. package/dist/next-steps-tool.d.ts +2 -3
  147. package/dist/next-steps.d.ts +4 -0
  148. package/dist/next-steps.js +9 -175
  149. package/dist/outdated.d.ts +5 -29
  150. package/dist/outdated.js +3 -3
  151. package/dist/pack.js +51 -51
  152. package/dist/patch.d.ts +2 -3
  153. package/dist/patch.js +5 -5
  154. package/dist/plan.d.ts +4 -4
  155. package/dist/plan.js +3 -3
  156. package/dist/process-registry.js +2 -2
  157. package/dist/ps-slash.js +4 -4
  158. package/dist/pwsh.d.ts +1 -0
  159. package/dist/read.d.ts +5 -5
  160. package/dist/read.js +5 -5
  161. package/dist/replace.d.ts +2 -3
  162. package/dist/replace.js +6 -6
  163. package/dist/scaffold.d.ts +7 -3
  164. package/dist/scaffold.js +3 -1
  165. package/dist/search.d.ts +17 -3
  166. package/dist/search.js +5 -1
  167. package/dist/set-working-dir.d.ts +2 -3
  168. package/dist/skill.d.ts +4 -5
  169. package/dist/skill.js +1 -1
  170. package/dist/task.d.ts +6 -6
  171. package/dist/task.js +3 -3
  172. package/dist/test.d.ts +5 -4
  173. package/dist/test.js +6 -6
  174. package/dist/todo.d.ts +8 -8
  175. package/dist/todo.js +2 -2
  176. package/dist/tool-diff.js +11 -230
  177. package/dist/tool-help.d.ts +2 -3
  178. package/dist/tool-help.js +1 -1
  179. package/dist/tool-search.d.ts +2 -3
  180. package/dist/tool-search.js +1 -1
  181. package/dist/tool-summary.js +5 -281
  182. package/dist/tool-tier.js +52 -52
  183. package/dist/tool-use.d.ts +2 -3
  184. package/dist/tool-use.js +1 -1
  185. package/dist/tree.d.ts +5 -3
  186. package/dist/tree.js +5 -1
  187. package/dist/typecheck.d.ts +3 -3
  188. package/dist/typecheck.js +6 -6
  189. package/dist/write.d.ts +2 -3
  190. package/dist/write.js +6 -6
  191. package/package.json +5 -5
  192. package/dist/spawn-background.d.ts +0 -80
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  e2ePlanTool
3
- } from "./chunk-VPALDFYM.js";
3
+ } from "./chunk-RV7BVTDG.js";
4
4
  import {
5
5
  codebaseAstReplaceTool,
6
6
  codebaseImpactAnalysisTool,
@@ -14,97 +14,97 @@ import {
14
14
  codebaseStatsTool,
15
15
  codebaseTargetedTestTool,
16
16
  deadCodeScanTool
17
- } from "./chunk-LRDIRJJL.js";
17
+ } from "./chunk-YEISRT4S.js";
18
18
  import {
19
19
  planTool
20
- } from "./chunk-B4HTSV6Z.js";
20
+ } from "./chunk-5KS24LTS.js";
21
21
  import {
22
22
  taskTool
23
- } from "./chunk-3M7LLN7W.js";
23
+ } from "./chunk-LQSOU63Z.js";
24
24
  import {
25
25
  toolSearchTool
26
- } from "./chunk-T77XOX7E.js";
26
+ } from "./chunk-24T5XIJU.js";
27
27
  import {
28
28
  toolUseTool
29
- } from "./chunk-FRN7TIAA.js";
29
+ } from "./chunk-B3MGJBFI.js";
30
30
  import {
31
31
  batchToolUseTool
32
- } from "./chunk-WXJY3BKV.js";
32
+ } from "./chunk-VBF2YXUW.js";
33
33
  import {
34
34
  toolHelpTool
35
- } from "./chunk-QBV725YG.js";
35
+ } from "./chunk-7ODZTPCU.js";
36
36
  import {
37
37
  designTool
38
- } from "./chunk-ELRRTWNP.js";
38
+ } from "./chunk-IXIS7RSG.js";
39
39
  import {
40
40
  testTool
41
- } from "./chunk-YTKSNTT4.js";
41
+ } from "./chunk-QA6IASYX.js";
42
42
  import {
43
43
  installTool
44
- } from "./chunk-WAQASTXB.js";
44
+ } from "./chunk-O6BY43ZB.js";
45
45
  import {
46
46
  auditTool
47
- } from "./chunk-UZFY3CKD.js";
47
+ } from "./chunk-WEEVSWQB.js";
48
48
  import {
49
49
  outdatedTool
50
- } from "./chunk-DFQDJT22.js";
50
+ } from "./chunk-6GOZTS6F.js";
51
51
  import {
52
52
  logsTool
53
- } from "./chunk-FQNXYA6W.js";
53
+ } from "./chunk-VU3QBYL4.js";
54
54
  import {
55
55
  documentTool
56
- } from "./chunk-IU4DV2PA.js";
56
+ } from "./chunk-CHEK3ASV.js";
57
57
  import {
58
58
  scaffoldTool
59
- } from "./chunk-2OXHS3KZ.js";
59
+ } from "./chunk-KLJZ4WV4.js";
60
60
  import {
61
61
  gitTool
62
- } from "./chunk-6AAOT4PW.js";
62
+ } from "./chunk-AQ5YBURX.js";
63
63
  import {
64
64
  patchTool
65
- } from "./chunk-JLYA4X7K.js";
65
+ } from "./chunk-CGXTR34H.js";
66
66
  import {
67
67
  jsonTool
68
- } from "./chunk-VD2LV5WO.js";
68
+ } from "./chunk-VZGPASGD.js";
69
69
  import {
70
70
  diffTool
71
- } from "./chunk-34VLZ35Z.js";
71
+ } from "./chunk-7HL23T3T.js";
72
72
  import {
73
73
  treeTool
74
- } from "./chunk-W232EFEM.js";
74
+ } from "./chunk-JDOO4P6Z.js";
75
75
  import {
76
76
  lintTool
77
- } from "./chunk-KWXIKGE3.js";
77
+ } from "./chunk-3D5DJWOE.js";
78
78
  import {
79
79
  formatTool
80
- } from "./chunk-J74TMK4M.js";
80
+ } from "./chunk-NJX2RXKJ.js";
81
81
  import {
82
82
  typecheckTool
83
- } from "./chunk-QSNVDHOZ.js";
83
+ } from "./chunk-4WPBS45A.js";
84
84
  import {
85
85
  languageInfoTool,
86
86
  languagePackageTool,
87
87
  languageTool
88
- } from "./chunk-NDIT3SBZ.js";
88
+ } from "./chunk-7N5U2RAU.js";
89
89
  import {
90
90
  replaceTool
91
- } from "./chunk-HR67OWEP.js";
91
+ } from "./chunk-IYH4OHBP.js";
92
92
  import {
93
93
  globTool
94
- } from "./chunk-ZMW6WJFT.js";
94
+ } from "./chunk-ASEXQRA7.js";
95
95
  import {
96
96
  grepTool
97
- } from "./chunk-XSSFBS5I.js";
97
+ } from "./chunk-4ERMPDHV.js";
98
98
  import {
99
99
  bashTool,
100
100
  checkAndBlockKillCommand,
101
101
  diagnoseBashism,
102
102
  shellArgs
103
- } from "./chunk-5UFVCIUB.js";
103
+ } from "./chunk-6H4ERJP7.js";
104
104
  import {
105
105
  detectDanger,
106
106
  execTool
107
- } from "./chunk-OTPTQBYE.js";
107
+ } from "./chunk-MGPR7VG3.js";
108
108
  import {
109
109
  buildChildEnv
110
110
  } from "./chunk-BTSFTGIL.js";
@@ -115,31 +115,31 @@ import {
115
115
  import {
116
116
  getProcessRegistry,
117
117
  redactCommand
118
- } from "./chunk-ESLPBT5A.js";
118
+ } from "./chunk-HDYUBRMF.js";
119
119
  import {
120
120
  fetchTool
121
- } from "./chunk-C2DQKVLO.js";
121
+ } from "./chunk-MJSJWXBF.js";
122
122
  import {
123
123
  searchTool
124
- } from "./chunk-QPNYDH5B.js";
124
+ } from "./chunk-62OAECEQ.js";
125
125
  import {
126
126
  todoTool
127
- } from "./chunk-BK732J7I.js";
127
+ } from "./chunk-FBUP524S.js";
128
128
  import {
129
129
  kanbanTool
130
- } from "./chunk-W2CECGTG.js";
130
+ } from "./chunk-SMARDKAC.js";
131
131
  import {
132
132
  browserTools
133
- } from "./chunk-QWKSKFKZ.js";
133
+ } from "./chunk-SOR7OCYP.js";
134
134
  import {
135
135
  readTool
136
- } from "./chunk-NSPNFOJ7.js";
136
+ } from "./chunk-MK2JK35J.js";
137
137
  import {
138
138
  writeTool
139
- } from "./chunk-3GIKYHLA.js";
139
+ } from "./chunk-GKSG5CPH.js";
140
140
  import {
141
141
  editTool
142
- } from "./chunk-Z6IHMJMC.js";
142
+ } from "./chunk-DK4J2WMH.js";
143
143
  import {
144
144
  resolvePowerShell
145
145
  } from "./chunk-KE7A76VC.js";
@@ -204,12 +204,13 @@ var clarifyTool = {
204
204
  const hostAsk = ctx.askUserChoices;
205
205
  if (typeof hostAsk === "function") {
206
206
  const res = await hostAsk(input.question, options, input.isMultiSelect);
207
+ const selected = Array.isArray(res?.selected) ? res.selected : [];
207
208
  return {
208
209
  status: "answered",
209
210
  question: input.question,
210
- selectedOptions: res.selected,
211
- customResponse: res.custom,
212
- decisionSummary: `User selected: ${res.selected.join(", ")}${res.custom ? ` (Custom: ${res.custom})` : ""}`
211
+ selectedOptions: selected,
212
+ customResponse: res?.custom,
213
+ decisionSummary: `User selected: ${selected.join(", ")}${res?.custom ? ` (Custom: ${res.custom})` : ""}`
213
214
  };
214
215
  }
215
216
  const defaultChoice = input.recommendedOption ?? options[0] ?? "Default";
@@ -473,14 +474,72 @@ var pwshTool = {
473
474
  const startedAt = Date.now();
474
475
  const detached = !isWin;
475
476
  if (isBackground) {
476
- const child2 = spawn(bin, args, {
477
+ let child2;
478
+ try {
479
+ child2 = spawn(bin, args, {
480
+ cwd: targetCwd,
481
+ env,
482
+ detached,
483
+ stdio: ["ignore", "ignore", "ignore"],
484
+ windowsHide: true
485
+ });
486
+ } catch (err) {
487
+ registry.afterCall(Date.now() - startedAt, true, isBackground);
488
+ emitProcessStarted({
489
+ parentPid: process.pid,
490
+ command: redactCommand(`${bin} ${args.join(" ")}`),
491
+ args: redactCommand(args.join(" ")).split(" ").filter(Boolean),
492
+ cwd: targetCwd,
493
+ background: true,
494
+ startedAt: new Date(startedAt).toISOString()
495
+ });
496
+ emitProcessCompleted({
497
+ exitCode: 1,
498
+ durationMs: Date.now() - startedAt,
499
+ stdoutBytes: 0,
500
+ stderrBytes: 0,
501
+ timedOut: false,
502
+ endedAt: (/* @__PURE__ */ new Date()).toISOString()
503
+ });
504
+ yield {
505
+ type: "final",
506
+ output: {
507
+ output: "",
508
+ exit_code: 1,
509
+ timed_out: false,
510
+ pid: null,
511
+ error: `pwsh: spawn failed: ${err instanceof Error ? err.message : String(err)}`
512
+ }
513
+ };
514
+ return;
515
+ }
516
+ const pid2 = child2.pid;
517
+ let bgTelemetryCompleted = false;
518
+ let bgErrorOccurred = false;
519
+ let bgSettled = false;
520
+ emitProcessStarted({
521
+ ...pid2 !== void 0 ? { pid: pid2 } : {},
522
+ parentPid: process.pid,
523
+ command: redactCommand(`${bin} ${args.join(" ")}`),
524
+ args: redactCommand(args.join(" ")).split(" ").filter(Boolean),
477
525
  cwd: targetCwd,
478
- env,
479
- detached,
480
- stdio: ["ignore", "ignore", "ignore"],
481
- windowsHide: true
526
+ background: true,
527
+ startedAt: new Date(startedAt).toISOString()
482
528
  });
483
- const pid2 = child2.pid;
529
+ const completeBackground = (exitCode, sig) => {
530
+ if (bgTelemetryCompleted) return;
531
+ bgTelemetryCompleted = true;
532
+ emitProcessCompleted({
533
+ ...pid2 !== void 0 ? { pid: pid2 } : {},
534
+ exitCode,
535
+ ...sig ? { signal: sig } : {},
536
+ durationMs: Date.now() - startedAt,
537
+ stdoutBytes: 0,
538
+ stderrBytes: 0,
539
+ timedOut: false,
540
+ endedAt: (/* @__PURE__ */ new Date()).toISOString()
541
+ });
542
+ };
484
543
  if (typeof pid2 === "number") {
485
544
  registry.register({
486
545
  pid: pid2,
@@ -492,10 +551,19 @@ var pwshTool = {
492
551
  processGroupLeader: detached && child2.pid === pid2,
493
552
  background: true
494
553
  });
495
- child2.on("close", () => registry.unregister(pid2));
496
- child2.on("error", () => {
554
+ child2.on("close", (code, signal) => {
555
+ bgSettled = true;
497
556
  registry.unregister(pid2);
557
+ if (bgErrorOccurred) return;
558
+ const failed = code !== 0 && code !== null || !!signal;
559
+ registry.afterCall(Date.now() - startedAt, failed, isBackground);
560
+ completeBackground(code ?? (signal ? 1 : 0), signal ?? void 0);
561
+ });
562
+ child2.on("error", () => {
563
+ if (bgSettled) return;
564
+ bgErrorOccurred = true;
498
565
  registry.afterCall(Date.now() - startedAt, true, isBackground);
566
+ completeBackground(1);
499
567
  });
500
568
  child2.unref();
501
569
  const jobId = `job_${pid2}`;
@@ -520,6 +588,7 @@ Working directory: ${targetCwd}`,
520
588
  };
521
589
  return;
522
590
  }
591
+ completeBackground(1);
523
592
  yield {
524
593
  type: "final",
525
594
  output: {
@@ -533,13 +602,46 @@ Working directory: ${targetCwd}`,
533
602
  return;
534
603
  }
535
604
  const spool = createOutputSpool({ tool: "pwsh", thresholdBytes: MAX_OUTPUT });
536
- const child = spawn(bin, args, {
537
- cwd: targetCwd,
538
- env,
539
- detached,
540
- stdio: ["ignore", "pipe", "pipe"],
541
- windowsHide: true
542
- });
605
+ let child;
606
+ try {
607
+ child = spawn(bin, args, {
608
+ cwd: targetCwd,
609
+ env,
610
+ detached,
611
+ stdio: ["ignore", "pipe", "pipe"],
612
+ windowsHide: true
613
+ });
614
+ } catch (err) {
615
+ registry.afterCall(Date.now() - startedAt, true, isBackground);
616
+ spool.finalize();
617
+ emitProcessStarted({
618
+ parentPid: process.pid,
619
+ command: redactCommand(`${bin} ${args.join(" ")}`),
620
+ args: redactCommand(args.join(" ")).split(" ").filter(Boolean),
621
+ cwd: targetCwd,
622
+ background: false,
623
+ startedAt: new Date(startedAt).toISOString()
624
+ });
625
+ emitProcessCompleted({
626
+ exitCode: 1,
627
+ durationMs: Date.now() - startedAt,
628
+ stdoutBytes: 0,
629
+ stderrBytes: 0,
630
+ timedOut: false,
631
+ endedAt: (/* @__PURE__ */ new Date()).toISOString()
632
+ });
633
+ yield {
634
+ type: "final",
635
+ output: {
636
+ output: "",
637
+ exit_code: 1,
638
+ timed_out: false,
639
+ pid: null,
640
+ error: `pwsh: spawn failed: ${err instanceof Error ? err.message : String(err)}`
641
+ }
642
+ };
643
+ return;
644
+ }
543
645
  const pid = child.pid;
544
646
  let stdoutBytes = 0;
545
647
  let stderrBytes = 0;
@@ -687,17 +789,25 @@ Working directory: ${targetCwd}`,
687
789
  push({ kind: "data", text });
688
790
  pauseIfFlooded();
689
791
  };
690
- child.stdout?.on("data", (chunk) => onData(chunk, "stdout"));
691
- child.stderr?.on("data", (chunk) => onData(chunk, "stderr"));
792
+ const onStdoutData = (chunk) => onData(chunk, "stdout");
793
+ const onStderrData = (chunk) => onData(chunk, "stderr");
794
+ child.stdout?.on("data", onStdoutData);
795
+ child.stderr?.on("data", onStderrData);
796
+ let fgErrorOccurred = false;
797
+ let sawClose = false;
692
798
  child.on("error", (err) => {
799
+ if (sawClose) return;
800
+ fgErrorOccurred = true;
693
801
  for (const t of timers) clearTimeout(t);
694
802
  registry.afterCall(Date.now() - startedAt, true);
695
803
  completeForeground(1);
696
804
  push({ kind: "error", err });
697
805
  });
698
806
  child.on("close", (code, signal) => {
807
+ sawClose = true;
699
808
  for (const t of timers) clearTimeout(t);
700
809
  if (typeof pid === "number") registry.unregister(pid);
810
+ if (fgErrorOccurred) return;
701
811
  registry.afterCall(Date.now() - startedAt, code !== 0 && code !== null);
702
812
  completeForeground(timedOut ? 124 : code ?? (signal ? 1 : 0), signal ?? void 0);
703
813
  const tail = stdoutDecoder.end() + stderrDecoder.end();
@@ -712,7 +822,33 @@ Working directory: ${targetCwd}`,
712
822
  while (true) {
713
823
  const c = await next();
714
824
  resumeIfDrained();
715
- if (c.kind === "error") throw c.err;
825
+ if (c.kind === "error") {
826
+ const isAbort = c.err?.code === "ABORT_ERR" || callerSignal.aborted;
827
+ const remainder = flush();
828
+ if (remainder !== null) {
829
+ yield { type: "partial_output", text: remainder };
830
+ }
831
+ const spooled = spool.finalize();
832
+ yield {
833
+ type: "final",
834
+ output: {
835
+ output: normalizeCommandOutput(buf) + (spooled ? spoolNote(spooled) : ""),
836
+ exit_code: isAbort ? 124 : 1,
837
+ timed_out: isAbort,
838
+ pid: pid ?? null,
839
+ error: isAbort ? "Command aborted by user or signal" : c.err.message
840
+ }
841
+ };
842
+ ctx.recordSideEffect?.({
843
+ toolUseId: `pwsh-${Date.now()}`,
844
+ toolName: "pwsh",
845
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
846
+ input: { command: redactCommand(input.command) },
847
+ outcome: isAbort ? "aborted" : `error (${c.err.message})`,
848
+ risk: "shell"
849
+ });
850
+ return;
851
+ }
716
852
  if (c.kind === "end") {
717
853
  const remainder = flush();
718
854
  if (remainder !== null) {
@@ -738,21 +874,25 @@ Working directory: ${targetCwd}`,
738
874
  const finalResultText = formattedOutput + (spooled ? spoolNote(spooled) : "") + (hint ? `
739
875
 
740
876
  ${hint}` : "") + cautionText;
741
- ctx.recordSideEffect?.({
742
- toolUseId: `pwsh-${Date.now()}`,
743
- toolName: "pwsh",
744
- ts: (/* @__PURE__ */ new Date()).toISOString(),
745
- input: { command: redactCommand(input.command) },
746
- outcome: timedOut ? `timed out (exit ${c.code})` : `exit ${c.code}`,
747
- risk: "shell"
748
- });
877
+ if (!fgErrorOccurred) {
878
+ ctx.recordSideEffect?.({
879
+ toolUseId: `pwsh-${Date.now()}`,
880
+ toolName: "pwsh",
881
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
882
+ input: { command: redactCommand(input.command) },
883
+ outcome: timedOut ? `timed out (exit ${c.code})` : `exit ${c.code}`,
884
+ risk: "shell"
885
+ });
886
+ }
887
+ const isAborted = callerSignal.aborted;
749
888
  yield {
750
889
  type: "final",
751
890
  output: {
752
891
  output: finalResultText,
753
- exit_code: timedOut ? 1 : c.code,
754
- timed_out: timedOut,
755
- pid
892
+ exit_code: timedOut || isAborted ? 124 : c.code,
893
+ timed_out: timedOut || isAborted,
894
+ pid: pid ?? null,
895
+ ...timedOut ? { error: "Command timed out" } : isAborted ? { error: "Command aborted by user or signal" } : {}
756
896
  }
757
897
  };
758
898
  return;
@@ -765,6 +905,16 @@ ${hint}` : "") + cautionText;
765
905
  }
766
906
  } finally {
767
907
  for (const t of timers) clearTimeout(t);
908
+ spool.finalize();
909
+ callerSignal.removeEventListener("abort", onAbort);
910
+ child.stdout?.off("data", onStdoutData);
911
+ child.stderr?.off("data", onStderrData);
912
+ child.stdout?.destroy();
913
+ child.stderr?.destroy();
914
+ if (!sawClose && child.exitCode === null && !child.killed) {
915
+ if (typeof pid === "number") registry.kill(pid, { force: true });
916
+ else killWithTimeout(2e3);
917
+ }
768
918
  }
769
919
  }
770
920
  };
@@ -1034,8 +1184,13 @@ var setWorkingDirTool = {
1034
1184
  }
1035
1185
  if (!isDirectory) {
1036
1186
  try {
1037
- ctx.setWorkingDir(previous);
1187
+ if (typeof previous === "string") {
1188
+ ctx.setWorkingDir(previous);
1189
+ } else {
1190
+ ctx.workingDir = previous;
1191
+ }
1038
1192
  } catch {
1193
+ ctx.workingDir = previous;
1039
1194
  }
1040
1195
  return {
1041
1196
  current: ctx.workingDir,
@@ -1078,7 +1233,7 @@ var BUILTIN_TOOL_DESCRIPTIONS = {
1078
1233
  "codebase-stats": "Report codebase-index health, indexed file and symbol counts, languages, and freshness. Use it before relying on indexed discovery results.",
1079
1234
  "codebase-search": "Search indexed symbols, signatures, and documentation with optional language, kind, path, or LSP-kind filters. Use it for semantic discovery before broad text search.",
1080
1235
  "codebase-skeleton": "Extract a compact structural skeleton from a source file or directory, preserving declarations while omitting implementation detail. Use it to understand unfamiliar code quickly.",
1081
- "codebase-repo-map": "Generate a concise map of important files, symbols, and relationships in a project area. Use it for orientation before a cross-file change.",
1236
+ "codebase-repo-map": "Generate a reference-weighted, token-budgeted Repository Map of the codebase within ~1200 tokens by default. Use at the beginning of complex tasks or when navigating unfamiliar repositories to get a bird-eye view of the architecture.",
1082
1237
  "codebase-impact-analysis": "Find likely callers, dependents, related tests, and change risk for a named symbol. Use it before changing a public or widely used declaration.",
1083
1238
  "codebase-targeted-test": "Discover and run tests that cover a specified symbol, source file, or explicit test files. Use it for focused regression validation after a change.",
1084
1239
  "security-ast-scan": "Statically scan source code for supported security patterns and return findings with locations. Use it as a focused code check, not as a substitute for a full security assessment.",
@@ -1100,8 +1255,8 @@ var BUILTIN_TOOL_DESCRIPTIONS = {
1100
1255
  task: "Manage structured task records, dependencies, ownership, and promotion into actionable session work. Use it to organize bounded work before delegation or execution.",
1101
1256
  git: "Inspect or run scoped Git operations in the project, including status, diff, history, branches, and commits. Review the target and working tree before mutating operations.",
1102
1257
  patch: "Apply a unified diff to project files with patch-style context checking. Use it for a reviewed multi-file change when exact patch content is available.",
1103
- json: "Read, query, validate, or update JSON files while preserving valid structure. Use it instead of raw text edits when changing structured JSON data.",
1104
- diff: "Compare two files, revisions, or text inputs and return a readable unified diff. Use it to review intended changes before applying or committing them.",
1258
+ json: "Read, query, validate, or merge JSON/JSON5/YAML files while preserving valid structure (read-only \u2014 does not write). Use it instead of raw text edits when reading or querying structured data.",
1259
+ diff: "Show file content with line numbers, staged/working-tree diffs via git, or commit/branch diffs. A safer and more structured alternative to raw `git diff` via shell.",
1105
1260
  tree: "Render a bounded directory tree with depth, file, hidden-file, and ignore controls. Use it for repository orientation without reading every file.",
1106
1261
  lint: "Run the project\u2019s configured linter for a target path or working directory and return diagnostics. Use it after code edits to catch style and static-analysis issues.",
1107
1262
  format: "Run the project\u2019s configured formatter on selected files or directories. Use it after editing code, while reviewing the resulting diff for unintended formatting scope.",
@@ -1114,9 +1269,9 @@ var BUILTIN_TOOL_DESCRIPTIONS = {
1114
1269
  audit: "Run the package manager\u2019s dependency vulnerability audit and summarize actionable findings. Use it to assess known dependency advisories, not source-code vulnerabilities.",
1115
1270
  outdated: "List outdated project dependencies and available versions without changing manifests or lockfiles. Use it to plan dependency maintenance.",
1116
1271
  logs: "Read or tail configured local, container, or process logs with bounded output. Use it to investigate a known runtime failure or service behavior.",
1117
- document: "Generate or update project documentation from supplied scope and source context. Use it to record verified behavior; review generated text before treating it as authoritative.",
1118
- scaffold: "Preview or generate files from a built-in or custom scaffold template. Use dry_run first to inspect paths and content before creating project files.",
1119
- design: "Create a structured implementation design with goals, constraints, approach, and risks. Use it before a substantial change that needs an explicit technical decision.",
1272
+ document: "List undocumented symbols as read-only candidates; this deprecated preview stub does not generate docstrings or write files. Use the auto-doc plugin when it is enabled.",
1273
+ scaffold: "Preview or generate files from a built-in or custom scaffold template. Writes files to disk unless dry_run is set. Use dry_run first to inspect paths and content before creating project files.",
1274
+ design: "Choose, preview, or materialize a UI design kit (e.g. minimal-clarity, neo-brutalist) for the active stack. Lists available kits, previews tokens, or writes a design-token source file to the project.",
1120
1275
  tool_search: "Discover registered tools by name, description, tag, permission, or mutating status. Use it to find a lazy capability before calling it through tool-use.",
1121
1276
  tool_use: "Invoke a registered tool by name with its input object, including a tool discovered lazily. Use it only after confirming the target tool\u2019s schema and side effects.",
1122
1277
  batch_tool_use: "Invoke several independent registered tools as a batch and return each result. Use it for parallel read-only discovery; avoid batching dependent or destructive operations.",
@@ -1266,9 +1421,11 @@ var builtinTools = rawBuiltinTools.map((tool) => {
1266
1421
  export {
1267
1422
  clarifyTool,
1268
1423
  PWSH_TOOL_DESCRIPTION,
1424
+ PWSH_TOOL_USAGE_HINT,
1269
1425
  pwshTool,
1270
1426
  analyzeSecurityAndPerformance,
1271
1427
  securityAstScanTool,
1428
+ setWorkingDirTool,
1272
1429
  BUILTIN_TOOL_DESCRIPTIONS,
1273
1430
  OPTIONAL_TOOLS,
1274
1431
  OFF_ONLY_TOOLS,
@@ -1277,4 +1434,4 @@ export {
1277
1434
  TIER3_TOOLS,
1278
1435
  builtinTools
1279
1436
  };
1280
- //# sourceMappingURL=chunk-4BABEJC2.js.map
1437
+ //# sourceMappingURL=chunk-IAYMTTR2.js.map
@@ -306,7 +306,7 @@ ${result.content}
306
306
  }
307
307
  signal?.throwIfAborted();
308
308
  const tokens = applyTokenOverrides(rawTokens, active.overrides);
309
- const normalizedFiles = input.files ? (Array.isArray(input.files) ? input.files : String(input.files).split(",")).map((f) => f.trim().replace(/\\/g, "/")).filter(Boolean) : void 0;
309
+ const normalizedFiles = input.files ? (Array.isArray(input.files) ? input.files : String(input.files).split(",")).filter((f) => typeof f === "string").map((f) => f.trim().replace(/\\/g, "/")).filter(Boolean) : void 0;
310
310
  const report = await runDesignVerify(ctx.projectRoot, tokens, normalizedFiles);
311
311
  const pct = Math.round(report.score * 100);
312
312
  const top = report.violations.slice(0, 25).map((v) => ` ${v.file}:${v.line} \u2014 ${v.reason}: ${v.snippet}`).join("\n");
@@ -334,4 +334,4 @@ Replace off-palette colors with kit tokens (or the materialized CSS vars / token
334
334
  export {
335
335
  designTool
336
336
  };
337
- //# sourceMappingURL=chunk-ELRRTWNP.js.map
337
+ //# sourceMappingURL=chunk-IXIS7RSG.js.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  compileUserRegex
3
- } from "./chunk-Q5JPPCZC.js";
3
+ } from "./chunk-YJTXRH5Y.js";
4
4
  import {
5
5
  mapWithConcurrency
6
6
  } from "./chunk-ZBMANLYH.js";
7
7
  import {
8
8
  enqueueReindex
9
- } from "./chunk-Z5Q3TXRY.js";
9
+ } from "./chunk-ZTCJCYLN.js";
10
10
  import {
11
11
  isBinaryBuffer,
12
12
  safeResolveReal,
@@ -275,7 +275,7 @@ function passesExtraGlob(extraGlob, name, full, base) {
275
275
  }
276
276
  async function resolveFiles(filesInput, ctx, extraGlob) {
277
277
  const base = ctx.cwd;
278
- const parts = Array.isArray(filesInput) ? filesInput.map((s) => s.trim()).filter(Boolean) : filesInput.trim().split(",").map((s) => s.trim()).filter(Boolean);
278
+ const parts = Array.isArray(filesInput) ? filesInput.filter((s) => typeof s === "string").map((s) => s.trim()).filter(Boolean) : filesInput.trim().split(",").map((s) => s.trim()).filter(Boolean);
279
279
  const resolved = [];
280
280
  for (const p of parts) {
281
281
  if (p.includes("*") || p.includes("?")) {
@@ -289,7 +289,7 @@ async function resolveFiles(filesInput, ctx, extraGlob) {
289
289
  resolved.push(absPath);
290
290
  }
291
291
  }
292
- return resolved;
292
+ return [...new Set(resolved)];
293
293
  }
294
294
  async function globFiles(pattern, base, extraGlob) {
295
295
  const rgAvailable = await checkRg();
@@ -413,4 +413,4 @@ export {
413
413
  replaceTool,
414
414
  __resetRgDetectionForTests
415
415
  };
416
- //# sourceMappingURL=chunk-HR67OWEP.js.map
416
+ //# sourceMappingURL=chunk-IYH4OHBP.js.map
@@ -13,7 +13,8 @@ var DEFAULT_IGNORE = /* @__PURE__ */ new Set([
13
13
  ".gnupg",
14
14
  ".aws"
15
15
  ]);
16
- var DEFAULT_MAX_ENTRIES = 5e3;
16
+ var DEFAULT_MAX_TREE_ENTRIES = 5e3;
17
+ var DEFAULT_MAX_ENTRIES = DEFAULT_MAX_TREE_ENTRIES;
17
18
  var MAX_TREE_OUTPUT_BYTES = 256 * 1024;
18
19
  var treeTool = {
19
20
  name: "tree",
@@ -88,7 +89,7 @@ var treeTool = {
88
89
  const exclude = /* @__PURE__ */ new Set([
89
90
  ...DEFAULT_IGNORE,
90
91
  ...rawExclude.filter((s) => typeof s === "string").map(
91
- (s) => s.trim().replace(/[\\/]+$/, "").replace(/^\.\//, "")
92
+ (s) => s.trim().replace(/\\/g, "/").replace(/\/+$/, "").replace(/^\.\//, "")
92
93
  ).filter(Boolean)
93
94
  ]);
94
95
  const globRe = input.glob ? compileGlob(input.glob) : void 0;
@@ -204,7 +205,7 @@ async function walkDir(dir, depth, opts) {
204
205
  opts.totalDirs.value += dirCount;
205
206
  opts.totalFiles.value += fileCount;
206
207
  opts.onProgress?.();
207
- const items = filtered.sort((a, b) => {
208
+ const items = filtered.filter((e) => e.isDirectory() || opts.showFiles).sort((a, b) => {
208
209
  if (a.isDirectory() && !b.isDirectory()) return -1;
209
210
  if (!a.isDirectory() && b.isDirectory()) return 1;
210
211
  return a.name.localeCompare(b.name);
@@ -243,6 +244,8 @@ async function walkDir(dir, depth, opts) {
243
244
  }
244
245
 
245
246
  export {
247
+ DEFAULT_MAX_TREE_ENTRIES,
248
+ MAX_TREE_OUTPUT_BYTES,
246
249
  treeTool
247
250
  };
248
- //# sourceMappingURL=chunk-W232EFEM.js.map
251
+ //# sourceMappingURL=chunk-JDOO4P6Z.js.map
@@ -100,7 +100,7 @@ describe('{{Name}}', () => {
100
100
  var scaffoldTool = {
101
101
  name: "scaffold",
102
102
  category: "Project",
103
- description: "Generate new files and folder structures from built-in templates or custom definitions. This is the recommended way to bootstrap new packages, components, or modules instead of creating files one by one with `write`.",
103
+ description: "Generate or preview files and folder structures from built-in templates or custom definitions. Writes files to disk unless dry_run is set. This is the recommended way to bootstrap new packages, components, or modules instead of creating files one by one with `write`.",
104
104
  usageHint: "PREFERRED FOR SCAFFOLDING:\n\n- Use built-in templates when they match your needs (e.g. react-component, npm-package).\n- Supports `dry_run` so you can preview exactly what will be created.\n- Has the powerful `fs.write.outside-project` capability \u2014 review paths carefully.\nMuch cleaner and safer than manually writing multiple files.",
105
105
  permission: "confirm",
106
106
  mutating: true,
@@ -195,7 +195,7 @@ function escapeRegexLiteral(value) {
195
195
  }
196
196
  function substituteVars(content, name, vars) {
197
197
  const kebab = name.toLowerCase().replace(/\s+/g, "-");
198
- const pascal = name.replace(/(?:^|[-_\s]+)([a-z])/g, (_, c) => c.toUpperCase());
198
+ const pascal = name.replace(/(?:^|[-_\s]+)([a-zA-Z])/g, (_, c) => c.toUpperCase());
199
199
  let result = content;
200
200
  result = result.replace(/\{\{name\}\}/g, () => kebab);
201
201
  result = result.replace(/\{\{Name\}\}/g, () => pascal);
@@ -207,6 +207,7 @@ function substituteVars(content, name, vars) {
207
207
  }
208
208
 
209
209
  export {
210
+ BUILT_IN_TEMPLATES,
210
211
  scaffoldTool
211
212
  };
212
- //# sourceMappingURL=chunk-2OXHS3KZ.js.map
213
+ //# sourceMappingURL=chunk-KLJZ4WV4.js.map