@wrongstack/tools 1.0.3 → 1.0.5
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.
- package/README.md +0 -6
- package/dist/_util.d.ts +18 -0
- package/dist/audit.js +4 -4
- package/dist/bash.js +2 -2
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/index.js +9 -1
- package/dist/browser/tools.d.ts +14 -0
- package/dist/builtin.d.ts +16 -13
- package/dist/builtin.js +41 -45
- package/dist/{chunk-AQ5YBURX.js → chunk-2IC5FRD7.js} +2 -2
- package/dist/{chunk-VU3QBYL4.js → chunk-2ZWQIVEW.js} +2 -2
- package/dist/{chunk-JDOO4P6Z.js → chunk-3F7HQ3KS.js} +2 -2
- package/dist/{chunk-DX5KZEMK.js → chunk-47GYABZW.js} +2 -2
- package/dist/{chunk-KYVOTHG7.js → chunk-4KI4HHID.js} +2 -2
- package/dist/{chunk-3JVSOBHU.js → chunk-54SIRJ6D.js} +4 -4
- package/dist/{chunk-X6KXNHUO.js → chunk-5BKQVP56.js} +22 -5
- package/dist/{chunk-SMARDKAC.js → chunk-5UA4TNJJ.js} +2 -2
- package/dist/{chunk-SOR7OCYP.js → chunk-6XYFYLN7.js} +23 -1
- package/dist/{chunk-VO6M2FVG.js → chunk-6ZRP5IKQ.js} +2 -2
- package/dist/{chunk-E2ZD4ERD.js → chunk-7EQ2LUXU.js} +3 -3
- package/dist/{chunk-6LCKF5KH.js → chunk-7PEZU5Y4.js} +1 -1
- package/dist/{chunk-7HL23T3T.js → chunk-BU6VUXWG.js} +2 -2
- package/dist/{chunk-KIQTABBJ.js → chunk-C64UUXTA.js} +3 -3
- package/dist/{chunk-PNLDTRC5.js → chunk-CYPYJIAF.js} +7 -7
- package/dist/{chunk-IRUEHGCR.js → chunk-D4HWMWGE.js} +3 -3
- package/dist/{chunk-CVNCSMVU.js → chunk-DOHU3XHS.js} +46 -6
- package/dist/{chunk-32XPUSY3.js → chunk-FRIUJ534.js} +3 -3
- package/dist/{chunk-AMURQAJX.js → chunk-G35NLPG5.js} +3 -3
- package/dist/{chunk-ZUFHAHTE.js → chunk-HKR56VNF.js} +15 -2
- package/dist/{chunk-ASEXQRA7.js → chunk-IMIHTHF7.js} +8 -6
- package/dist/{chunk-77MBK46T.js → chunk-IOOFLBVM.js} +3 -3
- package/dist/{chunk-3LS3FYEF.js → chunk-JK5WXW4S.js} +2 -2
- package/dist/{chunk-GU7QJ37F.js → chunk-JQ43NVFU.js} +2 -2
- package/dist/{chunk-YECHJJJF.js → chunk-K7Y2IWEB.js} +4 -4
- package/dist/{chunk-VZGPASGD.js → chunk-MG7CUN6R.js} +2 -2
- package/dist/{chunk-NOCU555K.js → chunk-NKOTOW6X.js} +3 -3
- package/dist/{chunk-YDTRKEYY.js → chunk-OBVXDVLE.js} +3 -3
- package/dist/{chunk-TYRVYBHW.js → chunk-OVFQC6FU.js} +235 -176
- package/dist/{chunk-VKAJMHVG.js → chunk-OZVGRDCM.js} +3 -3
- package/dist/{chunk-FC3X7GGJ.js → chunk-R36RWYXE.js} +3 -3
- package/dist/{chunk-Z34CUZCZ.js → chunk-S6E2AM4U.js} +3 -3
- package/dist/chunk-SIIOHBNY.js +38 -0
- package/dist/{chunk-4YKVHCQC.js → chunk-TGVQMKVH.js} +3 -3
- package/dist/{chunk-QU2VRCMM.js → chunk-TL5T4A4E.js} +3 -3
- package/dist/{chunk-6ZLRRC74.js → chunk-WBAPU3AB.js} +40 -2
- package/dist/{chunk-RV7BVTDG.js → chunk-WKXL5XHU.js} +2 -2
- package/dist/{chunk-2CTZW6JQ.js → chunk-XHSHNOAF.js} +12 -11
- package/dist/{chunk-24T5XIJU.js → chunk-YA2ZYCJY.js} +4 -4
- package/dist/{chunk-T7YVY2BV.js → chunk-YILT3CSO.js} +2 -2
- package/dist/{chunk-OUEH4I4X.js → chunk-YJQQ5F5J.js} +3 -3
- package/dist/{chunk-MIV2RU5B.js → chunk-ZETZHHV5.js} +3 -3
- package/dist/{chunk-4ERMPDHV.js → chunk-ZSW5KO5S.js} +21 -17
- package/dist/clarify.d.ts +18 -3
- package/dist/codebase-index/codebase-search-tool.d.ts +2 -3
- package/dist/codebase-index/gitignore.d.ts +1 -1
- package/dist/codebase-index/index.js +7 -7
- package/dist/codebase-index/parser-worker-script.js +1 -1
- package/dist/codebase-index/project-server-endpoint.d.ts +33 -0
- package/dist/codebase-index/project-server.js +6 -5
- package/dist/codebase-index/worker.js +3 -3
- package/dist/diff.js +2 -2
- package/dist/e2e.js +2 -2
- package/dist/edit.js +7 -7
- package/dist/exec.js +2 -2
- package/dist/fetch.js +2 -2
- package/dist/format.js +4 -4
- package/dist/git.js +2 -2
- package/dist/glob.js +3 -3
- package/dist/grep.js +3 -3
- package/dist/index.d.ts +2 -8
- package/dist/index.js +76 -117
- package/dist/install.js +4 -4
- package/dist/json.js +2 -2
- package/dist/kanban.js +2 -2
- package/dist/languages/index.js +2 -2
- package/dist/{legacy-bridge-WVQ4BHDI.js → legacy-bridge-XM2GV665.js} +4 -4
- package/dist/lint.js +4 -4
- package/dist/logs.js +2 -2
- package/dist/outdated.js +2 -2
- package/dist/pack.js +42 -46
- package/dist/{parser-dispatch-UQAB4E6V.js → parser-dispatch-HZDZSIYH.js} +2 -2
- package/dist/patch.js +7 -7
- package/dist/plan.js +4 -4
- package/dist/read-url-content.d.ts +17 -0
- package/dist/read.js +7 -7
- package/dist/replace.js +7 -7
- package/dist/session-kanban.js +1 -1
- package/dist/session-shell.d.ts +12 -0
- package/dist/session-shell.js +8 -0
- package/dist/task.js +4 -4
- package/dist/test.js +4 -4
- package/dist/todo.js +3 -3
- package/dist/tool-search.js +1 -1
- package/dist/tool-tier.d.ts +12 -2
- package/dist/tool-tier.js +43 -47
- package/dist/tree.js +2 -2
- package/dist/typecheck.js +4 -4
- package/dist/write.js +7 -7
- package/package.json +9 -21
- package/dist/batch-tool-use.d.ts +0 -24
- package/dist/batch-tool-use.js +0 -7
- package/dist/chunk-7ODZTPCU.js +0 -128
- package/dist/chunk-CHEK3ASV.js +0 -183
- package/dist/chunk-KLJZ4WV4.js +0 -213
- package/dist/chunk-VBF2YXUW.js +0 -203
- package/dist/document.d.ts +0 -25
- package/dist/document.js +0 -8
- package/dist/scaffold.d.ts +0 -23
- package/dist/scaffold.js +0 -10
- package/dist/set-working-dir.d.ts +0 -17
- package/dist/tool-help.d.ts +0 -21
- package/dist/tool-help.js +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wrongstack/tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "WrongStack built-in tools: read/write/edit, bash/exec, grep/glob, git, fetch, test, lint, and more.",
|
|
6
6
|
"repository": {
|
|
@@ -160,14 +160,6 @@
|
|
|
160
160
|
"types": "./dist/logs.d.ts",
|
|
161
161
|
"import": "./dist/logs.js"
|
|
162
162
|
},
|
|
163
|
-
"./document": {
|
|
164
|
-
"types": "./dist/document.d.ts",
|
|
165
|
-
"import": "./dist/document.js"
|
|
166
|
-
},
|
|
167
|
-
"./scaffold": {
|
|
168
|
-
"types": "./dist/scaffold.d.ts",
|
|
169
|
-
"import": "./dist/scaffold.js"
|
|
170
|
-
},
|
|
171
163
|
"./tool-search": {
|
|
172
164
|
"types": "./dist/tool-search.d.ts",
|
|
173
165
|
"import": "./dist/tool-search.js"
|
|
@@ -176,14 +168,6 @@
|
|
|
176
168
|
"types": "./dist/tool-use.d.ts",
|
|
177
169
|
"import": "./dist/tool-use.js"
|
|
178
170
|
},
|
|
179
|
-
"./batch-tool-use": {
|
|
180
|
-
"types": "./dist/batch-tool-use.d.ts",
|
|
181
|
-
"import": "./dist/batch-tool-use.js"
|
|
182
|
-
},
|
|
183
|
-
"./tool-help": {
|
|
184
|
-
"types": "./dist/tool-help.d.ts",
|
|
185
|
-
"import": "./dist/tool-help.js"
|
|
186
|
-
},
|
|
187
171
|
"./memory": {
|
|
188
172
|
"types": "./dist/memory.d.ts",
|
|
189
173
|
"import": "./dist/memory.js"
|
|
@@ -220,6 +204,10 @@
|
|
|
220
204
|
"types": "./dist/session-kanban.d.ts",
|
|
221
205
|
"import": "./dist/session-kanban.js"
|
|
222
206
|
},
|
|
207
|
+
"./session-shell": {
|
|
208
|
+
"types": "./dist/session-shell.d.ts",
|
|
209
|
+
"import": "./dist/session-shell.js"
|
|
210
|
+
},
|
|
223
211
|
"./process-registry": {
|
|
224
212
|
"types": "./dist/process-registry.d.ts",
|
|
225
213
|
"import": "./dist/process-registry.js"
|
|
@@ -249,10 +237,10 @@
|
|
|
249
237
|
"@msgpack/msgpack": "^3.1.3",
|
|
250
238
|
"@playwright/test": "^1.62.1",
|
|
251
239
|
"@typescript/typescript6": "^6.0.2",
|
|
252
|
-
"@wrongstack/core": "1.0.
|
|
253
|
-
"@wrongstack/kanban": "1.0.
|
|
254
|
-
"@wrongstack/persistence": "1.0.
|
|
255
|
-
"@wrongstack/primitives": "1.0.
|
|
240
|
+
"@wrongstack/core": "1.0.5",
|
|
241
|
+
"@wrongstack/kanban": "1.0.5",
|
|
242
|
+
"@wrongstack/persistence": "1.0.5",
|
|
243
|
+
"@wrongstack/primitives": "1.0.5",
|
|
256
244
|
"tree-sitter-wasm": "1.1.4",
|
|
257
245
|
"turndown": "^7.2.4",
|
|
258
246
|
"undici": "^8.10.0",
|
package/dist/batch-tool-use.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type Tool } from '@wrongstack/core/types';
|
|
2
|
-
export interface BatchToolUseInput {
|
|
3
|
-
calls: {
|
|
4
|
-
tool: string;
|
|
5
|
-
input: Record<string, unknown>;
|
|
6
|
-
}[];
|
|
7
|
-
stop_on_error?: boolean | undefined;
|
|
8
|
-
parallel?: boolean | undefined;
|
|
9
|
-
}
|
|
10
|
-
export interface BatchToolUseOutput {
|
|
11
|
-
results: {
|
|
12
|
-
tool: string;
|
|
13
|
-
success: boolean;
|
|
14
|
-
result?: unknown | undefined;
|
|
15
|
-
error?: string | undefined;
|
|
16
|
-
executionMs: number;
|
|
17
|
-
}[];
|
|
18
|
-
total: number;
|
|
19
|
-
succeeded: number;
|
|
20
|
-
failed: number;
|
|
21
|
-
stop_on_error: boolean;
|
|
22
|
-
}
|
|
23
|
-
export declare const batchToolUseTool: Tool<BatchToolUseInput, BatchToolUseOutput>;
|
|
24
|
-
//# sourceMappingURL=batch-tool-use.d.ts.map
|
package/dist/batch-tool-use.js
DELETED
package/dist/chunk-7ODZTPCU.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// src/tool-help.ts
|
|
2
|
-
var toolHelpTool = {
|
|
3
|
-
name: "tool_help",
|
|
4
|
-
category: "Meta",
|
|
5
|
-
description: "Get detailed help for a specific tool, including its full input schema and usage guidance. If you do not know which tool to use, search with `tool_search` first, then call this with the tool name.",
|
|
6
|
-
usageHint: "USE WHEN YOU NEED PRECISE TOOL INFORMATION:\n\n- Call with a specific `tool` name when you want the full schema and current usageHint.\n- Omit `tool` to get an overview of all available tools.\n- Different `format` options give you different levels of detail.\n- Tip: use `tool_search` to find the right tool name, then `tool_help` for the full schema.\nThis tool is extremely valuable for self-correction when you are unsure about a tool's interface.",
|
|
7
|
-
permission: "auto",
|
|
8
|
-
mutating: false,
|
|
9
|
-
timeoutMs: 5e3,
|
|
10
|
-
capabilities: ["tool.meta"],
|
|
11
|
-
icon: "meta",
|
|
12
|
-
inputSchema: {
|
|
13
|
-
type: "object",
|
|
14
|
-
properties: {
|
|
15
|
-
tool: {
|
|
16
|
-
type: "string",
|
|
17
|
-
description: "Specific tool name to get detailed help for. Omit to get a list of all tools."
|
|
18
|
-
},
|
|
19
|
-
format: {
|
|
20
|
-
type: "string",
|
|
21
|
-
enum: ["short", "full", "markdown"],
|
|
22
|
-
description: 'Level of detail: "short" (summary), "full" (with full schema), "markdown" (human readable).'
|
|
23
|
-
},
|
|
24
|
-
include_examples: {
|
|
25
|
-
type: "boolean",
|
|
26
|
-
description: "Whether to include example usage in the response."
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
async execute(input, ctx) {
|
|
31
|
-
const format = input.format ?? "short";
|
|
32
|
-
const includeExamples = input.include_examples ?? false;
|
|
33
|
-
if (input.tool) {
|
|
34
|
-
const tool = (ctx.catalogTools ?? ctx.tools).find((t) => t.name === input.tool);
|
|
35
|
-
if (!tool) {
|
|
36
|
-
return {
|
|
37
|
-
tool: input.tool,
|
|
38
|
-
help: `No tool found with name "${input.tool}"`,
|
|
39
|
-
tools: [],
|
|
40
|
-
total: 0
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
tool: tool.name,
|
|
45
|
-
help: formatToolHelp(tool, format, includeExamples),
|
|
46
|
-
tools: [
|
|
47
|
-
{
|
|
48
|
-
name: tool.name,
|
|
49
|
-
description: tool.description,
|
|
50
|
-
usageHint: tool.usageHint ?? "",
|
|
51
|
-
inputSchema: tool.inputSchema,
|
|
52
|
-
permission: tool.permission,
|
|
53
|
-
mutating: tool.mutating
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
|
-
total: 1
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
const allTools = (ctx.catalogTools ?? ctx.tools).map((t) => ({
|
|
60
|
-
name: t.name,
|
|
61
|
-
description: t.description,
|
|
62
|
-
usageHint: t.usageHint ?? "",
|
|
63
|
-
inputSchema: format === "full" ? t.inputSchema : void 0,
|
|
64
|
-
permission: t.permission,
|
|
65
|
-
mutating: t.mutating
|
|
66
|
-
}));
|
|
67
|
-
return {
|
|
68
|
-
help: format === "markdown" ? formatAllToolsMarkdown(allTools) : formatAllToolsShort(allTools),
|
|
69
|
-
tools: allTools,
|
|
70
|
-
total: allTools.length
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
function formatToolHelp(tool, format, includeExamples) {
|
|
75
|
-
const lines = [];
|
|
76
|
-
if (format === "short") {
|
|
77
|
-
lines.push(`${tool.name}: ${tool.description}`);
|
|
78
|
-
if (tool.usageHint) lines.push(`Hint: ${tool.usageHint}`);
|
|
79
|
-
return lines.join("\n");
|
|
80
|
-
}
|
|
81
|
-
if (format === "markdown") {
|
|
82
|
-
lines.push(`## ${tool.name}`);
|
|
83
|
-
lines.push("");
|
|
84
|
-
lines.push(tool.description);
|
|
85
|
-
lines.push("");
|
|
86
|
-
lines.push("**Permission:** " + tool.permission);
|
|
87
|
-
lines.push("**Mutating:** " + (tool.mutating ? "yes" : "no"));
|
|
88
|
-
if (tool.usageHint) {
|
|
89
|
-
lines.push("");
|
|
90
|
-
lines.push("### Usage Hint");
|
|
91
|
-
lines.push(tool.usageHint);
|
|
92
|
-
}
|
|
93
|
-
if (includeExamples && tool.inputSchema) {
|
|
94
|
-
lines.push("");
|
|
95
|
-
lines.push("### Input Schema");
|
|
96
|
-
lines.push("```json");
|
|
97
|
-
lines.push(JSON.stringify(tool.inputSchema, null, 2));
|
|
98
|
-
lines.push("```");
|
|
99
|
-
}
|
|
100
|
-
return lines.join("\n");
|
|
101
|
-
}
|
|
102
|
-
lines.push(`Tool: ${tool.name}`);
|
|
103
|
-
lines.push(`Description: ${tool.description}`);
|
|
104
|
-
lines.push(`Permission: ${tool.permission}`);
|
|
105
|
-
lines.push(`Mutating: ${tool.mutating}`);
|
|
106
|
-
if (tool.usageHint) lines.push(`Usage: ${tool.usageHint}`);
|
|
107
|
-
if (format === "full" && tool.inputSchema) {
|
|
108
|
-
lines.push("Schema: " + JSON.stringify(tool.inputSchema, null, 2));
|
|
109
|
-
}
|
|
110
|
-
return lines.join("\n");
|
|
111
|
-
}
|
|
112
|
-
function formatAllToolsShort(tools) {
|
|
113
|
-
return tools.map((t) => ` ${t.name.padEnd(16)} ${t.description}`).join("\n");
|
|
114
|
-
}
|
|
115
|
-
function formatAllToolsMarkdown(tools) {
|
|
116
|
-
const lines = ["## Available Tools", ""];
|
|
117
|
-
lines.push("| Tool | Description |");
|
|
118
|
-
lines.push("|------|-------------|");
|
|
119
|
-
for (const t of tools) {
|
|
120
|
-
lines.push(`| \`${t.name}\` | ${t.description.replaceAll("|", "\\|")} |`);
|
|
121
|
-
}
|
|
122
|
-
return lines.join("\n");
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export {
|
|
126
|
-
toolHelpTool
|
|
127
|
-
};
|
|
128
|
-
//# sourceMappingURL=chunk-7ODZTPCU.js.map
|
package/dist/chunk-CHEK3ASV.js
DELETED
|
@@ -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
|
package/dist/chunk-KLJZ4WV4.js
DELETED
|
@@ -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
|