@caupulican/pi-adaptative 0.80.42 → 0.80.45
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/CHANGELOG.md +24 -0
- package/dist/bundled-resources/prompts/extensionify.md +20 -0
- package/dist/bundled-resources/prompts/learn.md +27 -0
- package/dist/bundled-resources/prompts/skillify.md +21 -0
- package/dist/bundled-resources/skills/pi-harness-learning/SKILL.md +217 -0
- package/dist/bundled-resources/skills/skill-architect/SKILL.md +162 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +30 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +37 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +215 -9
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +27 -5
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +10 -3
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +38 -7
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +6 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +53 -6
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +16 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/profile-registry.d.ts +39 -0
- package/dist/core/profile-registry.d.ts.map +1 -0
- package/dist/core/profile-registry.js +230 -0
- package/dist/core/profile-registry.js.map +1 -0
- package/dist/core/profile-resource-selection.d.ts +19 -0
- package/dist/core/profile-resource-selection.d.ts.map +1 -0
- package/dist/core/profile-resource-selection.js +84 -0
- package/dist/core/profile-resource-selection.js.map +1 -0
- package/dist/core/resource-loader.d.ts +33 -3
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +68 -11
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/settings-manager.d.ts +44 -2
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +557 -27
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +5 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +2 -2
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +5 -17
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/extensionify.d.ts +33 -0
- package/dist/core/tools/extensionify.d.ts.map +1 -0
- package/dist/core/tools/extensionify.js +146 -0
- package/dist/core/tools/extensionify.js.map +1 -0
- package/dist/core/tools/index.d.ts +10 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +36 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/skill-audit.d.ts +63 -0
- package/dist/core/tools/skill-audit.d.ts.map +1 -0
- package/dist/core/tools/skill-audit.js +175 -0
- package/dist/core/tools/skill-audit.js.map +1 -0
- package/dist/core/tools/skillify.d.ts +30 -0
- package/dist/core/tools/skillify.d.ts.map +1 -0
- package/dist/core/tools/skillify.js +91 -0
- package/dist/core/tools/skillify.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.d.ts +50 -0
- package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/profile-resource-editor.js +232 -0
- package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -0
- package/dist/modes/interactive/components/profile-selector.d.ts +8 -0
- package/dist/modes/interactive/components/profile-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/profile-selector.js +77 -0
- package/dist/modes/interactive/components/profile-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +8 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +75 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +14 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +434 -24
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/settings.md +20 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/12-full-control.ts +4 -0
- package/npm-shrinkwrap.json +12 -12
- package/package.json +6 -6
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { Type } from "typebox";
|
|
5
|
+
import { createEventBus } from "../event-bus.js";
|
|
6
|
+
import { createExtensionRuntime, loadExtension } from "../extensions/loader.js";
|
|
7
|
+
import { wrapToolDefinition } from "./tool-definition-wrapper.js";
|
|
8
|
+
const extensionifySchema = Type.Object({
|
|
9
|
+
name: Type.String({ description: "Extension name (lowercase, a-z 0-9 hyphens only)" }),
|
|
10
|
+
code: Type.String({ description: "Extension factory code (TypeScript/JavaScript)" }),
|
|
11
|
+
packageJson: Type.Optional(Type.String({ description: "Optional package.json content as JSON string" })),
|
|
12
|
+
});
|
|
13
|
+
export function createExtensionifyToolDefinition(_cwd, _options) {
|
|
14
|
+
return {
|
|
15
|
+
name: "extensionify",
|
|
16
|
+
label: "extensionify",
|
|
17
|
+
description: "Smoke-test a draft extension in an isolated throwaway runtime. Pure analysis tool: creates temporary scaffold, loads it, inspects registrations, then completely deletes temp dir. Does NOT write to the real extensions dir or modify the live runtime. Returns proposal with registration details.",
|
|
18
|
+
promptSnippet: "Smoke-test a draft extension",
|
|
19
|
+
promptGuidelines: [
|
|
20
|
+
"Use extensionify to validate draft extensions before creating them.",
|
|
21
|
+
"Fix any factory errors or registration issues; review tools and commands registered.",
|
|
22
|
+
"The tool runs in complete isolation; the live session is never touched.",
|
|
23
|
+
"Persistent write and activation happen later via a separate step.",
|
|
24
|
+
],
|
|
25
|
+
parameters: extensionifySchema,
|
|
26
|
+
async execute(_toolCallId, { name, code, packageJson }, _signal, _onUpdate, _ctx) {
|
|
27
|
+
const diagnostics = [];
|
|
28
|
+
let smokeTestPassed = false;
|
|
29
|
+
const registeredTools = [];
|
|
30
|
+
const registeredCommands = [];
|
|
31
|
+
const proposedPath = join(homedir(), ".pi", "agent", "extensions", name);
|
|
32
|
+
// Create a temporary directory for the test extension
|
|
33
|
+
let tempDir = null;
|
|
34
|
+
try {
|
|
35
|
+
const tempRoot = require("node:os").tmpdir();
|
|
36
|
+
tempDir = mkdtempSync(join(tempRoot, `extensionify-${Date.now()}-`));
|
|
37
|
+
// Write index.ts with the factory code
|
|
38
|
+
const indexPath = join(tempDir, "index.ts");
|
|
39
|
+
writeFileSync(indexPath, code, "utf-8");
|
|
40
|
+
// Write package.json if provided
|
|
41
|
+
if (packageJson) {
|
|
42
|
+
const packageJsonPath = join(tempDir, "package.json");
|
|
43
|
+
try {
|
|
44
|
+
// Validate it's valid JSON
|
|
45
|
+
JSON.parse(packageJson);
|
|
46
|
+
writeFileSync(packageJsonPath, packageJson, "utf-8");
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
diagnostics.push(`Invalid package.json: ${err instanceof Error ? err.message : String(err)}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Create isolated runtime and event bus
|
|
53
|
+
const eventBus = createEventBus();
|
|
54
|
+
const runtime = createExtensionRuntime();
|
|
55
|
+
// Load the extension in isolation
|
|
56
|
+
const { extension, error: loadError } = await loadExtension(indexPath, tempDir, eventBus, runtime, {
|
|
57
|
+
fresh: true,
|
|
58
|
+
});
|
|
59
|
+
if (loadError) {
|
|
60
|
+
diagnostics.push(`Factory error: ${loadError}`);
|
|
61
|
+
smokeTestPassed = false;
|
|
62
|
+
}
|
|
63
|
+
else if (extension) {
|
|
64
|
+
smokeTestPassed = true;
|
|
65
|
+
// Inspect registered tools
|
|
66
|
+
for (const [toolName] of extension.tools) {
|
|
67
|
+
registeredTools.push(toolName);
|
|
68
|
+
}
|
|
69
|
+
// Inspect registered commands
|
|
70
|
+
for (const [cmdName] of extension.commands) {
|
|
71
|
+
registeredCommands.push(cmdName);
|
|
72
|
+
}
|
|
73
|
+
if (registeredTools.length === 0 && registeredCommands.length === 0) {
|
|
74
|
+
diagnostics.push("Extension loaded but registered no tools or commands");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
diagnostics.push(`Test error: ${err instanceof Error ? err.message : String(err)}`);
|
|
80
|
+
smokeTestPassed = false;
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
// Always clean up the temporary directory
|
|
84
|
+
if (tempDir) {
|
|
85
|
+
try {
|
|
86
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
87
|
+
}
|
|
88
|
+
catch (cleanupErr) {
|
|
89
|
+
diagnostics.push(`Cleanup warning: ${cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr)}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const ok = smokeTestPassed && diagnostics.length === 0;
|
|
94
|
+
const report = {
|
|
95
|
+
ok,
|
|
96
|
+
smokeTestPassed,
|
|
97
|
+
diagnostics,
|
|
98
|
+
registered: {
|
|
99
|
+
tools: registeredTools,
|
|
100
|
+
commands: registeredCommands,
|
|
101
|
+
},
|
|
102
|
+
proposedPath,
|
|
103
|
+
draft: { name, code, packageJson },
|
|
104
|
+
};
|
|
105
|
+
// Format the report as readable text
|
|
106
|
+
const lines = [];
|
|
107
|
+
lines.push(`Extensionify smoke-test: ${smokeTestPassed ? "✓ passed" : "✗ failed"}`);
|
|
108
|
+
if (diagnostics.length > 0) {
|
|
109
|
+
lines.push("\nDiagnostics:");
|
|
110
|
+
for (const diag of diagnostics) {
|
|
111
|
+
lines.push(`- ${diag}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (smokeTestPassed) {
|
|
115
|
+
lines.push("\n✓ No errors during factory execution.");
|
|
116
|
+
}
|
|
117
|
+
if (registeredTools.length > 0) {
|
|
118
|
+
lines.push(`\nRegistered tools (${registeredTools.length}):`);
|
|
119
|
+
for (const toolName of registeredTools) {
|
|
120
|
+
lines.push(`- ${toolName}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (registeredCommands.length > 0) {
|
|
124
|
+
lines.push(`\nRegistered commands (${registeredCommands.length}):`);
|
|
125
|
+
for (const cmdName of registeredCommands) {
|
|
126
|
+
lines.push(`- ${cmdName}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (registeredTools.length === 0 && registeredCommands.length === 0 && smokeTestPassed) {
|
|
130
|
+
lines.push("\n⚠ Extension loaded but registered nothing.");
|
|
131
|
+
}
|
|
132
|
+
if (ok) {
|
|
133
|
+
lines.push("\n✓ Extension ready for creation.");
|
|
134
|
+
}
|
|
135
|
+
lines.push(`\nProposed install path: ${proposedPath}`);
|
|
136
|
+
return {
|
|
137
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
138
|
+
details: report,
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export function createExtensionifyTool(cwd, options) {
|
|
144
|
+
return wrapToolDefinition(createExtensionifyToolDefinition(cwd, options));
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=extensionify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensionify.js","sourceRoot":"","sources":["../../../src/core/tools/extensionify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAEhF,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;IACtF,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;IACpF,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC,CAAC;CACxG,CAAC,CAAC;AA0BH,MAAM,UAAU,gCAAgC,CAC/C,IAAY,EACZ,QAAkC,EAC8B;IAChE,OAAO;QACN,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,cAAc;QACrB,WAAW,EACV,sSAAsS;QACvS,aAAa,EAAE,8BAA8B;QAC7C,gBAAgB,EAAE;YACjB,qEAAqE;YACrE,sFAAsF;YACtF,yEAAyE;YACzE,mEAAmE;SACnE;QACD,UAAU,EAAE,kBAAkB;QAC9B,KAAK,CAAC,OAAO,C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{ homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport { type Static, Type } from \"typebox\";\nimport { createEventBus } from \"../event-bus.ts\";\nimport { createExtensionRuntime, loadExtension } from \"../extensions/loader.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst extensionifySchema = Type.Object({\n\tname: Type.String({ description: \"Extension name (lowercase, a-z 0-9 hyphens only)\" }),\n\tcode: Type.String({ description: \"Extension factory code (TypeScript/JavaScript)\" }),\n\tpackageJson: Type.Optional(Type.String({ description: \"Optional package.json content as JSON string\" })),\n});\n\nexport type ExtensionifyInput = Static<typeof extensionifySchema>;\n\nexport interface ExtensionifyReport {\n\tok: boolean;\n\tsmokeTestPassed: boolean;\n\tdiagnostics: string[];\n\tregistered: {\n\t\ttools: string[];\n\t\tcommands: string[];\n\t};\n\tproposedPath: string;\n\tdraft: {\n\t\tname: string;\n\t\tcode: string;\n\t\tpackageJson?: string;\n\t};\n}\n\nexport interface ExtensionifyToolDetails {\n\treport?: ExtensionifyReport;\n}\n\nexport interface ExtensionifyToolOptions {}\n\nexport function createExtensionifyToolDefinition(\n\t_cwd: string,\n\t_options?: ExtensionifyToolOptions,\n): ToolDefinition<typeof extensionifySchema, ExtensionifyReport> {\n\treturn {\n\t\tname: \"extensionify\",\n\t\tlabel: \"extensionify\",\n\t\tdescription:\n\t\t\t\"Smoke-test a draft extension in an isolated throwaway runtime. Pure analysis tool: creates temporary scaffold, loads it, inspects registrations, then completely deletes temp dir. Does NOT write to the real extensions dir or modify the live runtime. Returns proposal with registration details.\",\n\t\tpromptSnippet: \"Smoke-test a draft extension\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use extensionify to validate draft extensions before creating them.\",\n\t\t\t\"Fix any factory errors or registration issues; review tools and commands registered.\",\n\t\t\t\"The tool runs in complete isolation; the live session is never touched.\",\n\t\t\t\"Persistent write and activation happen later via a separate step.\",\n\t\t],\n\t\tparameters: extensionifySchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ name, code, packageJson }: ExtensionifyInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: ExtensionifyReport;\n\t\t}> {\n\t\t\tconst diagnostics: string[] = [];\n\t\t\tlet smokeTestPassed = false;\n\t\t\tconst registeredTools: string[] = [];\n\t\t\tconst registeredCommands: string[] = [];\n\t\t\tconst proposedPath = join(homedir(), \".pi\", \"agent\", \"extensions\", name);\n\n\t\t\t// Create a temporary directory for the test extension\n\t\t\tlet tempDir: string | null = null;\n\t\t\ttry {\n\t\t\t\tconst tempRoot = require(\"node:os\").tmpdir();\n\t\t\t\ttempDir = mkdtempSync(join(tempRoot, `extensionify-${Date.now()}-`));\n\n\t\t\t\t// Write index.ts with the factory code\n\t\t\t\tconst indexPath = join(tempDir, \"index.ts\");\n\t\t\t\twriteFileSync(indexPath, code, \"utf-8\");\n\n\t\t\t\t// Write package.json if provided\n\t\t\t\tif (packageJson) {\n\t\t\t\t\tconst packageJsonPath = join(tempDir, \"package.json\");\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Validate it's valid JSON\n\t\t\t\t\t\tJSON.parse(packageJson);\n\t\t\t\t\t\twriteFileSync(packageJsonPath, packageJson, \"utf-8\");\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tdiagnostics.push(`Invalid package.json: ${err instanceof Error ? err.message : String(err)}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Create isolated runtime and event bus\n\t\t\t\tconst eventBus = createEventBus();\n\t\t\t\tconst runtime = createExtensionRuntime();\n\n\t\t\t\t// Load the extension in isolation\n\t\t\t\tconst { extension, error: loadError } = await loadExtension(indexPath, tempDir, eventBus, runtime, {\n\t\t\t\t\tfresh: true,\n\t\t\t\t});\n\n\t\t\t\tif (loadError) {\n\t\t\t\t\tdiagnostics.push(`Factory error: ${loadError}`);\n\t\t\t\t\tsmokeTestPassed = false;\n\t\t\t\t} else if (extension) {\n\t\t\t\t\tsmokeTestPassed = true;\n\n\t\t\t\t\t// Inspect registered tools\n\t\t\t\t\tfor (const [toolName] of extension.tools) {\n\t\t\t\t\t\tregisteredTools.push(toolName);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Inspect registered commands\n\t\t\t\t\tfor (const [cmdName] of extension.commands) {\n\t\t\t\t\t\tregisteredCommands.push(cmdName);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (registeredTools.length === 0 && registeredCommands.length === 0) {\n\t\t\t\t\t\tdiagnostics.push(\"Extension loaded but registered no tools or commands\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tdiagnostics.push(`Test error: ${err instanceof Error ? err.message : String(err)}`);\n\t\t\t\tsmokeTestPassed = false;\n\t\t\t} finally {\n\t\t\t\t// Always clean up the temporary directory\n\t\t\t\tif (tempDir) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\trmSync(tempDir, { recursive: true, force: true });\n\t\t\t\t\t} catch (cleanupErr) {\n\t\t\t\t\t\tdiagnostics.push(\n\t\t\t\t\t\t\t`Cleanup warning: ${cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst ok = smokeTestPassed && diagnostics.length === 0;\n\n\t\t\tconst report: ExtensionifyReport = {\n\t\t\t\tok,\n\t\t\t\tsmokeTestPassed,\n\t\t\t\tdiagnostics,\n\t\t\t\tregistered: {\n\t\t\t\t\ttools: registeredTools,\n\t\t\t\t\tcommands: registeredCommands,\n\t\t\t\t},\n\t\t\t\tproposedPath,\n\t\t\t\tdraft: { name, code, packageJson },\n\t\t\t};\n\n\t\t\t// Format the report as readable text\n\t\t\tconst lines: string[] = [];\n\t\t\tlines.push(`Extensionify smoke-test: ${smokeTestPassed ? \"✓ passed\" : \"✗ failed\"}`);\n\n\t\t\tif (diagnostics.length > 0) {\n\t\t\t\tlines.push(\"\\nDiagnostics:\");\n\t\t\t\tfor (const diag of diagnostics) {\n\t\t\t\t\tlines.push(`- ${diag}`);\n\t\t\t\t}\n\t\t\t} else if (smokeTestPassed) {\n\t\t\t\tlines.push(\"\\n✓ No errors during factory execution.\");\n\t\t\t}\n\n\t\t\tif (registeredTools.length > 0) {\n\t\t\t\tlines.push(`\\nRegistered tools (${registeredTools.length}):`);\n\t\t\t\tfor (const toolName of registeredTools) {\n\t\t\t\t\tlines.push(`- ${toolName}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (registeredCommands.length > 0) {\n\t\t\t\tlines.push(`\\nRegistered commands (${registeredCommands.length}):`);\n\t\t\t\tfor (const cmdName of registeredCommands) {\n\t\t\t\t\tlines.push(`- ${cmdName}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (registeredTools.length === 0 && registeredCommands.length === 0 && smokeTestPassed) {\n\t\t\t\tlines.push(\"\\n⚠ Extension loaded but registered nothing.\");\n\t\t\t}\n\n\t\t\tif (ok) {\n\t\t\t\tlines.push(\"\\n✓ Extension ready for creation.\");\n\t\t\t}\n\n\t\t\tlines.push(`\\nProposed install path: ${proposedPath}`);\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: lines.join(\"\\n\") }],\n\t\t\t\tdetails: report,\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport function createExtensionifyTool(\n\tcwd: string,\n\toptions?: ExtensionifyToolOptions,\n): AgentTool<typeof extensionifySchema> {\n\treturn wrapToolDefinition(createExtensionifyToolDefinition(cwd, options));\n}\n"]}
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, createBashTool, createBashToolDefinition, createLocalBashOperations, } from "./bash.ts";
|
|
2
2
|
export { createEditTool, createEditToolDefinition, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, } from "./edit.ts";
|
|
3
|
+
export { createExtensionifyTool, createExtensionifyToolDefinition, type ExtensionifyInput, type ExtensionifyReport, type ExtensionifyToolDetails, type ExtensionifyToolOptions, } from "./extensionify.ts";
|
|
3
4
|
export { withFileMutationQueue } from "./file-mutation-queue.ts";
|
|
4
5
|
export { createFindTool, createFindToolDefinition, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, } from "./find.ts";
|
|
5
6
|
export { createGrepTool, createGrepToolDefinition, type GrepOperations, type GrepToolDetails, type GrepToolInput, type GrepToolOptions, } from "./grep.ts";
|
|
6
7
|
export { createLsTool, createLsToolDefinition, type LsOperations, type LsToolDetails, type LsToolInput, type LsToolOptions, } from "./ls.ts";
|
|
7
8
|
export { createReadTool, createReadToolDefinition, type ReadOperations, type ReadToolDetails, type ReadToolInput, type ReadToolOptions, } from "./read.ts";
|
|
9
|
+
export { createSkillAuditTool, createSkillAuditToolDefinition, jaccard, type SkillAuditInput, type SkillAuditReport, type SkillAuditToolDetails, type SkillAuditToolOptions, tokenize, } from "./skill-audit.ts";
|
|
10
|
+
export { createSkillifyTool, createSkillifyToolDefinition, type SkillifyInput, type SkillifyReport, type SkillifyToolDetails, type SkillifyToolOptions, } from "./skillify.ts";
|
|
8
11
|
export { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationOptions, type TruncationResult, truncateHead, truncateLine, truncateTail, } from "./truncate.ts";
|
|
9
12
|
export { createWriteTool, createWriteToolDefinition, type WriteOperations, type WriteToolInput, type WriteToolOptions, } from "./write.ts";
|
|
10
13
|
import type { AgentTool } from "@caupulican/pi-agent-core";
|
|
11
14
|
import type { ToolDefinition } from "../extensions/types.ts";
|
|
12
15
|
import { type BashToolOptions } from "./bash.ts";
|
|
13
16
|
import { type EditToolOptions } from "./edit.ts";
|
|
17
|
+
import { type ExtensionifyToolOptions } from "./extensionify.ts";
|
|
14
18
|
import { type FindToolOptions } from "./find.ts";
|
|
15
19
|
import { type GrepToolOptions } from "./grep.ts";
|
|
16
20
|
import { type LsToolOptions } from "./ls.ts";
|
|
17
21
|
import { type ReadToolOptions } from "./read.ts";
|
|
22
|
+
import { type SkillAuditToolOptions } from "./skill-audit.ts";
|
|
23
|
+
import { type SkillifyToolOptions } from "./skillify.ts";
|
|
18
24
|
import { type WriteToolOptions } from "./write.ts";
|
|
19
25
|
export type Tool = AgentTool<any>;
|
|
20
26
|
export type ToolDef = ToolDefinition<any, any>;
|
|
21
|
-
export type ToolName = "read" | "bash" | "edit" | "write" | "grep" | "find" | "ls";
|
|
27
|
+
export type ToolName = "read" | "bash" | "edit" | "write" | "grep" | "find" | "ls" | "skill_audit" | "skillify" | "extensionify";
|
|
22
28
|
export declare const allToolNames: Set<ToolName>;
|
|
23
29
|
export interface ToolsOptions {
|
|
24
30
|
read?: ReadToolOptions;
|
|
@@ -28,6 +34,9 @@ export interface ToolsOptions {
|
|
|
28
34
|
grep?: GrepToolOptions;
|
|
29
35
|
find?: FindToolOptions;
|
|
30
36
|
ls?: LsToolOptions;
|
|
37
|
+
skill_audit?: SkillAuditToolOptions;
|
|
38
|
+
skillify?: SkillifyToolOptions;
|
|
39
|
+
extensionify?: ExtensionifyToolOptions;
|
|
31
40
|
}
|
|
32
41
|
export declare function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef;
|
|
33
42
|
export declare function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,W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,6BAA6B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,EAAE,CAO5F;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAUvG;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO7E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAU1F","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\";\nexport const allToolNames: Set<ToolName> = new Set([\"read\", \"bash\", \"edit\", \"write\", \"grep\", \"find\", \"ls\"]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa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AO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAa1F","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport {\n\tcreateExtensionifyTool,\n\tcreateExtensionifyToolDefinition,\n\ttype ExtensionifyInput,\n\ttype ExtensionifyReport,\n\ttype ExtensionifyToolDetails,\n\ttype ExtensionifyToolOptions,\n} from \"./extensionify.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tcreateSkillAuditTool,\n\tcreateSkillAuditToolDefinition,\n\tjaccard,\n\ttype SkillAuditInput,\n\ttype SkillAuditReport,\n\ttype SkillAuditToolDetails,\n\ttype SkillAuditToolOptions,\n\ttokenize,\n} from \"./skill-audit.ts\";\nexport {\n\tcreateSkillifyTool,\n\tcreateSkillifyToolDefinition,\n\ttype SkillifyInput,\n\ttype SkillifyReport,\n\ttype SkillifyToolDetails,\n\ttype SkillifyToolOptions,\n} from \"./skillify.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport {\n\tcreateExtensionifyTool,\n\tcreateExtensionifyToolDefinition,\n\ttype ExtensionifyToolOptions,\n} from \"./extensionify.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createSkillAuditTool, createSkillAuditToolDefinition, type SkillAuditToolOptions } from \"./skill-audit.ts\";\nimport { createSkillifyTool, createSkillifyToolDefinition, type SkillifyToolOptions } from \"./skillify.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"grep\"\n\t| \"find\"\n\t| \"ls\"\n\t| \"skill_audit\"\n\t| \"skillify\"\n\t| \"extensionify\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"skill_audit\",\n\t\"skillify\",\n\t\"extensionify\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n\tskill_audit?: SkillAuditToolOptions;\n\tskillify?: SkillifyToolOptions;\n\textensionify?: ExtensionifyToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"skill_audit\":\n\t\t\treturn createSkillAuditToolDefinition(cwd, options?.skill_audit);\n\t\tcase \"skillify\":\n\t\t\treturn createSkillifyToolDefinition(cwd, options?.skillify);\n\t\tcase \"extensionify\":\n\t\t\treturn createExtensionifyToolDefinition(cwd, options?.extensionify);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"skill_audit\":\n\t\t\treturn createSkillAuditTool(cwd, options?.skill_audit);\n\t\tcase \"skillify\":\n\t\t\treturn createSkillifyTool(cwd, options?.skillify);\n\t\tcase \"extensionify\":\n\t\t\treturn createExtensionifyTool(cwd, options?.extensionify);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tskill_audit: createSkillAuditToolDefinition(cwd, options?.skill_audit),\n\t\tskillify: createSkillifyToolDefinition(cwd, options?.skillify),\n\t\textensionify: createExtensionifyToolDefinition(cwd, options?.extensionify),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tskill_audit: createSkillAuditTool(cwd, options?.skill_audit),\n\t\tskillify: createSkillifyTool(cwd, options?.skillify),\n\t\textensionify: createExtensionifyTool(cwd, options?.extensionify),\n\t};\n}\n"]}
|
package/dist/core/tools/index.js
CHANGED
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
export { createBashTool, createBashToolDefinition, createLocalBashOperations, } from "./bash.js";
|
|
2
2
|
export { createEditTool, createEditToolDefinition, } from "./edit.js";
|
|
3
|
+
export { createExtensionifyTool, createExtensionifyToolDefinition, } from "./extensionify.js";
|
|
3
4
|
export { withFileMutationQueue } from "./file-mutation-queue.js";
|
|
4
5
|
export { createFindTool, createFindToolDefinition, } from "./find.js";
|
|
5
6
|
export { createGrepTool, createGrepToolDefinition, } from "./grep.js";
|
|
6
7
|
export { createLsTool, createLsToolDefinition, } from "./ls.js";
|
|
7
8
|
export { createReadTool, createReadToolDefinition, } from "./read.js";
|
|
9
|
+
export { createSkillAuditTool, createSkillAuditToolDefinition, jaccard, tokenize, } from "./skill-audit.js";
|
|
10
|
+
export { createSkillifyTool, createSkillifyToolDefinition, } from "./skillify.js";
|
|
8
11
|
export { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead, truncateLine, truncateTail, } from "./truncate.js";
|
|
9
12
|
export { createWriteTool, createWriteToolDefinition, } from "./write.js";
|
|
10
13
|
import { createBashTool, createBashToolDefinition } from "./bash.js";
|
|
11
14
|
import { createEditTool, createEditToolDefinition } from "./edit.js";
|
|
15
|
+
import { createExtensionifyTool, createExtensionifyToolDefinition, } from "./extensionify.js";
|
|
12
16
|
import { createFindTool, createFindToolDefinition } from "./find.js";
|
|
13
17
|
import { createGrepTool, createGrepToolDefinition } from "./grep.js";
|
|
14
18
|
import { createLsTool, createLsToolDefinition } from "./ls.js";
|
|
15
19
|
import { createReadTool, createReadToolDefinition } from "./read.js";
|
|
20
|
+
import { createSkillAuditTool, createSkillAuditToolDefinition } from "./skill-audit.js";
|
|
21
|
+
import { createSkillifyTool, createSkillifyToolDefinition } from "./skillify.js";
|
|
16
22
|
import { createWriteTool, createWriteToolDefinition } from "./write.js";
|
|
17
|
-
export const allToolNames = new Set([
|
|
23
|
+
export const allToolNames = new Set([
|
|
24
|
+
"read",
|
|
25
|
+
"bash",
|
|
26
|
+
"edit",
|
|
27
|
+
"write",
|
|
28
|
+
"grep",
|
|
29
|
+
"find",
|
|
30
|
+
"ls",
|
|
31
|
+
"skill_audit",
|
|
32
|
+
"skillify",
|
|
33
|
+
"extensionify",
|
|
34
|
+
]);
|
|
18
35
|
export function createToolDefinition(toolName, cwd, options) {
|
|
19
36
|
switch (toolName) {
|
|
20
37
|
case "read":
|
|
@@ -31,6 +48,12 @@ export function createToolDefinition(toolName, cwd, options) {
|
|
|
31
48
|
return createFindToolDefinition(cwd, options?.find);
|
|
32
49
|
case "ls":
|
|
33
50
|
return createLsToolDefinition(cwd, options?.ls);
|
|
51
|
+
case "skill_audit":
|
|
52
|
+
return createSkillAuditToolDefinition(cwd, options?.skill_audit);
|
|
53
|
+
case "skillify":
|
|
54
|
+
return createSkillifyToolDefinition(cwd, options?.skillify);
|
|
55
|
+
case "extensionify":
|
|
56
|
+
return createExtensionifyToolDefinition(cwd, options?.extensionify);
|
|
34
57
|
default:
|
|
35
58
|
throw new Error(`Unknown tool name: ${toolName}`);
|
|
36
59
|
}
|
|
@@ -51,6 +74,12 @@ export function createTool(toolName, cwd, options) {
|
|
|
51
74
|
return createFindTool(cwd, options?.find);
|
|
52
75
|
case "ls":
|
|
53
76
|
return createLsTool(cwd, options?.ls);
|
|
77
|
+
case "skill_audit":
|
|
78
|
+
return createSkillAuditTool(cwd, options?.skill_audit);
|
|
79
|
+
case "skillify":
|
|
80
|
+
return createSkillifyTool(cwd, options?.skillify);
|
|
81
|
+
case "extensionify":
|
|
82
|
+
return createExtensionifyTool(cwd, options?.extensionify);
|
|
54
83
|
default:
|
|
55
84
|
throw new Error(`Unknown tool name: ${toolName}`);
|
|
56
85
|
}
|
|
@@ -80,6 +109,9 @@ export function createAllToolDefinitions(cwd, options) {
|
|
|
80
109
|
grep: createGrepToolDefinition(cwd, options?.grep),
|
|
81
110
|
find: createFindToolDefinition(cwd, options?.find),
|
|
82
111
|
ls: createLsToolDefinition(cwd, options?.ls),
|
|
112
|
+
skill_audit: createSkillAuditToolDefinition(cwd, options?.skill_audit),
|
|
113
|
+
skillify: createSkillifyToolDefinition(cwd, options?.skillify),
|
|
114
|
+
extensionify: createExtensionifyToolDefinition(cwd, options?.extensionify),
|
|
83
115
|
};
|
|
84
116
|
}
|
|
85
117
|
export function createCodingTools(cwd, options) {
|
|
@@ -107,6 +139,9 @@ export function createAllTools(cwd, options) {
|
|
|
107
139
|
grep: createGrepTool(cwd, options?.grep),
|
|
108
140
|
find: createFindTool(cwd, options?.find),
|
|
109
141
|
ls: createLsTool(cwd, options?.ls),
|
|
142
|
+
skill_audit: createSkillAuditTool(cwd, options?.skill_audit),
|
|
143
|
+
skillify: createSkillifyTool(cwd, options?.skillify),
|
|
144
|
+
extensionify: createExtensionifyTool(cwd, options?.extensionify),
|
|
110
145
|
};
|
|
111
146
|
}
|
|
112
147
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,GAKtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAGV,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,eAAe,EACf,yBAAyB,GAIzB,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAwB,cAAc,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAwB,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAwB,MA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IAAI,CAAC;QAClC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QAClC,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;KAC9B,CAAC;AAAA,CACF;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAsB,EAA0B;IAC3F,OAAO;QACN,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,KAAK,EAAE,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC;QAC3C,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;KAClC,CAAC;AAAA,CACF","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\";\nexport const allToolNames: Set<ToolName> = new Set([\"read\", \"bash\", \"edit\", \"write\", \"grep\", \"find\", \"ls\"]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index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AC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC;QAC3C,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QAClC,WAAW,EAAE,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,CAAC;QAC5D,QAAQ,EAAE,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC;QACpD,YAAY,EAAE,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,CAAC;KAChE,CAAC;AAAA,CACF","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport {\n\tcreateExtensionifyTool,\n\tcreateExtensionifyToolDefinition,\n\ttype ExtensionifyInput,\n\ttype ExtensionifyReport,\n\ttype ExtensionifyToolDetails,\n\ttype ExtensionifyToolOptions,\n} from \"./extensionify.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tcreateSkillAuditTool,\n\tcreateSkillAuditToolDefinition,\n\tjaccard,\n\ttype SkillAuditInput,\n\ttype SkillAuditReport,\n\ttype SkillAuditToolDetails,\n\ttype SkillAuditToolOptions,\n\ttokenize,\n} from \"./skill-audit.ts\";\nexport {\n\tcreateSkillifyTool,\n\tcreateSkillifyToolDefinition,\n\ttype SkillifyInput,\n\ttype SkillifyReport,\n\ttype SkillifyToolDetails,\n\ttype SkillifyToolOptions,\n} from \"./skillify.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport {\n\tcreateExtensionifyTool,\n\tcreateExtensionifyToolDefinition,\n\ttype ExtensionifyToolOptions,\n} from \"./extensionify.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createSkillAuditTool, createSkillAuditToolDefinition, type SkillAuditToolOptions } from \"./skill-audit.ts\";\nimport { createSkillifyTool, createSkillifyToolDefinition, type SkillifyToolOptions } from \"./skillify.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"grep\"\n\t| \"find\"\n\t| \"ls\"\n\t| \"skill_audit\"\n\t| \"skillify\"\n\t| \"extensionify\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"skill_audit\",\n\t\"skillify\",\n\t\"extensionify\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n\tskill_audit?: SkillAuditToolOptions;\n\tskillify?: SkillifyToolOptions;\n\textensionify?: ExtensionifyToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"skill_audit\":\n\t\t\treturn createSkillAuditToolDefinition(cwd, options?.skill_audit);\n\t\tcase \"skillify\":\n\t\t\treturn createSkillifyToolDefinition(cwd, options?.skillify);\n\t\tcase \"extensionify\":\n\t\t\treturn createExtensionifyToolDefinition(cwd, options?.extensionify);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"skill_audit\":\n\t\t\treturn createSkillAuditTool(cwd, options?.skill_audit);\n\t\tcase \"skillify\":\n\t\t\treturn createSkillifyTool(cwd, options?.skillify);\n\t\tcase \"extensionify\":\n\t\t\treturn createExtensionifyTool(cwd, options?.extensionify);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tskill_audit: createSkillAuditToolDefinition(cwd, options?.skill_audit),\n\t\tskillify: createSkillifyToolDefinition(cwd, options?.skillify),\n\t\textensionify: createExtensionifyToolDefinition(cwd, options?.extensionify),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tskill_audit: createSkillAuditTool(cwd, options?.skill_audit),\n\t\tskillify: createSkillifyTool(cwd, options?.skillify),\n\t\textensionify: createExtensionifyTool(cwd, options?.extensionify),\n\t};\n}\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { AgentTool } from "@caupulican/pi-agent-core";
|
|
2
|
+
import { type Static, Type } from "typebox";
|
|
3
|
+
import type { ToolDefinition } from "../extensions/types.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Tokenize text by lowercasing, removing non-alphanumeric chars (except hyphens and colons),
|
|
6
|
+
* splitting on whitespace, and filtering out short tokens and stopwords.
|
|
7
|
+
*/
|
|
8
|
+
export declare function tokenize(text: string): string[];
|
|
9
|
+
/**
|
|
10
|
+
* Calculate Jaccard similarity between two token sets.
|
|
11
|
+
* Jaccard(A, B) = |A ∩ B| / |A ∪ B|
|
|
12
|
+
*/
|
|
13
|
+
export declare function jaccard(a: string[], b: string[]): number;
|
|
14
|
+
export interface SkillSummary {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
path: string;
|
|
18
|
+
scope: string;
|
|
19
|
+
keywords: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface SkillAuditReport {
|
|
22
|
+
generatedAt: string;
|
|
23
|
+
skills: SkillSummary[];
|
|
24
|
+
nearDuplicates: Array<{
|
|
25
|
+
a: string;
|
|
26
|
+
b: string;
|
|
27
|
+
similarity: number;
|
|
28
|
+
reason: string;
|
|
29
|
+
}>;
|
|
30
|
+
compartmentWarnings: Array<{
|
|
31
|
+
skill: string;
|
|
32
|
+
path: string;
|
|
33
|
+
reason: string;
|
|
34
|
+
}>;
|
|
35
|
+
nameCollisions: Array<{
|
|
36
|
+
name: string;
|
|
37
|
+
paths: string[];
|
|
38
|
+
}>;
|
|
39
|
+
recommendations?: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Audit existing skills for overlap and compare against a draft skill.
|
|
43
|
+
*/
|
|
44
|
+
export declare function runSkillAudit(cwd: string, draftSkill?: {
|
|
45
|
+
name?: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
body?: string;
|
|
48
|
+
}): SkillAuditReport;
|
|
49
|
+
declare const skillAuditSchema: Type.TObject<{
|
|
50
|
+
draftName: Type.TOptional<Type.TString>;
|
|
51
|
+
draftDescription: Type.TOptional<Type.TString>;
|
|
52
|
+
draftBody: Type.TOptional<Type.TString>;
|
|
53
|
+
}>;
|
|
54
|
+
export type SkillAuditInput = Static<typeof skillAuditSchema>;
|
|
55
|
+
export interface SkillAuditToolDetails {
|
|
56
|
+
reportPath?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface SkillAuditToolOptions {
|
|
59
|
+
}
|
|
60
|
+
export declare function createSkillAuditToolDefinition(cwd: string, _options?: SkillAuditToolOptions): ToolDefinition<typeof skillAuditSchema, SkillAuditReport>;
|
|
61
|
+
export declare function createSkillAuditTool(cwd: string, options?: SkillAuditToolOptions): AgentTool<typeof skillAuditSchema>;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=skill-audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-audit.d.ts","sourceRoot":"","sources":["../../../src/core/tools/skill-audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAY7D;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAU/C;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAQxD;AAED,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ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AqB,GAAG,SAAS,CAAC,OAAO,gBAAgB,CAAC,CAErH","sourcesContent":["import type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport { type Static, Type } from \"typebox\";\nimport { getAgentDir } from \"../../config.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { loadSkills, type Skill } from \"../skills.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst DUPLICATE_THRESHOLD = 0.55;\n\nconst STOPWORDS = new Set(\n\t\"the a an and or of for to with when use using from into this that skill task work working project agent agents code files file in on by as is are be do not should about\".split(\n\t\t\" \",\n\t),\n);\n\n/**\n * Tokenize text by lowercasing, removing non-alphanumeric chars (except hyphens and colons),\n * splitting on whitespace, and filtering out short tokens and stopwords.\n */\nexport function tokenize(text: string): string[] {\n\treturn [\n\t\t...new Set(\n\t\t\ttext\n\t\t\t\t.toLowerCase()\n\t\t\t\t.replace(/[^a-z0-9:-]+/g, \" \")\n\t\t\t\t.split(/\\s+/)\n\t\t\t\t.filter((token) => token.length >= 3 && !STOPWORDS.has(token)),\n\t\t),\n\t];\n}\n\n/**\n * Calculate Jaccard similarity between two token sets.\n * Jaccard(A, B) = |A ∩ B| / |A ∪ B|\n */\nexport function jaccard(a: string[], b: string[]): number {\n\tif (a.length === 0 || b.length === 0) return 0;\n\tconst setA = new Set(a);\n\tconst setB = new Set(b);\n\tlet intersection = 0;\n\tfor (const item of setA) if (setB.has(item)) intersection++;\n\tconst union = new Set([...a, ...b]).size;\n\treturn union === 0 ? 0 : intersection / union;\n}\n\nexport interface SkillSummary {\n\tname: string;\n\tdescription: string;\n\tpath: string;\n\tscope: string;\n\tkeywords: string[];\n}\n\nexport interface SkillAuditReport {\n\tgeneratedAt: string;\n\tskills: SkillSummary[];\n\tnearDuplicates: Array<{\n\t\ta: string;\n\t\tb: string;\n\t\tsimilarity: number;\n\t\treason: string;\n\t}>;\n\tcompartmentWarnings: Array<{\n\t\tskill: string;\n\t\tpath: string;\n\t\treason: string;\n\t}>;\n\tnameCollisions: Array<{\n\t\tname: string;\n\t\tpaths: string[];\n\t}>;\n\trecommendations?: string[];\n}\n\n/**\n * Audit existing skills for overlap and compare against a draft skill.\n */\nexport function runSkillAudit(\n\tcwd: string,\n\tdraftSkill?: { name?: string; description?: string; body?: string },\n): SkillAuditReport {\n\t// Load existing skills\n\tconst result = loadSkills({\n\t\tcwd,\n\t\tagentDir: getAgentDir(),\n\t\tskillPaths: [],\n\t\tincludeDefaults: true,\n\t});\n\n\tconst skills: SkillSummary[] = result.skills.map((skill: Skill) => ({\n\t\tname: skill.name,\n\t\tdescription: skill.description,\n\t\tpath: skill.filePath,\n\t\tscope: skill.sourceInfo.scope ?? \"unknown\",\n\t\tkeywords: tokenize(`${skill.name} ${skill.description}`),\n\t}));\n\n\t// If a draft skill is provided, add it to the set for comparison\n\tif (draftSkill) {\n\t\tconst draftName = draftSkill.name || \"draft-skill\";\n\t\tconst draftDesc = draftSkill.description || \"\";\n\t\tskills.push({\n\t\t\tname: draftName,\n\t\t\tdescription: draftDesc,\n\t\t\tpath: \"[draft]\",\n\t\t\tscope: \"draft\",\n\t\t\tkeywords: tokenize(`${draftName} ${draftDesc} ${draftSkill.body || \"\"}`),\n\t\t});\n\t}\n\n\t// Find near-duplicates based on Jaccard similarity\n\tconst nearDuplicates: SkillAuditReport[\"nearDuplicates\"] = [];\n\tfor (let i = 0; i < skills.length; i++) {\n\t\tfor (let j = i + 1; j < skills.length; j++) {\n\t\t\tconst similarity = jaccard(skills[i].keywords, skills[j].keywords);\n\t\t\tif (similarity >= DUPLICATE_THRESHOLD) {\n\t\t\t\tconst reason =\n\t\t\t\t\tsimilarity >= 0.9\n\t\t\t\t\t\t? \"90%+ keyword overlap; merge/refine before adding another skill\"\n\t\t\t\t\t\t: \"high trigger/workflow overlap; review for dedup or compartmentalization\";\n\t\t\t\tnearDuplicates.push({\n\t\t\t\t\ta: skills[i].path,\n\t\t\t\t\tb: skills[j].path,\n\t\t\t\t\tsimilarity: Number(similarity.toFixed(3)),\n\t\t\t\t\treason,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\tnearDuplicates.sort((a, b) => b.similarity - a.similarity);\n\n\t// Check for name collisions\n\tconst byName = new Map<string, string[]>();\n\tfor (const skill of skills) {\n\t\tconst existing = byName.get(skill.name) ?? [];\n\t\tbyName.set(skill.name, [...existing, skill.path]);\n\t}\n\tconst nameCollisions = [...byName.entries()]\n\t\t.filter(([, paths]) => paths.length > 1)\n\t\t.map(([name, paths]) => ({ name, paths }));\n\n\t// Build recommendations\n\tconst recommendations: string[] = [];\n\tif (draftSkill && nearDuplicates.length > 0) {\n\t\tconst draftNearDupes = nearDuplicates.filter((d) => d.a === \"[draft]\" || d.b === \"[draft]\");\n\t\tif (draftNearDupes.length > 0) {\n\t\t\trecommendations.push(\n\t\t\t\t`Draft skill has ${draftNearDupes.length} similar existing skill(s). Consider merging or refining the trigger/scope.`,\n\t\t\t);\n\t\t}\n\t}\n\tif (nameCollisions.length > 0) {\n\t\trecommendations.push(\n\t\t\t`Found ${nameCollisions.length} skill name collision(s). Resolve naming conflicts before deployment.`,\n\t\t);\n\t}\n\n\treturn {\n\t\tgeneratedAt: new Date().toISOString(),\n\t\tskills: skills.filter((s) => s.path !== \"[draft]\"), // Don't include draft in final skill list\n\t\tnearDuplicates,\n\t\tcompartmentWarnings: [],\n\t\tnameCollisions,\n\t\trecommendations,\n\t};\n}\n\nconst skillAuditSchema = Type.Object({\n\tdraftName: Type.Optional(Type.String({ description: \"Name of the draft skill to audit\" })),\n\tdraftDescription: Type.Optional(Type.String({ description: \"Description of the draft skill\" })),\n\tdraftBody: Type.Optional(Type.String({ description: \"Body/content of the draft skill\" })),\n});\n\nexport type SkillAuditInput = Static<typeof skillAuditSchema>;\n\nexport interface SkillAuditToolDetails {\n\treportPath?: string;\n}\n\nexport interface SkillAuditToolOptions {}\n\nexport function createSkillAuditToolDefinition(\n\tcwd: string,\n\t_options?: SkillAuditToolOptions,\n): ToolDefinition<typeof skillAuditSchema, SkillAuditReport> {\n\treturn {\n\t\tname: \"skill_audit\",\n\t\tlabel: \"skill audit\",\n\t\tdescription:\n\t\t\t\"Check a draft/new skill for overlap with existing skills before creating it; flags near-duplicate triggers/descriptions via local Jaccard similarity. Read-only: does not write files.\",\n\t\tpromptSnippet: \"Audit skill for overlaps\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use skill_audit to check draft skills for conflicts before creating them.\",\n\t\t\t\"Similarity >= 55% indicates potential dedup or compartmentalization work.\",\n\t\t],\n\t\tparameters: skillAuditSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ draftName, draftDescription, draftBody }: SkillAuditInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: SkillAuditReport;\n\t\t}> {\n\t\t\tconst draftSkill =\n\t\t\t\tdraftName || draftDescription\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tname: draftName,\n\t\t\t\t\t\t\tdescription: draftDescription,\n\t\t\t\t\t\t\tbody: draftBody,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined;\n\n\t\t\tconst report = runSkillAudit(cwd, draftSkill);\n\n\t\t\t// Format the report as readable text\n\t\t\tconst lines: string[] = [];\n\t\t\tlines.push(\n\t\t\t\t`Skill audit: ${report.skills.length} skill(s), ${report.nearDuplicates.length} overlap warning(s).`,\n\t\t\t);\n\n\t\t\tif (report.nearDuplicates.length > 0) {\n\t\t\t\tlines.push(\"\\nTop overlap warnings:\");\n\t\t\t\tfor (const item of report.nearDuplicates.slice(0, 8)) {\n\t\t\t\t\tconst aName = item.a.split(\"/\").pop() || item.a;\n\t\t\t\t\tconst bName = item.b.split(\"/\").pop() || item.b;\n\t\t\t\t\tlines.push(`- ${(item.similarity * 100).toFixed(1)}%: ${aName} ↔ ${bName} — ${item.reason}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (report.nameCollisions.length > 0) {\n\t\t\t\tlines.push(\"\\nName collisions:\");\n\t\t\t\tfor (const item of report.nameCollisions.slice(0, 8)) {\n\t\t\t\t\tlines.push(`- ${item.name}: ${item.paths.length} paths`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (report.recommendations && report.recommendations.length > 0) {\n\t\t\t\tlines.push(\"\\nRecommendations:\");\n\t\t\t\tfor (const rec of report.recommendations) {\n\t\t\t\t\tlines.push(`- ${rec}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (report.nearDuplicates.length === 0 && report.nameCollisions.length === 0) {\n\t\t\t\tlines.push(\"\\nNo overlaps detected. This skill appears to be unique.\");\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: lines.join(\"\\n\") }],\n\t\t\t\tdetails: report,\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport function createSkillAuditTool(cwd: string, options?: SkillAuditToolOptions): AgentTool<typeof skillAuditSchema> {\n\treturn wrapToolDefinition(createSkillAuditToolDefinition(cwd, options));\n}\n"]}
|