@wrongstack/tools 0.320.1 → 1.0.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 (191) 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.js +9 -160
  6. package/dist/bash-kill-guard.d.ts +2 -3
  7. package/dist/bash.d.ts +2 -3
  8. package/dist/bash.js +4 -4
  9. package/dist/batch-tool-use.d.ts +2 -3
  10. package/dist/batch-tool-use.js +1 -1
  11. package/dist/browser/index.d.ts +1 -1
  12. package/dist/browser/index.js +1 -1
  13. package/dist/browser/tools.d.ts +56 -45
  14. package/dist/builtin.js +50 -50
  15. package/dist/{chunk-T77XOX7E.js → chunk-24T5XIJU.js} +1 -1
  16. package/dist/{chunk-DTQ75VBC.js → chunk-2CTZW6JQ.js} +2 -2
  17. package/dist/chunk-37QKUQ2Z.js +171 -0
  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-34VLZ35Z.js → chunk-7HL23T3T.js} +63 -10
  26. package/dist/{chunk-HFXSNKCV.js → chunk-7JJFC6CT.js} +1 -1
  27. package/dist/{chunk-NDIT3SBZ.js → chunk-7N5U2RAU.js} +2 -2
  28. package/dist/{chunk-QBV725YG.js → chunk-7ODZTPCU.js} +2 -2
  29. package/dist/{chunk-4BABEJC2.js → chunk-AB2CAUOP.js} +64 -53
  30. package/dist/{chunk-6AAOT4PW.js → chunk-AQ5YBURX.js} +16 -4
  31. package/dist/{chunk-ZMW6WJFT.js → chunk-ASEXQRA7.js} +3 -3
  32. package/dist/{chunk-FRN7TIAA.js → chunk-B3MGJBFI.js} +1 -1
  33. package/dist/{chunk-JLYA4X7K.js → chunk-CGXTR34H.js} +21 -6
  34. package/dist/{chunk-IU4DV2PA.js → chunk-CHEK3ASV.js} +6 -3
  35. package/dist/{chunk-GOIZNNOA.js → chunk-DJYLI7EW.js} +1 -1
  36. package/dist/{chunk-Z6IHMJMC.js → chunk-DK4J2WMH.js} +11 -11
  37. package/dist/{chunk-OYP27E3I.js → chunk-DRRY6SCM.js} +47 -20
  38. package/dist/{chunk-BK732J7I.js → chunk-FBUP524S.js} +4 -4
  39. package/dist/{chunk-NYRLWDT5.js → chunk-FVM3O4JQ.js} +1 -1
  40. package/dist/chunk-FYDBUVQD.js +244 -0
  41. package/dist/{chunk-PV6HIZQD.js → chunk-GDDXX27P.js} +50 -50
  42. package/dist/{chunk-3GIKYHLA.js → chunk-GKSG5CPH.js} +6 -6
  43. package/dist/{chunk-ESLPBT5A.js → chunk-HDYUBRMF.js} +4 -3
  44. package/dist/{chunk-ELRRTWNP.js → chunk-IXIS7RSG.js} +2 -2
  45. package/dist/{chunk-HR67OWEP.js → chunk-IYH4OHBP.js} +5 -5
  46. package/dist/{chunk-W232EFEM.js → chunk-JDOO4P6Z.js} +7 -4
  47. package/dist/{chunk-OTPTQBYE.js → chunk-KDEXUQY7.js} +19 -8
  48. package/dist/{chunk-2OXHS3KZ.js → chunk-KLJZ4WV4.js} +4 -3
  49. package/dist/{chunk-3M7LLN7W.js → chunk-LQSOU63Z.js} +12 -11
  50. package/dist/{chunk-JVRLTEO7.js → chunk-M6UV67BH.js} +2 -2
  51. package/dist/{chunk-C2DQKVLO.js → chunk-MJSJWXBF.js} +1 -1
  52. package/dist/{chunk-NSPNFOJ7.js → chunk-MK2JK35J.js} +25 -10
  53. package/dist/{chunk-JSNSMG5R.js → chunk-MSOAX3GC.js} +1 -1
  54. package/dist/{chunk-J43O3BOX.js → chunk-N3K2SFEI.js} +532 -492
  55. package/dist/{chunk-J74TMK4M.js → chunk-NJX2RXKJ.js} +50 -7
  56. package/dist/{chunk-5UFVCIUB.js → chunk-NN2SNP2R.js} +4 -4
  57. package/dist/{chunk-WAQASTXB.js → chunk-O6BY43ZB.js} +29 -8
  58. package/dist/{chunk-QGF2C7TF.js → chunk-PVCB7RUZ.js} +2 -2
  59. package/dist/{chunk-YTKSNTT4.js → chunk-QA6IASYX.js} +8 -8
  60. package/dist/{chunk-VPALDFYM.js → chunk-RV7BVTDG.js} +1 -1
  61. package/dist/chunk-S57CDR2H.js +288 -0
  62. package/dist/{chunk-W2CECGTG.js → chunk-SMARDKAC.js} +1 -1
  63. package/dist/{chunk-QWKSKFKZ.js → chunk-SOR7OCYP.js} +1 -1
  64. package/dist/{chunk-I7FBZOEP.js → chunk-T3SMFF5Q.js} +11 -5
  65. package/dist/{chunk-4BHUSMNL.js → chunk-UI3ZJIG3.js} +1 -1
  66. package/dist/{chunk-WXJY3BKV.js → chunk-VBF2YXUW.js} +2 -2
  67. package/dist/{chunk-FQNXYA6W.js → chunk-VU3QBYL4.js} +36 -5
  68. package/dist/{chunk-VD2LV5WO.js → chunk-VZGPASGD.js} +37 -12
  69. package/dist/{chunk-UZFY3CKD.js → chunk-WEEVSWQB.js} +17 -6
  70. package/dist/chunk-XXRMF2BC.js +186 -0
  71. package/dist/{chunk-LRDIRJJL.js → chunk-YEISRT4S.js} +5 -11
  72. package/dist/{chunk-Q5JPPCZC.js → chunk-YJTXRH5Y.js} +3 -2
  73. package/dist/{chunk-23EX5WDO.js → chunk-YULVUTK5.js} +3 -3
  74. package/dist/{chunk-Z5Q3TXRY.js → chunk-ZTCJCYLN.js} +3 -3
  75. package/dist/circuit-breaker.d.ts +1 -0
  76. package/dist/circuit-breaker.js +1 -1
  77. package/dist/clarify.d.ts +1 -0
  78. package/dist/codebase-index/codebase-ast-replace-tool.d.ts +2 -3
  79. package/dist/codebase-index/codebase-impact-analysis-tool.d.ts +5 -4
  80. package/dist/codebase-index/codebase-incoming-calls-tool.d.ts +4 -3
  81. package/dist/codebase-index/codebase-index-tool.d.ts +2 -3
  82. package/dist/codebase-index/codebase-invariant-check-tool.d.ts +2 -3
  83. package/dist/codebase-index/codebase-outgoing-calls-tool.d.ts +4 -3
  84. package/dist/codebase-index/codebase-repo-map-tool.d.ts +2 -3
  85. package/dist/codebase-index/codebase-search-tool.d.ts +2 -3
  86. package/dist/codebase-index/codebase-skeleton-tool.d.ts +2 -3
  87. package/dist/codebase-index/codebase-stats-tool.d.ts +9 -3
  88. package/dist/codebase-index/codebase-targeted-test-tool.d.ts +4 -3
  89. package/dist/codebase-index/index.d.ts +11 -11
  90. package/dist/codebase-index/index.js +8 -8
  91. package/dist/codebase-index/project-server-framing.d.ts +29 -0
  92. package/dist/codebase-index/project-server-lifecycle.d.ts +20 -0
  93. package/dist/codebase-index/project-server-operations.d.ts +37 -0
  94. package/dist/codebase-index/project-server-types.d.ts +30 -0
  95. package/dist/codebase-index/project-server-watcher.d.ts +25 -0
  96. package/dist/codebase-index/project-server.js +448 -391
  97. package/dist/codebase-index/worker.js +2 -2
  98. package/dist/codebase-index/writer-init.d.ts +13 -0
  99. package/dist/codebase-index/writer-maintenance.d.ts +14 -0
  100. package/dist/codebase-index/writer.d.ts +0 -15
  101. package/dist/design.d.ts +2 -2
  102. package/dist/design.js +1 -1
  103. package/dist/diff.d.ts +4 -4
  104. package/dist/diff.js +1 -1
  105. package/dist/document.d.ts +3 -4
  106. package/dist/document.js +1 -1
  107. package/dist/e2e.d.ts +1 -1
  108. package/dist/e2e.js +1 -1
  109. package/dist/edit.d.ts +3 -3
  110. package/dist/edit.js +6 -6
  111. package/dist/exec.d.ts +2 -3
  112. package/dist/exec.js +4 -4
  113. package/dist/fetch.d.ts +4 -3
  114. package/dist/fetch.js +1 -1
  115. package/dist/format.d.ts +17 -45
  116. package/dist/format.js +12 -8
  117. package/dist/git.d.ts +3 -3
  118. package/dist/git.js +1 -1
  119. package/dist/glob.d.ts +2 -3
  120. package/dist/glob.js +2 -2
  121. package/dist/grep.d.ts +7 -5
  122. package/dist/grep.js +3 -3
  123. package/dist/index.d.ts +54 -45
  124. package/dist/index.js +118 -59
  125. package/dist/install.d.ts +7 -55
  126. package/dist/install.js +6 -6
  127. package/dist/json.d.ts +3 -4
  128. package/dist/json.js +2 -2
  129. package/dist/kanban-tool-types.d.ts +1 -2
  130. package/dist/kanban.d.ts +3 -19
  131. package/dist/kanban.js +1 -1
  132. package/dist/languages/execute-tool.d.ts +2 -3
  133. package/dist/languages/index.d.ts +2 -2
  134. package/dist/languages/index.js +4 -4
  135. package/dist/languages/tool.d.ts +3 -4
  136. package/dist/{legacy-bridge-FOV5ODDI.js → legacy-bridge-YXANP5QB.js} +6 -6
  137. package/dist/lint.d.ts +5 -4
  138. package/dist/lint.js +6 -6
  139. package/dist/logs.d.ts +3 -4
  140. package/dist/logs.js +2 -2
  141. package/dist/memory.d.ts +7 -8
  142. package/dist/memory.js +1 -1
  143. package/dist/mode.d.ts +3 -4
  144. package/dist/mode.js +1 -1
  145. package/dist/next-steps-tool.d.ts +2 -3
  146. package/dist/next-steps.d.ts +4 -0
  147. package/dist/next-steps.js +9 -175
  148. package/dist/outdated.d.ts +5 -29
  149. package/dist/outdated.js +3 -3
  150. package/dist/pack.js +51 -51
  151. package/dist/patch.d.ts +2 -3
  152. package/dist/patch.js +5 -5
  153. package/dist/plan.d.ts +4 -4
  154. package/dist/plan.js +3 -3
  155. package/dist/process-registry.js +2 -2
  156. package/dist/ps-slash.js +4 -4
  157. package/dist/pwsh.d.ts +1 -0
  158. package/dist/read.d.ts +5 -5
  159. package/dist/read.js +5 -5
  160. package/dist/replace.d.ts +2 -3
  161. package/dist/replace.js +6 -6
  162. package/dist/scaffold.d.ts +7 -3
  163. package/dist/scaffold.js +3 -1
  164. package/dist/search.d.ts +17 -3
  165. package/dist/search.js +5 -1
  166. package/dist/set-working-dir.d.ts +2 -3
  167. package/dist/skill.d.ts +4 -5
  168. package/dist/skill.js +1 -1
  169. package/dist/task.d.ts +6 -6
  170. package/dist/task.js +3 -3
  171. package/dist/test.d.ts +5 -4
  172. package/dist/test.js +6 -6
  173. package/dist/todo.d.ts +8 -8
  174. package/dist/todo.js +2 -2
  175. package/dist/tool-diff.js +11 -230
  176. package/dist/tool-help.d.ts +2 -3
  177. package/dist/tool-help.js +1 -1
  178. package/dist/tool-search.d.ts +2 -3
  179. package/dist/tool-search.js +1 -1
  180. package/dist/tool-summary.js +5 -281
  181. package/dist/tool-tier.js +52 -52
  182. package/dist/tool-use.d.ts +2 -3
  183. package/dist/tool-use.js +1 -1
  184. package/dist/tree.d.ts +5 -3
  185. package/dist/tree.js +5 -1
  186. package/dist/typecheck.d.ts +3 -3
  187. package/dist/typecheck.js +6 -6
  188. package/dist/write.d.ts +2 -3
  189. package/dist/write.js +6 -6
  190. package/package.json +5 -5
  191. package/dist/spawn-background.d.ts +0 -80
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  compileUserRegex
3
- } from "./chunk-Q5JPPCZC.js";
3
+ } from "./chunk-YJTXRH5Y.js";
4
4
  import {
5
5
  safeResolveReal
6
6
  } from "./chunk-ZUFHAHTE.js";
@@ -8,8 +8,9 @@ import {
8
8
  // src/logs.ts
9
9
  import { spawn } from "node:child_process";
10
10
  import { StringDecoder } from "node:string_decoder";
11
- import { buildChildEnv } from "@wrongstack/core/utils";
12
- import { ToolValidationError } from "@wrongstack/core/types";
11
+ import * as fs from "node:fs/promises";
12
+ import { buildChildEnv, toErrorMessage } from "@wrongstack/core/utils";
13
+ import { FsError, ToolValidationError } from "@wrongstack/core/types";
13
14
  var logsTool = {
14
15
  name: "logs",
15
16
  category: "Logs",
@@ -86,7 +87,37 @@ var logsTool = {
86
87
  return await dockerLogs(input.service, lines, filterRe, cwd, signal, input.since);
87
88
  }
88
89
  if (input.path) {
89
- return await fileLogs(await safeResolveReal(input.path, ctx), lines, filterRe);
90
+ const resolved = await safeResolveReal(input.path, ctx);
91
+ let stat2;
92
+ try {
93
+ stat2 = await fs.stat(resolved);
94
+ } catch (err) {
95
+ const code = err.code;
96
+ if (code === "ENOENT") {
97
+ throw new FsError({
98
+ message: `logs: file not found "${input.path}"`,
99
+ code: "FS_READ_FAILED",
100
+ path: resolved,
101
+ context: { errno: "ENOENT" }
102
+ });
103
+ }
104
+ throw new FsError({
105
+ message: `logs: failed to stat "${input.path}": ${toErrorMessage(err)}`,
106
+ code: "FS_READ_FAILED",
107
+ path: resolved,
108
+ context: { errno: code },
109
+ cause: err
110
+ });
111
+ }
112
+ if (!stat2.isFile()) {
113
+ throw new FsError({
114
+ message: `logs: "${input.path}" is not a regular file`,
115
+ code: "FS_READ_FAILED",
116
+ path: resolved,
117
+ context: { reason: "not-a-regular-file" }
118
+ });
119
+ }
120
+ return await fileLogs(resolved, lines, filterRe);
90
121
  }
91
122
  return {
92
123
  source: "none",
@@ -268,4 +299,4 @@ function parseLine(line) {
268
299
  export {
269
300
  logsTool
270
301
  };
271
- //# sourceMappingURL=chunk-FQNXYA6W.js.map
302
+ //# sourceMappingURL=chunk-VU3QBYL4.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  capSubject,
3
3
  compileUserRegex
4
- } from "./chunk-Q5JPPCZC.js";
4
+ } from "./chunk-YJTXRH5Y.js";
5
5
  import {
6
6
  safeResolveReal
7
7
  } from "./chunk-ZUFHAHTE.js";
@@ -39,7 +39,7 @@ async function readJsonFileBounded(filePath, ctx) {
39
39
  var jsonTool = {
40
40
  name: "json",
41
41
  category: "Data",
42
- description: "Parse, pretty-print, query, validate, transform, and merge JSON/JSON5/YAML. Use `action` to select the operation: parse (default), query, validate, transform, or merge.",
42
+ description: "Parse, pretty-print, query, validate, transform, and merge JSON/JSON5/YAML (read-only \u2014 does not write files). Use `action` to select the operation: parse (default), query, validate, transform, or merge.",
43
43
  usageHint: 'VERY USEFUL FOR DATA INSPECTION:\n\n- `action: "parse"` (default): read/pretty-print/convert JSON, JSON5, or YAML from `file` or `data`.\n- `action: "query"`: JMESPath-like query (`a.b[0].c`, `items[*].name`, filters, functions).\n- `action: "validate"`: validate data against a JSON Schema (`schema` param).\n- `action: "transform"`: chain multiple JMESPath transforms (`transforms` param).\n- `action: "merge"`: deep merge `base` and `patch` objects (`conflictResolution` param).\nPrefer this over raw `read` + manual parsing when dealing with configuration or data files.',
44
44
  permission: "auto",
45
45
  mutating: false,
@@ -444,20 +444,35 @@ function jmespathSearch(data, query) {
444
444
  if (rest === void 0) return val;
445
445
  return jmespathSearch(val, rest);
446
446
  }
447
- const arrMatch = query.match(/^\[(\d+)\](?:\.(.+))?$/);
447
+ const propIdxMatch = query.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(\d+)\](?:\.?(.*))?$/);
448
+ if (propIdxMatch) {
449
+ const key = propIdxMatch[1];
450
+ if (key === "__proto__" || key === "prototype" || key === "constructor") {
451
+ return void 0;
452
+ }
453
+ const idx = Number.parseInt(propIdxMatch[2], 10);
454
+ const rest = propIdxMatch[3] ? propIdxMatch[3] : void 0;
455
+ const arr = data?.[key];
456
+ if (!Array.isArray(arr)) return void 0;
457
+ const val = arr[idx];
458
+ if (rest === void 0) return val;
459
+ return jmespathSearch(val, rest);
460
+ }
461
+ const arrMatch = query.match(/^\[(\d+)\](?:\.?(.*))?$/);
448
462
  if (arrMatch) {
449
463
  const idx = Number.parseInt(arrMatch[1], 10);
450
- const rest = arrMatch[2];
464
+ const rest = arrMatch[2] ? arrMatch[2] : void 0;
451
465
  const arr = data;
452
466
  const val = arr?.[idx];
453
467
  if (rest === void 0) return val;
454
468
  return jmespathSearch(val, rest);
455
469
  }
456
- if (query === "[*]") {
457
- if (Array.isArray(data)) {
458
- return data;
459
- }
460
- return data;
470
+ const wildcardMatch = query.match(/^\[\*\](?:\.(.+))?$/);
471
+ if (wildcardMatch) {
472
+ if (!Array.isArray(data)) return [];
473
+ const rest = wildcardMatch[1];
474
+ if (rest === void 0) return data;
475
+ return data.map((item) => jmespathSearch(item, rest));
461
476
  }
462
477
  const multiMatch = query.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\*\](?:\.(.+))?$/);
463
478
  if (multiMatch) {
@@ -469,14 +484,24 @@ function jmespathSearch(data, query) {
469
484
  return arr.map((item) => jmespathSearch(item, rest));
470
485
  }
471
486
  const filterMatch = query.match(
472
- /^\[\\?([a-zA-Z_][a-zA-Z0-9_]*)(==|!=|<|>|<=|>=)(`[^`]+`|'[^']*')\](?:\.(.+))?$/
487
+ /^\[\??([a-zA-Z_][a-zA-Z0-9_]*)(==|!=|<|>|<=|>=)(`[^`]+`|'[^']*')\](?:\.(.+))?$/
473
488
  );
474
489
  if (filterMatch) {
475
490
  const field = filterMatch[1];
476
491
  const op = filterMatch[2];
477
492
  const rawVal = filterMatch[3];
478
493
  const rest = filterMatch[4];
479
- const cmpVal = JSON.parse(rawVal.slice(1, -1));
494
+ let cmpVal;
495
+ if (rawVal.startsWith("'") && rawVal.endsWith("'")) {
496
+ cmpVal = rawVal.slice(1, -1);
497
+ } else {
498
+ const inner = rawVal.slice(1, -1);
499
+ try {
500
+ cmpVal = JSON.parse(inner);
501
+ } catch {
502
+ cmpVal = inner;
503
+ }
504
+ }
480
505
  const arr = data;
481
506
  if (!Array.isArray(arr)) return [];
482
507
  const filtered = arr.filter((item) => {
@@ -676,4 +701,4 @@ ${toYaml(v, indent + 1)}`;
676
701
  export {
677
702
  jsonTool
678
703
  };
679
- //# sourceMappingURL=chunk-VD2LV5WO.js.map
704
+ //# sourceMappingURL=chunk-VZGPASGD.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  tryLegacyPackageOperation
3
- } from "./chunk-I7FBZOEP.js";
3
+ } from "./chunk-T3SMFF5Q.js";
4
4
  import {
5
5
  spawnStream
6
- } from "./chunk-OYP27E3I.js";
6
+ } from "./chunk-DRRY6SCM.js";
7
7
  import {
8
8
  COMMAND_OUTPUT_MAX_BYTES,
9
9
  detectPackageManager,
@@ -117,7 +117,8 @@ var auditTool = {
117
117
  type: "final",
118
118
  output: parseAuditOutput(result.stdout, result.exitCode, {
119
119
  level: input.level,
120
- spawnTruncated: result.truncated
120
+ spawnTruncated: result.truncated,
121
+ rawError: result.stderr || result.error || ""
121
122
  })
122
123
  };
123
124
  }
@@ -129,7 +130,7 @@ function parseAuditOutput(json, exitCode, opts = {}) {
129
130
  vulnerabilities: [],
130
131
  total: 0,
131
132
  summary: exitCode === 0 ? "No vulnerabilities found" : "Audit failed",
132
- output: "",
133
+ output: normalizeCommandOutput(opts.rawError || ""),
133
134
  truncated: false
134
135
  };
135
136
  }
@@ -143,7 +144,17 @@ function parseAuditOutput(json, exitCode, opts = {}) {
143
144
  advisories = advisories.filter((a) => (SEVERITY_RANK[a.severity] ?? 0) >= minRank);
144
145
  }
145
146
  const total = advisories.length;
146
- const summary = total === 0 ? "No vulnerabilities found" : `Found ${total} vulnerabilities: ${advisories.filter((a) => a.severity === "critical").length} critical, ${advisories.filter((a) => a.severity === "high").length} high`;
147
+ let summary;
148
+ if (total === 0) {
149
+ if (exitCode !== 0) {
150
+ const errObj = data.error;
151
+ summary = typeof errObj?.summary === "string" ? errObj.summary : typeof errObj?.code === "string" ? `Audit failed (${errObj.code})` : "Audit failed";
152
+ } else {
153
+ summary = "No vulnerabilities found";
154
+ }
155
+ } else {
156
+ summary = `Found ${total} vulnerabilities: ${advisories.filter((a) => a.severity === "critical").length} critical, ${advisories.filter((a) => a.severity === "high").length} high`;
157
+ }
147
158
  return {
148
159
  exit_code: exitCode,
149
160
  vulnerabilities: advisories,
@@ -209,4 +220,4 @@ function extractAdvisories(data) {
209
220
  export {
210
221
  auditTool
211
222
  };
212
- //# sourceMappingURL=chunk-UZFY3CKD.js.map
223
+ //# sourceMappingURL=chunk-WEEVSWQB.js.map
@@ -0,0 +1,186 @@
1
+ // src/next-steps.ts
2
+ function projectNextStepsToolInput(input) {
3
+ if (!input || typeof input !== "object" || Array.isArray(input)) return [];
4
+ const rawSteps = input["steps"];
5
+ if (!Array.isArray(rawSteps)) return [];
6
+ const steps = [];
7
+ for (const candidate of rawSteps) {
8
+ if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) continue;
9
+ const text = candidate["text"];
10
+ if (typeof text !== "string" || !text.trim()) continue;
11
+ const auto = steps.length === 0 && candidate["auto"] === true;
12
+ steps.push(
13
+ auto ? { index: steps.length + 1, text: text.trim(), auto: true } : { index: steps.length + 1, text: text.trim() }
14
+ );
15
+ if (steps.length >= MAX_STEPS) break;
16
+ }
17
+ return steps;
18
+ }
19
+ function isFinalTurnStopReason(stopReason) {
20
+ return stopReason !== "tool_use" && stopReason !== "tool_call";
21
+ }
22
+ function fenceSpans(content) {
23
+ const spans = [];
24
+ const lines = content.split("\n");
25
+ let offset = 0;
26
+ let open = null;
27
+ for (const line of lines) {
28
+ const lineStart = offset;
29
+ offset += line.length + 1;
30
+ const trimmed = line.trim();
31
+ const marker = /^(`{3,}|~{3,})/.exec(trimmed)?.[1];
32
+ if (marker === void 0) continue;
33
+ if (open === null) {
34
+ open = { markerChar: marker[0], markerLength: marker.length, start: lineStart };
35
+ continue;
36
+ }
37
+ if (marker[0] === open.markerChar && marker.length >= open.markerLength && trimmed === marker) {
38
+ spans.push([open.start, offset]);
39
+ open = null;
40
+ }
41
+ }
42
+ if (open !== null) spans.push([open.start, content.length]);
43
+ return spans;
44
+ }
45
+ function indexInsideCodeFence(content, index) {
46
+ return fenceSpans(content).some(([start, end]) => index >= start && index < end);
47
+ }
48
+ function nonFencedIndexOf(content, needle, fromIndex, spans) {
49
+ let at = fromIndex;
50
+ for (; ; ) {
51
+ const found = content.indexOf(needle, at);
52
+ if (found === -1) return -1;
53
+ if (!spans.some(([start, end]) => found >= start && found < end)) return found;
54
+ at = found + 1;
55
+ }
56
+ }
57
+ var ITEM_RE = /^(?:(\d+)[.)]\s*|[-*•]\s*)(.+?)(\s+auto="true")?$/;
58
+ var MAX_STEPS = 6;
59
+ function parseNextSteps(content, requireHeading = true) {
60
+ if (requireHeading) {
61
+ return parseWithHeading(content);
62
+ }
63
+ return parseRawNumbered(content);
64
+ }
65
+ function pushStep(steps, index, text, hasAuto) {
66
+ steps.push(hasAuto ? { index, text, auto: true } : { index, text });
67
+ }
68
+ function parseRawNumbered(content) {
69
+ const lines = content.split("\n");
70
+ const steps = [];
71
+ const seenNumbers = /* @__PURE__ */ new Set();
72
+ for (const rawLine of lines) {
73
+ const line = rawLine.trim();
74
+ if (!line) continue;
75
+ const m = ITEM_RE.exec(line);
76
+ if (!m) continue;
77
+ const numPart = m[1];
78
+ const text = m[2].trim();
79
+ let index;
80
+ if (numPart !== void 0) {
81
+ index = Number.parseInt(numPart, 10);
82
+ } else {
83
+ index = steps.length + 1;
84
+ }
85
+ if (seenNumbers.has(index)) continue;
86
+ seenNumbers.add(index);
87
+ const hasAuto = !!m[3] && steps.length === 0 && index === 1;
88
+ pushStep(steps, index, text, hasAuto);
89
+ if (steps.length >= MAX_STEPS) break;
90
+ }
91
+ return {
92
+ steps,
93
+ texts: steps.map((s) => s.text),
94
+ stripped: content,
95
+ autoTexts: steps.filter((s) => s.auto).map((s) => s.text)
96
+ };
97
+ }
98
+ function parseWithHeading(content) {
99
+ const empty = { steps: [], texts: [], stripped: content, autoTexts: [] };
100
+ const spans = fenceSpans(content);
101
+ const outsideFences = (index) => !spans.some(([start, end]) => index >= start && index < end);
102
+ const headingScan = /<nextsteps\b[^>]*>\s*\n+/gi;
103
+ let heading = null;
104
+ for (let m = headingScan.exec(content); m !== null; m = headingScan.exec(content)) {
105
+ if (outsideFences(m.index)) {
106
+ heading = { index: m.index, length: m[0].length };
107
+ break;
108
+ }
109
+ }
110
+ if (heading === null) return empty;
111
+ const headingEnd = heading.index + heading.length;
112
+ const afterHeading = content.slice(headingEnd);
113
+ const lines = afterHeading.split("\n");
114
+ const steps = [];
115
+ const seenNumbers = /* @__PURE__ */ new Set();
116
+ for (const rawLine of lines) {
117
+ const line = rawLine.trim();
118
+ if (!line) continue;
119
+ const m = ITEM_RE.exec(line);
120
+ if (!m) break;
121
+ const numPart = m[1];
122
+ const text = m[2].trim();
123
+ let index;
124
+ if (numPart !== void 0) {
125
+ index = Number.parseInt(numPart, 10);
126
+ } else {
127
+ index = steps.length + 1;
128
+ }
129
+ if (seenNumbers.has(index)) continue;
130
+ seenNumbers.add(index);
131
+ const hasAuto = !!m[3] && steps.length === 0 && index === 1;
132
+ pushStep(steps, index, text, hasAuto);
133
+ if (steps.length >= MAX_STEPS) break;
134
+ }
135
+ if (steps.length === 0) return empty;
136
+ const closeAbs = nonFencedIndexOf(content, "</nextsteps>", headingEnd, spans);
137
+ if (closeAbs === -1) return empty;
138
+ const texts = steps.map((s) => s.text);
139
+ const autoTexts = steps.filter((s) => s.auto).map((s) => s.text);
140
+ let blockEndAbs = closeAbs + "</nextsteps>".length;
141
+ if (content[blockEndAbs] === "\n") blockEndAbs += 1;
142
+ const stripped = (content.slice(0, heading.index) + content.slice(blockEndAbs)).replace(/\n{3,}/g, "\n\n").trim();
143
+ return { steps, texts, stripped, autoTexts };
144
+ }
145
+ function stripNextStepsBlock(text) {
146
+ const spans = fenceSpans(text);
147
+ const outsideFences = (index) => !spans.some(([start, end]) => index >= start && index < end);
148
+ let result = "";
149
+ let cursor = 0;
150
+ const openTagRe = /<next_?steps\b[^>]*>/gi;
151
+ for (let match = openTagRe.exec(text); match !== null; match = openTagRe.exec(text)) {
152
+ if (!outsideFences(match.index)) continue;
153
+ let removed;
154
+ if (match[0].endsWith("/>")) {
155
+ removed = match[0].length;
156
+ } else {
157
+ const closeRe = /<\/next_?steps\s*>/gi;
158
+ closeRe.lastIndex = match.index + match[0].length;
159
+ removed = -1;
160
+ for (let close = closeRe.exec(text); close !== null; close = closeRe.exec(text)) {
161
+ if (!outsideFences(close.index)) continue;
162
+ removed = close.index + close[0].length - match.index;
163
+ break;
164
+ }
165
+ if (removed === -1) {
166
+ removed = match[0].length;
167
+ }
168
+ }
169
+ result += text.slice(cursor, match.index);
170
+ cursor = match.index + removed;
171
+ openTagRe.lastIndex = cursor;
172
+ }
173
+ result += text.slice(cursor);
174
+ return result.replace(/\n{3,}/g, "\n\n").trim();
175
+ }
176
+ var stripNextSteps = stripNextStepsBlock;
177
+
178
+ export {
179
+ projectNextStepsToolInput,
180
+ isFinalTurnStopReason,
181
+ indexInsideCodeFence,
182
+ parseNextSteps,
183
+ stripNextStepsBlock,
184
+ stripNextSteps
185
+ };
186
+ //# sourceMappingURL=chunk-XXRMF2BC.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-XRNN44QY.js";
4
4
  import {
5
5
  spawnStream
6
- } from "./chunk-OYP27E3I.js";
6
+ } from "./chunk-DRRY6SCM.js";
7
7
  import {
8
8
  codebaseIndexStats,
9
9
  enqueueReindex,
@@ -13,7 +13,7 @@ import {
13
13
  outgoingCallsService,
14
14
  runStartupIndex,
15
15
  searchCodebaseIndex
16
- } from "./chunk-Z5Q3TXRY.js";
16
+ } from "./chunk-ZTCJCYLN.js";
17
17
  import {
18
18
  IndexTimeoutError,
19
19
  SCHEMA_VERSION,
@@ -21,7 +21,7 @@ import {
21
21
  indexCircuitBreaker,
22
22
  indexStorePool,
23
23
  resolveIndexDir
24
- } from "./chunk-J43O3BOX.js";
24
+ } from "./chunk-N3K2SFEI.js";
25
25
  import {
26
26
  EXT_TO_LANG,
27
27
  detectLang,
@@ -254,12 +254,6 @@ var PolyglotInvariantEngine = class {
254
254
  params,
255
255
  returnType
256
256
  });
257
- functions.set(methodName, {
258
- name: methodName,
259
- isExported: isExp,
260
- params,
261
- returnType
262
- });
263
257
  }
264
258
  }
265
259
  }
@@ -1990,7 +1984,7 @@ var codebaseRepoMapTool = {
1990
1984
  permission: "auto",
1991
1985
  mutating: false,
1992
1986
  capabilities: ["fs.read"],
1993
- description: "Generate a reference-weighted, token-budgeted Repository Map (Repo Map) of the codebase. Extracts the most architecturally central types, interfaces, classes, and function signatures across the repository into a compact outline (~800-1500 tokens). Use this at the beginning of tasks or when navigating unfamiliar repositories to get a bird-eye view of the architecture.",
1987
+ description: "Generate a reference-weighted, token-budgeted Repository Map of the codebase (~1200 token default). Use it for orientation before a cross-file change. Extracts the most architecturally central types, interfaces, classes, and function signatures across the repository into a compact outline (~800-1500 tokens). Use this at the beginning of tasks or when navigating unfamiliar repositories to get a bird-eye view of the architecture.",
1994
1988
  usageHint: 'USE AT THE START OF COMPLEX OR REPOSITORY-WIDE TASKS:\n\n- Call with default parameters to get a global architecture map within ~1200 tokens.\n- Pass `focusFiles: ["src/auth.ts"]` to ensure candidate files are guaranteed to be mapped alongside related entry-points.\n- Use the returned line numbers (e.g. `/* L32-L45 */`) to navigate or partially read only the functions you need.',
1995
1989
  inputSchema: {
1996
1990
  type: "object",
@@ -2866,4 +2860,4 @@ export {
2866
2860
  deadCodeScanTool,
2867
2861
  runDeadCodeScan
2868
2862
  };
2869
- //# sourceMappingURL=chunk-LRDIRJJL.js.map
2863
+ //# sourceMappingURL=chunk-YEISRT4S.js.map
@@ -7,6 +7,7 @@ import {
7
7
 
8
8
  export {
9
9
  capSubject,
10
- compileUserRegex
10
+ compileUserRegex,
11
+ MAX_SUBJECT_LEN
11
12
  };
12
- //# sourceMappingURL=chunk-Q5JPPCZC.js.map
13
+ //# sourceMappingURL=chunk-YJTXRH5Y.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  builtinToolsPack
3
- } from "./chunk-JVRLTEO7.js";
3
+ } from "./chunk-M6UV67BH.js";
4
4
  import {
5
5
  TIER1_TOOLS,
6
6
  TIER2_TOOLS
7
- } from "./chunk-4BABEJC2.js";
7
+ } from "./chunk-AB2CAUOP.js";
8
8
 
9
9
  // src/tool-tier.ts
10
10
  function toolNameSet(tools) {
@@ -54,4 +54,4 @@ export {
54
54
  selectBuiltinToolsForTier,
55
55
  registerBuiltinToolTier
56
56
  };
57
- //# sourceMappingURL=chunk-23EX5WDO.js.map
57
+ //# sourceMappingURL=chunk-YULVUTK5.js.map
@@ -9,7 +9,7 @@ import {
9
9
  projectIndexServerBuildId,
10
10
  projectIndexServerEndpoint,
11
11
  projectIndexServerMetadataPath
12
- } from "./chunk-PV6HIZQD.js";
12
+ } from "./chunk-GDDXX27P.js";
13
13
  import {
14
14
  CircuitOpenError,
15
15
  IndexTimeoutError,
@@ -24,7 +24,7 @@ import {
24
24
  searchService,
25
25
  statsService,
26
26
  symbolGraphService
27
- } from "./chunk-J43O3BOX.js";
27
+ } from "./chunk-N3K2SFEI.js";
28
28
  import {
29
29
  isIndexablePath
30
30
  } from "./chunk-YOHO4DVT.js";
@@ -1269,4 +1269,4 @@ export {
1269
1269
  checkCodebaseIndexServerHealth,
1270
1270
  ensureCodebaseIndexServer
1271
1271
  };
1272
- //# sourceMappingURL=chunk-Z5Q3TXRY.js.map
1272
+ //# sourceMappingURL=chunk-ZTCJCYLN.js.map
@@ -47,6 +47,7 @@ export interface CircuitBreakerConfig {
47
47
  */
48
48
  cooldownMs?: number | undefined;
49
49
  }
50
+ export type BreakerState = 'closed' | 'open' | 'half-open';
50
51
  export interface CircuitBreakerSnapshot {
51
52
  state: 'closed' | 'open' | 'half-open';
52
53
  consecutiveFailures: number;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CircuitBreaker
3
- } from "./chunk-HFXSNKCV.js";
3
+ } from "./chunk-7JJFC6CT.js";
4
4
  export {
5
5
  CircuitBreaker
6
6
  };
package/dist/clarify.d.ts CHANGED
@@ -20,6 +20,7 @@ export interface ClarifyQuestionInput {
20
20
  /** Allow write-in custom responses in addition to options (default: true). */
21
21
  allowCustomResponse?: boolean | undefined;
22
22
  }
23
+ export type ClarifyInput = ClarifyQuestionInput;
23
24
  export interface ClarifyOutput {
24
25
  status: 'answered' | 'auto_decided' | 'skipped';
25
26
  question: string;
@@ -10,9 +10,9 @@
10
10
  */
11
11
  import type { Tool } from '@wrongstack/core/types';
12
12
  import { type MutateSymbolOptions } from './ast-symbol-mutator.js';
13
- interface CodebaseAstReplaceInput extends MutateSymbolOptions {
13
+ export interface CodebaseAstReplaceInput extends MutateSymbolOptions {
14
14
  }
15
- interface CodebaseAstReplaceOutput {
15
+ export interface CodebaseAstReplaceOutput {
16
16
  status: 'ok' | 'error';
17
17
  file: string;
18
18
  symbol: string;
@@ -28,5 +28,4 @@ interface CodebaseAstReplaceOutput {
28
28
  error?: string | undefined;
29
29
  }
30
30
  export declare const codebaseAstReplaceTool: Tool<CodebaseAstReplaceInput, CodebaseAstReplaceOutput>;
31
- export {};
32
31
  //# sourceMappingURL=codebase-ast-replace-tool.d.ts.map
@@ -8,7 +8,7 @@
8
8
  * })
9
9
  */
10
10
  import type { Tool } from '@wrongstack/core/types';
11
- interface ImpactAnalysisInput {
11
+ export interface ImpactAnalysisInput {
12
12
  /** The symbol name (function, method, class, interface, type) to analyze. */
13
13
  symbol: string;
14
14
  /** Optional file path to disambiguate when multiple symbols share a name. */
@@ -16,7 +16,8 @@ interface ImpactAnalysisInput {
16
16
  /** Whether to traverse transitive callers (callers of callers). Defaults to true. */
17
17
  transitive?: boolean | undefined;
18
18
  }
19
- interface ImpactCallSite {
19
+ export type CodebaseImpactAnalysisInput = ImpactAnalysisInput;
20
+ export interface ImpactCallSite {
20
21
  file: string;
21
22
  line: number;
22
23
  callerName: string;
@@ -24,7 +25,7 @@ interface ImpactCallSite {
24
25
  callType: string;
25
26
  isTest: boolean;
26
27
  }
27
- interface ImpactAnalysisOutput {
28
+ export interface ImpactAnalysisOutput {
28
29
  status: 'ok' | 'error';
29
30
  symbol: string;
30
31
  riskLevel: 'low' | 'medium' | 'high';
@@ -38,6 +39,6 @@ interface ImpactAnalysisOutput {
38
39
  symbolFound?: boolean;
39
40
  error?: string | undefined;
40
41
  }
42
+ export type CodebaseImpactAnalysisOutput = ImpactAnalysisOutput;
41
43
  export declare const codebaseImpactAnalysisTool: Tool<ImpactAnalysisInput, ImpactAnalysisOutput>;
42
- export {};
43
44
  //# sourceMappingURL=codebase-impact-analysis-tool.d.ts.map
@@ -16,13 +16,14 @@
16
16
  import type { Tool } from '@wrongstack/core/types';
17
17
  import type { CallSite } from './schema.js';
18
18
  export declare const codebaseIncomingCallsTool: Tool<IncomingCallsInput, IncomingCallsOutput>;
19
- interface IncomingCallsInput {
19
+ export interface IncomingCallsInput {
20
20
  symbol: string;
21
21
  file?: string | undefined;
22
22
  limit?: number | undefined;
23
23
  transitive?: boolean | undefined;
24
24
  }
25
- interface IncomingCallsOutput {
25
+ export type CodebaseIncomingCallsInput = IncomingCallsInput;
26
+ export interface IncomingCallsOutput {
26
27
  symbol: string;
27
28
  calls: CallSite[];
28
29
  total: number;
@@ -37,5 +38,5 @@ interface IncomingCallsOutput {
37
38
  /** Advisory note when the symbol was not found in the index. */
38
39
  note?: string | undefined;
39
40
  }
40
- export {};
41
+ export type CodebaseIncomingCallsOutput = IncomingCallsOutput;
41
42
  //# sourceMappingURL=codebase-incoming-calls-tool.d.ts.map
@@ -1,10 +1,10 @@
1
1
  import type { Tool } from '@wrongstack/core/types';
2
2
  export declare const codebaseIndexTool: Tool<CodebaseIndexInput, CodebaseIndexOutput>;
3
- interface CodebaseIndexInput {
3
+ export interface CodebaseIndexInput {
4
4
  force?: boolean | undefined;
5
5
  langs?: string[] | undefined;
6
6
  }
7
- interface CodebaseIndexOutput {
7
+ export interface CodebaseIndexOutput {
8
8
  filesIndexed: number;
9
9
  fileOutcomes?: {
10
10
  parsed: number;
@@ -19,5 +19,4 @@ interface CodebaseIndexOutput {
19
19
  /** Advisory note when the indexer was skipped (e.g. another index in progress). */
20
20
  note?: string | undefined;
21
21
  }
22
- export {};
23
22
  //# sourceMappingURL=codebase-index-tool.d.ts.map
@@ -7,18 +7,17 @@
7
7
  import type { Tool } from '@wrongstack/core/types';
8
8
  import { type InvariantViolation } from './ast-invariant-engine.js';
9
9
  import type { SymbolLang } from './schema.js';
10
- interface CodebaseInvariantCheckInput {
10
+ export interface CodebaseInvariantCheckInput {
11
11
  file?: string | undefined;
12
12
  originalCode?: string | undefined;
13
13
  modifiedCode: string;
14
14
  lang?: SymbolLang | undefined;
15
15
  }
16
- interface CodebaseInvariantCheckOutput {
16
+ export interface CodebaseInvariantCheckOutput {
17
17
  valid: boolean;
18
18
  violations: InvariantViolation[];
19
19
  summary: string;
20
20
  error?: string | undefined;
21
21
  }
22
22
  export declare const codebaseInvariantCheckTool: Tool<CodebaseInvariantCheckInput, CodebaseInvariantCheckOutput>;
23
- export {};
24
23
  //# sourceMappingURL=codebase-invariant-check-tool.d.ts.map