ccg-workflow 1.6.0 → 1.7.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 +175 -408
- package/bin/codeagent-wrapper-linux-arm64 +0 -0
- package/bin/codeagent-wrapper-windows-arm64.exe +0 -0
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +1 -1
- package/dist/shared/{ccg-workflow.CjatSnB0.mjs → ccg-workflow._fNXxrRQ.mjs} +194 -286
- package/package.json +1 -1
- package/templates/commands/analyze.md +130 -57
- package/templates/commands/backend.md +92 -152
- package/templates/commands/clean-branches.md +81 -66
- package/templates/commands/commit.md +81 -117
- package/templates/commands/debug.md +117 -90
- package/templates/commands/feat.md +68 -282
- package/templates/commands/frontend.md +92 -154
- package/templates/commands/init.md +100 -36
- package/templates/commands/optimize.md +137 -70
- package/templates/commands/review.md +123 -63
- package/templates/commands/rollback.md +86 -60
- package/templates/commands/test.md +143 -54
- package/templates/commands/workflow.md +244 -0
- package/templates/commands/worktree.md +78 -226
- package/templates/commands/bugfix.md +0 -114
- package/templates/commands/code.md +0 -255
- package/templates/commands/dev.md +0 -179
- package/templates/commands/think.md +0 -102
|
@@ -1,89 +1,149 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: '多模型代码审查:无参数时自动审查 git diff,双模型交叉验证'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
`/review [CODE_OR_DESCRIPTION]`
|
|
5
|
+
# Review - 多模型代码审查
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
- Arguments: $ARGUMENTS
|
|
10
|
-
- This command triggers multi-model code review based on your configuration.
|
|
11
|
-
- Configured models review simultaneously for comprehensive feedback.
|
|
7
|
+
双模型并行审查,交叉验证综合反馈。无参数时自动审查当前 git 变更。
|
|
12
8
|
|
|
13
|
-
##
|
|
14
|
-
- **No arguments**: Automatically review current git changes (staged + unstaged)
|
|
15
|
-
- **With arguments**: Review specified code or description
|
|
9
|
+
## 多模型调用语法
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
You are the **Code Review Coordinator** orchestrating multi-model review. You direct:
|
|
19
|
-
1. **ace-tool** – for retrieving code context
|
|
20
|
-
2. **Configured Review Models** – for comprehensive code review
|
|
21
|
-
3. **Claude (Self)** – for synthesizing feedback and recommendations
|
|
11
|
+
**⚠️ 必须使用 heredoc 语法调用外部模型**:
|
|
22
12
|
|
|
23
|
-
|
|
13
|
+
```bash
|
|
14
|
+
~/.claude/bin/codeagent-wrapper --backend <codex|gemini> - "$PWD" <<'EOF'
|
|
15
|
+
<任务内容>
|
|
16
|
+
EOF
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 使用方法
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
/review [代码或描述]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- **无参数**:自动审查 `git diff HEAD`
|
|
28
|
+
- **有参数**:审查指定代码或描述
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 执行工作流
|
|
33
|
+
|
|
34
|
+
### 🔍 阶段 1:获取待审查代码
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
`[模式:研究]`
|
|
37
|
+
|
|
38
|
+
**无参数时**:
|
|
28
39
|
```bash
|
|
29
|
-
# Get staged and unstaged changes
|
|
30
40
|
git diff HEAD
|
|
31
41
|
git status --short
|
|
32
42
|
```
|
|
33
43
|
|
|
34
|
-
|
|
44
|
+
**有参数时**:使用指定的代码/描述
|
|
35
45
|
|
|
36
|
-
|
|
37
|
-
- `project_root_path`: Project root directory absolute path
|
|
38
|
-
- `query`: Description of code/files to review
|
|
46
|
+
调用 `mcp__ace-tool__search_context` 获取相关上下文。
|
|
39
47
|
|
|
40
|
-
###
|
|
48
|
+
### 🔬 阶段 2:并行审查
|
|
41
49
|
|
|
42
|
-
|
|
50
|
+
`[模式:审查]`
|
|
43
51
|
|
|
44
|
-
|
|
52
|
+
**并行调用两个模型**:
|
|
45
53
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
for model in $(echo '{{REVIEW_MODELS}}' | jq -r '.[]'); do
|
|
49
|
-
codeagent-wrapper --backend $model - $PROJECT_DIR <<'EOF' &
|
|
50
|
-
ROLE_FILE: ~/.claude/.ccg/prompts/$model/reviewer.md
|
|
54
|
+
**执行步骤**:
|
|
55
|
+
1. 使用 **Bash 工具的 `run_in_background: true` 参数**启动两个后台进程:
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
**Codex 审查进程**:
|
|
58
|
+
```
|
|
59
|
+
Bash({
|
|
60
|
+
command: "~/.claude/bin/codeagent-wrapper --backend codex - \"$PWD\" <<'EOF_CODEX'
|
|
61
|
+
[角色] 后端代码审查专家
|
|
62
|
+
[任务] 审查以下代码变更
|
|
56
63
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
## 审查重点
|
|
65
|
+
- 安全性:注入、认证、授权
|
|
66
|
+
- 性能:N+1 查询、缓存、复杂度
|
|
67
|
+
- 错误处理:异常捕获、边界条件
|
|
68
|
+
- 可维护性:命名、结构、文档
|
|
69
|
+
|
|
70
|
+
## 待审查代码
|
|
71
|
+
<粘贴 git diff 内容>
|
|
72
|
+
|
|
73
|
+
## 输出格式
|
|
74
|
+
按 Critical/Major/Minor/Suggestion 分类列出问题
|
|
75
|
+
EOF_CODEX",
|
|
76
|
+
run_in_background: true,
|
|
77
|
+
timeout: 3600000,
|
|
78
|
+
description: "Codex 后端代码审查"
|
|
79
|
+
})
|
|
61
80
|
```
|
|
62
81
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
82
|
+
**Gemini 审查进程**:
|
|
83
|
+
```
|
|
84
|
+
Bash({
|
|
85
|
+
command: "~/.claude/bin/codeagent-wrapper --backend gemini - \"$PWD\" <<'EOF_GEMINI'
|
|
86
|
+
[角色] 前端代码审查专家
|
|
87
|
+
[任务] 审查以下代码变更
|
|
88
|
+
|
|
89
|
+
## 审查重点
|
|
90
|
+
- 可访问性:ARIA、键盘导航、色彩对比
|
|
91
|
+
- 响应式:移动端适配、断点
|
|
92
|
+
- 设计一致性:组件复用、样式规范
|
|
93
|
+
- 用户体验:加载状态、错误提示
|
|
70
94
|
|
|
71
|
-
|
|
72
|
-
|
|
95
|
+
## 待审查代码
|
|
96
|
+
<粘贴 git diff 内容>
|
|
73
97
|
|
|
74
98
|
## 输出格式
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
99
|
+
按 Critical/Major/Minor/Suggestion 分类列出问题
|
|
100
|
+
EOF_GEMINI",
|
|
101
|
+
run_in_background: true,
|
|
102
|
+
timeout: 3600000,
|
|
103
|
+
description: "Gemini 前端代码审查"
|
|
104
|
+
})
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
2. 使用 `TaskOutput` 监控并获取 2 个模型的审查结果。
|
|
108
|
+
|
|
109
|
+
**⚠️ 强制规则:必须等待 TaskOutput 返回两个模型的完整结果后才能进入下一阶段,禁止跳过或提前继续!**
|
|
110
|
+
|
|
111
|
+
### 🔀 阶段 3:综合反馈
|
|
112
|
+
|
|
113
|
+
`[模式:综合]`
|
|
114
|
+
|
|
115
|
+
1. 收集双方审查结果
|
|
116
|
+
2. 按严重程度分类:Critical / Major / Minor / Suggestion
|
|
117
|
+
3. 去重合并 + 交叉验证
|
|
118
|
+
|
|
119
|
+
### 📊 阶段 4:呈现审查结果
|
|
120
|
+
|
|
121
|
+
`[模式:总结]`
|
|
122
|
+
|
|
123
|
+
```markdown
|
|
124
|
+
## 📋 代码审查报告
|
|
125
|
+
|
|
126
|
+
### 审查范围
|
|
127
|
+
- 变更文件:<数量> | 代码行数:+X / -Y
|
|
128
|
+
|
|
129
|
+
### 关键问题 (Critical)
|
|
130
|
+
> 必须修复才能合并
|
|
131
|
+
1. <问题描述> - [Codex/Gemini]
|
|
132
|
+
|
|
133
|
+
### 主要问题 (Major) / 次要问题 (Minor) / 建议 (Suggestions)
|
|
134
|
+
...
|
|
135
|
+
|
|
136
|
+
### 总体评价
|
|
137
|
+
- 代码质量:[优秀/良好/需改进]
|
|
138
|
+
- 是否可合并:[是/否/需修复后]
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## 关键规则
|
|
144
|
+
|
|
145
|
+
1. **无参数 = 审查 git diff** – 自动获取当前变更
|
|
146
|
+
2. **heredoc 语法** – 必须使用 `<<'EOF'` 传递多行任务
|
|
147
|
+
3. **双模型交叉验证** – 后端问题以 Codex 为准,前端问题以 Gemini 为准
|
|
148
|
+
4. **使用 Bash 工具的 `run_in_background: true` 参数 + `TaskOutput` 获取结果**
|
|
149
|
+
5. **必须等待所有模型返回** – 禁止提前进入下一步
|
|
@@ -1,90 +1,116 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
3
|
-
allowed-tools: Read(**), Exec(git fetch, git branch, git tag, git log, git reflog, git checkout, git reset, git revert, git switch), Write()
|
|
4
|
-
argument-hint: [--branch <branch>] [--target <rev>] [--mode reset|revert] [--depth <n>] [--dry-run] [--yes]
|
|
5
|
-
# examples:
|
|
6
|
-
# - /git-rollback # 全交互模式,dry‑run
|
|
7
|
-
# - /git-rollback --branch dev # 直接选 dev,其他交互
|
|
8
|
-
# - /git-rollback --branch dev --target v1.2.0 --mode reset --yes
|
|
2
|
+
description: '交互式 Git 回滚:安全回滚分支到历史版本,支持 reset/revert 模式'
|
|
9
3
|
---
|
|
10
4
|
|
|
11
|
-
#
|
|
5
|
+
# Rollback - 交互式 Git 回滚
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
安全地将分支回滚到指定历史版本,默认 dry-run 模式。
|
|
8
|
+
|
|
9
|
+
## 使用方法
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
/rollback [options]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 选项
|
|
16
|
+
|
|
17
|
+
| 选项 | 说明 |
|
|
18
|
+
|------|------|
|
|
19
|
+
| `--branch <branch>` | 要回滚的分支 |
|
|
20
|
+
| `--target <rev>` | 目标版本(commit/tag/reflog) |
|
|
21
|
+
| `--mode reset\|revert` | 回滚模式 |
|
|
22
|
+
| `--depth <n>` | 列出最近 n 个版本(默认 20) |
|
|
23
|
+
| `--dry-run` | 只预览,不执行(**默认**) |
|
|
24
|
+
| `--yes` | 跳过确认直接执行 |
|
|
15
25
|
|
|
16
26
|
---
|
|
17
27
|
|
|
18
|
-
##
|
|
28
|
+
## 执行工作流
|
|
29
|
+
|
|
30
|
+
### 🔍 阶段 1:同步远端
|
|
31
|
+
|
|
32
|
+
`[模式:准备]`
|
|
19
33
|
|
|
20
34
|
```bash
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
git fetch --all --prune
|
|
36
|
+
```
|
|
23
37
|
|
|
24
|
-
|
|
25
|
-
/git-rollback --branch feature/calculator
|
|
38
|
+
### 📋 阶段 2:选择分支
|
|
26
39
|
|
|
27
|
-
|
|
28
|
-
/git-rollback --branch main --target 1a2b3c4d --mode reset --yes
|
|
40
|
+
`[模式:选择]`
|
|
29
41
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
42
|
+
1. 列出本地 + 远端分支
|
|
43
|
+
2. 过滤受保护分支
|
|
44
|
+
3. 用户选择或使用 `--branch` 参数
|
|
33
45
|
|
|
34
|
-
###
|
|
46
|
+
### 📜 阶段 3:选择版本
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
| ---------------------- | ---------------------------------------------------------------------------------- |
|
|
38
|
-
| `--branch <branch>` | 要回滚的分支;缺省时交互选择。 |
|
|
39
|
-
| `--target <rev>` | 目标版本(commit Hash、Tag、reflog 引用都行);缺省时交互选择近 `--depth` 条记录。 |
|
|
40
|
-
| `--mode reset\|revert` | `reset`:硬回滚历史;`revert`:生成反向提交保持历史完整。默认询问。 |
|
|
41
|
-
| `--depth <n>` | 在交互模式下列出最近 n 个版本(默认 20)。 |
|
|
42
|
-
| `--dry-run` | **默认开启**,只预览即将执行的命令。 |
|
|
43
|
-
| `--yes` | 跳过所有确认直接执行,适合 CI/CD 脚本。 |
|
|
48
|
+
`[模式:选择]`
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
1. 显示最近 N 个版本(`git log --oneline`)
|
|
51
|
+
2. 显示相关 tags(`git tag --merged`)
|
|
52
|
+
3. 用户选择或使用 `--target` 参数
|
|
53
|
+
|
|
54
|
+
### ⚙️ 阶段 4:选择模式
|
|
55
|
+
|
|
56
|
+
`[模式:决策]`
|
|
57
|
+
|
|
58
|
+
| 模式 | 说明 | 推送方式 |
|
|
59
|
+
|------|------|----------|
|
|
60
|
+
| `reset` | 硬回滚,改变历史 | `--force-with-lease` |
|
|
61
|
+
| `revert` | 生成反向提交,保留历史 | 普通 push |
|
|
46
62
|
|
|
47
|
-
|
|
63
|
+
### ⛔ 阶段 5:最终确认
|
|
48
64
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
`[模式:确认]`
|
|
66
|
+
|
|
67
|
+
显示即将执行的命令,等待用户确认(除非 `--yes`)。
|
|
68
|
+
|
|
69
|
+
### ✅ 阶段 6:执行回滚
|
|
70
|
+
|
|
71
|
+
`[模式:执行]`
|
|
72
|
+
|
|
73
|
+
**reset 模式**:
|
|
74
|
+
```bash
|
|
75
|
+
git switch <branch>
|
|
76
|
+
git reset --hard <target>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**revert 模式**:
|
|
80
|
+
```bash
|
|
81
|
+
git switch <branch>
|
|
82
|
+
git revert --no-edit <target>..HEAD
|
|
83
|
+
```
|
|
60
84
|
|
|
61
85
|
---
|
|
62
86
|
|
|
63
87
|
## 安全护栏
|
|
64
88
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
89
|
+
1. **备份**:执行前自动记录当前 HEAD 到 reflog
|
|
90
|
+
2. **保护分支**:`main`/`master`/`production` 需额外确认
|
|
91
|
+
3. **dry-run 默认**:防止误操作
|
|
92
|
+
4. **禁止 --force**:如需强推,手动执行
|
|
69
93
|
|
|
70
94
|
---
|
|
71
95
|
|
|
72
|
-
##
|
|
96
|
+
## 示例
|
|
73
97
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
| 运维同事误推了 debug 日志提交,需要生成反向提交 | `/git-rollback --branch main --target 3f2e7c9 --mode revert` |
|
|
78
|
-
| 调研历史 bug,引导新人浏览分支历史 | `/git-rollback` (全交互,dry‑run) |
|
|
98
|
+
```bash
|
|
99
|
+
# 全交互模式(dry-run)
|
|
100
|
+
/rollback
|
|
79
101
|
|
|
80
|
-
|
|
102
|
+
# 指定分支
|
|
103
|
+
/rollback --branch dev
|
|
81
104
|
|
|
82
|
-
|
|
105
|
+
# 完整指定,一键执行
|
|
106
|
+
/rollback --branch main --target v1.2.0 --mode reset --yes
|
|
83
107
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
2. **嵌入式仓库** 常有大体积二进制文件;回滚前请确保 LFS/子模块状态一致。
|
|
88
|
-
3. 若仓库启用了 CI 强制校验,回滚后可能自动触发流水线;确认管控策略以免误部署旧版本。
|
|
108
|
+
# 生成反向提交
|
|
109
|
+
/rollback --branch release/v2.1 --target v2.0.5 --mode revert
|
|
110
|
+
```
|
|
89
111
|
|
|
90
|
-
|
|
112
|
+
## 注意事项
|
|
113
|
+
|
|
114
|
+
- **reset vs revert**:reset 改变历史,需强推;revert 更安全
|
|
115
|
+
- **LFS/子模块**:回滚前确保状态一致
|
|
116
|
+
- **CI 触发**:回滚后可能自动触发流水线
|
|
@@ -1,83 +1,172 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: '多模型测试生成:智能路由 Codex 后端测试 / Gemini 前端测试'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
# Test - 多模型测试生成
|
|
6
|
+
|
|
7
|
+
根据代码类型智能路由,生成高质量测试用例。
|
|
8
|
+
|
|
9
|
+
## 多模型调用语法
|
|
10
|
+
|
|
11
|
+
**必须使用 heredoc 语法调用 codeagent-wrapper**:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
~/.claude/bin/codeagent-wrapper --backend <codex|gemini> - [工作目录] <<'EOF'
|
|
15
|
+
<任务内容>
|
|
16
|
+
EOF
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 使用方法
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
/test <测试目标>
|
|
23
|
+
```
|
|
7
24
|
|
|
8
25
|
## 上下文
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
|
|
27
|
+
- 测试目标:$ARGUMENTS
|
|
28
|
+
- 智能路由:后端 → Codex,前端 → Gemini,全栈 → 并行
|
|
29
|
+
- 遵循项目现有测试框架和风格
|
|
30
|
+
|
|
31
|
+
## 你的角色
|
|
32
|
+
|
|
33
|
+
你是**测试工程师**,编排测试生成流程:
|
|
34
|
+
- **Codex** – 后端测试生成(**后端权威**)
|
|
35
|
+
- **Gemini** – 前端测试生成(**前端权威**)
|
|
36
|
+
- **Claude (自己)** – 整合测试、验证运行
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 执行工作流
|
|
41
|
+
|
|
42
|
+
**测试目标**:$ARGUMENTS
|
|
43
|
+
|
|
44
|
+
### 🔍 阶段 0:Prompt 增强(可选)
|
|
45
|
+
|
|
46
|
+
`[模式:准备]` - 增强测试需求
|
|
47
|
+
|
|
48
|
+
**如果 ace-tool MCP 可用**,调用 `mcp__ace-tool__enhance_prompt`:
|
|
49
|
+
- 输入原始测试目标
|
|
50
|
+
- 获取增强后的详细测试需求
|
|
51
|
+
- 用增强后的需求替代原始 $ARGUMENTS
|
|
52
|
+
|
|
53
|
+
### 🔍 阶段 1:测试分析
|
|
54
|
+
|
|
55
|
+
`[模式:研究]`
|
|
56
|
+
|
|
57
|
+
1. 检索目标代码的完整实现
|
|
58
|
+
2. 查找现有测试文件和测试框架配置
|
|
59
|
+
3. 识别代码类型:[后端/前端/全栈]
|
|
60
|
+
4. 评估当前测试覆盖率和缺口
|
|
61
|
+
|
|
62
|
+
### 🔬 阶段 2:智能路由测试生成
|
|
63
|
+
|
|
64
|
+
`[模式:生成]`
|
|
65
|
+
|
|
25
66
|
| 代码类型 | 路由 | 角色 |
|
|
26
67
|
|---------|------|------|
|
|
27
|
-
| 后端 | Codex | `tester` |
|
|
28
|
-
| 前端 | Gemini | `tester` |
|
|
68
|
+
| 后端 | Codex | `tester.md` |
|
|
69
|
+
| 前端 | Gemini | `tester.md` |
|
|
29
70
|
| 全栈 | 并行执行 | 两者 |
|
|
30
71
|
|
|
31
|
-
|
|
72
|
+
**全栈代码并行调用**:
|
|
32
73
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
codeagent-wrapper --backend {{BACKEND_PRIMARY}} - $PROJECT_DIR <<'EOF'
|
|
36
|
-
ROLE_FILE: ~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/tester.md
|
|
74
|
+
**执行步骤**:
|
|
75
|
+
1. 使用 **Bash 工具的 `run_in_background: true` 参数**启动两个后台进程:
|
|
37
76
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
77
|
+
**Codex 测试生成进程**:
|
|
78
|
+
```
|
|
79
|
+
Bash({
|
|
80
|
+
command: "~/.claude/bin/codeagent-wrapper --backend codex - \"$PWD\" <<'EOF_CODEX'
|
|
81
|
+
你是后端测试专家,角色提示词见 ~/.claude/.ccg/prompts/codex/tester.md
|
|
82
|
+
|
|
83
|
+
任务:为以下代码生成单元测试
|
|
84
|
+
<代码内容>
|
|
85
|
+
|
|
86
|
+
要求:
|
|
87
|
+
1. 使用项目现有测试框架
|
|
88
|
+
2. 覆盖正常路径、边界条件、异常处理
|
|
89
|
+
3. 输出完整测试代码
|
|
90
|
+
EOF_CODEX",
|
|
91
|
+
run_in_background: true,
|
|
92
|
+
timeout: 3600000,
|
|
93
|
+
description: "Codex 后端测试生成"
|
|
94
|
+
})
|
|
95
|
+
```
|
|
42
96
|
|
|
43
|
-
|
|
44
|
-
|
|
97
|
+
**Gemini 测试生成进程**:
|
|
98
|
+
```
|
|
99
|
+
Bash({
|
|
100
|
+
command: "~/.claude/bin/codeagent-wrapper --backend gemini - \"$PWD\" <<'EOF_GEMINI'
|
|
101
|
+
你是前端测试专家,角色提示词见 ~/.claude/.ccg/prompts/gemini/tester.md
|
|
102
|
+
|
|
103
|
+
任务:为以下组件生成测试
|
|
104
|
+
<组件代码>
|
|
105
|
+
|
|
106
|
+
要求:
|
|
107
|
+
1. 使用项目现有测试框架
|
|
108
|
+
2. 测试渲染、交互、状态变化
|
|
109
|
+
3. 输出完整测试代码
|
|
110
|
+
EOF_GEMINI",
|
|
111
|
+
run_in_background: true,
|
|
112
|
+
timeout: 3600000,
|
|
113
|
+
description: "Gemini 前端测试生成"
|
|
114
|
+
})
|
|
45
115
|
```
|
|
46
116
|
|
|
47
|
-
|
|
48
|
-
# Gemini 前端测试生成
|
|
49
|
-
codeagent-wrapper --backend {{FRONTEND_PRIMARY}} - $PROJECT_DIR <<'EOF'
|
|
50
|
-
ROLE_FILE: ~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/tester.md
|
|
117
|
+
2. 使用 `TaskOutput` 监控并获取 2 个模型的测试代码。
|
|
51
118
|
|
|
52
|
-
|
|
53
|
-
生成测试: {{需要测试的代码}}
|
|
54
|
-
Context: {{现有测试和测试框架配置}}
|
|
55
|
-
</TASK>
|
|
119
|
+
**⚠️ 强制规则:必须等待 TaskOutput 返回两个模型的完整结果后才能进入下一阶段,禁止跳过或提前继续!**
|
|
56
120
|
|
|
57
|
-
|
|
58
|
-
EOF
|
|
59
|
-
```
|
|
121
|
+
### 🔀 阶段 3:测试整合
|
|
60
122
|
|
|
61
|
-
|
|
123
|
+
`[模式:计划]`
|
|
62
124
|
|
|
63
|
-
|
|
64
|
-
1. 收集模型输出(`TaskOutput`)
|
|
125
|
+
1. 收集模型输出
|
|
65
126
|
2. Claude 重构:统一风格、确保命名一致、优化结构、移除冗余
|
|
66
127
|
|
|
67
|
-
###
|
|
68
|
-
|
|
69
|
-
|
|
128
|
+
### ✅ 阶段 4:测试验证
|
|
129
|
+
|
|
130
|
+
`[模式:执行]`
|
|
131
|
+
|
|
132
|
+
1. 创建测试文件
|
|
133
|
+
2. 运行生成的测试
|
|
70
134
|
3. 如有失败,分析原因并修复
|
|
71
135
|
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 输出格式
|
|
139
|
+
|
|
140
|
+
```markdown
|
|
141
|
+
## 🧪 测试生成:<测试目标>
|
|
142
|
+
|
|
143
|
+
### 分析结果
|
|
144
|
+
- 代码类型:[后端/前端/全栈]
|
|
145
|
+
- 测试框架:<检测到的框架>
|
|
146
|
+
|
|
147
|
+
### 生成的测试
|
|
148
|
+
- 测试文件:<文件路径>
|
|
149
|
+
- 测试用例数:<数量>
|
|
150
|
+
|
|
151
|
+
### 运行结果
|
|
152
|
+
- 通过:X / Y
|
|
153
|
+
- 失败:<如有,列出原因>
|
|
154
|
+
```
|
|
155
|
+
|
|
72
156
|
## 测试策略金字塔
|
|
157
|
+
|
|
73
158
|
```
|
|
74
159
|
/\ E2E (10%)
|
|
75
160
|
/--\ Integration (20%)
|
|
76
161
|
/----\ Unit (70%)
|
|
77
162
|
```
|
|
78
163
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 关键规则
|
|
167
|
+
|
|
168
|
+
1. **测试行为,不测试实现** – 关注输入输出
|
|
169
|
+
2. **智能路由** – 后端测试用 Codex,前端测试用 Gemini
|
|
170
|
+
3. **复用现有模式** – 遵循项目已有的测试风格
|
|
171
|
+
4. **使用 Bash 工具的 `run_in_background: true` 参数 + `TaskOutput` 获取结果**
|
|
172
|
+
5. **必须等待所有模型返回** – 禁止提前进入下一步
|