@archon-claw/cli 0.5.0 → 0.5.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.
@@ -1,151 +0,0 @@
1
- ---
2
- name: create-mcp-config
3
- description: 创建或修改 MCP 服务器配置文件。当用户需要连接外部 MCP 服务器、添加 MCP 工具时使用。
4
- ---
5
-
6
- 创建或修改 `agents/my-agent/mcp.json` MCP 服务器配置文件。
7
-
8
- ## 规范
9
-
10
- - 文件位于 Agent 配置文件夹根目录,文件名固定为 `mcp.json`
11
- - 该文件是可选的,不存在时 agent 只使用本地工具
12
- - MCP 工具会自动合并到 agent 的工具列表中,与本地工具无区别
13
-
14
- ## 字段
15
-
16
- ### 顶层
17
-
18
- | 字段 | 类型 | 必填 | 说明 |
19
- |------|------|------|------|
20
- | `mcpServers` | object | 是 | 服务器配置,key 为服务器名称 |
21
-
22
- ### 每个 server 配置
23
-
24
- | 字段 | 类型 | 必填 | 说明 |
25
- |------|------|------|------|
26
- | `command` | string | stdio 时必填 | 可执行命令 |
27
- | `args` | string[] | 否 | 命令行参数 |
28
- | `env` | object | 否 | 环境变量,支持 `${VAR}` 引用 process.env |
29
- | `cwd` | string | 否 | 工作目录 |
30
- | `url` | string | SSE/HTTP 时必填 | 远程服务器 URL |
31
- | `headers` | object | 否 | HTTP 请求头 |
32
- | `transport` | string | 否 | `"stdio"` / `"sse"` / `"streamable-http"`,可自动推断 |
33
- | `enabled` | boolean | 否 | 设为 `false` 可禁用,默认 `true` |
34
- | `timeout` | number | 否 | 工具调用超时(毫秒),默认 30000 |
35
- | `tools` | object | 否 | 工具过滤配置 |
36
-
37
- ### tools 过滤
38
-
39
- | 字段 | 类型 | 说明 |
40
- |------|------|------|
41
- | `include` | string[] | glob 模式白名单,只暴露匹配的工具 |
42
- | `exclude` | string[] | glob 模式黑名单,隐藏匹配的工具 |
43
- | `rename` | object | 重命名映射,如 `{"browser_navigate": "goto"}` |
44
-
45
- ## Transport 自动推断
46
-
47
- - 有 `command` → `stdio`(本地进程通信)
48
- - 有 `url` → 先尝试 `streamable-http`,失败后自动 fallback 到 `sse`
49
- - 显式指定 `transport` 可跳过自动推断(如确定只用 SSE 时写 `"transport": "sse"`)
50
- - `command` 和 `url` 至少提供一个
51
-
52
- ## 工具命名规则
53
-
54
- - 默认名称格式:`{serverName}__{toolName}`(避免冲突)
55
- - 通过 `rename` 可自定义名称(不加前缀)
56
- - 名称会自动规范化为 `^[a-z][a-z0-9_]*$`
57
-
58
- ## 示例
59
-
60
- ### 本地 stdio 服务器
61
-
62
- ```json
63
- {
64
- "mcpServers": {
65
- "playwright": {
66
- "command": "npx",
67
- "args": ["@playwright/mcp@latest"],
68
- "timeout": 60000,
69
- "tools": {
70
- "include": ["browser_*"],
71
- "exclude": ["browser_install"]
72
- }
73
- }
74
- }
75
- }
76
- ```
77
-
78
- ### 远程服务器(自动协商协议)
79
-
80
- 只需提供 `url`,会先尝试 streamable-http,不支持则自动降级为 SSE:
81
-
82
- ```json
83
- {
84
- "mcpServers": {
85
- "remote_api": {
86
- "url": "https://my-server.com/mcp",
87
- "headers": {
88
- "Authorization": "Bearer ${API_TOKEN}"
89
- }
90
- }
91
- }
92
- }
93
- ```
94
-
95
- ### 强制指定 SSE
96
-
97
- 如果确定服务器只支持 SSE,可显式指定以跳过 streamable-http 尝试:
98
-
99
- ```json
100
- {
101
- "mcpServers": {
102
- "legacy": {
103
- "transport": "sse",
104
- "url": "https://old-server.com/sse"
105
- }
106
- }
107
- }
108
- ```
109
-
110
- ### 多服务器配置
111
-
112
- ```json
113
- {
114
- "mcpServers": {
115
- "filesystem": {
116
- "command": "npx",
117
- "args": ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"]
118
- },
119
- "github": {
120
- "command": "npx",
121
- "args": ["-y", "@modelcontextprotocol/server-github"],
122
- "env": {
123
- "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
124
- }
125
- }
126
- }
127
- }
128
- ```
129
-
130
- ## 在系统提示词中引用 MCP 工具
131
-
132
- MCP 服务器和工具会自动注入到 `system-prompt.md` 的 Liquid 模板变量 `mcp` 中,可按服务器名称访问:
133
-
134
- ```markdown
135
- {% for tool in mcp.playwright.tools %}
136
- - {{ tool.name }}:{{ tool.description }}
137
- {% endfor %}
138
- ```
139
-
140
- 详见 `/create-system-prompt` 技能中的 `mcp 变量` 部分。
141
-
142
- ## 注意
143
-
144
- - `command` 和 `url` 至少提供一个,否则校验失败
145
- - 环境变量中的敏感信息(API Key 等)用 `${VAR}` 引用,不要硬编码
146
- - 服务器连接失败不会阻止 agent 启动,只会打印警告
147
- - MCP 工具与本地工具同名时,本地工具优先(MCP 工具被跳过并打印警告)
148
- - 不要添加未定义的字段(strict 模式)
149
- - `mcpServers` 的 key(服务器名称)会作为 `mcp.{name}` 暴露给系统提示词模板
150
-
151
- 请根据用户的需求创建或修改 MCP 配置。$ARGUMENTS
@@ -1,45 +0,0 @@
1
- ---
2
- name: create-model-config
3
- description: 创建或修改模型配置文件。当用户需要配置 LLM 模型、修改 model.json 时使用。
4
- ---
5
-
6
- 创建或修改 `agents/my-agent/model.json` 模型配置文件。
7
-
8
- ## 规范
9
-
10
- - 文件位于 Agent 配置文件夹根目录
11
- - 必须通过 `src/schemas/model.schema.json` 的校验
12
-
13
- ## 字段
14
-
15
- | 字段 | 类型 | 必填 | 默认值 | 说明 |
16
- |------|------|------|--------|------|
17
- | `provider` | string | 是 | - | `"anthropic"` 或 `"openai"` |
18
- | `model` | string | 是 | - | 模型 ID |
19
- | `maxTokens` | number | 否 | 4096 | 最大输出 token 数 |
20
- | `temperature` | number | 否 | 0.7 | 采样温度,0~2 |
21
- | `apiKey` | string | 否 | - | API Key,优先用环境变量 |
22
-
23
- ## 常用模型 ID
24
-
25
- Anthropic: `claude-sonnet-4-20250514`、`claude-opus-4-20250514`、`claude-haiku-4-5-20251001`
26
- OpenAI: `gpt-4o`、`gpt-4o-mini`
27
-
28
- ## 示例
29
-
30
- ```json
31
- {
32
- "provider": "anthropic",
33
- "model": "claude-sonnet-4-20250514",
34
- "maxTokens": 4096,
35
- "temperature": 0.7
36
- }
37
- ```
38
-
39
- ## 注意
40
-
41
- - `provider` 和 `model` 必填
42
- - `apiKey` 建议不写在文件里,用环境变量(`ANTHROPIC_API_KEY` / `OPENAI_API_KEY`)
43
- - 不要添加未定义的字段(`additionalProperties: false`)
44
-
45
- 请根据用户的需求创建或修改模型配置。$ARGUMENTS
@@ -1,63 +0,0 @@
1
- ---
2
- name: create-skill
3
- description: 创建 agent skill 技能。当用户需要为 agent 添加新的技能(如代码审查、解释代码等)时使用。
4
- ---
5
-
6
- 在 `agents/my-agent/skills/` 目录下创建一个新的技能。
7
-
8
- ## 规范
9
-
10
- - 创建 `skills/<skill-name>/SKILL.md` 文件
11
- - 必须通过 `src/schemas/agent-skill.schema.json` 的校验
12
- - frontmatter 必须包含 `name` 和 `description`
13
- - body 不能为空
14
-
15
- ## 文件结构
16
-
17
- ```
18
- skills/
19
- └── <skill-name>/
20
- └── SKILL.md
21
- ```
22
-
23
- ## 格式
24
-
25
- ```markdown
26
- ---
27
- name: skill-name
28
- description: 技能描述,说明什么场景下使用
29
- ---
30
-
31
- 技能的具体指令内容...
32
- ```
33
-
34
- ## frontmatter 字段
35
-
36
- | 字段 | 类型 | 必填 | 说明 |
37
- |------|------|------|------|
38
- | `name` | string | 是 | 技能名称 |
39
- | `description` | string | 是 | 技能用途描述 |
40
-
41
- ## 示例
42
-
43
- ```markdown
44
- ---
45
- name: code-review
46
- description: 对代码进行 review,检查潜在问题并给出改进建议
47
- ---
48
-
49
- 对用户提供的代码进行审查,关注以下方面:
50
-
51
- 1. **正确性**:逻辑是否正确
52
- 2. **安全性**:是否有安全隐患
53
- 3. **性能**:是否有明显的性能问题
54
- 4. **可读性**:命名是否清晰
55
- ```
56
-
57
- ## 注意
58
-
59
- - `name` 和 `description` 都是必填的
60
- - body 内容是技能的具体指令,不能为空
61
- - 不要添加 `name` 和 `description` 以外的 frontmatter 字段
62
-
63
- 请根据用户需求创建技能。$ARGUMENTS
@@ -1,168 +0,0 @@
1
- ---
2
- name: create-system-prompt
3
- description: 创建或修改系统提示词。当用户需要编写 system-prompt.md 时使用。
4
- ---
5
-
6
- 创建或修改 agent 的 `system-prompt.md` 系统提示词文件。
7
-
8
- ## 规范
9
-
10
- - 文件位于 agent 配置文件夹根目录
11
- - 内容不能为空
12
- - 支持 Liquid 模板语法引用 datasets/ 和 skills/ 中的数据
13
- - 模板语法会在启动时由 liquidjs 解析验证
14
-
15
- ## Liquid 模板变量
16
-
17
- ### datasets 变量
18
-
19
- datasets/ 中的文件名(去掉 `.json`)即为变量名:
20
-
21
- ```markdown
22
- {% for rule in rules %}
23
- - {{ rule }}
24
- {% endfor %}
25
- ```
26
-
27
- ### skills 变量
28
-
29
- skills/ 中的技能会自动注入为 `skills` 数组,每个元素包含 `name` 和 `description`:
30
-
31
- ```markdown
32
- {% for skill in skills %}
33
- - **{{ skill.name }}**:{{ skill.description }}
34
- {% endfor %}
35
- ```
36
-
37
- ### tools / tool 变量
38
-
39
- 所有工具(本地 + MCP)提供两种访问方式:
40
-
41
- - `tools` — 数组,用于遍历
42
- - `tool` — 对象(map),按名字直接访问
43
-
44
- ```markdown
45
- {# 数组遍历 #}
46
- {% for tool in tools %}
47
- - **{{ tool.name }}**:{{ tool.description }}
48
- {% endfor %}
49
-
50
- {# 按名字访问 #}
51
- {{ tool.search.description }}
52
- ```
53
-
54
- ### mcp 变量
55
-
56
- mcp.json 中配置的 MCP 服务器和工具,按服务器名称分组访问:
57
-
58
- 每个服务器也提供 `tools`(数组)和 `tool`(对象)两种形式:
59
-
60
- **遍历特定服务器的工具:**
61
-
62
- ```markdown
63
- {% for tool in mcp.playwright.tools %}
64
- - {{ tool.name }}:{{ tool.description }}
65
- {% endfor %}
66
- ```
67
-
68
- **按名字访问特定工具:**
69
-
70
- ```markdown
71
- {{ mcp.playwright.tool.playwright__browser_click.description }}
72
- ```
73
-
74
- **遍历所有服务器:**
75
-
76
- ```markdown
77
- {% for server in mcp.servers %}
78
- ### {{ server.name }}
79
- {% for tool in server.tools %}
80
- - {{ tool.name }}:{{ tool.description }}
81
- {% endfor %}
82
- {% endfor %}
83
- ```
84
-
85
- **访问服务器名称:**
86
-
87
- ```markdown
88
- {{ mcp.playwright.name }}
89
- ```
90
-
91
- > `mcp.{serverName}` 中的 serverName 对应 mcp.json 里 `mcpServers` 的 key。
92
-
93
- ## Liquid 模板语法
94
-
95
- ### 遍历对象数组
96
-
97
- ```markdown
98
- {% for item in examples %}
99
- ### 问:{{ item.input }}
100
- {{ item.output }}
101
- {% endfor %}
102
- ```
103
-
104
- ### 条件判断
105
-
106
- ```markdown
107
- {% if greeting %}
108
- {{ greeting }}
109
- {% endif %}
110
- ```
111
-
112
- ## 示例
113
-
114
- ```markdown
115
- 你是一个专业的编程助手。
116
-
117
- ## 规则
118
-
119
- {% for rule in rules %}
120
- - {{ rule }}
121
- {% endfor %}
122
-
123
- ## 可用技能
124
-
125
- {% for skill in skills %}
126
- - **{{ skill.name }}**:{{ skill.description }}
127
- {% endfor %}
128
-
129
- ## 可用工具
130
-
131
- {% for tool in tools %}
132
- - **{{ tool.name }}**:{{ tool.description }}
133
- {% endfor %}
134
-
135
- ## 浏览器工具
136
-
137
- {% for tool in mcp.playwright.tools %}
138
- - {{ tool.name }}:{{ tool.description }}
139
- {% endfor %}
140
-
141
- ## 示例
142
-
143
- {% for item in examples %}
144
- ### 问:{{ item.input }}
145
-
146
- {{ item.output }}
147
-
148
- {% endfor %}
149
- ```
150
-
151
- ## 写作建议
152
-
153
- 1. 开头明确 agent 的角色定位
154
- 2. 用 Markdown 标题组织结构(# 角色、## 规则、## 技能、## 示例)
155
- 3. 规则用列表形式,简洁明了
156
- 4. few-shot 示例放在 datasets/ 中通过模板引用,保持文件整洁
157
- 5. 避免在提示词中硬编码大量数据,用 datasets 管理
158
- 6. 用 `skills` 变量列出可用技能,让 agent 知道自己能做什么
159
- 7. 用 `tools` 变量列出所有工具,用 `mcp.{serverName}.tools` 按服务器分类展示 MCP 工具
160
-
161
- ## 注意
162
-
163
- - 不要使用 YAML frontmatter(system-prompt.md 不需要)
164
- - Liquid 标签必须正确闭合(`{% for %}...{% endfor %}`、`{% if %}...{% endif %}`)
165
- - datasets 模板变量名必须和 datasets/ 中的文件名一致
166
- - `skills`、`tools`、`tool`、`mcp` 是内置变量名,不要在 datasets/ 中创建同名文件
167
-
168
- 请根据用户需求创建或修改系统提示词。$ARGUMENTS
@@ -1,56 +0,0 @@
1
- ---
2
- name: create-tool
3
- description: 创建工具定义 JSON 文件。当用户需要新增一个 tool、定义工具 schema 时使用。
4
- argument-hint: "[tool_name]"
5
- ---
6
-
7
- 在 `agents/my-agent/tools/` 目录下创建一个新的工具定义 JSON 文件。
8
-
9
- ## 规范
10
-
11
- - 文件名与工具 `name` 一致,如 `send_email.json`
12
- - 必须通过 `src/schemas/tool.schema.json` 的校验
13
-
14
- ## 必填字段
15
-
16
- - `name`:工具名称,匹配 `^[a-z][a-z0-9_]*$`
17
- - `description`:工具用途描述,要让模型理解何时调用
18
- - `input_schema`:入参定义,JSON Schema object 子集
19
-
20
- ## input_schema 规范
21
-
22
- - `type` 必须为 `"object"`
23
- - `properties` 中每个参数必须有 `type`(string / number / boolean / array / object)
24
- - 建议每个参数写 `description`
25
- - 可选:`enum`、`items`(array 子项)、`required`(必填参数列表)
26
-
27
- ## 示例
28
-
29
- ```json
30
- {
31
- "name": "web_search",
32
- "description": "Search the web and return relevant results for a given query",
33
- "input_schema": {
34
- "type": "object",
35
- "properties": {
36
- "query": {
37
- "type": "string",
38
- "description": "The search query"
39
- },
40
- "limit": {
41
- "type": "number",
42
- "description": "Maximum number of results to return"
43
- }
44
- },
45
- "required": ["query"]
46
- }
47
- }
48
- ```
49
-
50
- ## 注意
51
-
52
- - 一个文件只定义一个工具
53
- - `required` 只列真正必须的参数
54
- - 不要添加 `name`、`description`、`input_schema` 以外的字段
55
-
56
- 请根据用户的需求创建工具定义文件。$ARGUMENTS
@@ -1,83 +0,0 @@
1
- ---
2
- name: create-tool-impl
3
- description: 创建工具实现文件。当用户需要为 tool 编写具体的实现代码时使用。
4
- argument-hint: "[tool_name]"
5
- ---
6
-
7
- 在 `agents/my-agent/tool-impls/` 目录下创建工具实现文件。
8
-
9
- ## 规范
10
-
11
- - 文件名格式:`<tool-name>.impl.js`,与 `tools/<tool-name>.json` 一一对应
12
- - ES6 模块语法,`export default async function`
13
- - 函数接收参数对象,参数与对应 tool JSON 的 `input_schema.properties` 一致
14
- - 返回 Promise<object>
15
-
16
- ## 文件结构
17
-
18
- ```
19
- tool-impls/
20
- └── <tool-name>.impl.js ← 与 tools/<tool-name>.json 对应
21
- ```
22
-
23
- ## 模板
24
-
25
- ```javascript
26
- /**
27
- * <Tool description>
28
- * @param {object} params
29
- * @param {<type>} params.<param_name> - <param description>
30
- * @returns {Promise<object>} <return description>
31
- */
32
- export default async ({ param1, param2 }) => {
33
- // 实现逻辑
34
- return { result: "..." };
35
- };
36
- ```
37
-
38
- ## 示例
39
-
40
- ### 搜索工具(对应 tools/search.json)
41
-
42
- ```javascript
43
- /**
44
- * Search tool implementation
45
- * @param {object} params
46
- * @param {string} params.query - Search query
47
- * @returns {Promise<object>} Search results
48
- */
49
- export default async ({ query }) => {
50
- // TODO: integrate with real search API
51
- return {
52
- results: [
53
- { title: `Result for: ${query}`, url: "https://example.com" },
54
- ],
55
- };
56
- };
57
- ```
58
-
59
- ### 计算器(对应 tools/calculator.json)
60
-
61
- ```javascript
62
- /**
63
- * Calculator tool implementation
64
- * @param {object} params
65
- * @param {string} params.expression - Mathematical expression
66
- * @returns {Promise<object>} Calculation result
67
- */
68
- export default async ({ expression }) => {
69
- const result = Function(`"use strict"; return (${expression})`)();
70
- return { expression, result };
71
- };
72
- ```
73
-
74
- ## 注意
75
-
76
- - 文件名必须是 `<tool-name>.impl.js`,其中 `<tool-name>` 与 tools/ 中的 JSON 文件名一致
77
- - 函数参数通过解构获取,参数名与 tool JSON 中 `input_schema.properties` 的 key 一致
78
- - 必须使用 `export default`,不能用 `module.exports`
79
- - 函数必须是 async 的,返回对象
80
- - 用 JSDoc 注释描述参数和返回值
81
- - 每个 tool 必须有且仅有一个对应的 impl 文件
82
-
83
- 请根据用户的需求创建工具实现文件。$ARGUMENTS
@@ -1,117 +0,0 @@
1
- ---
2
- name: create-tool-test
3
- description: 创建工具测试文件。当用户需要为 tool-impl 编写测试用例时使用。
4
- argument-hint: "[tool_name]"
5
- ---
6
-
7
- 在 `agents/my-agent/tests/` 目录下创建工具测试文件。
8
-
9
- ## 规范
10
-
11
- - 文件名格式:`<tool-name>.test.js`,与 `tool-impls/<tool-name>.impl.js` 一一对应
12
- - ES6 模块语法,`export default` 导出测试用例数组
13
- - 每个测试用例是一个对象,包含 `name`、`args`,以及可选的 `expected` 或 `validate`
14
- - 通过 `archon-claw test <agent-dir>` 命令运行
15
-
16
- ## 文件结构
17
-
18
- ```
19
- agents/<agent-name>/
20
- ├── tool-impls/
21
- │ └── <tool-name>.impl.js ← 工具实现
22
- └── tests/
23
- └── <tool-name>.test.js ← 对应的测试文件
24
- ```
25
-
26
- ## 测试用例字段
27
-
28
- | 字段 | 类型 | 必填 | 说明 |
29
- |------|------|------|------|
30
- | `name` | string | 是 | 测试名称,描述测试内容 |
31
- | `args` | object | 是 | 传给 impl 函数的参数 |
32
- | `expected` | any | 否 | 期望返回值,深度比较 |
33
- | `validate` | function | 否 | 自定义校验函数 |
34
-
35
- ### 三种断言方式
36
-
37
- 1. **`expected`** — 精确匹配返回值(深度比较)
38
- 2. **`validate(result)`** — 自定义校验,返回 `true` 表示通过,返回字符串表示失败原因
39
- 3. **都不写** — 只验证调用不抛异常
40
-
41
- ## 模板
42
-
43
- ```javascript
44
- export default [
45
- {
46
- name: "描述测试内容",
47
- args: { param1: "value1" },
48
- expected: { result: "expected_value" },
49
- },
50
- {
51
- name: "自定义校验",
52
- args: { param1: "value1" },
53
- validate: (result) =>
54
- result.field === "expected" || `expected "expected", got "${result.field}"`,
55
- },
56
- {
57
- name: "只要不抛异常就通过",
58
- args: { param1: "value1" },
59
- },
60
- ];
61
- ```
62
-
63
- ## 示例
64
-
65
- ### 计算器测试(对应 tool-impls/calculator.impl.js)
66
-
67
- ```javascript
68
- export default [
69
- {
70
- name: "addition: 1 + 2 = 3",
71
- args: { expression: "1 + 2" },
72
- expected: { expression: "1 + 2", result: 3 },
73
- },
74
- {
75
- name: "complex expression",
76
- args: { expression: "(10 + 5) * 2 - 4" },
77
- validate: (result) => result.result === 26 || `expected 26, got ${result.result}`,
78
- },
79
- ];
80
- ```
81
-
82
- ### 搜索测试(对应 tool-impls/search.impl.js)
83
-
84
- ```javascript
85
- export default [
86
- {
87
- name: "returns results array",
88
- args: { query: "hello" },
89
- validate: (result) =>
90
- Array.isArray(result.results) || "expected results to be an array",
91
- },
92
- {
93
- name: "result contains query in title",
94
- args: { query: "test query" },
95
- validate: (result) =>
96
- result.results[0]?.title.includes("test query") ||
97
- `expected title to contain "test query"`,
98
- },
99
- ];
100
- ```
101
-
102
- ## 运行测试
103
-
104
- ```bash
105
- archon-claw test agents/my-agent
106
- ```
107
-
108
- ## 注意
109
-
110
- - 测试文件放在 `tests/` 目录,与 `tool-impls/` 同级
111
- - 文件名必须是 `<tool-name>.test.js`,其中 `<tool-name>` 与 `tool-impls/` 中的 `.impl.js` 文件名一致
112
- - 必须使用 `export default`,导出数组
113
- - 每个用例必须有 `name` 和 `args`
114
- - `validate` 函数返回 `true` 或错误消息字符串
115
- - `expected` 和 `validate` 二选一,都不写则只检查不抛异常
116
-
117
- 请根据用户的需求创建工具测试文件。$ARGUMENTS