@nano-step/skill-manager 4.0.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -174
- package/dist/config.d.ts +5 -0
- package/dist/config.js +59 -0
- package/dist/index.js +147 -21
- package/dist/installer.d.ts +4 -0
- package/dist/installer.js +92 -0
- package/dist/registry.d.ts +3 -0
- package/dist/registry.js +63 -0
- package/dist/state.d.ts +4 -0
- package/dist/state.js +52 -0
- package/dist/utils.d.ts +25 -18
- package/dist/utils.js +7 -106
- package/package.json +4 -2
- package/skills/graphql-inspector/SKILL.md +170 -0
- package/skills/graphql-inspector/skill.json +9 -0
- package/{templates/skill → skills/skill-management}/SKILL.md +18 -18
- package/{templates/skill → skills/skill-management}/assets/tools-template.json +1 -1
- package/{templates/skill → skills/skill-management}/assets/workflow-schema.json +1 -1
- package/{templates/skill → skills/skill-management}/references/error-handling.md +7 -7
- package/{templates/skill → skills/skill-management}/references/tool-categories.md +4 -4
- package/{templates/skill → skills/skill-management}/references/tool-execution.md +7 -7
- package/{templates/skill → skills/skill-management}/references/workflows.md +9 -9
- package/{templates/command-refresh.md → skills/skill-management/skill-refresh.md} +8 -8
- package/skills/skill-management/skill.json +18 -0
- package/dist/install.d.ts +0 -1
- package/dist/install.js +0 -35
- package/dist/remove.d.ts +0 -1
- package/dist/remove.js +0 -32
- package/dist/update.d.ts +0 -1
- package/dist/update.js +0 -53
- package/templates/agent.json +0 -11
- package/templates/command-workflow.md +0 -188
- /package/{templates/skill → skills/skill-management}/assets/workflow-templates.json +0 -0
- /package/{templates/skill → skills/skill-management}/references/result-handling.md +0 -0
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
## Automatic Retry Mechanism
|
|
14
14
|
|
|
15
|
-
The
|
|
15
|
+
The skill-manager automatically retries failed tool executions before returning errors.
|
|
16
16
|
|
|
17
17
|
### Retry Configuration
|
|
18
18
|
- Maximum attempts: 3
|
|
@@ -67,7 +67,7 @@ Template:
|
|
|
67
67
|
```
|
|
68
68
|
Error: Tool not found: <tool-id>
|
|
69
69
|
Suggestions: <tool-a>, <tool-b>, <tool-c>
|
|
70
|
-
Next: confirm the intended tool or run /
|
|
70
|
+
Next: confirm the intended tool or run /skill-refresh.
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
## Execution Failure Handling
|
|
@@ -113,18 +113,18 @@ Next: confirm retry with new parameters
|
|
|
113
113
|
|
|
114
114
|
## Cache Missing Recovery
|
|
115
115
|
Symptoms:
|
|
116
|
-
- `.opencode/
|
|
116
|
+
- `.opencode/skill-tools.json` missing.
|
|
117
117
|
- Cache file invalid or unreadable.
|
|
118
118
|
|
|
119
119
|
Recovery steps:
|
|
120
120
|
1. Inform that cache is missing or invalid.
|
|
121
|
-
2. Recommend /
|
|
121
|
+
2. Recommend /skill-refresh to regenerate.
|
|
122
122
|
3. Proceed with dynamic tool discovery if possible.
|
|
123
123
|
|
|
124
124
|
Template:
|
|
125
125
|
```
|
|
126
|
-
Cache missing or invalid at .opencode/
|
|
127
|
-
Suggestion: run /
|
|
126
|
+
Cache missing or invalid at .opencode/skill-tools.json
|
|
127
|
+
Suggestion: run /skill-refresh
|
|
128
128
|
Fallback: dynamic discovery enabled
|
|
129
129
|
```
|
|
130
130
|
|
|
@@ -247,7 +247,7 @@ Decision tree (text form):
|
|
|
247
247
|
- Yes -> request corrected params.
|
|
248
248
|
- No -> continue.
|
|
249
249
|
5. Is cache missing?
|
|
250
|
-
- Yes -> recommend /
|
|
250
|
+
- Yes -> recommend /skill-refresh and use dynamic discovery.
|
|
251
251
|
- No -> continue.
|
|
252
252
|
6. Unknown failure
|
|
253
253
|
- Provide generic error template and ask for clarification.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
This skill uses **semantic categorization**:
|
|
8
8
|
|
|
9
|
-
1. **Tool discovery** - `/
|
|
9
|
+
1. **Tool discovery** - `/skill-refresh` enumerates all tools available to the agent
|
|
10
10
|
2. **Semantic analysis** - the AI reads each tool's **name + description**
|
|
11
11
|
3. **Dynamic grouping** - tools are grouped into categories based on what they do
|
|
12
12
|
|
|
@@ -31,12 +31,12 @@ categories are **labels**, not fixed contracts, and can evolve with the tool set
|
|
|
31
31
|
|
|
32
32
|
- Categories are **not hard-coded**
|
|
33
33
|
- Category names are **derived from the tools** at refresh time
|
|
34
|
-
- Custom
|
|
35
|
-
- The system works with any
|
|
34
|
+
- Custom tool servers are handled automatically
|
|
35
|
+
- The system works with any tool configuration (MetaMCP, standalone, or custom)
|
|
36
36
|
|
|
37
37
|
## Cache File (v2.0.0) - How to Read It
|
|
38
38
|
|
|
39
|
-
The `/
|
|
39
|
+
The `/skill-refresh` command writes a cache file using the v2.0.0 schema. This
|
|
40
40
|
file is the **source of truth** for the current categorization state.
|
|
41
41
|
|
|
42
42
|
### Schema Overview
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
# Do not include category catalogs, result summarization, or error templates here.
|
|
4
4
|
|
|
5
5
|
## Cache Access and Reading
|
|
6
|
-
Cache location: .opencode/
|
|
7
|
-
Purpose: fast tool routing without reloading full
|
|
6
|
+
Cache location: .opencode/skill-tools.json
|
|
7
|
+
Purpose: fast tool routing without reloading full tool schemas.
|
|
8
8
|
|
|
9
9
|
How to read the cache:
|
|
10
|
-
1. Check if file exists at project root `.opencode/
|
|
10
|
+
1. Check if file exists at project root `.opencode/skill-tools.json`.
|
|
11
11
|
2. Parse JSON into a structured object.
|
|
12
12
|
3. Validate minimal fields: version, refreshed_at, tool_count, categories.
|
|
13
13
|
4. If missing or malformed, fall back to dynamic discovery.
|
|
@@ -18,10 +18,10 @@ Cache staleness heuristic:
|
|
|
18
18
|
|
|
19
19
|
## Cache Schema (TypeScript Interface)
|
|
20
20
|
```ts
|
|
21
|
-
interface
|
|
21
|
+
interface SkillToolCache {
|
|
22
22
|
version: string;
|
|
23
23
|
refreshed_at: string; // ISO string
|
|
24
|
-
|
|
24
|
+
tool_sources: string[];
|
|
25
25
|
tool_count: number;
|
|
26
26
|
categories: {
|
|
27
27
|
[name: string]: {
|
|
@@ -156,7 +156,7 @@ params: { fullPage: true }
|
|
|
156
156
|
## When to Avoid Cache
|
|
157
157
|
- During tool upgrades or when discrepancies are reported.
|
|
158
158
|
- When a tool id from cache fails execution.
|
|
159
|
-
- When the user references a new
|
|
159
|
+
- When the user references a new tool server prefix.
|
|
160
160
|
|
|
161
161
|
## Execution Prerequisites
|
|
162
162
|
- Ensure selected tool exists in cache or registry.
|
|
@@ -234,7 +234,7 @@ Tool: sequentialthinking { thought: "...", thoughtNumber: 1, totalThoughts: 4, n
|
|
|
234
234
|
## Cache Refresh Recommendation Text
|
|
235
235
|
Recommended message:
|
|
236
236
|
```
|
|
237
|
-
Cache appears stale or missing. Run /
|
|
237
|
+
Cache appears stale or missing. Run /skill-refresh to rebuild tool metadata.
|
|
238
238
|
```
|
|
239
239
|
|
|
240
240
|
## Execution Output Metadata (Internal)
|
|
@@ -70,7 +70,7 @@ Each prerequisite step has:
|
|
|
70
70
|
|
|
71
71
|
## Session State
|
|
72
72
|
|
|
73
|
-
Completed prerequisites are tracked in `.opencode/.
|
|
73
|
+
Completed prerequisites are tracked in `.opencode/.skill-session.json`:
|
|
74
74
|
|
|
75
75
|
```json
|
|
76
76
|
{
|
|
@@ -202,26 +202,26 @@ Also matched: 'custom-db-workflow'
|
|
|
202
202
|
|
|
203
203
|
## Managing Workflows
|
|
204
204
|
|
|
205
|
-
Use `/
|
|
205
|
+
Use `/skill-workflow` command:
|
|
206
206
|
|
|
207
207
|
```bash
|
|
208
208
|
# List all workflows
|
|
209
|
-
/
|
|
209
|
+
/skill-workflow list
|
|
210
210
|
|
|
211
211
|
# Add from template
|
|
212
|
-
/
|
|
212
|
+
/skill-workflow add --template database
|
|
213
213
|
|
|
214
214
|
# Add custom workflow
|
|
215
|
-
/
|
|
215
|
+
/skill-workflow add my-workflow
|
|
216
216
|
|
|
217
217
|
# Edit existing
|
|
218
|
-
/
|
|
218
|
+
/skill-workflow edit my-workflow
|
|
219
219
|
|
|
220
220
|
# Disable temporarily
|
|
221
|
-
/
|
|
221
|
+
/skill-workflow disable my-workflow
|
|
222
222
|
|
|
223
223
|
# Remove
|
|
224
|
-
/
|
|
224
|
+
/skill-workflow remove my-workflow
|
|
225
225
|
```
|
|
226
226
|
|
|
227
227
|
## Best Practices
|
|
@@ -230,4 +230,4 @@ Use `/agent-skill-workflow` command:
|
|
|
230
230
|
2. **Use enforce sparingly** - Only for critical safety workflows
|
|
231
231
|
3. **Keep prerequisites minimal** - Each step adds latency
|
|
232
232
|
4. **Mark optional steps** - Use `required: false` for nice-to-have steps
|
|
233
|
-
5. **Review session state** - Check `.
|
|
233
|
+
5. **Review session state** - Check `.skill-session.json` if prerequisites seem stuck
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# /
|
|
1
|
+
# /skill-refresh
|
|
2
2
|
|
|
3
|
-
Re-index and categorize all available
|
|
3
|
+
Re-index and categorize all available tools for intelligent routing.
|
|
4
4
|
|
|
5
5
|
## Purpose
|
|
6
6
|
|
|
7
|
-
Create a semantic tool index in `.opencode/
|
|
7
|
+
Create a semantic tool index in `.opencode/skill-tools.json` by analyzing **all available tools** in the current agent context. Categorization is AI-only and based on tool names + descriptions (no prefixes).
|
|
8
8
|
|
|
9
9
|
## When to Run
|
|
10
10
|
|
|
@@ -15,10 +15,10 @@ Create a semantic tool index in `.opencode/agent-skill-tools.json` by analyzing
|
|
|
15
15
|
|
|
16
16
|
## Auto-Refresh Triggers
|
|
17
17
|
|
|
18
|
-
The
|
|
18
|
+
The skill-manager will suggest running `/skill-refresh` automatically when:
|
|
19
19
|
|
|
20
20
|
- **Tool not found**: A requested tool doesn't exist in the cache
|
|
21
|
-
- **Cache missing**: The `.opencode/
|
|
21
|
+
- **Cache missing**: The `.opencode/skill-tools.json` file doesn't exist
|
|
22
22
|
- **Cache stale**: The cache is older than 24 hours
|
|
23
23
|
- **Tool count mismatch**: Available tools differ from cached count
|
|
24
24
|
|
|
@@ -59,7 +59,7 @@ Output as JSON.
|
|
|
59
59
|
|
|
60
60
|
### Step 3: Write Cache File (v2.0.0)
|
|
61
61
|
|
|
62
|
-
Write `.opencode/
|
|
62
|
+
Write `.opencode/skill-tools.json` with this schema:
|
|
63
63
|
|
|
64
64
|
```json
|
|
65
65
|
{
|
|
@@ -86,7 +86,7 @@ Write `.opencode/agent-skill-tools.json` with this schema:
|
|
|
86
86
|
### Step 4: Report Summary
|
|
87
87
|
|
|
88
88
|
```
|
|
89
|
-
|
|
89
|
+
Skill Tools Index Refreshed:
|
|
90
90
|
|
|
91
91
|
Categories:
|
|
92
92
|
- browser-automation: 25 tools
|
|
@@ -96,5 +96,5 @@ Categories:
|
|
|
96
96
|
Summary:
|
|
97
97
|
- Total tools: 75
|
|
98
98
|
- Categories: 3
|
|
99
|
-
- Cache: .opencode/
|
|
99
|
+
- Cache: .opencode/skill-tools.json
|
|
100
100
|
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "skill-management",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "AI skill routing and execution — isolates tool definitions in subagent context to save 80-95% tokens",
|
|
5
|
+
"compatibility": "OpenCode with any MCP server",
|
|
6
|
+
"agent": {
|
|
7
|
+
"id": "skill-manager",
|
|
8
|
+
"config": {
|
|
9
|
+
"mode": "subagent",
|
|
10
|
+
"model": "gitlab/duo-chat-haiku-4-5",
|
|
11
|
+
"temperature": 0.1,
|
|
12
|
+
"description": "Skill router - isolates tool definitions in separate context window to save tokens",
|
|
13
|
+
"prompt_append": "You are skill-manager, a specialized agent for routing and executing tools. Your purpose is to ISOLATE tool definitions from the main agent's context window, reducing token usage by 80-95%.\n\nWORKFLOW:\n1. Read .opencode/skill-tools.json cache for tool routing (if exists)\n2. Parse the task to identify which skill category is needed (browser, github, graphql, docs, reasoning)\n3. Select the appropriate tool(s) from that category\n4. Execute the tool with correct parameters\n5. Filter/summarize results before returning to main agent\n\nTOOL CATEGORIES:\n- browser: chrome-devtools__* (screenshots, clicks, navigation, DOM)\n- github: github-*__* (PRs, issues, repos, commits, branches)\n- graphql: graphql-tools__* (schema, queries, mutations)\n- docs: context7__* (documentation lookup, library references)\n- reasoning: Sequential-Thinking__* (complex multi-step analysis)\n\nRESULT HANDLING:\n- For large results (>1000 chars): Summarize key information\n- For file operations: Return path/status, not full content\n- For data queries: Return relevant subset, not full dataset\n- Always include: Success/failure status, key identifiers, actionable next steps\n\nERROR HANDLING:\n- Tool not found: Suggest similar tools or ask for clarification\n- Tool execution failed: Return error details and potential fixes\n- Cache missing: Prompt user to run /skill-refresh command\n- Never silently fail\n\nYou are FAST (Haiku model) and DETERMINISTIC (temp 0.1). Focus on accurate tool selection and execution."
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"commands": ["skill-refresh.md"],
|
|
17
|
+
"tags": ["skill", "routing", "token-saving"]
|
|
18
|
+
}
|
package/dist/install.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function install(): Promise<void>;
|
package/dist/install.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.install = install;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
async function install() {
|
|
12
|
-
const paths = await (0, utils_1.detectOpenCodePaths)();
|
|
13
|
-
await (0, utils_1.ensureDirExists)(paths.commandDir);
|
|
14
|
-
await (0, utils_1.ensureDirExists)(paths.skillsDir);
|
|
15
|
-
const skillTargetDir = path_1.default.join(paths.skillsDir, utils_1.SKILL_DIR_NAME);
|
|
16
|
-
const commandTargetPath = path_1.default.join(paths.commandDir, "agent-skill-refresh.md");
|
|
17
|
-
await fs_extra_1.default.copy(paths.templateSkillDir, skillTargetDir, { overwrite: true });
|
|
18
|
-
const commandTemplate = await (0, utils_1.readText)(paths.templateCommandPath);
|
|
19
|
-
await (0, utils_1.writeText)(commandTargetPath, commandTemplate);
|
|
20
|
-
const agentTemplate = await (0, utils_1.readJsonFile)(paths.templateAgentPath, {});
|
|
21
|
-
const agentConfig = await (0, utils_1.readJsonFile)(paths.agentConfigPath, {});
|
|
22
|
-
const agents = (agentConfig.agents || {});
|
|
23
|
-
const templateAgents = (agentTemplate.agents || agentTemplate);
|
|
24
|
-
agentConfig.agents = { ...agents, ...templateAgents };
|
|
25
|
-
await (0, utils_1.writeJsonFile)(paths.agentConfigPath, agentConfig);
|
|
26
|
-
await (0, utils_1.writeJsonFile)(paths.versionFilePath, { version: utils_1.PACKAGE_VERSION, installedAt: new Date().toISOString() });
|
|
27
|
-
const state = await (0, utils_1.getInstallationState)(paths);
|
|
28
|
-
if (!state.skillInstalled || !state.commandInstalled || !state.agentInstalled) {
|
|
29
|
-
throw new Error("Installation verification failed. Some files were not installed.");
|
|
30
|
-
}
|
|
31
|
-
if (Object.keys(agentConfig).length > 0 && Object.prototype.hasOwnProperty.call(agentConfig, utils_1.AGENT_ID)) {
|
|
32
|
-
console.log(chalk_1.default.yellow("agent-skill-manager agent already existed; configuration was updated."));
|
|
33
|
-
}
|
|
34
|
-
console.log(chalk_1.default.green("Agent skill manager installed successfully."));
|
|
35
|
-
}
|
package/dist/remove.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function remove(): Promise<void>;
|
package/dist/remove.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.remove = remove;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
async function remove() {
|
|
12
|
-
const paths = await (0, utils_1.detectOpenCodePaths)();
|
|
13
|
-
const skillTargetDir = path_1.default.join(paths.skillsDir, utils_1.SKILL_DIR_NAME);
|
|
14
|
-
const commandTargetPath = path_1.default.join(paths.commandDir, "agent-skill-refresh.md");
|
|
15
|
-
if (await fs_extra_1.default.pathExists(skillTargetDir)) {
|
|
16
|
-
await fs_extra_1.default.remove(skillTargetDir);
|
|
17
|
-
}
|
|
18
|
-
if (await fs_extra_1.default.pathExists(commandTargetPath)) {
|
|
19
|
-
await fs_extra_1.default.remove(commandTargetPath);
|
|
20
|
-
}
|
|
21
|
-
const agentConfig = await (0, utils_1.readJsonFile)(paths.agentConfigPath, {});
|
|
22
|
-
const agents = (agentConfig.agents || {});
|
|
23
|
-
if (Object.prototype.hasOwnProperty.call(agents, utils_1.AGENT_ID)) {
|
|
24
|
-
delete agents[utils_1.AGENT_ID];
|
|
25
|
-
agentConfig.agents = agents;
|
|
26
|
-
await (0, utils_1.writeJsonFile)(paths.agentConfigPath, agentConfig);
|
|
27
|
-
}
|
|
28
|
-
if (await fs_extra_1.default.pathExists(paths.versionFilePath)) {
|
|
29
|
-
await fs_extra_1.default.remove(paths.versionFilePath);
|
|
30
|
-
}
|
|
31
|
-
console.log(chalk_1.default.green("Agent skill manager removed successfully."));
|
|
32
|
-
}
|
package/dist/update.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function update(): Promise<void>;
|
package/dist/update.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.update = update;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
async function update() {
|
|
12
|
-
const paths = await (0, utils_1.detectOpenCodePaths)();
|
|
13
|
-
await (0, utils_1.ensureDirExists)(paths.commandDir);
|
|
14
|
-
await (0, utils_1.ensureDirExists)(paths.skillsDir);
|
|
15
|
-
const skillTargetDir = path_1.default.join(paths.skillsDir, utils_1.SKILL_DIR_NAME);
|
|
16
|
-
const commandTargetPath = path_1.default.join(paths.commandDir, "agent-skill-refresh.md");
|
|
17
|
-
await (0, utils_1.ensureDirExists)(skillTargetDir);
|
|
18
|
-
const state = await (0, utils_1.getInstallationState)(paths);
|
|
19
|
-
if (state.installedVersion === utils_1.PACKAGE_VERSION) {
|
|
20
|
-
console.log(chalk_1.default.green("Agent skill manager is already up to date."));
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const [skillCustomized, commandCustomized] = await Promise.all([
|
|
24
|
-
(0, utils_1.directoryDiffersFromTemplate)(skillTargetDir, paths.templateSkillDir),
|
|
25
|
-
(0, utils_1.fileDiffersFromTemplate)(commandTargetPath, paths.templateCommandPath),
|
|
26
|
-
]);
|
|
27
|
-
if (skillCustomized || commandCustomized) {
|
|
28
|
-
console.log(chalk_1.default.yellow("Detected customized files. Backups will be created before update."));
|
|
29
|
-
}
|
|
30
|
-
if (await fs_extra_1.default.pathExists(skillTargetDir)) {
|
|
31
|
-
console.log(chalk_1.default.yellow("Backing up existing skill directory before update."));
|
|
32
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
33
|
-
const backupDir = `${skillTargetDir}.backup-${timestamp}.bak`;
|
|
34
|
-
await fs_extra_1.default.copy(skillTargetDir, backupDir, { overwrite: true });
|
|
35
|
-
}
|
|
36
|
-
if (await fs_extra_1.default.pathExists(commandTargetPath)) {
|
|
37
|
-
await (0, utils_1.backupFile)(commandTargetPath, "backup");
|
|
38
|
-
}
|
|
39
|
-
if (await fs_extra_1.default.pathExists(paths.agentConfigPath)) {
|
|
40
|
-
await (0, utils_1.backupFile)(paths.agentConfigPath, "backup");
|
|
41
|
-
}
|
|
42
|
-
await fs_extra_1.default.copy(paths.templateSkillDir, skillTargetDir, { overwrite: true });
|
|
43
|
-
const commandTemplate = await fs_extra_1.default.readFile(paths.templateCommandPath, "utf8");
|
|
44
|
-
await fs_extra_1.default.writeFile(commandTargetPath, commandTemplate, "utf8");
|
|
45
|
-
const agentTemplate = await (0, utils_1.readJsonFile)(paths.templateAgentPath, {});
|
|
46
|
-
const agentConfig = await (0, utils_1.readJsonFile)(paths.agentConfigPath, {});
|
|
47
|
-
const agents = (agentConfig.agents || {});
|
|
48
|
-
const templateAgents = (agentTemplate.agents || agentTemplate);
|
|
49
|
-
agentConfig.agents = { ...agents, ...templateAgents };
|
|
50
|
-
await (0, utils_1.writeJsonFile)(paths.agentConfigPath, agentConfig);
|
|
51
|
-
await (0, utils_1.writeJsonFile)(paths.versionFilePath, { version: utils_1.PACKAGE_VERSION, updatedAt: new Date().toISOString() });
|
|
52
|
-
console.log(chalk_1.default.green("Agent skill manager updated successfully."));
|
|
53
|
-
}
|
package/templates/agent.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"agents": {
|
|
3
|
-
"mcp-manager": {
|
|
4
|
-
"mode": "subagent",
|
|
5
|
-
"model": "gitlab/duo-chat-haiku-4-5",
|
|
6
|
-
"temperature": 0.1,
|
|
7
|
-
"description": "MCP tool router - isolates MCP tools in separate context window to save tokens",
|
|
8
|
-
"prompt_append": "You are mcp-manager, a specialized agent for executing MCP (Model Context Protocol) tools. Your purpose is to ISOLATE MCP tool definitions from the main agent's context window, reducing token usage by 80-95%.\n\nWORKFLOW:\n1. Read .opencode/mcp-tools.json cache for tool routing (if exists)\n2. Parse the task to identify which MCP category is needed (browser, github, graphql, docs, reasoning)\n3. Select the appropriate tool(s) from that category\n4. Execute the tool with correct parameters\n5. Filter/summarize results before returning to main agent\n\nTOOL CATEGORIES:\n- browser: chrome-devtools__* (screenshots, clicks, navigation, DOM)\n- github: github-*__* (PRs, issues, repos, commits, branches)\n- graphql: graphql-tools__* (schema, queries, mutations)\n- docs: context7__* (documentation lookup, library references)\n- reasoning: Sequential-Thinking__* (complex multi-step analysis)\n\nRESULT HANDLING:\n- For large results (>1000 chars): Summarize key information\n- For file operations: Return path/status, not full content\n- For data queries: Return relevant subset, not full dataset\n- Always include: Success/failure status, key identifiers, actionable next steps\n\nERROR HANDLING:\n- Tool not found: Suggest similar tools or ask for clarification\n- Tool execution failed: Return error details and potential fixes\n- Cache missing: Prompt user to run /mcp-refresh command\n- Never silently fail\n\nYou are FAST (Haiku model) and DETERMINISTIC (temp 0.1). Focus on accurate tool selection and execution."
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
# /agent-skill-workflow
|
|
2
|
-
|
|
3
|
-
Manage workflow rules that define prerequisite steps before tool execution.
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
Create, list, edit, and remove workflow definitions that automatically execute prerequisite steps when certain tools are triggered. For example, always inspect database structure before running queries.
|
|
8
|
-
|
|
9
|
-
## Subcommands
|
|
10
|
-
|
|
11
|
-
### List Workflows
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
/agent-skill-workflow list
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Display all defined workflows with their status, triggers, and prerequisite count.
|
|
18
|
-
|
|
19
|
-
**Output format:**
|
|
20
|
-
```
|
|
21
|
-
Workflows (3 defined):
|
|
22
|
-
|
|
23
|
-
✓ database-safe-query [enforce]
|
|
24
|
-
Triggers: category=database, keywords=[query, select]
|
|
25
|
-
Prerequisites: 4 steps
|
|
26
|
-
|
|
27
|
-
✓ browser-safe-interaction [enforce]
|
|
28
|
-
Triggers: category=browser
|
|
29
|
-
Prerequisites: 1 step
|
|
30
|
-
|
|
31
|
-
○ github-pr-review [disabled]
|
|
32
|
-
Triggers: tools=[merge_pull_request]
|
|
33
|
-
Prerequisites: 3 steps
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Add Workflow (Interactive)
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
/agent-skill-workflow add <name>
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Create a new workflow interactively. The agent will prompt for:
|
|
43
|
-
|
|
44
|
-
1. **Description**: What does this workflow do?
|
|
45
|
-
2. **Triggers**:
|
|
46
|
-
- Category (optional): Which tool category triggers this?
|
|
47
|
-
- Tools (optional): Which specific tools trigger this?
|
|
48
|
-
- Keywords (optional): Which words in the task trigger this?
|
|
49
|
-
3. **Prerequisites**: For each step:
|
|
50
|
-
- Tool name
|
|
51
|
-
- Description (why this step is needed)
|
|
52
|
-
- Required? (yes/no)
|
|
53
|
-
4. **Mode**: enforce, warn, or suggest
|
|
54
|
-
|
|
55
|
-
**Example session:**
|
|
56
|
-
```
|
|
57
|
-
> /agent-skill-workflow add api-safety
|
|
58
|
-
|
|
59
|
-
Description: Check API schema before making requests
|
|
60
|
-
Trigger category (or skip): api
|
|
61
|
-
Trigger tools (comma-separated, or skip): execute_request, post_request
|
|
62
|
-
Trigger keywords (comma-separated, or skip): api call, request
|
|
63
|
-
|
|
64
|
-
Prerequisite 1:
|
|
65
|
-
Tool: get_schema
|
|
66
|
-
Description: Fetch API schema
|
|
67
|
-
Required? yes
|
|
68
|
-
|
|
69
|
-
Add another prerequisite? yes
|
|
70
|
-
|
|
71
|
-
Prerequisite 2:
|
|
72
|
-
Tool: list_endpoints
|
|
73
|
-
Description: List available endpoints
|
|
74
|
-
Required? no
|
|
75
|
-
|
|
76
|
-
Add another prerequisite? no
|
|
77
|
-
|
|
78
|
-
Mode (enforce/warn/suggest): warn
|
|
79
|
-
|
|
80
|
-
✓ Workflow 'api-safety' created with 2 prerequisites
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Add from Template
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
/agent-skill-workflow add --template <template-name>
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Create a workflow from a built-in template. Available templates:
|
|
90
|
-
|
|
91
|
-
| Template | Description | Prerequisites |
|
|
92
|
-
|----------|-------------|---------------|
|
|
93
|
-
| `database` | Safe database queries | list_databases → list_tables → inspect_table → get_indexes |
|
|
94
|
-
| `browser` | Safe browser interaction | take_snapshot |
|
|
95
|
-
| `github-pr` | PR review workflow | get_pull_request → get_files → get_status |
|
|
96
|
-
| `graphql` | Schema-aware GraphQL | get_schema → filter_types |
|
|
97
|
-
|
|
98
|
-
**Example:**
|
|
99
|
-
```
|
|
100
|
-
> /agent-skill-workflow add --template database
|
|
101
|
-
|
|
102
|
-
✓ Created workflow 'database-safe-query' from template
|
|
103
|
-
Mode: enforce
|
|
104
|
-
Prerequisites: 4 steps
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
To list available templates:
|
|
108
|
-
```
|
|
109
|
-
/agent-skill-workflow add --template
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Edit Workflow
|
|
113
|
-
|
|
114
|
-
```
|
|
115
|
-
/agent-skill-workflow edit <name>
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
Modify an existing workflow. Shows current values and allows changing any field.
|
|
119
|
-
|
|
120
|
-
### Remove Workflow
|
|
121
|
-
|
|
122
|
-
```
|
|
123
|
-
/agent-skill-workflow remove <name>
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
Delete a workflow after confirmation.
|
|
127
|
-
|
|
128
|
-
```
|
|
129
|
-
> /agent-skill-workflow remove api-safety
|
|
130
|
-
|
|
131
|
-
Remove workflow 'api-safety'? This cannot be undone. (yes/no): yes
|
|
132
|
-
|
|
133
|
-
✓ Workflow 'api-safety' removed
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Enable/Disable Workflow
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
/agent-skill-workflow enable <name>
|
|
140
|
-
/agent-skill-workflow disable <name>
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
Toggle a workflow's enabled status without removing it.
|
|
144
|
-
|
|
145
|
-
```
|
|
146
|
-
> /agent-skill-workflow disable database-safe-query
|
|
147
|
-
|
|
148
|
-
✓ Workflow 'database-safe-query' disabled
|
|
149
|
-
(Prerequisites will not run until re-enabled)
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## Workflow Modes
|
|
153
|
-
|
|
154
|
-
| Mode | Behavior |
|
|
155
|
-
|------|----------|
|
|
156
|
-
| `enforce` | Prerequisites run automatically before main action |
|
|
157
|
-
| `warn` | Warning shown, user can skip prerequisites |
|
|
158
|
-
| `suggest` | Prerequisites mentioned but don't block execution |
|
|
159
|
-
|
|
160
|
-
## Storage
|
|
161
|
-
|
|
162
|
-
Workflows are stored in `.opencode/agent-skill-tools.json` under the `workflows` key. They persist across sessions and are preserved when running `/agent-skill-refresh`.
|
|
163
|
-
|
|
164
|
-
## Session State
|
|
165
|
-
|
|
166
|
-
Completed prerequisites are tracked in `.opencode/.agent-skill-session.json`. Within a session, prerequisites only run once per workflow (unless the session expires after 24 hours).
|
|
167
|
-
|
|
168
|
-
## Examples
|
|
169
|
-
|
|
170
|
-
### Create a custom workflow for file operations
|
|
171
|
-
```
|
|
172
|
-
/agent-skill-workflow add file-safety
|
|
173
|
-
```
|
|
174
|
-
Then define triggers for file tools and prerequisites like "list directory" before "delete file".
|
|
175
|
-
|
|
176
|
-
### Use database template and customize
|
|
177
|
-
```
|
|
178
|
-
/agent-skill-workflow add --template database
|
|
179
|
-
/agent-skill-workflow edit database-safe-query
|
|
180
|
-
```
|
|
181
|
-
Modify the default database workflow to fit your needs.
|
|
182
|
-
|
|
183
|
-
### Temporarily disable a workflow
|
|
184
|
-
```
|
|
185
|
-
/agent-skill-workflow disable browser-safe-interaction
|
|
186
|
-
# ... do some quick browser tasks without snapshots ...
|
|
187
|
-
/agent-skill-workflow enable browser-safe-interaction
|
|
188
|
-
```
|
|
File without changes
|
|
File without changes
|