@wrongstack/tools 1.0.2 → 1.0.4

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 (114) hide show
  1. package/README.md +0 -6
  2. package/dist/_util.d.ts +18 -0
  3. package/dist/_win32-resolve.d.ts +1 -6
  4. package/dist/audit.js +6 -6
  5. package/dist/bash.js +3 -3
  6. package/dist/browser/index.d.ts +1 -1
  7. package/dist/browser/index.js +9 -1
  8. package/dist/browser/tools.d.ts +14 -0
  9. package/dist/builtin.d.ts +16 -13
  10. package/dist/builtin.js +43 -47
  11. package/dist/{chunk-DL2ARI4S.js → chunk-24Q4O34E.js} +5 -5
  12. package/dist/{chunk-AQ5YBURX.js → chunk-2IC5FRD7.js} +2 -2
  13. package/dist/{chunk-4ERMPDHV.js → chunk-2QY3DC3H.js} +20 -16
  14. package/dist/{chunk-VU3QBYL4.js → chunk-2ZWQIVEW.js} +2 -2
  15. package/dist/{chunk-JDOO4P6Z.js → chunk-3F7HQ3KS.js} +2 -2
  16. package/dist/{chunk-MJSJWXBF.js → chunk-47GYABZW.js} +15 -3
  17. package/dist/{chunk-6H4ERJP7.js → chunk-4KI4HHID.js} +3 -3
  18. package/dist/{chunk-X6KXNHUO.js → chunk-5BKQVP56.js} +22 -5
  19. package/dist/{chunk-KE7A76VC.js → chunk-5U5ULQX2.js} +4 -14
  20. package/dist/{chunk-SMARDKAC.js → chunk-5UA4TNJJ.js} +2 -2
  21. package/dist/{chunk-SOR7OCYP.js → chunk-6XYFYLN7.js} +23 -1
  22. package/dist/{chunk-KVTEIUND.js → chunk-A636Z2TG.js} +3 -3
  23. package/dist/{chunk-52UXXQMP.js → chunk-AX5ZG5O5.js} +3 -3
  24. package/dist/{chunk-7HL23T3T.js → chunk-BU6VUXWG.js} +2 -2
  25. package/dist/{chunk-WEEVSWQB.js → chunk-C64UUXTA.js} +4 -4
  26. package/dist/{chunk-4WPBS45A.js → chunk-D4HWMWGE.js} +4 -4
  27. package/dist/{chunk-DRRY6SCM.js → chunk-EMA2XENR.js} +2 -2
  28. package/dist/{chunk-TU5MTW2S.js → chunk-EMCIC2JA.js} +3 -3
  29. package/dist/{chunk-ASEXQRA7.js → chunk-FEXPWYU7.js} +7 -5
  30. package/dist/{chunk-ZUFHAHTE.js → chunk-HKR56VNF.js} +15 -2
  31. package/dist/{chunk-7N5U2RAU.js → chunk-JK5WXW4S.js} +3 -3
  32. package/dist/{chunk-T3SMFF5Q.js → chunk-JQ43NVFU.js} +2 -2
  33. package/dist/{chunk-7XUEPBNT.js → chunk-KVEL4EFI.js} +3 -3
  34. package/dist/{chunk-VZGPASGD.js → chunk-MG7CUN6R.js} +2 -2
  35. package/dist/{chunk-NFX2IUQA.js → chunk-NERS6GBT.js} +3 -3
  36. package/dist/{chunk-5KS24LTS.js → chunk-NKOTOW6X.js} +3 -3
  37. package/dist/{chunk-NJX2RXKJ.js → chunk-OBVXDVLE.js} +12 -4
  38. package/dist/{chunk-HWXIRVKH.js → chunk-OSXM3O3J.js} +29 -15
  39. package/dist/{chunk-LQSOU63Z.js → chunk-OZVGRDCM.js} +3 -3
  40. package/dist/{chunk-TI5COGLY.js → chunk-PVQBD3TA.js} +46 -6
  41. package/dist/{chunk-3D5DJWOE.js → chunk-R36RWYXE.js} +12 -4
  42. package/dist/{chunk-3AU6CZWL.js → chunk-REWOZIA4.js} +2 -2
  43. package/dist/{chunk-QA6IASYX.js → chunk-S6E2AM4U.js} +4 -4
  44. package/dist/{chunk-UCXFTCAI.js → chunk-T34DVSAE.js} +236 -177
  45. package/dist/{chunk-FBUP524S.js → chunk-TGVQMKVH.js} +15 -4
  46. package/dist/{chunk-MBR5VAB5.js → chunk-VQDSIHAR.js} +40 -2
  47. package/dist/{chunk-UOYRAS4J.js → chunk-VSOVZ5JI.js} +4 -4
  48. package/dist/{chunk-RV7BVTDG.js → chunk-WKXL5XHU.js} +2 -2
  49. package/dist/{chunk-DKHMPKDG.js → chunk-WWAXJKX3.js} +4 -4
  50. package/dist/{chunk-24T5XIJU.js → chunk-YA2ZYCJY.js} +4 -4
  51. package/dist/{chunk-MGPR7VG3.js → chunk-YILT3CSO.js} +3 -3
  52. package/dist/{chunk-6GOZTS6F.js → chunk-YJQQ5F5J.js} +4 -4
  53. package/dist/{chunk-EL2NJXSK.js → chunk-YZLOYJGN.js} +2 -2
  54. package/dist/{chunk-O6BY43ZB.js → chunk-ZETZHHV5.js} +4 -4
  55. package/dist/clarify.d.ts +18 -3
  56. package/dist/codebase-index/codebase-search-tool.d.ts +2 -3
  57. package/dist/codebase-index/index.js +9 -9
  58. package/dist/codebase-index/parser-worker-script.js +3 -3
  59. package/dist/codebase-index/project-server-endpoint.d.ts +33 -0
  60. package/dist/codebase-index/project-server.js +5 -5
  61. package/dist/codebase-index/worker.js +4 -4
  62. package/dist/diff.js +2 -2
  63. package/dist/e2e.js +2 -2
  64. package/dist/edit.js +8 -8
  65. package/dist/exec.js +3 -3
  66. package/dist/fetch.js +2 -2
  67. package/dist/format.js +6 -6
  68. package/dist/git.js +2 -2
  69. package/dist/glob.js +2 -2
  70. package/dist/{go-parser-QIEXU3P2.js → go-parser-EMKTAAD3.js} +2 -2
  71. package/dist/grep.js +2 -2
  72. package/dist/index.d.ts +2 -8
  73. package/dist/index.js +68 -84
  74. package/dist/install.js +6 -6
  75. package/dist/json.js +2 -2
  76. package/dist/kanban.js +2 -2
  77. package/dist/languages/index.js +4 -4
  78. package/dist/{legacy-bridge-YXANP5QB.js → legacy-bridge-XM2GV665.js} +6 -6
  79. package/dist/lint.js +6 -6
  80. package/dist/logs.js +2 -2
  81. package/dist/outdated.js +3 -3
  82. package/dist/pack.js +44 -48
  83. package/dist/{parser-dispatch-37FT3EXQ.js → parser-dispatch-IF75EZFB.js} +4 -4
  84. package/dist/patch.js +8 -8
  85. package/dist/plan.js +4 -4
  86. package/dist/{py-parser-6GJTGUXK.js → py-parser-DDG53RXI.js} +3 -3
  87. package/dist/read-url-content.d.ts +17 -0
  88. package/dist/read.js +8 -8
  89. package/dist/replace.js +8 -8
  90. package/dist/session-kanban.js +1 -1
  91. package/dist/task.js +4 -4
  92. package/dist/test.js +6 -6
  93. package/dist/todo.js +3 -3
  94. package/dist/tool-search.js +1 -1
  95. package/dist/tool-tier.d.ts +12 -2
  96. package/dist/tool-tier.js +45 -49
  97. package/dist/tree.js +2 -2
  98. package/dist/typecheck.js +6 -6
  99. package/dist/win32.js +1 -1
  100. package/dist/write.js +8 -8
  101. package/package.json +5 -21
  102. package/dist/batch-tool-use.d.ts +0 -24
  103. package/dist/batch-tool-use.js +0 -7
  104. package/dist/chunk-7ODZTPCU.js +0 -128
  105. package/dist/chunk-CHEK3ASV.js +0 -183
  106. package/dist/chunk-KLJZ4WV4.js +0 -213
  107. package/dist/chunk-VBF2YXUW.js +0 -203
  108. package/dist/document.d.ts +0 -25
  109. package/dist/document.js +0 -8
  110. package/dist/scaffold.d.ts +0 -23
  111. package/dist/scaffold.js +0 -10
  112. package/dist/set-working-dir.d.ts +0 -17
  113. package/dist/tool-help.d.ts +0 -21
  114. package/dist/tool-help.js +0 -7
@@ -1,183 +0,0 @@
1
- import {
2
- ensureInsideRoot,
3
- safeResolveReal
4
- } from "./chunk-ZUFHAHTE.js";
5
-
6
- // src/document.ts
7
- import * as fs from "node:fs/promises";
8
- import * as path from "node:path";
9
- var documentTool = {
10
- name: "document",
11
- category: "Project",
12
- description: "DEPRECATED \u2014 read-only preview stub that lists undocumented symbols as `skipped` candidates. It never writes files and does not generate real docstrings. If the auto-doc plugin is enabled, use its `auto_doc` tool (with `dry_run: true` to preview) instead.",
13
- usageHint: "Deprecated: this tool only lists undocumented symbols with placeholder comments \u2014 it does not generate real JSDoc/TSDoc and writes nothing. When the auto-doc plugin is enabled, prefer its `auto_doc` tool (`dry_run: true` for previewing, without it for writing).",
14
- permission: "auto",
15
- mutating: false,
16
- timeoutMs: 3e4,
17
- capabilities: ["fs.read"],
18
- icon: "document",
19
- inputSchema: {
20
- type: "object",
21
- properties: {
22
- target: {
23
- type: "string",
24
- enum: ["file", "function", "class", "type", "all"],
25
- description: "What to document"
26
- },
27
- path: {
28
- type: "string",
29
- description: "Specific file path to document"
30
- },
31
- files: {
32
- oneOf: [
33
- { type: "string" },
34
- { type: "array", items: { type: "string" } }
35
- ],
36
- description: "File(s) to process: single path, comma-separated list, or glob"
37
- },
38
- style: {
39
- type: "string",
40
- enum: ["jsdoc", "tsdoc", "block"],
41
- description: "Documentation style (default: jsdoc)"
42
- },
43
- cwd: { type: "string", description: "Working directory (default: cwd)" }
44
- }
45
- },
46
- async execute(input, ctx, _opts) {
47
- const signal = _opts?.signal ?? ctx?.signal;
48
- signal?.throwIfAborted();
49
- const cwd = input.cwd ? await safeResolveReal(input.cwd, ctx) : ctx.cwd;
50
- const style = input.style ?? "jsdoc";
51
- const results = [];
52
- let filesProcessed = 0;
53
- let itemsDocumented = 0;
54
- const fileList = input.files ? await resolveFiles(
55
- Array.isArray(input.files) ? input.files.join(",") : input.files,
56
- cwd,
57
- ctx
58
- ) : input.path ? [await safeResolveReal(input.path, ctx)] : [];
59
- for (const absPath of fileList) {
60
- if (signal?.aborted) break;
61
- try {
62
- const content = await fs.readFile(absPath, "utf8");
63
- filesProcessed++;
64
- const processed = processFile(
65
- content,
66
- absPath,
67
- style,
68
- input.overwrite ?? false,
69
- input.target ?? "all"
70
- );
71
- results.push(...processed);
72
- itemsDocumented += processed.filter((r) => r.status === "documented").length;
73
- } catch (e) {
74
- results.push({
75
- path: absPath,
76
- name: path.basename(absPath),
77
- signature: "",
78
- docstring: "",
79
- status: "error",
80
- error: e instanceof Error ? e.message : String(e)
81
- });
82
- }
83
- }
84
- return {
85
- files_processed: filesProcessed,
86
- items_documented: itemsDocumented,
87
- results,
88
- style
89
- };
90
- }
91
- };
92
- function getLineNumber(content, index) {
93
- let line = 1;
94
- for (let i = 0; i < index; i++) {
95
- if (content.charCodeAt(i) === 10) line++;
96
- }
97
- return line;
98
- }
99
- async function resolveFiles(filesInput, cwd, ctx) {
100
- const files = filesInput.split(",");
101
- const resolved = [];
102
- for (const f of files) {
103
- const entry = f.trim();
104
- if (!entry) continue;
105
- let absPath;
106
- try {
107
- absPath = ensureInsideRoot(path.resolve(cwd, entry), ctx);
108
- } catch {
109
- continue;
110
- }
111
- try {
112
- const stat2 = await fs.stat(absPath);
113
- if (stat2.isFile()) resolved.push(absPath);
114
- } catch {
115
- }
116
- }
117
- return [...new Set(resolved)];
118
- }
119
- function processFile(content, absPath, _style, _overwrite, target) {
120
- const results = [];
121
- const functionRegex = /(?:async\s+)?function\s+(\w+)\s*\(([^)]*)\)/g;
122
- const arrowRegex = /(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s+)?\(([^)]*)\)\s*=>/g;
123
- const classRegex = /class\s+(\w+)/g;
124
- const typeRegex = /(?:type|interface)\s+(\w+)\s*[=<]/g;
125
- const allMatches = [];
126
- if (target === "all" || target === "function") {
127
- for (const m of content.matchAll(functionRegex)) {
128
- if (!m[1]) continue;
129
- allMatches.push({
130
- name: m[1],
131
- sig: m[2] ?? "",
132
- type: "function",
133
- line: getLineNumber(content, m.index)
134
- });
135
- }
136
- for (const m of content.matchAll(arrowRegex)) {
137
- if (!m[1]) continue;
138
- allMatches.push({
139
- name: m[1],
140
- sig: m[2] ?? "",
141
- type: "arrow",
142
- line: getLineNumber(content, m.index)
143
- });
144
- }
145
- }
146
- if (target === "all" || target === "class") {
147
- for (const m of content.matchAll(classRegex)) {
148
- if (!m[1]) continue;
149
- allMatches.push({
150
- name: m[1],
151
- sig: "",
152
- type: "class",
153
- line: getLineNumber(content, m.index)
154
- });
155
- }
156
- }
157
- if (target === "all" || target === "type") {
158
- for (const m of content.matchAll(typeRegex)) {
159
- if (!m[1]) continue;
160
- allMatches.push({
161
- name: m[1],
162
- sig: m[0] ?? "",
163
- type: "type",
164
- line: getLineNumber(content, m.index)
165
- });
166
- }
167
- }
168
- for (const m of allMatches) {
169
- results.push({
170
- path: absPath,
171
- name: m.name,
172
- signature: m.sig,
173
- docstring: `/** ${m.name} - documented at line ${m.line} */`,
174
- status: "skipped"
175
- });
176
- }
177
- return results;
178
- }
179
-
180
- export {
181
- documentTool
182
- };
183
- //# sourceMappingURL=chunk-CHEK3ASV.js.map
@@ -1,213 +0,0 @@
1
- import {
2
- safeResolveReal
3
- } from "./chunk-ZUFHAHTE.js";
4
-
5
- // src/scaffold.ts
6
- import * as fs from "node:fs/promises";
7
- import * as path from "node:path";
8
- import { atomicWrite } from "@wrongstack/core/utils";
9
- var BUILT_IN_TEMPLATES = {
10
- "npm-package": {
11
- description: "Basic npm package with ESM",
12
- files: {
13
- "package.json": JSON.stringify(
14
- {
15
- name: "{{name}}",
16
- version: "0.1.1",
17
- type: "module",
18
- main: "./dist/index.js",
19
- scripts: { build: "tsc", test: "vitest run" },
20
- devDependencies: { typescript: "^5.0.0" }
21
- },
22
- null,
23
- 2
24
- ),
25
- "tsconfig.json": JSON.stringify(
26
- {
27
- compilerOptions: { target: "ES2022", module: "ESNext", strict: true },
28
- include: ["src"]
29
- },
30
- null,
31
- 2
32
- ),
33
- "src/index.ts": `export function hello() {
34
- return 'Hello from {{name}}';
35
- }
36
- `,
37
- "src/index.test.ts": `import { hello } from './index';
38
- import { describe, it, expect } from 'vitest';
39
-
40
- describe('hello', () => {
41
- it('returns greeting', () => {
42
- expect(hello()).toBe('Hello from {{name}}');
43
- });
44
- });
45
- `
46
- }
47
- },
48
- "cli-tool": {
49
- description: "CLI tool with argparse",
50
- files: {
51
- "package.json": JSON.stringify(
52
- {
53
- name: "{{name}}",
54
- version: "0.1.1",
55
- type: "module",
56
- bin: { "{{name}}": "./src/index.js" },
57
- scripts: { build: "tsc", start: "node dist/index.js" }
58
- },
59
- null,
60
- 2
61
- ),
62
- "src/index.ts": `#!/usr/bin/env node
63
-
64
- async function main() {
65
- console.log('Hello from {{name}}');
66
- }
67
-
68
- main();
69
- `
70
- }
71
- },
72
- "react-component": {
73
- description: "React component with TypeScript",
74
- files: {
75
- "{{name}}.tsx": `interface {{Name}}Props {
76
- className?: string;
77
- }
78
-
79
- export function {{Name}}({ className }: {{Name}}Props) {
80
- return (
81
- <div className={className}>
82
- {{Name}} Component
83
- </div>
84
- );
85
- }
86
- `,
87
- "{{name}}.test.tsx": `import { render, screen } from '@testing-library/react';
88
- import { {{Name}} } from './{{Name}}';
89
-
90
- describe('{{Name}}', () => {
91
- it('renders', () => {
92
- render(<{{Name}} />);
93
- expect(screen.getByText('{{Name}} Component')).toBeInTheDocument();
94
- });
95
- });
96
- `
97
- }
98
- }
99
- };
100
- var scaffoldTool = {
101
- name: "scaffold",
102
- category: "Project",
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
- 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
- permission: "confirm",
106
- mutating: true,
107
- subjectKey: "name",
108
- capabilities: ["fs.write.outside-project", "fs.write"],
109
- icon: "scaffold",
110
- timeoutMs: 3e4,
111
- inputSchema: {
112
- type: "object",
113
- properties: {
114
- template: {
115
- type: "string",
116
- description: "Template name (npm-package, cli-tool, react-component) or path to template directory"
117
- },
118
- name: {
119
- type: "string",
120
- description: "Project/component name (used in generated files)"
121
- },
122
- cwd: { type: "string", description: "Working directory (default: cwd)" },
123
- vars: {
124
- type: "object",
125
- additionalProperties: { type: "string" },
126
- description: "Template variables for custom templates"
127
- },
128
- dry_run: {
129
- type: "boolean",
130
- description: "Preview generated files without creating (default: false)"
131
- }
132
- },
133
- required: ["template", "name"]
134
- },
135
- async execute(input, ctx, _opts) {
136
- const signal = _opts?.signal ?? ctx?.signal;
137
- signal?.throwIfAborted();
138
- const cwd = input.cwd ? await safeResolveReal(input.cwd, ctx) : ctx.cwd;
139
- const name = input.name;
140
- const vars = { name, ...input.vars };
141
- const builtIn = BUILT_IN_TEMPLATES[input.template];
142
- if (builtIn) {
143
- return await handleBuiltIn(
144
- name,
145
- builtIn.files,
146
- cwd,
147
- ctx,
148
- input.dry_run ?? false,
149
- vars,
150
- signal
151
- );
152
- }
153
- return {
154
- template: input.template,
155
- name,
156
- files_created: 0,
157
- files: [],
158
- dry_run: input.dry_run ?? false,
159
- output: `Template "${input.template}" not found. Available: ${Object.keys(BUILT_IN_TEMPLATES).join(", ")}`
160
- };
161
- }
162
- };
163
- async function handleBuiltIn(name, templateFiles, cwd, ctx, dryRun, vars, signal) {
164
- const files = [];
165
- let filesCreated = 0;
166
- for (const [filePath, content] of Object.entries(templateFiles)) {
167
- if (signal?.aborted) break;
168
- const resolvedPath = substituteVars(filePath, name, vars);
169
- const joinedPath = path.join(cwd, resolvedPath);
170
- const root = path.resolve(ctx.projectRoot ?? ctx.cwd ?? process.cwd());
171
- const target = path.resolve(joinedPath);
172
- const rel = path.relative(root, target);
173
- if (rel.startsWith("..") || path.isAbsolute(rel)) {
174
- throw new Error(`scaffold: generated path "${resolvedPath}" would escape project root`);
175
- }
176
- const fullPath = target;
177
- if (!dryRun) {
178
- await fs.mkdir(path.dirname(fullPath), { recursive: true });
179
- await atomicWrite(fullPath, substituteVars(content, name, vars));
180
- }
181
- files.push(resolvedPath);
182
- filesCreated++;
183
- }
184
- return {
185
- template: "built-in",
186
- name,
187
- files_created: filesCreated,
188
- files,
189
- dry_run: dryRun,
190
- output: dryRun ? `Would create ${filesCreated} files: ${files.join(", ")}` : `Created ${filesCreated} files: ${files.join(", ")}`
191
- };
192
- }
193
- function escapeRegexLiteral(value) {
194
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
195
- }
196
- function substituteVars(content, name, vars) {
197
- const kebab = name.toLowerCase().replace(/\s+/g, "-");
198
- const pascal = name.replace(/(?:^|[-_\s]+)([a-zA-Z])/g, (_, c) => c.toUpperCase());
199
- let result = content;
200
- result = result.replace(/\{\{name\}\}/g, () => kebab);
201
- result = result.replace(/\{\{Name\}\}/g, () => pascal);
202
- for (const [k, v] of Object.entries(vars)) {
203
- if (k === "name" || k === "Name") continue;
204
- result = result.replace(new RegExp(`\\{\\{${escapeRegexLiteral(k)}\\}\\}`, "g"), () => v);
205
- }
206
- return result;
207
- }
208
-
209
- export {
210
- BUILT_IN_TEMPLATES,
211
- scaffoldTool
212
- };
213
- //# sourceMappingURL=chunk-KLJZ4WV4.js.map
@@ -1,203 +0,0 @@
1
- // src/batch-tool-use.ts
2
- import {
3
- GOVERNED_TOOL_EXECUTOR_META_KEY
4
- } from "@wrongstack/core/types";
5
- var BATCHABLE_TOOL_NAMES = [
6
- "read",
7
- "glob",
8
- "grep",
9
- "tree",
10
- "codebase-stats",
11
- "codebase-search",
12
- "language_info",
13
- "tool_search",
14
- "memory_for_file",
15
- "memory_for_path",
16
- "memory_search"
17
- ];
18
- var BATCHABLE_TOOLS = new Set(BATCHABLE_TOOL_NAMES);
19
- var MAX_BATCH_CALLS = 8;
20
- var MAX_PARALLEL_BATCH_CALLS = 3;
21
- var batchToolUseTool = {
22
- name: "batch_tool_use",
23
- category: "Meta",
24
- description: "Execute a small batch of independent, read-only discovery calls. Process, mutation, browser-action, MCP, delegation, and nested meta tools are not eligible.",
25
- usageHint: `BOUNDED READ-ONLY BATCHING:
26
-
27
- - Use only for a small set of independent reads or searches that are all needed now.
28
- - Do not wrap normal sequential reasoning or every tool call in a batch.
29
- - \`parallel: true\` (default) runs at most three eligible calls concurrently.
30
- - \`stop_on_error: true\` makes it fail fast on the first error.
31
- - Eligible tools: ${BATCHABLE_TOOL_NAMES.join(", ")}.`,
32
- permission: "confirm",
33
- // Scheduling barrier: keep the outer meta-call out of ToolExecutor's
34
- // non-mutating fan-out even though every eligible inner tool is read-only.
35
- mutating: true,
36
- timeoutMs: 12e4,
37
- capabilities: ["tool.meta"],
38
- icon: "meta",
39
- inputSchema: {
40
- type: "object",
41
- properties: {
42
- calls: {
43
- type: "array",
44
- maxItems: MAX_BATCH_CALLS,
45
- items: {
46
- type: "object",
47
- properties: {
48
- tool: {
49
- type: "string",
50
- enum: [...BATCHABLE_TOOL_NAMES],
51
- description: "An explicitly batch-safe, read-only discovery tool."
52
- },
53
- input: { type: "object" }
54
- },
55
- required: ["tool"]
56
- },
57
- description: `Up to ${MAX_BATCH_CALLS} independent, batch-safe read calls.`
58
- },
59
- stop_on_error: {
60
- type: "boolean",
61
- description: "Stop execution on first error (default: false)"
62
- },
63
- parallel: {
64
- type: "boolean",
65
- description: "Execute calls in parallel (default: true)"
66
- }
67
- },
68
- required: ["calls"]
69
- },
70
- async execute(input, ctx, _opts) {
71
- if (!input?.calls || input.calls.length === 0) {
72
- return {
73
- results: [],
74
- total: 0,
75
- succeeded: 0,
76
- failed: 0,
77
- stop_on_error: false
78
- };
79
- }
80
- if (input.calls.length > MAX_BATCH_CALLS) {
81
- throw new Error(`batch_tool_use: calls must contain at most ${MAX_BATCH_CALLS} items`);
82
- }
83
- const governedExecute = ctx.meta?.[GOVERNED_TOOL_EXECUTOR_META_KEY];
84
- if (typeof governedExecute !== "function") {
85
- return {
86
- results: input.calls.map((call) => ({
87
- tool: call.tool,
88
- success: false,
89
- error: "governed nested execution is unavailable; call the tool directly",
90
- executionMs: 0
91
- })),
92
- total: input.calls.length,
93
- succeeded: 0,
94
- failed: input.calls.length,
95
- stop_on_error: input.stop_on_error ?? false
96
- };
97
- }
98
- const results = [];
99
- let succeeded = 0;
100
- let failed = 0;
101
- if (input.parallel !== false) {
102
- let stopRequested = false;
103
- const allResults = await mapWithConcurrency(
104
- input.calls,
105
- MAX_PARALLEL_BATCH_CALLS,
106
- async (call) => {
107
- const result = await executeSingle(call, ctx, governedExecute);
108
- if (input.stop_on_error && !result.success) stopRequested = true;
109
- return result;
110
- },
111
- () => stopRequested
112
- );
113
- const executed = allResults.filter(
114
- (r) => r !== void 0
115
- );
116
- results.push(...executed);
117
- succeeded = executed.filter((r) => r.success).length;
118
- failed = executed.filter((r) => !r.success).length;
119
- } else {
120
- for (const call of input.calls) {
121
- const result = await executeSingle(call, ctx, governedExecute);
122
- results.push(result);
123
- if (result.success) {
124
- succeeded++;
125
- } else {
126
- failed++;
127
- if (input.stop_on_error) break;
128
- }
129
- }
130
- }
131
- return {
132
- results,
133
- total: input.calls.length,
134
- succeeded,
135
- failed,
136
- stop_on_error: input.stop_on_error ?? false
137
- };
138
- }
139
- };
140
- async function mapWithConcurrency(items, limit, run, shouldStop) {
141
- const results = new Array(items.length);
142
- let nextIndex = 0;
143
- const worker = async () => {
144
- while (nextIndex < items.length) {
145
- if (shouldStop?.()) return;
146
- const index = nextIndex++;
147
- results[index] = await run(items[index]);
148
- }
149
- };
150
- await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => worker()));
151
- return results;
152
- }
153
- async function executeSingle(call, ctx, governedExecute) {
154
- const start = Date.now();
155
- if (call.tool === batchToolUseTool.name) {
156
- return {
157
- tool: call.tool,
158
- success: false,
159
- error: "recursive batch_tool_use execution is not allowed",
160
- executionMs: Date.now() - start
161
- };
162
- }
163
- const tool = (ctx.catalogTools ?? ctx.tools).find(
164
- (candidate) => candidate.name === call.tool
165
- );
166
- if (!tool) {
167
- return {
168
- tool: call.tool,
169
- success: false,
170
- error: `tool "${call.tool}" not found`,
171
- executionMs: Date.now() - start
172
- };
173
- }
174
- if (!BATCHABLE_TOOLS.has(tool.name) || tool.mutating) {
175
- return {
176
- tool: call.tool,
177
- success: false,
178
- error: `tool "${call.tool}" is not eligible for batch execution; call it directly. Allowed: ${BATCHABLE_TOOL_NAMES.join(", ")}`,
179
- executionMs: Date.now() - start
180
- };
181
- }
182
- try {
183
- const result = await governedExecute(call.tool, call.input);
184
- return {
185
- tool: call.tool,
186
- success: result.success,
187
- ...result.success ? { result: result.result } : { error: result.error ?? "nested tool failed" },
188
- executionMs: Date.now() - start
189
- };
190
- } catch (e) {
191
- return {
192
- tool: call.tool,
193
- success: false,
194
- error: e instanceof Error ? e.message : String(e),
195
- executionMs: Date.now() - start
196
- };
197
- }
198
- }
199
-
200
- export {
201
- batchToolUseTool
202
- };
203
- //# sourceMappingURL=chunk-VBF2YXUW.js.map
@@ -1,25 +0,0 @@
1
- import type { Tool } from '@wrongstack/core/types';
2
- export interface DocumentInput {
3
- target: 'file' | 'function' | 'class' | 'type' | 'all';
4
- path?: string | undefined;
5
- files?: string | string[] | undefined;
6
- style?: 'jsdoc' | 'tsdoc' | 'block' | undefined;
7
- overwrite?: boolean | undefined;
8
- cwd?: string | undefined;
9
- }
10
- export interface DocumentedItem {
11
- path: string;
12
- name: string;
13
- signature: string;
14
- docstring: string;
15
- status: 'documented' | 'skipped' | 'error';
16
- error?: string | undefined;
17
- }
18
- export interface DocumentOutput {
19
- files_processed: number;
20
- items_documented: number;
21
- results: DocumentedItem[];
22
- style: string;
23
- }
24
- export declare const documentTool: Tool<DocumentInput, DocumentOutput>;
25
- //# sourceMappingURL=document.d.ts.map
package/dist/document.js DELETED
@@ -1,8 +0,0 @@
1
- import {
2
- documentTool
3
- } from "./chunk-CHEK3ASV.js";
4
- import "./chunk-ZUFHAHTE.js";
5
- export {
6
- documentTool
7
- };
8
- //# sourceMappingURL=document.js.map
@@ -1,23 +0,0 @@
1
- import type { Tool } from '@wrongstack/core/types';
2
- export interface ScaffoldInput {
3
- template: string;
4
- name: string;
5
- cwd?: string | undefined;
6
- vars?: Record<string, string>;
7
- dry_run?: boolean | undefined;
8
- }
9
- export interface ScaffoldOutput {
10
- template: string;
11
- name: string;
12
- files_created: number;
13
- files: string[];
14
- dry_run: boolean;
15
- output: string;
16
- }
17
- export interface ScaffoldTemplate {
18
- description: string;
19
- files: Record<string, string>;
20
- }
21
- export declare const BUILT_IN_TEMPLATES: Record<string, ScaffoldTemplate>;
22
- export declare const scaffoldTool: Tool<ScaffoldInput, ScaffoldOutput>;
23
- //# sourceMappingURL=scaffold.d.ts.map
package/dist/scaffold.js DELETED
@@ -1,10 +0,0 @@
1
- import {
2
- BUILT_IN_TEMPLATES,
3
- scaffoldTool
4
- } from "./chunk-KLJZ4WV4.js";
5
- import "./chunk-ZUFHAHTE.js";
6
- export {
7
- BUILT_IN_TEMPLATES,
8
- scaffoldTool
9
- };
10
- //# sourceMappingURL=scaffold.js.map
@@ -1,17 +0,0 @@
1
- import type { Tool } from '@wrongstack/core/types';
2
- export interface SetWorkingDirInput {
3
- /** Relative or absolute path to navigate to. Must stay within projectRoot. */
4
- path?: string | undefined;
5
- }
6
- export interface SetWorkingDirOutput {
7
- /** The new working directory (absolute path). */
8
- current: string;
9
- /** The previous working directory (absolute path). */
10
- previous?: string | undefined;
11
- /** Human-readable confirmation message. */
12
- message?: string | undefined;
13
- /** Error if the directory doesn't exist or is outside the project root. */
14
- error?: string | undefined;
15
- }
16
- export declare const setWorkingDirTool: Tool<SetWorkingDirInput, SetWorkingDirOutput>;
17
- //# sourceMappingURL=set-working-dir.d.ts.map