ccgx-workflow 1.0.3 → 1.0.5
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 +1 -1
- package/dist/cli.mjs +182 -2
- package/dist/index.mjs +3 -2
- package/dist/shared/{ccgx-workflow.BnfaZnVu.mjs → ccgx-workflow.CZSjTyQd.mjs} +79 -1
- package/package.json +1 -1
- package/templates/commands/agents/code-fixer.md +1 -1
- package/templates/commands/agents/codebase-mapper.md +1 -1
- package/templates/commands/agents/debug-session-manager.md +1 -1
- package/templates/commands/agents/debugger.md +1 -1
- package/templates/commands/agents/interface-auditor.md +34 -8
- package/templates/commands/agents/phase-runner.md +27 -27
- package/templates/commands/agents/plan-checker.md +4 -4
- package/templates/commands/analyze.md +10 -10
- package/templates/commands/autonomous.md +45 -46
- package/templates/commands/cancel.md +8 -8
- package/templates/commands/codex-exec.md +2 -2
- package/templates/commands/debate.md +5 -5
- package/templates/commands/debug.md +8 -8
- package/templates/commands/execute.md +6 -6
- package/templates/commands/init.md +1 -1
- package/templates/commands/optimize.md +10 -10
- package/templates/commands/plan.md +15 -15
- package/templates/commands/result.md +1 -1
- package/templates/commands/review.md +70 -31
- package/templates/commands/spec-impl.md +1 -1
- package/templates/commands/spec-plan.md +2 -2
- package/templates/commands/spec-research.md +1 -1
- package/templates/commands/spec-review.md +1 -1
- package/templates/commands/status.md +15 -15
- package/templates/commands/team-exec.md +1 -1
- package/templates/commands/team.md +6 -6
- package/templates/commands/test.md +9 -9
- package/templates/commands/verify-work.md +8 -8
- package/templates/commands/verify.md +3 -3
- package/templates/commands/workflow.md +2 -2
- package/templates/rules/ccg-skills.md +1 -1
- package/templates/scripts/ccgx-call-plugin.mjs +324 -0
- package/templates/scripts/repatch-gemini-plugin.mjs +10 -0
- package/templates/skills/tools/extract-learnings/SKILL.md +1 -3
- package/templates/skills/tools/forensics/SKILL.md +0 -2
- package/templates/skills/tools/health/SKILL.md +0 -2
- package/templates/skills/tools/map-codebase/SKILL.md +0 -2
- package/templates/skills/tools/verify-change/SKILL.md +2 -2
- package/templates/skills/tools/verify-module/SKILL.md +2 -2
- package/templates/skills/tools/verify-quality/SKILL.md +2 -2
- package/templates/skills/tools/verify-security/SKILL.md +2 -2
|
@@ -67,7 +67,7 @@ argument-hint: "<topic> [--max-rounds N] [--layer backend|frontend|fullstack]"
|
|
|
67
67
|
- **降级路径**(`models[idx] === 'general-purpose'`):spawn `Agent(subagent_type="general-purpose", prompt=<内嵌 round.ccgPromptFiles[idx] 文件全文> + <下面的 prompt 模板>)`
|
|
68
68
|
3. ⛔ **plugin spawn 失败必须重试**:若 `Agent(subagent_type="codex:codex-rescue"|"gemini:gemini-rescue")` 调用失败(spawn 抛错 / 返回非结构化错误 / `parseRoundSummary` 返回 `parsed=false`),最多重试 **2 次**(间隔 **5 秒**)。仅当 **3 次全部失败**时才把该模型本轮替换为 general-purpose 降级路径,并在合成的 `RoundSummary.notes` 标 `plugin spawn failed after 3 attempts, degraded: <具体根因>`。⛔ **禁止**单次失败或单次 broker 负信号即降级——broker 懒启动属正常态。
|
|
69
69
|
|
|
70
|
-
**
|
|
70
|
+
**schema 硬约束**:标记格式必须是 `plugin spawn failed after N attempts, degraded: <reason>` 三段式(N 必须 ≥ 3,reason 必须给具体根因如 `broker timeout` / `API quota` / `parse-failed`,禁用占位文本如 `unknown` / `n/a`)。`parseRoundSummary` 自动从 NOTES 抽取 populate `RoundSummary.degraded`,Step 2 综合阶段会调 `validateRetryProtocol(累积 RoundSummary[])` 校验合规——违规会出现在最终输出的 ⚠️ 协议违规区段(用户可见)。这是把"3 次重试 + degraded 标记"从 prompt 软约束硬化为 schema-level 校验。
|
|
71
71
|
4. **等待所有 model 返回**(`run_in_background: true` + 事件驱动等通知(不调 TaskOutput))
|
|
72
72
|
5. 对每个返回的 ≤200 token 摘要调用 `parseRoundSummary(text)` → `RoundSummary`
|
|
73
73
|
6. 把本轮的 `RoundSummary[]`(fullstack 为 2 条;backend/frontend 为 1 条)合成一条主 `RoundSummary`(取最长 length,合并 propose/challenge/respond/notes 字段)追加到累积数组
|
|
@@ -80,10 +80,10 @@ argument-hint: "<topic> [--max-rounds N] [--layer backend|frontend|fullstack]"
|
|
|
80
80
|
- **分歧点列表**(所有 challenge 内容去重 + 简化)
|
|
81
81
|
- **各方观点摘要表**(每轮 model × kind × 一行核心观点)
|
|
82
82
|
- **收敛理由**(哪个信号触发了停止:`no critical` / `max rounds` / `length-converged`)
|
|
83
|
-
- ⚠️
|
|
83
|
+
- ⚠️ **协议违规区段**(**强制**):在输出最终 markdown 前调用 `validateRetryProtocol(累积 RoundSummary[])` → `RetryProtocolReport`:
|
|
84
84
|
- `report.compliant === false` → 主线 **必须** 在最终输出加一段 `## ⚠️ Retry Protocol Violations`,逐条列 `report.violations[]`(含 `round` / `kind` / `message`)
|
|
85
85
|
- 4 类违规枚举:`parse-failed-no-degraded` / `insufficient-attempts` / `missing-reason` / `silent-success`
|
|
86
|
-
- 设计动机:原 prompt 软约束 "3 次重试 + degraded 标记" 实测会被主线 LLM
|
|
86
|
+
- 设计动机:原 prompt 软约束 "3 次重试 + degraded 标记" 实测会被主线 LLM 跳过(真实案例:主线 R1 一次 fallback 就接受未重试也未标 degraded)。schema 硬校验让违规可观测、可枚举,避免 silent fallback 在 debate 综合阶段被吞
|
|
87
87
|
- **不要**把 violations 摘要塞进对辩主体内容然后跑路——必须独立成段,让用户看见具体哪轮哪种违规
|
|
88
88
|
|
|
89
89
|
主线输出 markdown 表格,**不写文件**——主线直接展示给用户。
|
|
@@ -147,9 +147,9 @@ shouldStop(rounds, maxRounds) → boolean
|
|
|
147
147
|
|
|
148
148
|
helper 暴露:
|
|
149
149
|
- `debateStateMachine(topic, options)` → `DebateRoundPlan[]`
|
|
150
|
-
- `parseRoundSummary(text)` → `RoundSummary
|
|
150
|
+
- `parseRoundSummary(text)` → `RoundSummary`(含 `degraded?: { attempts, reason }` 字段)
|
|
151
151
|
- `shouldStop(rounds, maxRounds)` → `boolean`
|
|
152
|
-
- `validateRetryProtocol(rounds)` → `RetryProtocolReport
|
|
152
|
+
- `validateRetryProtocol(rounds)` → `RetryProtocolReport`(Step 2 综合阶段必须调;非 compliant 时主线必须在输出加协议违规区段)
|
|
153
153
|
- `REQUIRED_RETRY_ATTEMPTS` = `3`(与 Step 1.3 的 "3 次全部失败" 文档同步)
|
|
154
154
|
|
|
155
155
|
## 不做
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: '多模型调试(
|
|
2
|
+
description: '多模型调试(manager + debugger 双层 fresh-context):科学方法 hypothesis 链 + 持久 session + cap 3 升级'
|
|
3
3
|
argument-hint: "<问题描述> [--mode=find_root_cause_only|find_and_fix] [--role=architect|critic|implementer|tester|writer]"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Debug - 多模型调试(
|
|
6
|
+
# Debug - 多模型调试(manager + debugger 双层)
|
|
7
7
|
|
|
8
|
-
## Role-based routing(
|
|
8
|
+
## Role-based routing(specialist matrix)
|
|
9
9
|
|
|
10
10
|
可选 `--role=<name>` 叠加 role 维度路由(debug-session-manager 内 spawn 的 debugger 用 role 选 prompt):
|
|
11
11
|
|
|
@@ -15,11 +15,11 @@ argument-hint: "<问题描述> [--mode=find_root_cause_only|find_and_fix] [--rol
|
|
|
15
15
|
| **frontend** | gemini/architect.md | gemini/reviewer.md (adversarial) | gemini/debugger.md | gemini/tester.md | gemini/analyzer.md |
|
|
16
16
|
| **fullstack** | codex+gemini/architect.md | both reviewer.md (adversarial) | runner 决 | runner 决 | claude |
|
|
17
17
|
|
|
18
|
-
**未传 --role 时按
|
|
18
|
+
**未传 --role 时按 manager + debugger 双层流程**(debugger.md 默认 implementer 角色)——完全兼容。`--role=critic` 触发"反向假设"调试(强制构造反证),适合定位概率性 bug。详见 `src/utils/specialist-router.ts`。
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
**核心架构**:从单次双模型并行调用 → **manager + debugger 双层 fresh-context** 模式。
|
|
23
23
|
|
|
24
24
|
主线(你)只 spawn `debug-session-manager` 一次,manager 在隔离 context 内跑完整 hypothesis 多轮循环,最终返回 ≤ 200 token 的紧凑摘要。**主线 context 不再被多轮调试 transcript 污染**——这是 GSD ROI #3 (`02-subagent-matrix.md` Section 2.6) 的核心模式。
|
|
25
25
|
|
|
@@ -198,16 +198,16 @@ manager 的 3 轮 hypothesis 都被证伪。这通常意味着:
|
|
|
198
198
|
|
|
199
199
|
1. **只 spawn manager 一次**:禁止主线自己跑多轮 hypothesis 循环(违反 fresh-context 隔离的 GSD ROI #3 设计)
|
|
200
200
|
2. **不读 manager transcript**:主线只读返回的 ≤ 200 token 摘要 + (用户需要时)`.context/debug/<slug>.md` 文件
|
|
201
|
-
3. **mode 默认 find_and_fix
|
|
201
|
+
3. **mode 默认 find_and_fix**:用户期待修好,仅在 `--mode=find_root_cause_only` 时仅找根因
|
|
202
202
|
4. **cap 3 = 升级**:CCG 全体系硬规约,manager 不会偷偷继续;主线尊重 CHECKPOINT_REACHED 不重 spawn
|
|
203
203
|
5. **session 文件持久**:中断恢复 / 用户审计的唯一通道
|
|
204
204
|
6. **科学方法守门**:每个 hypothesis 必须 falsifiable(manager 会拒收 debugger 给的空话)
|
|
205
205
|
|
|
206
206
|
---
|
|
207
207
|
|
|
208
|
-
##
|
|
208
|
+
## 与早期实现的差异
|
|
209
209
|
|
|
210
|
-
| 维度 |
|
|
210
|
+
| 维度 | 早期实现(已废) | 当前 |
|
|
211
211
|
|------|-------------|-------------|
|
|
212
212
|
| 调用模式 | 双模型并行单次诊断 | manager + debugger 双层 fresh-context |
|
|
213
213
|
| 多轮 | ❌ 没有(一次性) | ✅ hypothesis 链,cap 3 |
|
|
@@ -20,12 +20,12 @@ $ARGUMENTS
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
-
## 调用通道路由(
|
|
23
|
+
## 调用通道路由(CCG codeagent 退役)
|
|
24
24
|
|
|
25
|
-
CCG
|
|
25
|
+
CCG 把 6 核心命令的"双模型并行"通道从 `Bash(codeagent-wrapper)` **默认切换**为 plugin spawn。判定流程:
|
|
26
26
|
|
|
27
27
|
1. **优先 plugin spawn 路径**(默认):用户已装 `codex@openai-codex` 和 `gemini@google-gemini` plugin → 用 `Agent(subagent_type="codex:codex-rescue")` + `Agent(subagent_type="gemini:gemini-rescue")` 并行 spawn,主线只接 plugin 自家 ≤200 token 摘要。
|
|
28
|
-
2. **降级 codeagent-wrapper 路径**(
|
|
28
|
+
2. **降级 codeagent-wrapper 路径**(BC fallback):plugin 未装 → fallback 到 `Bash(~/.claude/bin/codeagent-wrapper ...)`,行为与 plugin 路径等价。
|
|
29
29
|
|
|
30
30
|
**判断方法**:preflight 用 `Bash` 跑 `ls ~/.claude/plugins/ 2>/dev/null | grep -E '^(codex|gemini)@'`;两个 plugin 独立判定。
|
|
31
31
|
|
|
@@ -42,7 +42,7 @@ CCG v4.1 把 6 核心命令的"双模型并行"通道从 `Bash(codeagent-wrapper
|
|
|
42
42
|
- 如果用户通过 `/add-dir` 添加了多个工作区,先用 Glob/Grep 确定任务相关的工作区
|
|
43
43
|
- 如果无法确定,用 `AskUserQuestion` 询问用户选择目标工作区
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
**调用语法**(双通道):
|
|
46
46
|
|
|
47
47
|
**通道 A — plugin spawn(默认,原型生成)**:
|
|
48
48
|
|
|
@@ -133,7 +133,7 @@ EOF",
|
|
|
133
133
|
|
|
134
134
|
**会话复用**:如果 `/ccg:plan` 提供了 SESSION_ID,使用 `resume <SESSION_ID>` 复用上下文。
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
**事件驱动等待**:spawn 后主线说明 task-id 然后 **turn end**,引擎自动 `<task-notification>` 触发新 turn 处理结果。**不调 TaskOutput**。
|
|
137
137
|
|
|
138
138
|
⛔ **禁止**:调 `TaskOutput({block: true, timeout: 600000})` 旧 freeze poll 模式 / Kill task。
|
|
139
139
|
|
|
@@ -296,7 +296,7 @@ EOF",
|
|
|
296
296
|
3. 执行必要的修复
|
|
297
297
|
4. 修复后按需重复 Phase 5.1(直到风险可接受)
|
|
298
298
|
|
|
299
|
-
#### 5.3 写入 phase-scoped SUMMARY.md
|
|
299
|
+
#### 5.3 写入 phase-scoped SUMMARY.md(状态机)
|
|
300
300
|
|
|
301
301
|
**强制**:每完成一个 plan 后,写 `.context/<phase>/SUMMARY.md` 让上层 orchestrator(autonomous / team-exec)只读 frontmatter(< 200 tokens / phase)就能决策推进,避免接整段 builder stdout 污染主线 context。
|
|
302
302
|
|
|
@@ -42,7 +42,7 @@ Task({
|
|
|
42
42
|
|
|
43
43
|
等待返回时间戳后,保存为 `$TIMESTAMP` 供后续使用。
|
|
44
44
|
|
|
45
|
-
### 🗺️ 步骤 1.5:codebase-mapper 4
|
|
45
|
+
### 🗺️ 步骤 1.5:codebase-mapper 4 路并行扫描
|
|
46
46
|
|
|
47
47
|
**强制**:在调用 init-architect 之前,**必须在同一条 assistant message 中并行 spawn 4 个 `codebase-mapper`**(多 tool calls 一次发出)。每个实例只处理一个 focus,把扫描结果写到 `.context/codebase/` 下对应文件,主线只接收一行确认。
|
|
48
48
|
|
|
@@ -13,7 +13,7 @@ argument-hint: "<优化目标> [--role=architect|critic|implementer|tester|write
|
|
|
13
13
|
/optimize <优化目标> [--role=<name>]
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
## Role-based routing(
|
|
16
|
+
## Role-based routing(specialist matrix)
|
|
17
17
|
|
|
18
18
|
可选 `--role=<name>` 叠加 role 维度路由:
|
|
19
19
|
|
|
@@ -23,7 +23,7 @@ argument-hint: "<优化目标> [--role=architect|critic|implementer|tester|write
|
|
|
23
23
|
| **frontend** | gemini/architect.md | gemini/reviewer.md (adversarial) | gemini/architect.md | gemini/tester.md | gemini/analyzer.md |
|
|
24
24
|
| **fullstack** | codex+gemini/architect.md | both reviewer.md (adversarial) | runner 决 | runner 决 | claude |
|
|
25
25
|
|
|
26
|
-
**未传 --role
|
|
26
|
+
**未传 --role 时按双模型并行({{BACKEND_PRIMARY}}/{{FRONTEND_PRIMARY}} optimizer.md),完全兼容**。`--role=critic` 触发"性价比反对意见"——挑战通用优化套路(如盲目缓存 / over-engineering)。详见 `src/utils/specialist-router.ts`。
|
|
27
27
|
|
|
28
28
|
## 上下文
|
|
29
29
|
|
|
@@ -40,12 +40,12 @@ argument-hint: "<优化目标> [--role=architect|critic|implementer|tester|write
|
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
43
|
-
## 调用通道路由(
|
|
43
|
+
## 调用通道路由(CCG codeagent 退役)
|
|
44
44
|
|
|
45
|
-
CCG
|
|
45
|
+
CCG 把双模型并行通道从 `Bash(codeagent-wrapper)` **默认切换**为 plugin spawn:
|
|
46
46
|
|
|
47
47
|
1. **优先 plugin spawn**(默认):装了 `codex@openai-codex` + `gemini@google-gemini` plugin → 用 `Agent(subagent_type="codex:codex-rescue")` + `Agent(subagent_type="gemini:gemini-rescue")` 并行,主线接 ≤200 token 摘要。
|
|
48
|
-
2. **降级 codeagent-wrapper**(
|
|
48
|
+
2. **降级 codeagent-wrapper**(BC fallback):plugin 未装 → fallback 到 Bash 调用,行为与 plugin 路径等价。
|
|
49
49
|
|
|
50
50
|
**判定**:preflight `Bash` 跑 `ls ~/.claude/plugins/` 看有无 `codex@*` / `gemini@*` 子目录。helper 见 `src/utils/plugin-detection.ts`。
|
|
51
51
|
|
|
@@ -60,7 +60,7 @@ CCG v4.1 把双模型并行通道从 `Bash(codeagent-wrapper)` **默认切换**
|
|
|
60
60
|
- 如果用户通过 `/add-dir` 添加了多个工作区,先用 Glob/Grep 确定任务相关的工作区
|
|
61
61
|
- 如果无法确定,用 `AskUserQuestion` 询问用户选择目标工作区
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
**调用语法**(双通道):
|
|
64
64
|
|
|
65
65
|
**通道 A — plugin spawn(默认)**:
|
|
66
66
|
|
|
@@ -101,7 +101,7 @@ EOF",
|
|
|
101
101
|
})
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
> ⚠️ 通道 B `codeagent-wrapper`
|
|
104
|
+
> ⚠️ 通道 B `codeagent-wrapper` 已标 **deprecated**。
|
|
105
105
|
|
|
106
106
|
**角色提示词**:
|
|
107
107
|
|
|
@@ -110,7 +110,7 @@ EOF",
|
|
|
110
110
|
| 后端 | `~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/optimizer.md` |
|
|
111
111
|
| 前端 | `~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/optimizer.md` |
|
|
112
112
|
|
|
113
|
-
**并行调用 +
|
|
113
|
+
**并行调用 + 事件驱动等待**:
|
|
114
114
|
|
|
115
115
|
1. 同 message 内 spawn 多个 `Bash(run_in_background: true)` 并行任务
|
|
116
116
|
2. spawn 完后主线说明已启动 task-id,**直接 turn end**,**不调 TaskOutput**
|
|
@@ -119,7 +119,7 @@ EOF",
|
|
|
119
119
|
5. **必须等所有相关 task 都收到通知**才进入下一阶段(按 task-id 计数已收齐)
|
|
120
120
|
|
|
121
121
|
⛔ **禁止**:
|
|
122
|
-
- 调 `TaskOutput({block: true, timeout: 600000})` ——
|
|
122
|
+
- 调 `TaskOutput({block: true, timeout: 600000})` —— 旧 freeze poll 模式,已废弃
|
|
123
123
|
- 收到部分通知就跳过等其他模型
|
|
124
124
|
- 主动 Kill task
|
|
125
125
|
|
|
@@ -165,7 +165,7 @@ EOF",
|
|
|
165
165
|
- 需求:分析前端性能问题(Core Web Vitals)
|
|
166
166
|
- OUTPUT:性能瓶颈列表、优化方案、预期收益
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
事件驱动等待:spawn 完两个 Bash bg 后主线 turn end,等 task-notification 自动唤醒。**必须等所有模型返回后才能进入下一阶段**。
|
|
169
169
|
|
|
170
170
|
**务必遵循上方 `多模型调用规范` 的 `重要` 指示**
|
|
171
171
|
|
|
@@ -9,9 +9,9 @@ $ARGUMENTS
|
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
## Role-based routing(
|
|
12
|
+
## Role-based routing(specialist matrix)
|
|
13
13
|
|
|
14
|
-
可选参数 `--role=<name>` 在
|
|
14
|
+
可选参数 `--role=<name>` 在 backend/frontend layer 路由之上叠加 **role 维度**,自动选择更精准的 prompt 文件。**未传 `--role` 时按现状路由({{BACKEND_PRIMARY}}/{{FRONTEND_PRIMARY}}),完全保留默认行为兼容**——无破坏性变更。
|
|
15
15
|
|
|
16
16
|
**Role × Layer 路由矩阵**:
|
|
17
17
|
|
|
@@ -23,11 +23,11 @@ $ARGUMENTS
|
|
|
23
23
|
|
|
24
24
|
**判定流程**:
|
|
25
25
|
|
|
26
|
-
1. **解析 layer**:根据 $ARGUMENTS 涉及文件类型推断 `backend` / `frontend` / `fullstack
|
|
27
|
-
2. **解析 role**:从 $ARGUMENTS 提取 `--role=<name>`(5 个合法值:`architect` / `critic` / `implementer` / `tester` / `writer`),不存在或非法值 → fallback
|
|
26
|
+
1. **解析 layer**:根据 $ARGUMENTS 涉及文件类型推断 `backend` / `frontend` / `fullstack`。
|
|
27
|
+
2. **解析 role**:从 $ARGUMENTS 提取 `--role=<name>`(5 个合法值:`architect` / `critic` / `implementer` / `tester` / `writer`),不存在或非法值 → fallback 默认模型路由。
|
|
28
28
|
3. **选 prompt 文件**:按矩阵查 `(role, layer)` 单元格 → ROLE_FILE 路径。
|
|
29
29
|
4. **adversarial 标记**:role=critic 时,prompt 段额外注入 "deliberately hunt for flaws / contradict majority view" 指令,触发敌对审查模式。
|
|
30
|
-
5. **runner 决**:fullstack × {implementer, tester} 时,per-file 选 codex 或 gemini(同
|
|
30
|
+
5. **runner 决**:fullstack × {implementer, tester} 时,per-file 选 codex 或 gemini(同 phase-runner Type 路由逻辑)。
|
|
31
31
|
|
|
32
32
|
**示例**:
|
|
33
33
|
|
|
@@ -50,18 +50,18 @@ $ARGUMENTS
|
|
|
50
50
|
|
|
51
51
|
---
|
|
52
52
|
|
|
53
|
-
## 调用通道路由(
|
|
53
|
+
## 调用通道路由(CCG codeagent 退役)
|
|
54
54
|
|
|
55
|
-
CCG
|
|
55
|
+
CCG 把 6 核心命令的"双模型并行"通道从 `Bash(codeagent-wrapper)` **默认切换**为 plugin spawn。判定流程:
|
|
56
56
|
|
|
57
57
|
1. **优先 plugin spawn 路径**(默认):用户已装 `codex@openai-codex` 和 `gemini@google-gemini` plugin → 用 `Agent(subagent_type="codex:codex-rescue")` + `Agent(subagent_type="gemini:gemini-rescue")` 并行 spawn,主线只接 plugin 自家 ≤200 token 摘要协议(`STATUS: ... / FINDINGS: ... / NOTES: ...`)。
|
|
58
|
-
2. **降级 codeagent-wrapper 路径**(
|
|
58
|
+
2. **降级 codeagent-wrapper 路径**(BC fallback):plugin 未装 → fallback 到 `Bash(~/.claude/bin/codeagent-wrapper --backend ... resume ... <<'EOF' ... EOF)`,与 plugin 路径行为等价。
|
|
59
59
|
|
|
60
60
|
**判断方法**:preflight 用 `Bash` 跑 `ls ~/.claude/plugins/ 2>/dev/null | grep -E '^codex@'` 与 `... | grep -E '^gemini@'` 各一次。匹配到对应行 → plugin 已装。两个 plugin 独立判定,可分别 mix-and-match(仅 codex plugin 装了 → backend 走 plugin、frontend 走 codeagent)。
|
|
61
61
|
|
|
62
62
|
**单一真相源**:plugin 检测逻辑 helper 见 `src/utils/plugin-detection.ts`(导出 `detectPlugin` / `detectPluginAvailability` / `bothPluginsInstalled`)。命令模板把判定结果渲染到执行计划,`Agent(...)` 调用与 `Bash(...)` 调用的具体语法见下面"多模型调用规范"段。
|
|
63
63
|
|
|
64
|
-
**为什么默认 plugin**:
|
|
64
|
+
**为什么默认 plugin**:nested-spawn 测试证明 plugin advisor 摘要协议(≤200 token)压制了 codeagent stdout 全文回灌主线的痛点,主线 context 增量从 +5%/调用 降到 +1.5%/调用。详见 `.ccg-research/07-multimodel-collaboration-rethink.md`。
|
|
65
65
|
|
|
66
66
|
⚠️ **重要**:本命令本身不在 subagent context 内(主线命令),**可以**调 `Agent(...)` 工具——这跟 `phase-runner` 等 subagent 的"引擎层禁止嵌套 spawn Agent"约束不冲突。
|
|
67
67
|
|
|
@@ -74,7 +74,7 @@ CCG v4.1 把 6 核心命令的"双模型并行"通道从 `Bash(codeagent-wrapper
|
|
|
74
74
|
- 如果用户通过 `/add-dir` 添加了多个工作区,先用 Glob/Grep 确定任务相关的工作区
|
|
75
75
|
- 如果无法确定,用 `AskUserQuestion` 询问用户选择目标工作区
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
**调用语法**(双通道):
|
|
78
78
|
|
|
79
79
|
**通道 A — plugin spawn(默认)**:
|
|
80
80
|
|
|
@@ -115,7 +115,7 @@ EOF",
|
|
|
115
115
|
})
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
-
> ⚠️ 通道 B 走 `codeagent-wrapper`(Node 脚本 `templates/scripts/invoke-model.mjs
|
|
118
|
+
> ⚠️ 通道 B 走 `codeagent-wrapper`(Node 脚本 `templates/scripts/invoke-model.mjs`),已标 **deprecated**,建议用户安装 codex/gemini plugin 享受主线 context 优化。
|
|
119
119
|
|
|
120
120
|
**角色提示词**:
|
|
121
121
|
|
|
@@ -126,7 +126,7 @@ EOF",
|
|
|
126
126
|
|
|
127
127
|
**会话复用**:每次调用返回 `SESSION_ID: xxx`(通常由 wrapper 输出),**必须保存**以供后续 `/ccg:execute` 使用。
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
**事件驱动等待**:spawn 后主线说明 task-id 然后 **turn end**,引擎自动 `<task-notification>` 触发新 turn 处理结果。**不调 TaskOutput**。
|
|
130
130
|
|
|
131
131
|
⛔ **禁止**:调 `TaskOutput({block: true, timeout: 600000})` 旧 freeze poll 模式 / Kill task。
|
|
132
132
|
|
|
@@ -192,7 +192,7 @@ EOF",
|
|
|
192
192
|
- 关注:UI/UX 影响、用户体验、视觉设计
|
|
193
193
|
- OUTPUT: 多角度解决方案 + 优劣势分析
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
事件驱动等待:spawn 完两个 Bash bg 后主线 turn end,等 task-notification 自动唤醒。**📌 保存 SESSION_ID**(`CODEX_SESSION` 和 `GEMINI_SESSION`)。
|
|
196
196
|
|
|
197
197
|
#### 2.2 交叉验证
|
|
198
198
|
|
|
@@ -251,7 +251,7 @@ EOF",
|
|
|
251
251
|
- GEMINI_SESSION: <session_id>
|
|
252
252
|
```
|
|
253
253
|
|
|
254
|
-
### 🛡 Phase 2.5:自动 plan-checker 校验(5 维度 + max-3-loop
|
|
254
|
+
### 🛡 Phase 2.5:自动 plan-checker 校验(5 维度 + max-3-loop)
|
|
255
255
|
|
|
256
256
|
写出 `.claude/plan/<功能名>.md` 后、向用户交付前,**必须**自动 spawn `plan-checker` agent 做 5 维度强校验:
|
|
257
257
|
|
|
@@ -289,7 +289,7 @@ if loop_count == 3 and result.hasBlocker:
|
|
|
289
289
|
|
|
290
290
|
1. 向用户展示完整实施计划(含伪代码)+ plan-checker 报告摘要(BLOCKER/WARNING 数量 + verdict)
|
|
291
291
|
2. 将计划保存至 `.claude/plan/<功能名>.md`(功能名从需求中提取,如 `user-auth`、`payment-module` 等)
|
|
292
|
-
3. **写 phase-scoped CONTEXT.md
|
|
292
|
+
3. **写 phase-scoped CONTEXT.md**(状态机):把本次 plan 的冻结决策固化到 `.context/<phase>/CONTEXT.md`,下游 `/ccg:execute` 与 `/ccg:team-exec` 仅读此文件的 YAML frontmatter 即可获得全部决策(< 200 tokens / phase)。**目录约定**:`<phase>` 取计划文件主名(如 `user-auth`),用 `sanitizePhase()` 规范化非法字符。
|
|
293
293
|
|
|
294
294
|
**CONTEXT.md 必含 frontmatter 字段(机器可读契约)**:
|
|
295
295
|
```yaml
|
|
@@ -5,7 +5,7 @@ argument-hint: "[代码或描述] [--adversarial] [--fix [--all] [--auto]] [--ro
|
|
|
5
5
|
|
|
6
6
|
# Review - 多模型代码审查
|
|
7
7
|
|
|
8
|
-
## Role-based routing(
|
|
8
|
+
## Role-based routing(specialist matrix)
|
|
9
9
|
|
|
10
10
|
可选 `--role=<name>` 叠加 role 维度路由:
|
|
11
11
|
|
|
@@ -15,13 +15,13 @@ argument-hint: "[代码或描述] [--adversarial] [--fix [--all] [--auto]] [--ro
|
|
|
15
15
|
| **frontend** | gemini/architect.md | gemini/reviewer.md (adversarial) | gemini/architect.md | gemini/tester.md | gemini/analyzer.md |
|
|
16
16
|
| **fullstack** | codex+gemini/architect.md | both reviewer.md (adversarial) | runner 决 | runner 决 | claude |
|
|
17
17
|
|
|
18
|
-
**未传 --role
|
|
18
|
+
**未传 --role 时按双模型路由({{BACKEND_PRIMARY}}/{{FRONTEND_PRIMARY}} reviewer.md)**——完全兼容现有 `--adversarial` / `--fix` 行为。`--role=critic` 等价于隐式 `--adversarial`(语义同义)。详见 `src/utils/specialist-router.ts`。
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
22
|
双模型并行审查,交叉验证综合反馈。无参数时自动审查当前 git 变更。
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
**双模型并行通道**:默认走 plugin spawn —— 装了 `codex@openai-codex` + `gemini@google-gemini` plugin → 用 `Agent(subagent_type="codex:codex-rescue")` + `Agent(subagent_type="gemini:gemini-rescue")` 并行,主线只接 ≤200 token 摘要;plugin 未装 → fallback 到 codeagent-wrapper 路径(BC fallback)。preflight 用 `Bash` 跑 `ls ~/.claude/plugins/` 检测,helper 见 `src/utils/plugin-detection.ts`。
|
|
25
25
|
|
|
26
26
|
`--adversarial` 模式下额外触发第三层"敌对视角"审查,由官方 codex plugin 的 `Agent(codex:codex-rescue)` 在 fresh context 中专门挑前两轮意见的漏洞,适合极重要 PR / 安全敏感变更。需用户已装 `codex@openai-codex` plugin,否则降级为双模型审查。
|
|
27
27
|
|
|
@@ -49,27 +49,55 @@ argument-hint: "[代码或描述] [--adversarial] [--fix [--all] [--auto]] [--ro
|
|
|
49
49
|
- 如果用户通过 `/add-dir` 添加了多个工作区,先用 Glob/Grep 确定任务相关的工作区
|
|
50
50
|
- 如果无法确定,用 `AskUserQuestion` 询问用户选择目标工作区
|
|
51
51
|
|
|
52
|
-
**调用语法**(
|
|
52
|
+
**调用语法**(review/verify 路径默认走 Bash 直调):
|
|
53
53
|
|
|
54
|
-
**通道 A — Bash 直调 plugin script
|
|
54
|
+
**通道 A — Bash 直调 plugin script(默认,绕开 sonnet wrapper)**:
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})
|
|
56
|
+
> 占位符 `{{CODEX_BASH_TASK}}` / `{{GEMINI_BASH_TASK}}` 由 install 时渲染为
|
|
57
|
+
> `node <ccgx-call-plugin.mjs 绝对路径> <vendor> --json`。LLM **只需把 prompt
|
|
58
|
+
> 写入 tmpfile、追加 `--prompt-file <tmpfile>`、运行**。helper 内部处理路径解析、
|
|
59
|
+
> spawn array args、shell escape 全部规避——LLM 不参与任何命令构造。
|
|
60
|
+
|
|
61
|
+
**LLM 工作流(严格 3 步)**:
|
|
63
62
|
|
|
64
|
-
Bash({
|
|
65
|
-
command: `node "$(ls ~/.claude/plugins/cache/google-gemini/gemini/*/scripts/gemini-companion.mjs | head -1)" task -p "<整段 prompt>" --json`,
|
|
66
|
-
description: "Review: frontend (gemini direct)",
|
|
67
|
-
run_in_background: true,
|
|
68
|
-
timeout: 3600000
|
|
69
|
-
})
|
|
70
63
|
```
|
|
64
|
+
Step 1. 用 Write 工具把完整 prompt 写到 tmpfile
|
|
65
|
+
Write({ file_path: "/tmp/ccg-review-codex-$JOB.txt", content: "<完整 prompt>" })
|
|
66
|
+
Write({ file_path: "/tmp/ccg-review-gemini-$JOB.txt", content: "<完整 prompt>" })
|
|
67
|
+
|
|
68
|
+
Step 2. 用 Bash 调 helper(占位符已渲染):
|
|
69
|
+
Bash({
|
|
70
|
+
command: `{{CODEX_BASH_TASK}} --prompt-file /tmp/ccg-review-codex-$JOB.txt`,
|
|
71
|
+
description: "Review: backend (codex direct)",
|
|
72
|
+
run_in_background: true,
|
|
73
|
+
timeout: 3600000
|
|
74
|
+
})
|
|
75
|
+
Bash({
|
|
76
|
+
command: `{{GEMINI_BASH_TASK}} --prompt-file /tmp/ccg-review-gemini-$JOB.txt`,
|
|
77
|
+
description: "Review: frontend (gemini direct)",
|
|
78
|
+
run_in_background: true,
|
|
79
|
+
timeout: 3600000
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
Step 3. 等 task-notification 通知后 Read 各自 stdout(即 helper 输出的 JSON),parse
|
|
83
|
+
`result.stdout` 拿真实 plugin 输出,再按 plugin --json schema 解析。
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
⛔ **严禁** 任何形式自拼命令:
|
|
87
|
+
- 不要写 `node "$(ls ...)/codex-companion.mjs"`
|
|
88
|
+
- 不要 `cat <<EOF`、不要 heredoc、不要 `-p "..."` 内联 prompt
|
|
89
|
+
- 不要硬编码 plugin 路径——helper 内部解析 SSoT
|
|
90
|
+
- **唯一允许**:copy 占位符内容 + 追加 `--prompt-file <tmpfile>`
|
|
71
91
|
|
|
72
|
-
⛔ **不要**用 `Agent(subagent_type="codex:codex-rescue"|"gemini:gemini-rescue")
|
|
92
|
+
⛔ **不要**用 `Agent(subagent_type="codex:codex-rescue"|"gemini:gemini-rescue")`:
|
|
93
|
+
|
|
94
|
+
review/verify 路径输出**直接落地**决策(PR merge / advance / revise / escalate),无下游兜底。
|
|
95
|
+
plugin 经由 `Agent(...)` spawn 时引擎启动 sonnet wrapper 扮演 codex/gemini 客户端,broker 故障 /
|
|
96
|
+
CLI 空答 / auth 过期时 wrapper 受 instruction-tuning 驱动**自答 fabricated cross-vendor 视角**
|
|
97
|
+
(silent fallback),主线无法察觉。Bash 直调消除 wrapper 层,stdout 即真实 plugin 输出。
|
|
98
|
+
|
|
99
|
+
详见 `src/utils/verify-orchestrator.ts:planVerifyWave` 的 `useDirectBashInvocation` 选项 +
|
|
100
|
+
`src/utils/plugin-bash-codegen.ts`(1.0.4 install-time codegen)。
|
|
73
101
|
|
|
74
102
|
主线接 stdout JSON(5-50KB),按 plugin --json schema 解析 `result.text` 字段,失败信号:
|
|
75
103
|
- exit code ≠ 0 → loud fail,触发 v1.7.87 标准 2-retry / 5s / 3-attempts 规则
|
|
@@ -95,7 +123,7 @@ EOF",
|
|
|
95
123
|
})
|
|
96
124
|
```
|
|
97
125
|
|
|
98
|
-
> ⚠️ 通道 B `codeagent-wrapper`
|
|
126
|
+
> ⚠️ 通道 B `codeagent-wrapper` 已标 **deprecated**。
|
|
99
127
|
|
|
100
128
|
**角色提示词**:
|
|
101
129
|
|
|
@@ -104,7 +132,7 @@ EOF",
|
|
|
104
132
|
| 后端 | `~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/reviewer.md` |
|
|
105
133
|
| 前端 | `~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/reviewer.md` |
|
|
106
134
|
|
|
107
|
-
**并行调用 +
|
|
135
|
+
**并行调用 + 事件驱动等待**:
|
|
108
136
|
|
|
109
137
|
1. 在同一 message 内 spawn 两个(或多个)`Bash(run_in_background: true)` 并行任务
|
|
110
138
|
2. spawn 完成后主线说明已启动哪些 task(含 task-id),然后**直接 turn end**,**不调 TaskOutput**
|
|
@@ -116,7 +144,7 @@ EOF",
|
|
|
116
144
|
5. **必须等所有相关 task 都收到通知**才进入下一阶段(主线按 task-id 计数已收齐)
|
|
117
145
|
|
|
118
146
|
⛔ **禁止做**:
|
|
119
|
-
- 调 `TaskOutput({block: true, timeout: 600000})` —— 这会 freeze 主线 10
|
|
147
|
+
- 调 `TaskOutput({block: true, timeout: 600000})` —— 这会 freeze 主线 10 分钟,且超时后还要轮询,体验极差(旧模式,已废弃)
|
|
120
148
|
- 收到部分通知就跳过等其他模型
|
|
121
149
|
- 主动 Kill task
|
|
122
150
|
|
|
@@ -165,11 +193,25 @@ EOF",
|
|
|
165
193
|
|
|
166
194
|
**仅当 `$ARGUMENTS` 含 `--adversarial` 字面量时启动**。否则跳过本阶段。
|
|
167
195
|
|
|
168
|
-
调用方式(
|
|
196
|
+
调用方式(Bash 直调,绕开 sonnet wrapper):
|
|
169
197
|
|
|
170
198
|
```
|
|
171
|
-
|
|
172
|
-
|
|
199
|
+
Step 1. 用 Write 把以下 adversarial prompt 写入 tmpfile:
|
|
200
|
+
Write({ file_path: "/tmp/ccg-review-adv-$JOB.txt", content: <见下方 prompt body> })
|
|
201
|
+
|
|
202
|
+
Step 2. 调 helper:
|
|
203
|
+
Bash({
|
|
204
|
+
command: `{{CODEX_BASH_TASK}} --prompt-file /tmp/ccg-review-adv-$JOB.txt`,
|
|
205
|
+
description: "Adversarial review (codex direct)",
|
|
206
|
+
run_in_background: true,
|
|
207
|
+
timeout: 3600000
|
|
208
|
+
})
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Adversarial prompt body**(写入 tmpfile 的内容):
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
--adversarial-review
|
|
173
215
|
|
|
174
216
|
请对以下代码变更进行敌对视角审查:
|
|
175
217
|
|
|
@@ -184,14 +226,11 @@ Bash({
|
|
|
184
226
|
你的任务:
|
|
185
227
|
1. 找出前两轮**未发现或低估**的安全/性能/正确性漏洞
|
|
186
228
|
2. 假设代码作者刻意误导,挑刺
|
|
187
|
-
3. 输出格式:[Critical-Adversarial] / [Major-Adversarial] 列表,每条标
|
|
188
|
-
description: "Adversarial review (codex direct)",
|
|
189
|
-
run_in_background: true,
|
|
190
|
-
timeout: 3600000
|
|
191
|
-
})
|
|
229
|
+
3. 输出格式:[Critical-Adversarial] / [Major-Adversarial] 列表,每条标"为什么前两轮没发现"
|
|
192
230
|
```
|
|
193
231
|
|
|
194
|
-
⛔ 不用 `Agent(subagent_type="codex:codex-rescue")
|
|
232
|
+
⛔ 不用 `Agent(subagent_type="codex:codex-rescue")`:review/verify 路径输出直接落地,silent fallback
|
|
233
|
+
风险(sonnet wrapper 受 instruction-tuning 自答冒充 adversarial 视角)不可接受。详见前文「通道 A」段。
|
|
195
234
|
|
|
196
235
|
收到 stdout JSON 后解析 `result.text` 字段保留待阶段 3 综合。stdout 空或 exit≠0 → 走标准 2-retry 规则。
|
|
197
236
|
|
|
@@ -100,7 +100,7 @@ description: '按规范执行 + 多模型协作 + 归档'
|
|
|
100
100
|
})
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
-
**Step 7.2 (
|
|
103
|
+
**Step 7.2 (事件驱动)**: spawn 两个 Bash bg 后说明 task-id 然后 **turn end**。引擎在每个 task 完成时自动发 `<task-notification>`,主线在通知触发的新 turn 处理结果。**不调 TaskOutput**。两个 task 都收到通知后才进 step 7.3。
|
|
104
104
|
|
|
105
105
|
⛔ **禁止**:调 `TaskOutput({block: true, timeout: 600000})` (旧 freeze poll 模式) / Kill task。
|
|
106
106
|
⚠️ **失败处理**:notification status=failed / exit ≠ 0 / parse 失败 → v1.7.87 标准 2-retry / 5s / 3-attempts;3 次全失败才降级单模型。
|
|
@@ -50,7 +50,7 @@ description: '多模型分析 → 消除歧义 → 零决策可执行计划'
|
|
|
50
50
|
})
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
**Step 2.2 (
|
|
53
|
+
**Step 2.2 (事件驱动)**: spawn 两个 Bash bg 后说明 task-id 然后 **turn end**。引擎在每个 task 完成时自动发 `<task-notification>`,主线在通知触发的新 turn 处理结果。**不调 TaskOutput**。两个 task 都收到通知后才进 step 2.3。
|
|
54
54
|
|
|
55
55
|
⛔ **禁止**:调 `TaskOutput({block: true, timeout: 600000})` (旧 freeze poll 模式) / Kill task。
|
|
56
56
|
⚠️ **失败处理**:notification status=failed / exit ≠ 0 / parse 失败 → v1.7.87 标准 2-retry / 5s / 3-attempts;3 次全失败才降级单模型。
|
|
@@ -158,7 +158,7 @@ description: '多模型分析 → 消除歧义 → 零决策可执行计划'
|
|
|
158
158
|
"Plan phase complete. Artifacts generated: specs.md, design.md, tasks.md. Run `/ccg:spec-impl` to start implementation."
|
|
159
159
|
Do NOT proceed to modify source code.
|
|
160
160
|
|
|
161
|
-
5.5. **自动 plan-checker 校验(5 维度 + max-3-loop
|
|
161
|
+
5.5. **自动 plan-checker 校验(5 维度 + max-3-loop)**
|
|
162
162
|
|
|
163
163
|
生成 OPSX artifacts 后,**必须**自动 spawn `plan-checker` agent 对 specs.md / design.md / tasks.md 做 5 维度校验:
|
|
164
164
|
|
|
@@ -89,7 +89,7 @@ description: '需求 → 约束集(并行探索 + OPSX 提案)'
|
|
|
89
89
|
})
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
**Step 4.2 (
|
|
92
|
+
**Step 4.2 (事件驱动)**: spawn 两个 Bash bg 后说明 task-id 然后 **turn end**。引擎在每个 task 完成时自动发 `<task-notification>`,主线在通知触发的新 turn 处理结果。**不调 TaskOutput**。两个 task 都收到通知后才进 step 4.3。
|
|
93
93
|
|
|
94
94
|
⛔ **禁止**:调 `TaskOutput({block: true, timeout: 600000})` (旧 freeze poll 模式) / Kill task。
|
|
95
95
|
⚠️ **失败处理**:notification status=failed / exit ≠ 0 / parse 失败 → v1.7.87 标准 2-retry / 5s / 3-attempts;3 次全失败才降级单模型。
|
|
@@ -51,7 +51,7 @@ description: '双模型交叉审查(独立工具,随时可用)'
|
|
|
51
51
|
})
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
**Step 3.2 (
|
|
54
|
+
**Step 3.2 (事件驱动)**: spawn 两个 Bash bg 后说明 task-id 然后 **turn end**。引擎在每个 task 完成时自动发 `<task-notification>`,主线在通知触发的新 turn 处理结果。**不调 TaskOutput**。两个 task 都收到通知后才进 step 3.3。
|
|
55
55
|
|
|
56
56
|
⛔ **禁止**:调 `TaskOutput({block: true, timeout: 600000})` (旧 freeze poll 模式) / Kill task。
|
|
57
57
|
⚠️ **失败处理**:notification status=failed / exit ≠ 0 / parse 失败 → v1.7.87 标准 2-retry / 5s / 3-attempts;3 次全失败才降级单模型。
|