@ia-ccun/code-agent-cli 0.0.50 → 0.0.51-beta.10

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 CHANGED
@@ -217,22 +217,48 @@ aicode-cli --list-models # 列出可用模型
217
217
 
218
218
  ### 创建自定义 Skill
219
219
 
220
- 在 `~/.aicode-cli/skills/` 目录下创建 `.md` 文件:
220
+ 在 `~/.aicode-cli/agent/skills/<skill-name>/` 目录下创建 `SKILL.md` 文件:
221
+
222
+ ```bash
223
+ # 创建技能目录
224
+ mkdir -p ~/.aicode-cli/agent/skills/my-skill
225
+
226
+ # 创建 SKILL.md
227
+ cat > ~/.aicode-cli/agent/skills/my-skill/SKILL.md << 'EOF'
228
+ ---
229
+ name: my-skill
230
+ description: "技能的简短描述。Use when 触发条件描述。"
231
+ metadata:
232
+ version: "1.0.0"
233
+ author: "your-name"
234
+ ---
221
235
 
222
- ```markdown
223
236
  # My Skill
224
237
 
225
238
  ## 描述
226
- 技能说明
239
+ 技能的详细说明
227
240
 
228
241
  ## 触发方式
229
- /skill:my-skill
242
+ `/skill:my-skill`
230
243
 
231
244
  ## 执行步骤
232
245
  1. 步骤一
233
246
  2. 步骤二
247
+ EOF
234
248
  ```
235
249
 
250
+ **字段说明:**
251
+
252
+ | 字段 | 必填 | 说明 |
253
+ |------|------|------|
254
+ | `name` | 是 | 技能标识符(小写+连字符),与目录名一致 |
255
+ | `description` | 是 | 触发条件描述,Agent 据此判断何时使用该技能 |
256
+ | `disable-model-invocation` | 否 | 设为 `true` 时禁止调用 LLM,纯本地执行 |
257
+ | `metadata.version` | 否 | 版本号 |
258
+ | `metadata.author` | 否 | 作者 |
259
+
260
+ > ⚠️ 文件名必须为 `SKILL.md`,且放在独立目录中(目录名与 `name` 一致)。
261
+
236
262
  ## 预置 Prompts
237
263
 
238
264
  内置 Prompt 模板位于 `config/agent/prompts/`(打包在 npm 包中)
@@ -246,6 +272,68 @@ aicode-cli --list-models # 列出可用模型
246
272
  | `/feat` | 功能开发 - 辅助功能开发 |
247
273
  | `/workflow` | 工作流 - 执行复杂工作流 |
248
274
 
275
+ ## 自定义 Agents
276
+
277
+ 内置 Agent 示例位于 `config/agent/agents/`(打包在 npm 包中)
278
+
279
+ | Agent | 说明 |
280
+ |-------|------|
281
+ | `agent-example` | 示例 Agent - 展示如何创建自定义 subagent |
282
+
283
+ ### 创建自定义 Agent
284
+
285
+ 在 `~/.aicode-cli/agent/agents/` 目录下创建 `<name>.md` 文件:
286
+
287
+ ```bash
288
+ # 创建 Agent 文件
289
+ cat > ~/.aicode-cli/agent/agents/my-agent.md << 'EOF'
290
+ ---
291
+ name: my-agent
292
+ description: "自定义 Agent 的简短描述"
293
+ tools: "read,bash,write,edit"
294
+ model: "qwen3.5-35b-a3b"
295
+ ---
296
+
297
+ # My Agent
298
+
299
+ ## 角色
300
+ 你是一个专业的代码优化助手...
301
+
302
+ ## 能力
303
+ 1. 代码分析
304
+ 2. 性能优化
305
+ 3. 重构建议
306
+
307
+ ## 工作流程
308
+ 1. 阅读代码
309
+ 2. 分析问题
310
+ 3. 提供建议
311
+ EOF
312
+ ```
313
+
314
+ **字段说明:**
315
+
316
+ | 字段 | 必填 | 说明 |
317
+ |------|------|------|
318
+ | `name` | 是 | Agent 标识符(小写+连字符) |
319
+ | `description` | 是 | 功能描述,用户据此选择 Agent |
320
+ | `tools` | 否 | 逗号分隔的工具列表 |
321
+ | `model` | 否 | 指定使用的模型 |
322
+
323
+ ### 使用 Agent
324
+
325
+ 在对话中自然语言调用:
326
+
327
+ ```
328
+ 使用 my-agent 来优化这段代码
329
+ ```
330
+
331
+ 或配合 pi-subagents 使用:
332
+
333
+ ```
334
+ /run my-agent "Review this implementation"
335
+ ```
336
+
249
337
  ## 项目结构
250
338
 
251
339
  ```
@@ -265,11 +353,3 @@ aicode-cli --list-models # 列出可用模型
265
353
  │ └── postinstall.js # 安装脚本
266
354
  └── package.json
267
355
  ```
268
-
269
- ## 文档
270
-
271
- 更多功能请参考 [pi-coding-agent 文档](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent)
272
-
273
- ## License
274
-
275
- MIT
package/bin/cli.js CHANGED
@@ -144,7 +144,7 @@ if (config.banner === '__default__' || config.banner !== '') {
144
144
  // 检查新版本
145
145
  async function checkForUpdates() {
146
146
  try {
147
- const { execSync } = await import('child_process');
147
+ const { execFileSync } = await import('child_process');
148
148
  // 读取本地版本 - 向上查找 package.json
149
149
  let rootDir = __dirname;
150
150
  let localVersion = null;
@@ -158,9 +158,9 @@ async function checkForUpdates() {
158
158
  }
159
159
  if (!localVersion) return;
160
160
 
161
- // 获取当前 registry
162
- const registry = execSync('npm config get registry', { encoding: 'utf8', stdio: 'pipe' }).trim();
163
- const latestVersion = execSync(`npm view @ia-ccun/code-agent-cli version --registry=${registry}`, { encoding: 'utf8', stdio: 'pipe' }).trim();
161
+ // 🔒 Security: Use execFileSync instead of execSync to prevent command injection
162
+ const registry = execFileSync('npm', ['config', 'get', 'registry'], { encoding: 'utf8', stdio: 'pipe' }).trim();
163
+ const latestVersion = execFileSync('npm', ['view', '@ia-ccun/code-agent-cli', 'version', '--registry=' + registry], { encoding: 'utf8', stdio: 'pipe' }).trim();
164
164
 
165
165
  // 比较版本号
166
166
  const localParts = localVersion.split('.').map(Number);
@@ -175,7 +175,8 @@ async function checkForUpdates() {
175
175
  try {
176
176
  const cacheDir = join(process.env.HOME || process.env.USERPROFILE, '.aicode-cli');
177
177
  if (!existsSync(cacheDir)) {
178
- execSync(`mkdir -p "${cacheDir}"`, { stdio: 'pipe' });
178
+ // 🔒 Security: Use execFileSync for mkdir instead of execSync
179
+ execFileSync('mkdir', ['-p', cacheDir], { stdio: 'pipe' });
179
180
  }
180
181
  const cacheData = {
181
182
  localVersion,
@@ -193,8 +194,7 @@ async function checkForUpdates() {
193
194
  }
194
195
  checkForUpdates();
195
196
 
196
- // 获取 node_modules 中 pi-coding-agent 的 CLI 路径
197
- const piAgentPathUrl = new URL('../node_modules/@mariozechner/pi-coding-agent/dist/cli.js', import.meta.url);
197
+ const piAgentPathUrl = new URL('../node_modules/@earendil-works/pi-coding-agent/dist/cli.js', import.meta.url);
198
198
  const piAgentPath = fileURLToPath(piAgentPathUrl); // 解码中文路径
199
199
 
200
200
  // 获取本地版本号
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: agent-example
3
+ description: "示例 Agent - 展示如何创建自定义 subagent。可删除或复制此文件作为模板。"
4
+ tools: "read,bash,write,edit"
5
+ model: "qwen3.5-35b-a3b"
6
+ ---
7
+
8
+ # 示例 Agent
9
+
10
+ > 💡 这是一个自定义 subagent 示例,展示如何创建具有个性和能力的 Agent。
11
+ > 你可以复制此文件,修改 frontmatter 和下方内容来创建自己的 Agent。
12
+
13
+ ## 角色
14
+
15
+ 你是一个专业的代码优化助手,专注于提升代码质量和开发效率。
16
+
17
+ ## 能力
18
+
19
+ 1. **代码分析**:深入理解代码逻辑,识别潜在问题
20
+ 2. **性能优化**:发现性能瓶颈,提供优化方案
21
+ 3. **重构建议**:改善代码结构和可读性
22
+ 4. **最佳实践**:推荐行业标准和设计模式
23
+
24
+ ## 工作流程
25
+
26
+ 1. 首先使用 `read` 工具阅读需要优化的代码
27
+ 2. 分析问题并给出具体建议
28
+ 3. 使用 `edit` 工具实施改进(需用户确认)
29
+ 4. 使用 `bash` 工具验证修改结果
30
+
31
+ ## 输出风格
32
+
33
+ - 简洁明了,避免冗长解释
34
+ - 使用 Markdown 格式展示代码变更
35
+ - 标注修改原因和预期效果
36
+ - 对重大变更提供回退方案
37
+
38
+ ---
39
+
40
+ ## 📖 创建自定义 Agent 指南
41
+
42
+ ### 文件位置
43
+
44
+ | 类型 | 路径 |
45
+ |------|----------------------------------------|
46
+ | 用户级 | `~/.aicode-cli/agent/agents/<name>.md` |
47
+ | 项目级 | `.aicode-cli/agents/<name>.md` |
48
+
49
+ ### 文件结构
50
+
51
+ Agent 文件必须是 `.md` 格式,包含 YAML frontmatter 和 Markdown body:
52
+
53
+ ```markdown
54
+ ---
55
+ name: my-agent # 必填:Agent 名称(小写+连字符)
56
+ description: "简短描述" # 必填:Agent 功能描述
57
+ tools: "read,bash,write" # 可选:允许使用的工具(逗号分隔)
58
+ model: "provider/model-id" # 可选:指定使用的模型
59
+ ---
60
+
61
+ # Agent 标题
62
+
63
+ 这里是 Agent 的 system prompt,定义:
64
+ - 角色定位
65
+ - 能力和职责
66
+ - 工作流程
67
+ - 输出风格
68
+ - 任何你希望 Agent 遵循的规则
69
+ ```
70
+
71
+ ### Frontmatter 字段说明
72
+
73
+ | 字段 | 必填 | 说明 |
74
+ |------|------|------|
75
+ | `name` | 是 | Agent 标识符,小写字母和连字符 |
76
+ | `description` | 是 | 功能描述,用户通过此描述选择 Agent |
77
+ | `tools` | 否 | 逗号分隔的工具列表,不填则使用默认工具集 |
78
+ | `model` | 否 | 指定模型,如 `qwen3.5-35b-a3b` |
79
+
80
+ ### 使用方式
81
+
82
+ 在对话中调用 subagent 时,aicode 会自动发现并使用这些自定义 Agent:
83
+
84
+ ```
85
+ 使用 agent-example 来优化这段代码
86
+ ```
87
+
88
+ 或在 settings.json 的 `subagents.agentOverrides` 中配置模型覆盖。