foliko 2.0.5 → 2.0.6
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/.claude/settings.local.json +4 -1
- package/.cli_default_systemPrompt.md +291 -0
- package/.editorconfig +56 -56
- package/.lintstagedrc +7 -7
- package/.prettierignore +29 -29
- package/.prettierrc +11 -11
- package/CLAUDE.md +3 -0
- package/Dockerfile +63 -63
- package/README.md +20 -3
- package/docs/architecture.md +34 -2
- package/docs/extensions.md +199 -0
- package/docs/migration.md +100 -0
- package/docs/public-api.md +280 -24
- package/docs/usage.md +122 -30
- package/install.ps1 +129 -129
- package/install.sh +121 -121
- package/package.json +1 -1
- package/plugins/core/audit/index.js +1 -1
- package/plugins/core/default/bootstrap.js +44 -19
- package/plugins/core/python-loader/index.js +43 -25
- package/plugins/core/skill-manager/PROMPT.md +6 -0
- package/plugins/core/skill-manager/index.js +402 -115
- package/plugins/core/sub-agent/PROMPT.md +10 -0
- package/plugins/core/sub-agent/index.js +36 -3
- package/plugins/core/think/index.js +1 -0
- package/plugins/core/workflow/index.js +82 -22
- package/plugins/executors/data-splitter/PROMPT.md +13 -0
- package/plugins/executors/data-splitter/index.js +5 -4
- package/plugins/executors/extension/extension-registry.js +145 -0
- package/plugins/executors/extension/index.js +405 -437
- package/plugins/executors/extension/prompt-builder.js +359 -0
- package/plugins/executors/extension/skill-helper.js +143 -0
- package/plugins/messaging/feishu/index.js +5 -3
- package/plugins/messaging/qq/index.js +6 -4
- package/plugins/messaging/telegram/index.js +6 -3
- package/plugins/messaging/weixin/index.js +5 -3
- package/plugins/tools/PROMPT.md +26 -0
- package/plugins/tools/index.js +6 -5
- package/skills/find-skills/SKILL.md +133 -133
- package/skills/foliko/AGENTS.md +196 -43
- package/skills/foliko/SKILL.md +157 -28
- package/skills/mcp/SKILL.md +77 -118
- package/skills/plugins/SKILL.md +89 -3
- package/skills/python/SKILL.md +57 -39
- package/skills/skill-guide/SKILL.md +42 -34
- package/skills/workflows/SKILL.md +224 -9
- package/skills/workflows/workflow-troubleshooting/SKILL.md +221 -281
- package/src/agent/chat.js +48 -27
- package/src/agent/main.js +34 -13
- package/src/agent/prompt-registry.js +56 -16
- package/src/agent/prompts/PROMPT.md +3 -0
- package/src/agent/sub.js +1 -1
- package/src/cli/ui/chat-ui-old.js +5 -2
- package/src/cli/ui/chat-ui.js +5 -2
- package/src/common/constants.js +12 -0
- package/src/common/error-capture.js +91 -0
- package/src/common/logger.js +2 -2
- package/src/context/compressor.js +6 -2
- package/src/executors/mcp-executor.js +105 -125
- package/src/framework/framework.js +23 -11
- package/src/index.js +4 -0
- package/src/plugin/base.js +908 -5
- package/src/plugin/manager.js +29 -8
- package/src/tool/schema.js +32 -9
- package/website/index.html +821 -0
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: find-skills
|
|
3
|
-
description: Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Find Skills
|
|
7
|
-
|
|
8
|
-
This skill helps you discover and install skills from the open agent skills ecosystem.
|
|
9
|
-
|
|
10
|
-
## When to Use This Skill
|
|
11
|
-
|
|
12
|
-
Use this skill when the user:
|
|
13
|
-
|
|
14
|
-
- Asks "how do I do X" where X might be a common task with an existing skill
|
|
15
|
-
- Says "find a skill for X" or "is there a skill for X"
|
|
16
|
-
- Asks "can you do X" where X is a specialized capability
|
|
17
|
-
- Expresses interest in extending agent capabilities
|
|
18
|
-
- Wants to search for tools, templates, or workflows
|
|
19
|
-
- Mentions they wish they had help with a specific domain (design, testing, deployment, etc.)
|
|
20
|
-
|
|
21
|
-
## What is the Skills CLI?
|
|
22
|
-
|
|
23
|
-
The Skills CLI (`npx skills`) is the package manager for the open agent skills ecosystem. Skills are modular packages that extend agent capabilities with specialized knowledge, workflows, and tools.
|
|
24
|
-
|
|
25
|
-
**Key commands:**
|
|
26
|
-
|
|
27
|
-
- `npx skills find [query]` - Search for skills interactively or by keyword
|
|
28
|
-
- `npx skills add <package>` - Install a skill from GitHub or other sources
|
|
29
|
-
- `npx skills check` - Check for skill updates
|
|
30
|
-
- `npx skills update` - Update all installed skills
|
|
31
|
-
|
|
32
|
-
**Browse skills at:** https://skills.sh/
|
|
33
|
-
|
|
34
|
-
## How to Help Users Find Skills
|
|
35
|
-
|
|
36
|
-
### Step 1: Understand What They Need
|
|
37
|
-
|
|
38
|
-
When a user asks for help with something, identify:
|
|
39
|
-
|
|
40
|
-
1. The domain (e.g., React, testing, design, deployment)
|
|
41
|
-
2. The specific task (e.g., writing tests, creating animations, reviewing PRs)
|
|
42
|
-
3. Whether this is a common enough task that a skill likely exists
|
|
43
|
-
|
|
44
|
-
### Step 2: Search for Skills
|
|
45
|
-
|
|
46
|
-
Run the find command with a relevant query:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
npx skills find [query]
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
For example:
|
|
53
|
-
|
|
54
|
-
- User asks "how do I make my React app faster?" → `npx skills find react performance`
|
|
55
|
-
- User asks "can you help me with PR reviews?" → `npx skills find pr review`
|
|
56
|
-
- User asks "I need to create a changelog" → `npx skills find changelog`
|
|
57
|
-
|
|
58
|
-
The command will return results like:
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
Install with npx skills add <owner/repo@skill>
|
|
62
|
-
|
|
63
|
-
vercel-labs/agent-skills@vercel-react-best-practices
|
|
64
|
-
└ https://skills.sh/vercel-labs/agent-skills/vercel-react-best-practices
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Step 3: Present Options to the User
|
|
68
|
-
|
|
69
|
-
When you find relevant skills, present them to the user with:
|
|
70
|
-
|
|
71
|
-
1. The skill name and what it does
|
|
72
|
-
2. The install command they can run
|
|
73
|
-
3. A link to learn more at skills.sh
|
|
74
|
-
|
|
75
|
-
Example response:
|
|
76
|
-
|
|
77
|
-
```
|
|
78
|
-
I found a skill that might help! The "vercel-react-best-practices" skill provides
|
|
79
|
-
React and Next.js performance optimization guidelines from Vercel Engineering.
|
|
80
|
-
|
|
81
|
-
To install it:
|
|
82
|
-
npx skills add vercel-labs/agent-skills@vercel-react-best-practices
|
|
83
|
-
|
|
84
|
-
Learn more: https://skills.sh/vercel-labs/agent-skills/vercel-react-best-practices
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Step 4: Offer to Install
|
|
88
|
-
|
|
89
|
-
If the user wants to proceed, you can install the skill for them:
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
npx skills add <owner/repo@skill> -g -y
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
The `-g` flag installs globally (user-level) and `-y` skips confirmation prompts.
|
|
96
|
-
|
|
97
|
-
## Common Skill Categories
|
|
98
|
-
|
|
99
|
-
When searching, consider these common categories:
|
|
100
|
-
|
|
101
|
-
| Category | Example Queries |
|
|
102
|
-
| --------------- | ---------------------------------------- |
|
|
103
|
-
| Web Development | react, nextjs, typescript, css, tailwind |
|
|
104
|
-
| Testing | testing, jest, playwright, e2e |
|
|
105
|
-
| DevOps | deploy, docker, kubernetes, ci-cd |
|
|
106
|
-
| Documentation | docs, readme, changelog, api-docs |
|
|
107
|
-
| Code Quality | review, lint, refactor, best-practices |
|
|
108
|
-
| Design | ui, ux, design-system, accessibility |
|
|
109
|
-
| Productivity | workflow, automation, git |
|
|
110
|
-
|
|
111
|
-
## Tips for Effective Searches
|
|
112
|
-
|
|
113
|
-
1. **Use specific keywords**: "react testing" is better than just "testing"
|
|
114
|
-
2. **Try alternative terms**: If "deploy" doesn't work, try "deployment" or "ci-cd"
|
|
115
|
-
3. **Check popular sources**: Many skills come from `vercel-labs/agent-skills` or `ComposioHQ/awesome-claude-skills`
|
|
116
|
-
|
|
117
|
-
## When No Skills Are Found
|
|
118
|
-
|
|
119
|
-
If no relevant skills exist:
|
|
120
|
-
|
|
121
|
-
1. Acknowledge that no existing skill was found
|
|
122
|
-
2. Offer to help with the task directly using your general capabilities
|
|
123
|
-
3. Suggest the user could create their own skill with `npx skills init`
|
|
124
|
-
|
|
125
|
-
Example:
|
|
126
|
-
|
|
127
|
-
```
|
|
128
|
-
I searched for skills related to "xyz" but didn't find any matches.
|
|
129
|
-
I can still help you with this task directly! Would you like me to proceed?
|
|
130
|
-
|
|
131
|
-
If this is something you do often, you could create your own skill:
|
|
132
|
-
npx skills init my-xyz-skill
|
|
133
|
-
```
|
|
1
|
+
---
|
|
2
|
+
name: find-skills
|
|
3
|
+
description: Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Find Skills
|
|
7
|
+
|
|
8
|
+
This skill helps you discover and install skills from the open agent skills ecosystem.
|
|
9
|
+
|
|
10
|
+
## When to Use This Skill
|
|
11
|
+
|
|
12
|
+
Use this skill when the user:
|
|
13
|
+
|
|
14
|
+
- Asks "how do I do X" where X might be a common task with an existing skill
|
|
15
|
+
- Says "find a skill for X" or "is there a skill for X"
|
|
16
|
+
- Asks "can you do X" where X is a specialized capability
|
|
17
|
+
- Expresses interest in extending agent capabilities
|
|
18
|
+
- Wants to search for tools, templates, or workflows
|
|
19
|
+
- Mentions they wish they had help with a specific domain (design, testing, deployment, etc.)
|
|
20
|
+
|
|
21
|
+
## What is the Skills CLI?
|
|
22
|
+
|
|
23
|
+
The Skills CLI (`npx skills`) is the package manager for the open agent skills ecosystem. Skills are modular packages that extend agent capabilities with specialized knowledge, workflows, and tools.
|
|
24
|
+
|
|
25
|
+
**Key commands:**
|
|
26
|
+
|
|
27
|
+
- `npx skills find [query]` - Search for skills interactively or by keyword
|
|
28
|
+
- `npx skills add <package>` - Install a skill from GitHub or other sources
|
|
29
|
+
- `npx skills check` - Check for skill updates
|
|
30
|
+
- `npx skills update` - Update all installed skills
|
|
31
|
+
|
|
32
|
+
**Browse skills at:** https://skills.sh/
|
|
33
|
+
|
|
34
|
+
## How to Help Users Find Skills
|
|
35
|
+
|
|
36
|
+
### Step 1: Understand What They Need
|
|
37
|
+
|
|
38
|
+
When a user asks for help with something, identify:
|
|
39
|
+
|
|
40
|
+
1. The domain (e.g., React, testing, design, deployment)
|
|
41
|
+
2. The specific task (e.g., writing tests, creating animations, reviewing PRs)
|
|
42
|
+
3. Whether this is a common enough task that a skill likely exists
|
|
43
|
+
|
|
44
|
+
### Step 2: Search for Skills
|
|
45
|
+
|
|
46
|
+
Run the find command with a relevant query:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx skills find [query]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
For example:
|
|
53
|
+
|
|
54
|
+
- User asks "how do I make my React app faster?" → `npx skills find react performance`
|
|
55
|
+
- User asks "can you help me with PR reviews?" → `npx skills find pr review`
|
|
56
|
+
- User asks "I need to create a changelog" → `npx skills find changelog`
|
|
57
|
+
|
|
58
|
+
The command will return results like:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
Install with npx skills add <owner/repo@skill>
|
|
62
|
+
|
|
63
|
+
vercel-labs/agent-skills@vercel-react-best-practices
|
|
64
|
+
└ https://skills.sh/vercel-labs/agent-skills/vercel-react-best-practices
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Step 3: Present Options to the User
|
|
68
|
+
|
|
69
|
+
When you find relevant skills, present them to the user with:
|
|
70
|
+
|
|
71
|
+
1. The skill name and what it does
|
|
72
|
+
2. The install command they can run
|
|
73
|
+
3. A link to learn more at skills.sh
|
|
74
|
+
|
|
75
|
+
Example response:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
I found a skill that might help! The "vercel-react-best-practices" skill provides
|
|
79
|
+
React and Next.js performance optimization guidelines from Vercel Engineering.
|
|
80
|
+
|
|
81
|
+
To install it:
|
|
82
|
+
npx skills add vercel-labs/agent-skills@vercel-react-best-practices
|
|
83
|
+
|
|
84
|
+
Learn more: https://skills.sh/vercel-labs/agent-skills/vercel-react-best-practices
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Step 4: Offer to Install
|
|
88
|
+
|
|
89
|
+
If the user wants to proceed, you can install the skill for them:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npx skills add <owner/repo@skill> -g -y
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The `-g` flag installs globally (user-level) and `-y` skips confirmation prompts.
|
|
96
|
+
|
|
97
|
+
## Common Skill Categories
|
|
98
|
+
|
|
99
|
+
When searching, consider these common categories:
|
|
100
|
+
|
|
101
|
+
| Category | Example Queries |
|
|
102
|
+
| --------------- | ---------------------------------------- |
|
|
103
|
+
| Web Development | react, nextjs, typescript, css, tailwind |
|
|
104
|
+
| Testing | testing, jest, playwright, e2e |
|
|
105
|
+
| DevOps | deploy, docker, kubernetes, ci-cd |
|
|
106
|
+
| Documentation | docs, readme, changelog, api-docs |
|
|
107
|
+
| Code Quality | review, lint, refactor, best-practices |
|
|
108
|
+
| Design | ui, ux, design-system, accessibility |
|
|
109
|
+
| Productivity | workflow, automation, git |
|
|
110
|
+
|
|
111
|
+
## Tips for Effective Searches
|
|
112
|
+
|
|
113
|
+
1. **Use specific keywords**: "react testing" is better than just "testing"
|
|
114
|
+
2. **Try alternative terms**: If "deploy" doesn't work, try "deployment" or "ci-cd"
|
|
115
|
+
3. **Check popular sources**: Many skills come from `vercel-labs/agent-skills` or `ComposioHQ/awesome-claude-skills`
|
|
116
|
+
|
|
117
|
+
## When No Skills Are Found
|
|
118
|
+
|
|
119
|
+
If no relevant skills exist:
|
|
120
|
+
|
|
121
|
+
1. Acknowledge that no existing skill was found
|
|
122
|
+
2. Offer to help with the task directly using your general capabilities
|
|
123
|
+
3. Suggest the user could create their own skill with `npx skills init`
|
|
124
|
+
|
|
125
|
+
Example:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
I searched for skills related to "xyz" but didn't find any matches.
|
|
129
|
+
I can still help you with this task directly! Would you like me to proceed?
|
|
130
|
+
|
|
131
|
+
If this is something you do often, you could create your own skill:
|
|
132
|
+
npx skills init my-xyz-skill
|
|
133
|
+
```
|
package/skills/foliko/AGENTS.md
CHANGED
|
@@ -63,19 +63,18 @@ module.exports = function (Plugin) {
|
|
|
63
63
|
this.priority = 10;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
onStart(framework) {
|
|
67
|
+
// Register AI SDK tool
|
|
68
|
+
this.tool.register({
|
|
69
69
|
name: 'my_tool',
|
|
70
70
|
description: '工具描述',
|
|
71
|
-
inputSchema: z.object({
|
|
72
|
-
param: z.string().describe('参数描述'),
|
|
71
|
+
inputSchema: framework.z.object({
|
|
72
|
+
param: framework.z.string().describe('参数描述'),
|
|
73
73
|
}),
|
|
74
|
-
execute: async (args
|
|
74
|
+
execute: async (args) => {
|
|
75
75
|
return { success: true, result: args.param };
|
|
76
76
|
},
|
|
77
77
|
});
|
|
78
|
-
return this;
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
uninstall(framework) {
|
|
@@ -119,18 +118,17 @@ class MyPlugin extends Plugin {
|
|
|
119
118
|
this.priority = 10;
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
onStart(framework) {
|
|
122
|
+
this.tool.register({
|
|
124
123
|
name: 'my_tool',
|
|
125
124
|
description: '工具描述',
|
|
126
|
-
inputSchema: z.object({
|
|
127
|
-
param: z.string().describe('参数描述'),
|
|
125
|
+
inputSchema: framework.z.object({
|
|
126
|
+
param: framework.z.string().describe('参数描述'),
|
|
128
127
|
}),
|
|
129
|
-
execute: async (args
|
|
128
|
+
execute: async (args) => {
|
|
130
129
|
return { success: true, result: args.param };
|
|
131
130
|
},
|
|
132
131
|
});
|
|
133
|
-
return this;
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
uninstall(framework) {}
|
|
@@ -150,47 +148,204 @@ module.exports = { MyPlugin };
|
|
|
150
148
|
|
|
151
149
|
## Lifecycle Methods
|
|
152
150
|
|
|
153
|
-
| Method
|
|
154
|
-
|
|
155
|
-
| `install(framework)`
|
|
156
|
-
| `
|
|
157
|
-
| `
|
|
158
|
-
| `
|
|
151
|
+
| Method | Called When | Required | Description |
|
|
152
|
+
|--------|-------------|----------|-------------|
|
|
153
|
+
| `install(framework)` | Plugin installed | ✅ | Initialize, get framework |
|
|
154
|
+
| `onStart(framework)` | start/enable/reload | Recommended | Register tools, extensions, sub-agents |
|
|
155
|
+
| `onStop()` | disable | Optional | Cleanup resources |
|
|
156
|
+
| `reload(framework)` | Hot reload | Optional | prompts auto cleanup/register |
|
|
157
|
+
| `uninstall(framework)` | Plugin uninstalled | Recommended | Cleanup resources |
|
|
158
|
+
|
|
159
|
+
### onStart / onStop (Recommended)
|
|
160
|
+
|
|
161
|
+
**Use `onStart` to register tools and extensions** - base class handles lifecycle automatically:
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
class MyPlugin extends Plugin {
|
|
165
|
+
name = 'my-plugin';
|
|
166
|
+
version = '1.0.0';
|
|
167
|
+
description = '我的插件';
|
|
168
|
+
|
|
169
|
+
onStart(framework) {
|
|
170
|
+
// Register AI SDK tool (direct call)
|
|
171
|
+
this.tool.register({
|
|
172
|
+
name: 'hello',
|
|
173
|
+
description: '打招呼',
|
|
174
|
+
inputSchema: framework.z.object({
|
|
175
|
+
name: framework.z.string().describe('姓名')
|
|
176
|
+
}),
|
|
177
|
+
execute: async (args) => ({ message: `Hello, ${args.name}!` }),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Register extension tool (via ext_call)
|
|
181
|
+
this.extension.register({
|
|
182
|
+
name: 'greet',
|
|
183
|
+
description: '打招呼扩展',
|
|
184
|
+
inputSchema: framework.z.object({
|
|
185
|
+
name: framework.z.string()
|
|
186
|
+
}),
|
|
187
|
+
execute: async (args) => ({ message: `Hi, ${args.name}!` }),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Lifecycle Auto-Management
|
|
194
|
+
|
|
195
|
+
| Operation | Effect |
|
|
196
|
+
|-----------|--------|
|
|
197
|
+
| `disable` | Auto-remove tools/extensions (keep registration records) |
|
|
198
|
+
| `enable` | Auto re-register tools/extensions |
|
|
199
|
+
| `reload` | Remove and re-register |
|
|
200
|
+
| `uninstall` | Remove and clear registration records |
|
|
159
201
|
|
|
160
202
|
## Tool Registration
|
|
161
203
|
|
|
162
|
-
|
|
204
|
+
### Recommended: `this.tool.register()` in `onStart`
|
|
205
|
+
|
|
206
|
+
```javascript
|
|
207
|
+
onStart(framework) {
|
|
208
|
+
this.tool.register({
|
|
209
|
+
name: 'my_tool',
|
|
210
|
+
description: 'Tool description',
|
|
211
|
+
inputSchema: framework.z.object({
|
|
212
|
+
param: framework.z.string().describe('Parameter description')
|
|
213
|
+
}),
|
|
214
|
+
execute: async (args) => ({ success: true, result: args.param })
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Alternative: `this.tools = {}` (ExtensionExecutor auto-scan)
|
|
220
|
+
|
|
221
|
+
```javascript
|
|
222
|
+
class MyPlugin extends Plugin {
|
|
223
|
+
name = 'my-plugin';
|
|
224
|
+
|
|
225
|
+
tools = {
|
|
226
|
+
my_tool: {
|
|
227
|
+
description: 'Tool description',
|
|
228
|
+
inputSchema: z.object({
|
|
229
|
+
param: z.string().describe('Parameter description')
|
|
230
|
+
}),
|
|
231
|
+
execute: async (args) => ({ success: true })
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Legacy: `framework.registerTool()` in `install()`
|
|
163
238
|
|
|
164
239
|
```javascript
|
|
165
240
|
install(framework) {
|
|
166
|
-
const { z } = require('zod')
|
|
167
241
|
framework.registerTool({
|
|
168
242
|
name: 'my_tool',
|
|
169
|
-
description: '
|
|
170
|
-
inputSchema: z.object({
|
|
171
|
-
param: z.string().describe('
|
|
243
|
+
description: 'Tool description',
|
|
244
|
+
inputSchema: framework.z.object({
|
|
245
|
+
param: framework.z.string().describe('Parameter description')
|
|
172
246
|
}),
|
|
173
|
-
execute: async (args
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
247
|
+
execute: async (args) => ({ success: true })
|
|
248
|
+
});
|
|
249
|
+
return this;
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Extension Registration
|
|
254
|
+
|
|
255
|
+
```javascript
|
|
256
|
+
onStart(framework) {
|
|
257
|
+
this.extension.register({
|
|
258
|
+
name: 'my_ext_tool',
|
|
259
|
+
description: 'Extension tool',
|
|
260
|
+
inputSchema: framework.z.object({
|
|
261
|
+
param: framework.z.string()
|
|
262
|
+
}),
|
|
263
|
+
execute: async (args) => ({ success: true })
|
|
264
|
+
});
|
|
178
265
|
}
|
|
179
266
|
```
|
|
180
267
|
|
|
268
|
+
## Tool/Extension Operations
|
|
269
|
+
|
|
270
|
+
```javascript
|
|
271
|
+
// Register
|
|
272
|
+
this.tool.register({ name: 'xxx', ... });
|
|
273
|
+
this.extension.register({ name: 'xxx', ... });
|
|
274
|
+
|
|
275
|
+
// Remove
|
|
276
|
+
this.tool.remove('xxx');
|
|
277
|
+
this.extension.remove('xxx');
|
|
278
|
+
|
|
279
|
+
// Execute
|
|
280
|
+
const r1 = await this.tool.execute('any-tool', { arg: 'value' }); // Execute any registered tool
|
|
281
|
+
const r2 = await this.extension.execute('xxx', { arg: 'value' }); // Execute current plugin's extension
|
|
282
|
+
const r3 = await this.extension.execute('plugin-name', 'xxx', { arg: 'value' }); // Execute specified plugin's extension
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Workflow Operations
|
|
286
|
+
|
|
287
|
+
```javascript
|
|
288
|
+
// Register workflow
|
|
289
|
+
this.workflow.register('my-workflow', {
|
|
290
|
+
name: 'my-workflow',
|
|
291
|
+
description: 'My workflow',
|
|
292
|
+
steps: [
|
|
293
|
+
{ type: 'tool', tool: 'hello', args: {} }
|
|
294
|
+
]
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// Execute workflow
|
|
298
|
+
const result = await this.workflow.execute('my-workflow', { input: 'value' });
|
|
299
|
+
|
|
300
|
+
// Remove workflow
|
|
301
|
+
this.workflow.remove('my-workflow');
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Agent Operations
|
|
305
|
+
|
|
306
|
+
```javascript
|
|
307
|
+
// Register sub-agent
|
|
308
|
+
this.agent.register({
|
|
309
|
+
name: 'my-agent',
|
|
310
|
+
role: 'Assistant',
|
|
311
|
+
goal: 'Description',
|
|
312
|
+
tools: {},
|
|
313
|
+
parentTools: ['read_file', 'write_file']
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// Get sub-agent
|
|
317
|
+
const agent = this.agent.get('my-agent');
|
|
318
|
+
|
|
319
|
+
// Remove sub-agent
|
|
320
|
+
this.agent.remove('my-agent');
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Prompt Operations
|
|
324
|
+
|
|
325
|
+
```javascript
|
|
326
|
+
// Register prompt
|
|
327
|
+
this.prompt.register('my-prompt', () => 'Prompt content', {
|
|
328
|
+
scope: 'global',
|
|
329
|
+
priority: 50
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
// Remove prompt
|
|
333
|
+
this.prompt.remove('my-prompt');
|
|
334
|
+
```
|
|
335
|
+
|
|
181
336
|
## Framework Object
|
|
182
337
|
|
|
183
338
|
The framework object provides:
|
|
184
339
|
|
|
185
|
-
| Method
|
|
186
|
-
|
|
187
|
-
| `framework.registerTool(tool)`
|
|
188
|
-
| `framework.getTools()`
|
|
189
|
-
| `framework.executeTool(name, args)` | Execute tool
|
|
190
|
-
| `framework.callTool(name, args)`
|
|
191
|
-
| `framework.createAgent(config)`
|
|
192
|
-
| `framework.reloadPlugin(name)`
|
|
193
|
-
| `framework.reloadAllPlugins()`
|
|
340
|
+
| Method | Description |
|
|
341
|
+
|--------|-------------|
|
|
342
|
+
| `framework.registerTool(tool)` | Register tool (legacy) |
|
|
343
|
+
| `framework.getTools()` | Get all tools |
|
|
344
|
+
| `framework.executeTool(name, args)` | Execute tool |
|
|
345
|
+
| `framework.callTool(name, args)` | Call tool (for installing deps) |
|
|
346
|
+
| `framework.createAgent(config)` | Create Agent |
|
|
347
|
+
| `framework.reloadPlugin(name)` | Reload single plugin |
|
|
348
|
+
| `framework.reloadAllPlugins()` | Reload all plugins |
|
|
194
349
|
|
|
195
350
|
## Dependency Management
|
|
196
351
|
|
|
@@ -229,8 +384,6 @@ await framework.callTool('install', {
|
|
|
229
384
|
|
|
230
385
|
## Common Mistakes
|
|
231
386
|
|
|
232
|
-
1. ❌
|
|
233
|
-
2. ❌ Forgetting `
|
|
234
|
-
3. ❌ Using
|
|
235
|
-
4. ❌ Registering tools outside `install()`
|
|
236
|
-
5. ❌ Using same name for folder and file - folder takes priority, file will be ignored
|
|
387
|
+
1. ❌ Using `parameters` instead of `inputSchema`
|
|
388
|
+
2. ❌ Forgetting `framework.` prefix when using `framework.z.object()`
|
|
389
|
+
3. ❌ Using same name for folder and file - folder takes priority, file will be ignored
|