foliko 2.0.11 → 2.0.13
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 +3 -1
- package/.editorconfig +56 -56
- package/.lintstagedrc +7 -7
- package/.prettierignore +29 -29
- package/.prettierrc +11 -11
- package/CLAUDE.md +1 -1
- package/Dockerfile +63 -63
- package/README.md +2 -2
- package/docs/extensions.md +3 -4
- package/docs/migration.md +3 -3
- package/docs/usage.md +3 -3
- package/install.ps1 +129 -129
- package/install.sh +121 -121
- package/package.json +1 -1
- package/plugins/core/scheduler/index.js +40 -9
- package/plugins/core/skill-manager/index.js +125 -151
- package/plugins/core/workflow/context.js +941 -941
- package/plugins/core/workflow/engine.js +66 -66
- package/plugins/core/workflow/js-runner.js +318 -318
- package/plugins/core/workflow/json-runner.js +323 -323
- package/plugins/core/workflow/stages/choice.js +74 -74
- package/plugins/core/workflow/stages/each.js +123 -123
- package/plugins/core/workflow/stages/parallel.js +69 -69
- package/plugins/executors/extension/prompt-builder.js +32 -5
- package/plugins/executors/shell/index.js +28 -0
- package/skills/find-skills/SKILL.md +133 -133
- package/skills/skill-guide/SKILL.md +99 -60
- package/src/agent/chat.js +227 -54
- package/src/utils/message-validator.js +139 -16
- package/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.jsonl +0 -266
|
@@ -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
|
+
```
|
|
@@ -100,24 +100,24 @@ frontmatter 之后是技能的正文内容,支持 Markdown 格式,包含:
|
|
|
100
100
|
打招呼命令。
|
|
101
101
|
|
|
102
102
|
**参数:**
|
|
103
|
-
- `
|
|
103
|
+
- `name`(可选):名字,默认 "World"
|
|
104
|
+
- `lang`(可选):语言,如 "en",默认 "zh"
|
|
104
105
|
|
|
105
106
|
**示例:**
|
|
106
107
|
- `/my-skill:greet` → "Hello World"
|
|
107
|
-
- `/my-skill:greet Alice` → "Hello Alice"
|
|
108
|
+
- `/my-skill:greet {"name":"Alice"}` → "Hello Alice"
|
|
108
109
|
|
|
109
110
|
### /my-skill:split
|
|
110
111
|
|
|
111
112
|
切割会话命令。
|
|
112
113
|
|
|
113
114
|
**参数:**
|
|
114
|
-
-
|
|
115
|
-
-
|
|
116
|
-
- `[args...]`:位置参数
|
|
115
|
+
- `tokens`(可选):保留 token 数,默认 4000
|
|
116
|
+
- `keepRecent`(可选):保留最近 token,默认 1000
|
|
117
117
|
|
|
118
118
|
**示例:**
|
|
119
119
|
- `/my-skill:split` → 使用默认参数
|
|
120
|
-
- `/my-skill:split
|
|
120
|
+
- `/my-skill:split {"tokens":8000}` → tokens=8000
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
### index.js 格式
|
|
@@ -127,23 +127,26 @@ module.exports = [
|
|
|
127
127
|
{
|
|
128
128
|
name: 'greet', // 命令名
|
|
129
129
|
description: '打招呼', // 命令描述
|
|
130
|
+
options: [
|
|
131
|
+
{ flags: '-n, --name <value>', description: '名字', defaultValue: 'World' },
|
|
132
|
+
{ flags: '-l, --lang <value>', description: '语言', defaultValue: 'zh' }
|
|
133
|
+
],
|
|
130
134
|
execute: async (args, ctx) => {
|
|
131
|
-
// args:
|
|
135
|
+
// args: 解析后的结构化对象,如 { name: "Alice", lang: "en" }
|
|
132
136
|
// ctx: 上下文对象 { sessionId, agent, framework }
|
|
133
|
-
return
|
|
137
|
+
return `Hello ${args.name || 'World'}`;
|
|
134
138
|
}
|
|
135
139
|
},
|
|
136
140
|
{
|
|
137
141
|
name: 'split',
|
|
138
142
|
description: '切割会话',
|
|
139
|
-
// 简洁方式:定义选项数组,自动使用 Commander.js 解析
|
|
140
143
|
options: [
|
|
141
|
-
{ flags: '-t, --tokens <value>', description: '保留 token 数', defaultValue:
|
|
142
|
-
{ flags: '-k, --keep-recent <value>', description: '保留最近 token', defaultValue:
|
|
144
|
+
{ flags: '-t, --tokens <value>', type: 'number', description: '保留 token 数', defaultValue: 4000 },
|
|
145
|
+
{ flags: '-k, --keep-recent <value>', type: 'number', description: '保留最近 token', defaultValue: 1000 }
|
|
143
146
|
],
|
|
144
|
-
execute: async (
|
|
145
|
-
//
|
|
146
|
-
return `Split: tokens=${
|
|
147
|
+
execute: async (args, ctx) => {
|
|
148
|
+
// args: { tokens: 4000, keepRecent: 1000 }
|
|
149
|
+
return `Split: tokens=${args.tokens}`;
|
|
147
150
|
}
|
|
148
151
|
},
|
|
149
152
|
{
|
|
@@ -156,11 +159,12 @@ module.exports = [
|
|
|
156
159
|
];
|
|
157
160
|
```
|
|
158
161
|
|
|
159
|
-
|
|
162
|
+
**参数类型说明:**
|
|
160
163
|
|
|
161
|
-
-
|
|
162
|
-
-
|
|
163
|
-
-
|
|
164
|
+
- `options[].type`:可选,声明参数类型 (`String` | `Number` | `Boolean` | `Array` | `Object`),帮助 LLM 理解参数格式
|
|
165
|
+
- 不提供 `options` 时,`args` 是空对象 `{}`
|
|
166
|
+
- 提供 `options` 数组时,`execute` 收到解析后的结构化对象
|
|
167
|
+
- 对象格式:`{ name, lang, tokens, keepRecent, ... }`(camelCase,匹配 flag 名称)
|
|
164
168
|
|
|
165
169
|
### 命令调用方式
|
|
166
170
|
|
|
@@ -182,11 +186,11 @@ module.exports = [
|
|
|
182
186
|
// 1. 先查询命令参数
|
|
183
187
|
ext_skill({ plugin: "skill:<技能名>" })
|
|
184
188
|
|
|
185
|
-
// 2.
|
|
189
|
+
// 2. 用结构化参数调用
|
|
186
190
|
ext_call({
|
|
187
191
|
plugin: "skill:<技能名>",
|
|
188
192
|
tool: "<commandname>",
|
|
189
|
-
args: {
|
|
193
|
+
args: { name: "Alice", lang: "en" }
|
|
190
194
|
});
|
|
191
195
|
```
|
|
192
196
|
|
|
@@ -196,30 +200,30 @@ ext_call({
|
|
|
196
200
|
|------|------|------|
|
|
197
201
|
| `plugin` | string | 固定为 `"skill:<技能名>"`,如 `skill:test-skill` |
|
|
198
202
|
| `tool` | string | 命令名(不带技能前缀),如 `greet` |
|
|
199
|
-
| `args` | object |
|
|
203
|
+
| `args` | object | 结构化参数对象,字段名对应 `options` 中的参数名(camelCase) |
|
|
200
204
|
|
|
201
205
|
**示例:**
|
|
202
206
|
|
|
203
207
|
```javascript
|
|
204
|
-
// 调用 test-skill 的 greet
|
|
208
|
+
// 调用 test-skill 的 greet 命令(带参数)
|
|
205
209
|
ext_call({
|
|
206
210
|
plugin: "skill:test-skill",
|
|
207
211
|
tool: "greet",
|
|
208
|
-
args: {
|
|
212
|
+
args: { name: "Alice", lang: "en" }
|
|
209
213
|
});
|
|
210
214
|
|
|
211
|
-
// 调用 test-skill 的 greet
|
|
215
|
+
// 调用 test-skill 的 greet 命令(使用默认参数)
|
|
212
216
|
ext_call({
|
|
213
217
|
plugin: "skill:test-skill",
|
|
214
218
|
tool: "greet",
|
|
215
|
-
args: {
|
|
219
|
+
args: {}
|
|
216
220
|
});
|
|
217
221
|
|
|
218
|
-
// 调用 test-skill 的
|
|
222
|
+
// 调用 test-skill 的 split 命令
|
|
219
223
|
ext_call({
|
|
220
224
|
plugin: "skill:test-skill",
|
|
221
|
-
tool: "
|
|
222
|
-
args: {
|
|
225
|
+
tool: "split",
|
|
226
|
+
args: { tokens: 8000 }
|
|
223
227
|
});
|
|
224
228
|
```
|
|
225
229
|
|
|
@@ -234,8 +238,23 @@ ext_call({
|
|
|
234
238
|
|
|
235
239
|
```javascript
|
|
236
240
|
module.exports = [
|
|
237
|
-
{
|
|
238
|
-
|
|
241
|
+
{
|
|
242
|
+
name: 'greet',
|
|
243
|
+
description: '打招呼',
|
|
244
|
+
options: [
|
|
245
|
+
{ flags: '-n, --name <value>', description: '名字', defaultValue: 'World' },
|
|
246
|
+
{ flags: '-l, --lang <value>', description: '语言', defaultValue: 'zh' }
|
|
247
|
+
],
|
|
248
|
+
execute: async (args) => `Hello ${args.name || 'World'}`
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
name: 'echo',
|
|
252
|
+
description: '回声命令',
|
|
253
|
+
options: [
|
|
254
|
+
{ flags: '-t, --text <value>', description: '回显文本', required: true }
|
|
255
|
+
],
|
|
256
|
+
execute: async (args) => 'Echo: ' + args.text
|
|
257
|
+
}
|
|
239
258
|
];
|
|
240
259
|
```
|
|
241
260
|
|
|
@@ -249,21 +268,22 @@ module.exports = [
|
|
|
249
268
|
打招呼命令。
|
|
250
269
|
|
|
251
270
|
**参数:**
|
|
252
|
-
- `
|
|
271
|
+
- `name`(可选):名字,默认 "World"
|
|
272
|
+
- `lang`(可选):语言,默认 "zh"
|
|
253
273
|
|
|
254
274
|
**示例:**
|
|
255
275
|
- `/test-skill:greet` → "Hello World"
|
|
256
|
-
- `/test-skill:greet Alice` → "Hello Alice"
|
|
276
|
+
- `/test-skill:greet {"name":"Alice"}` → "Hello Alice"
|
|
257
277
|
|
|
258
278
|
### /test-skill:echo
|
|
259
279
|
|
|
260
280
|
回声命令,将输入原样返回。
|
|
261
281
|
|
|
262
282
|
**参数:**
|
|
263
|
-
- `
|
|
283
|
+
- `text`(必填):要回显的文本
|
|
264
284
|
|
|
265
285
|
**示例:**
|
|
266
|
-
- `/test-skill:echo Hello` → "Echo: Hello"
|
|
286
|
+
- `/test-skill:echo {"text":"Hello"}` → "Echo: Hello"
|
|
267
287
|
```
|
|
268
288
|
|
|
269
289
|
### 自动注册
|
|
@@ -338,23 +358,26 @@ module.exports = [
|
|
|
338
358
|
{
|
|
339
359
|
name: 'greet', // 命令名
|
|
340
360
|
description: '打招呼', // 命令描述
|
|
361
|
+
options: [
|
|
362
|
+
{ flags: '-n, --name <value>', description: '名字', defaultValue: 'World' },
|
|
363
|
+
{ flags: '-l, --lang <value>', description: '语言', defaultValue: 'zh' }
|
|
364
|
+
],
|
|
341
365
|
execute: async (args, ctx) => {
|
|
342
|
-
// args:
|
|
366
|
+
// args: 解析后的结构化对象,如 { name: "Alice", lang: "en" }
|
|
343
367
|
// ctx: 上下文对象 { sessionId, agent, framework }
|
|
344
|
-
return
|
|
368
|
+
return `Hello ${args.name || 'World'}`;
|
|
345
369
|
}
|
|
346
370
|
},
|
|
347
371
|
{
|
|
348
372
|
name: 'split',
|
|
349
373
|
description: '切割会话',
|
|
350
|
-
// 简洁方式:定义选项数组,自动使用 Commander.js 解析
|
|
351
374
|
options: [
|
|
352
|
-
{ flags: '-t, --tokens <value>', description: '保留 token 数', defaultValue:
|
|
353
|
-
{ flags: '-k, --keep-recent <value>', description: '保留最近 token', defaultValue:
|
|
375
|
+
{ flags: '-t, --tokens <value>', type: 'number', description: '保留 token 数', defaultValue: 4000 },
|
|
376
|
+
{ flags: '-k, --keep-recent <value>', type: 'number', description: '保留最近 token', defaultValue: 1000 }
|
|
354
377
|
],
|
|
355
|
-
execute: async (
|
|
356
|
-
//
|
|
357
|
-
return `Split: tokens=${
|
|
378
|
+
execute: async (args, ctx) => {
|
|
379
|
+
// args: { tokens: 4000, keepRecent: 1000 }
|
|
380
|
+
return `Split: tokens=${args.tokens}`;
|
|
358
381
|
}
|
|
359
382
|
},
|
|
360
383
|
{
|
|
@@ -367,11 +390,12 @@ module.exports = [
|
|
|
367
390
|
];
|
|
368
391
|
```
|
|
369
392
|
|
|
370
|
-
|
|
393
|
+
**参数类型说明:**
|
|
371
394
|
|
|
372
|
-
-
|
|
373
|
-
-
|
|
374
|
-
-
|
|
395
|
+
- `options[].type`:可选,声明参数类型 (`String` | `Number` | `Boolean` | `Array` | `Object`),帮助 LLM 理解参数格式
|
|
396
|
+
- 不提供 `options` 时,`args` 是空对象 `{}`
|
|
397
|
+
- 提供 `options` 数组时,`execute` 收到解析后的结构化对象
|
|
398
|
+
- 对象格式:`{ name, lang, tokens, keepRecent, ... }`(camelCase,匹配 flag 名称)
|
|
375
399
|
|
|
376
400
|
### 命令调用方式
|
|
377
401
|
|
|
@@ -393,11 +417,11 @@ module.exports = [
|
|
|
393
417
|
// 1. 先查询命令参数
|
|
394
418
|
ext_skill({ plugin: "skill:<技能名>" })
|
|
395
419
|
|
|
396
|
-
// 2.
|
|
420
|
+
// 2. 用结构化参数调用
|
|
397
421
|
ext_call({
|
|
398
422
|
plugin: "skill:<技能名>",
|
|
399
423
|
tool: "<commandname>",
|
|
400
|
-
args: {
|
|
424
|
+
args: { name: "Alice", lang: "en" }
|
|
401
425
|
});
|
|
402
426
|
```
|
|
403
427
|
|
|
@@ -407,30 +431,30 @@ ext_call({
|
|
|
407
431
|
|------|------|------|
|
|
408
432
|
| `plugin` | string | 固定为 `"skill:<技能名>"`,如 `skill:test-skill` |
|
|
409
433
|
| `tool` | string | 命令名(不带技能前缀),如 `greet` |
|
|
410
|
-
| `args` | object |
|
|
434
|
+
| `args` | object | 结构化参数对象,字段名对应 `options` 中的参数名(camelCase) |
|
|
411
435
|
|
|
412
436
|
**示例:**
|
|
413
437
|
|
|
414
438
|
```javascript
|
|
415
|
-
// 调用 test-skill 的 greet
|
|
439
|
+
// 调用 test-skill 的 greet 命令(带参数)
|
|
416
440
|
ext_call({
|
|
417
441
|
plugin: "skill:test-skill",
|
|
418
442
|
tool: "greet",
|
|
419
|
-
args: {
|
|
443
|
+
args: { name: "Alice", lang: "en" }
|
|
420
444
|
});
|
|
421
445
|
|
|
422
|
-
// 调用 test-skill 的 greet
|
|
446
|
+
// 调用 test-skill 的 greet 命令(使用默认参数)
|
|
423
447
|
ext_call({
|
|
424
448
|
plugin: "skill:test-skill",
|
|
425
449
|
tool: "greet",
|
|
426
|
-
args: {
|
|
450
|
+
args: {}
|
|
427
451
|
});
|
|
428
452
|
|
|
429
|
-
// 调用 test-skill 的
|
|
453
|
+
// 调用 test-skill 的 split 命令
|
|
430
454
|
ext_call({
|
|
431
455
|
plugin: "skill:test-skill",
|
|
432
|
-
tool: "
|
|
433
|
-
args: {
|
|
456
|
+
tool: "split",
|
|
457
|
+
args: { tokens: 8000 }
|
|
434
458
|
});
|
|
435
459
|
```
|
|
436
460
|
|
|
@@ -445,16 +469,31 @@ ext_call({
|
|
|
445
469
|
|
|
446
470
|
```javascript
|
|
447
471
|
module.exports = [
|
|
448
|
-
{
|
|
449
|
-
|
|
472
|
+
{
|
|
473
|
+
name: 'greet',
|
|
474
|
+
description: '打招呼',
|
|
475
|
+
options: [
|
|
476
|
+
{ flags: '-n, --name <value>', description: '名字', defaultValue: 'World' },
|
|
477
|
+
{ flags: '-l, --lang <value>', description: '语言', defaultValue: 'zh' }
|
|
478
|
+
],
|
|
479
|
+
execute: async (args) => `Hello ${args.name || 'World'}`
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
name: 'echo',
|
|
483
|
+
description: '回声命令',
|
|
484
|
+
options: [
|
|
485
|
+
{ flags: '-t, --text <value>', description: '回显文本', required: true }
|
|
486
|
+
],
|
|
487
|
+
execute: async (args) => 'Echo: ' + args.text
|
|
488
|
+
}
|
|
450
489
|
];
|
|
451
490
|
```
|
|
452
491
|
|
|
453
492
|
**使用方法:**
|
|
454
493
|
|
|
455
494
|
- `/test-skill:greet` → 返回 "Hello World"
|
|
456
|
-
- `/test-skill:greet Alice` → 返回 "Hello Alice"
|
|
457
|
-
- `/test-skill:echo Hello` → 返回 "Echo: Hello"
|
|
495
|
+
- `/test-skill:greet {"name":"Alice"}` → 返回 "Hello Alice"
|
|
496
|
+
- `/test-skill:echo {"text":"Hello"}` → 返回 "Echo: Hello"
|
|
458
497
|
|
|
459
498
|
### 自动注册
|
|
460
499
|
|