ccgx-workflow 2.1.2 → 2.3.0

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/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import cac from 'cac';
3
3
  import ansis from 'ansis';
4
- import { d as diagnoseMcpConfig, i as isWindows, r as readClaudeCodeConfig, f as fixWindowsMcpConfig, w as writeClaudeCodeConfig, a as readCcgConfig, b as initI18n, c as i18n, s as showMainMenu, e as init, g as configMcp, v as version } from './shared/ccgx-workflow.dK6O-vwe.mjs';
4
+ import { d as diagnoseMcpConfig, i as isWindows, r as readClaudeCodeConfig, f as fixWindowsMcpConfig, w as writeClaudeCodeConfig, a as readCcgConfig, b as initI18n, c as i18n, s as showMainMenu, e as init, g as configMcp, v as version } from './shared/ccgx-workflow.BYuVglaM.mjs';
5
5
  import { execSync } from 'node:child_process';
6
6
  import 'inquirer';
7
7
  import 'ora';
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { h as collectSkills, j as resolvePluginBashCommand } from './shared/ccgx-workflow.dK6O-vwe.mjs';
2
- export { k as changeLanguage, G as checkForUpdates, I as collectInvocableSkills, H as compareVersions, m as createDefaultConfig, n as createDefaultRouting, J as generateCommandContent, o as getCcgDir, p as getConfigPath, E as getCurrentVersion, F as getLatestVersion, t as getWorkflowById, q as getWorkflowConfigs, c as i18n, e as init, b as initI18n, y as installAceTool, z as installAceToolRs, K as installSkillCommands, x as installWorkflows, C as migrateToV1_4_0, D as needsMigration, L as parseFrontmatter, a as readCcgConfig, s as showMainMenu, B as uninstallAceTool, A as uninstallWorkflows, u as update, l as writeCcgConfig } from './shared/ccgx-workflow.dK6O-vwe.mjs';
1
+ import { h as collectSkills, j as resolvePluginBashCommand } from './shared/ccgx-workflow.BYuVglaM.mjs';
2
+ export { k as changeLanguage, G as checkForUpdates, I as collectInvocableSkills, H as compareVersions, m as createDefaultConfig, n as createDefaultRouting, J as generateCommandContent, o as getCcgDir, p as getConfigPath, E as getCurrentVersion, F as getLatestVersion, t as getWorkflowById, q as getWorkflowConfigs, c as i18n, e as init, b as initI18n, y as installAceTool, z as installAceToolRs, K as installSkillCommands, x as installWorkflows, C as migrateToV1_4_0, D as needsMigration, L as parseFrontmatter, a as readCcgConfig, s as showMainMenu, B as uninstallAceTool, A as uninstallWorkflows, u as update, l as writeCcgConfig } from './shared/ccgx-workflow.BYuVglaM.mjs';
3
3
  import { existsSync, readFileSync, mkdirSync, writeFileSync, statSync, readdirSync } from 'node:fs';
4
4
  import { join, dirname } from 'node:path';
5
5
  import { homedir } from 'node:os';
@@ -13,7 +13,7 @@ import { join as join$2 } from 'node:path/posix';
13
13
  import { join as join$1 } from 'node:path';
14
14
  import i18next from 'i18next';
15
15
 
16
- const version = "2.1.2";
16
+ const version = "2.3.0";
17
17
 
18
18
  function cmd(id, order, category, name, nameEn, description, descriptionEn, cmdOverride) {
19
19
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccgx-workflow",
3
- "version": "2.1.2",
3
+ "version": "2.3.0",
4
4
  "description": "Multi-model orchestration for Claude Code. Codex + Gemini parallel collaboration with fresh-context subagent protocols, OS-level process isolation, and Plan-Critic-Verify quality tiers. Successor to ccg-workflow.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@10.17.1",
@@ -46,60 +46,80 @@ $ARGUMENTS
46
46
  - 如果用户通过 `/add-dir` 添加了多个工作区,先用 Glob/Grep 确定任务相关的工作区
47
47
  - 如果无法确定,用 `AskUserQuestion` 询问用户选择目标工作区
48
48
 
49
- **{{BACKEND_PRIMARY}} 执行调用语法**:
49
+ **调用通道路由(CCG codeagent 退役,v2.2.0+)**
50
+
51
+ 1. **优先 plugin spawn**(默认):plugin 已装 → `Agent(subagent_type="codex:codex-rescue")`,session 复用通过 prompt 内 `--resume` flag 表达(subagent 映射为 codex `--resume-last`)。
52
+ 2. **降级 codeagent-wrapper**(BC fallback):plugin 未装 → Bash 调用,保留 `resume <SESSION_ID>` 显式会话管理。
53
+
54
+ **判定**:preflight `Bash` 跑 `ls ~/.claude/plugins/` 看有无 `codex@*` / `gemini@*` 子目录。
55
+
56
+ **会话模型差异**:
57
+ - **通道 A(plugin)**:session 是同一 Claude session 内的最近 codex/gemini thread(`--resume-last`)。同任务多 phase 顺序执行 OK;不支持跨任务跳点 resume by ID。
58
+ - **通道 B(wrapper)**:显式 `SESSION_ID`,可跨流程任意复用历史 thread。
59
+
60
+ ---
61
+
62
+ **{{BACKEND_PRIMARY}} 执行调用语法(通道 A 默认)**:
63
+
64
+ **预备动作**:spawn 前主线先 Read 角色提示词(如 `~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/architect.md`)拼入 `<role>` 块。
50
65
 
51
66
  ```
52
- Bash({
53
- command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend {{BACKEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}- \"{{WORKDIR}}\" <<'EXEC_EOF'
54
- <TASK>
67
+ Agent({
68
+ subagent_type: "codex:codex-rescue",
69
+ description: "简短描述",
70
+ prompt: `<role>
71
+ ${implementerRole}
72
+ </role>
73
+
74
+ <workdir>{{WORKDIR}}</workdir>
75
+
76
+ <task>
55
77
  <指令内容>
56
- </TASK>
57
- EXEC_EOF",
58
- run_in_background: true,
59
- timeout: 3600000,
60
- description: "简短描述"
78
+ </task>
79
+
80
+ <action_safety>
81
+ - Stay strictly within the plan scope
82
+ - Run lint/typecheck if available before reporting completion
83
+ </action_safety>`
61
84
  })
62
85
  ```
63
86
 
64
- **{{BACKEND_PRIMARY}} 复用会话调用**:
87
+ **{{BACKEND_PRIMARY}} 复用会话调用(通道 A,--resume)**:在 prompt 第一行加 `--resume`(subagent 提取为 routing flag 映射 codex `--resume-last`,不写入 task text):
65
88
 
66
89
  ```
67
- Bash({
68
- command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend {{BACKEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}resume <SESSION_ID> - \"{{WORKDIR}}\" <<'EXEC_EOF'
69
- <TASK>
70
- <指令内容>
71
- </TASK>
72
- EXEC_EOF",
73
- run_in_background: true,
74
- timeout: 3600000,
75
- description: "简短描述"
90
+ Agent({
91
+ subagent_type: "codex:codex-rescue",
92
+ description: "简短描述",
93
+ prompt: `--resume
94
+
95
+ <task>
96
+ <指令内容(仅 delta,不重述完整 plan)>
97
+ </task>`
76
98
  })
77
99
  ```
78
100
 
79
- **审核调用语法**(Codex Gemini 并行审查):
101
+ **通道 B wrapper BC fallback**(plugin 未装时):
80
102
 
81
103
  ```
104
+ # 新会话(保留 SESSION_ID)
82
105
  Bash({
83
- command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend <{{BACKEND_PRIMARY}}|{{FRONTEND_PRIMARY}}> {{GEMINI_MODEL_FLAG}}- \"{{WORKDIR}}\" <<'REVIEW_EOF'
84
- ROLE_FILE: <角色提示词路径>
85
- <TASK>
86
- Scope: Audit the code changes made by Codex.
87
- Inputs:
88
- - The git diff (applied changes)
89
- - The implementation plan
90
- Constraints:
91
- - Do NOT modify any files.
92
- </TASK>
93
- OUTPUT:
94
- 1) A prioritized list of issues (severity, file, rationale)
95
- 2) If code changes are needed, include a Unified Diff Patch in a fenced code block.
96
- REVIEW_EOF",
106
+ command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend {{BACKEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}- \"{{WORKDIR}}\" <<'EXEC_EOF'\n<TASK>\n<指令内容>\n</TASK>\nEXEC_EOF",
97
107
  run_in_background: true,
98
108
  timeout: 3600000,
99
- description: "简短描述"
109
+ description: "简短描述 (BC)"
110
+ })
111
+
112
+ # 复用会话
113
+ Bash({
114
+ command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend {{BACKEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}resume <SESSION_ID> - \"{{WORKDIR}}\" <<'EXEC_EOF'\n<TASK>\n<指令内容>\n</TASK>\nEXEC_EOF",
115
+ run_in_background: true,
116
+ timeout: 3600000,
117
+ description: "简短描述 (BC, resume)"
100
118
  })
101
119
  ```
102
120
 
121
+ **审核调用(通道 A,双模型并行)**:参照 `/ccg:spec-review` 的 Step 3.1 pattern——`Agent(codex:codex-rescue)` + `Agent(gemini:gemini-rescue)` 同 message 并行,预读 `reviewer.md` 拼入 `<role>` 块。通道 B 同 `<<'REVIEW_EOF'... wrapper` 模式(已 deprecated)。
122
+
103
123
  **角色提示词**:
104
124
 
105
125
  | 阶段 | 后端 | 前端 |
@@ -156,12 +176,21 @@ REVIEW_EOF",
156
176
 
157
177
  `[模式:执行]`
158
178
 
159
- **将计划转化为 Codex 结构化指令,一次性下发**:
179
+ **将计划转化为 Codex 结构化指令,一次性下发**。按顶部「调用通道路由」选 A 或 B:
180
+
181
+ **通道 A — plugin spawn(默认)**:
160
182
 
161
183
  ```
162
- Bash({
163
- command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend {{BACKEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}resume <CODEX_SESSION> - \"{{WORKDIR}}\" <<'EXEC_EOF'
164
- <TASK>
184
+ Agent({
185
+ subagent_type: "codex:codex-rescue",
186
+ description: "Codex 全权执行:<计划标题>",
187
+ prompt: `${codexSessionExists ? '--resume\n' : ''}<role>
188
+ ${implementerRole} // 主线预读 ~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/architect.md
189
+ </role>
190
+
191
+ <workdir>{{WORKDIR}}</workdir>
192
+
193
+ <task>
165
194
  You are a full-stack execution agent. Implement the following plan end-to-end.
166
195
 
167
196
  ## Implementation Plan
@@ -180,48 +209,53 @@ Before coding, verify you have sufficient context:
180
209
  Implement each step from the plan in order:
181
210
  <将计划的实施步骤逐条列出>
182
211
 
183
- Constraints:
184
- - Follow existing code conventions in this project
185
- - Handle edge cases and errors properly
186
- - Keep changes minimal and focused on the plan
187
- - Do NOT modify files outside the plan's scope
188
-
189
212
  ### Step 3: Self-Verification
190
213
  After implementation:
191
214
  - Run lint/typecheck if available
192
- - Run existing tests: <从计划中提取测试命令,如无则 "run project's test suite">
215
+ - Run existing tests: <从计划中提取测试命令>
193
216
  - Verify no regressions in touched modules
217
+ </task>
218
+
219
+ <action_safety>
220
+ - Follow existing code conventions in this project
221
+ - Handle edge cases and errors properly
222
+ - Keep changes minimal and focused on the plan
223
+ - Do NOT modify files outside the plan's scope
224
+ </action_safety>
194
225
 
195
- ## Output Format
196
- Respond with a structured report:
226
+ <structured_output_contract>
227
+ Respond with this structured report:
197
228
 
198
229
  ### CONTEXT_GATHERED
199
230
  <What information was searched/found, key findings from MCP tools>
200
231
 
201
232
  ### CHANGES_MADE
202
- For each file changed:
203
- - File path
204
- - What was changed and why
205
- - Lines added/removed
233
+ For each file changed: file path / what changed / why / lines added-removed
206
234
 
207
235
  ### VERIFICATION_RESULTS
208
236
  - Lint/typecheck: pass/fail
209
237
  - Tests: pass/fail (details if fail)
210
- - Manual checks performed
211
238
 
212
239
  ### REMAINING_ISSUES
213
- <Any unresolved issues, edge cases, or suggestions>
214
- </TASK>
215
- EXEC_EOF",
240
+ <Any unresolved issues>
241
+ </structured_output_contract>`
242
+ })
243
+ ```
244
+
245
+ **📌 同 Claude session 内后续 Phase 2.5(修正)会自动通过 `--resume` 接到 codex 的 last thread**(plugin 路径无显式 SESSION_ID)。
246
+
247
+ **通道 B — wrapper BC fallback**:
248
+
249
+ ```
250
+ Bash({
251
+ command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend {{BACKEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}resume <CODEX_SESSION> - \"{{WORKDIR}}\" <<'EXEC_EOF'\n<TASK>\nYou are a full-stack execution agent. Implement the following plan end-to-end.\n\n## Implementation Plan\n<完整计划>\n\n## Output Format\n<同上结构化报告>\n</TASK>\nEXEC_EOF",
216
252
  run_in_background: true,
217
253
  timeout: 3600000,
218
- description: "Codex 全权执行:<计划标题>"
254
+ description: "Codex 全权执行:<计划标题> (BC)"
219
255
  })
220
256
  ```
221
257
 
222
- **📌 记录 SESSION_ID**(`CODEX_EXEC_SESSION`)
223
-
224
- 如果计划中无 `CODEX_SESSION`(用户跳过了 `/ccg:plan` 的多模型分析),则使用新会话。
258
+ **📌 记录 SESSION_ID**(`CODEX_EXEC_SESSION`)供 Phase 2.5 显式 resume。
225
259
 
226
260
  事件驱动等待:spawn 完后主线 turn end,等 task-notification 自动唤醒。
227
261
 
@@ -256,12 +290,17 @@ EXEC_EOF",
256
290
 
257
291
  `[模式:追加]`
258
292
 
259
- **复用 Codex 会话,下发修正指令**:
293
+ **复用 Codex 会话,下发修正指令**。按顶部「调用通道路由」选 A 或 B:
294
+
295
+ **通道 A — plugin spawn(默认,--resume)**:
260
296
 
261
297
  ```
262
- Bash({
263
- command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend {{BACKEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}resume <CODEX_EXEC_SESSION> - \"{{WORKDIR}}\" <<'FIXEOF'
264
- <TASK>
298
+ Agent({
299
+ subagent_type: "codex:codex-rescue",
300
+ description: "Codex 修正:<问题简述>",
301
+ prompt: `--resume
302
+
303
+ <task>
265
304
  The implementation needs corrections:
266
305
 
267
306
  ## Issues Found
@@ -272,12 +311,19 @@ The implementation needs corrections:
272
311
  1. <具体修正要求>
273
312
  2. <具体修正要求>
274
313
 
275
- Apply fixes and re-run tests. Report results in the same format.
276
- </TASK>
277
- FIXEOF",
314
+ Apply fixes and re-run tests. Report results in the same format as Phase 1.
315
+ </task>`
316
+ })
317
+ ```
318
+
319
+ **通道 B — wrapper BC fallback**:
320
+
321
+ ```
322
+ Bash({
323
+ command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend {{BACKEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}resume <CODEX_EXEC_SESSION> - \"{{WORKDIR}}\" <<'FIXEOF'\n<TASK>\nThe implementation needs corrections:\n\n## Issues Found\n1. ...\n\n## Required Fixes\n1. ...\n\nApply fixes and re-run tests. Report results in the same format.\n</TASK>\nFIXEOF",
278
324
  run_in_background: true,
279
325
  timeout: 3600000,
280
- description: "Codex 修正:<问题简述>"
326
+ description: "Codex 修正:<问题简述> (BC)"
281
327
  })
282
328
  ```
283
329
 
@@ -45,17 +45,58 @@ description: '按规范执行 + 多模型协作 + 归档'
45
45
 
46
46
  **工作目录**:`{{WORKDIR}}` **必须通过 Bash 执行 `pwd`(Unix)或 `cd`(Windows CMD)获取当前工作目录的绝对路径**,禁止从 `$HOME` 或环境变量推断。如果用户通过 `/add-dir` 添加了多个工作区,先确定任务相关的工作区。
47
47
 
48
- For each task:
48
+ **调用通道路由(CCG codeagent 退役,v2.2.0+)**
49
+
50
+ 1. **优先 plugin spawn**(默认):plugin 已装 → `Agent(subagent_type="<codex:codex-rescue|gemini:gemini-rescue>")`,主线接 ≤200 token 摘要。
51
+ 2. **降级 codeagent-wrapper**(BC fallback):plugin 未装 → Bash 调用,保留 SESSION_ID 供 Step 7 review 复用。
52
+
53
+ **预备动作**:主线先 Read 角色提示词(这里用 `architect.md` 或对应实施角色),把内容拼入 `<role>` 块。
54
+
55
+ **通道 A — plugin spawn(默认,每 task 独立 fresh-context)**:
56
+
49
57
  ```
50
- codeagent-wrapper --progress --backend <{{BACKEND_PRIMARY}}|{{FRONTEND_PRIMARY}}> {{GEMINI_MODEL_FLAG}}- "{{WORKDIR}}" <<'EOF'
51
- TASK: <task description from tasks.md>
52
- CONTEXT: <relevant code context>
53
- CONSTRAINTS: <constraints from spec>
54
- OUTPUT: Unified Diff Patch format ONLY
55
- EOF
58
+ Agent({
59
+ subagent_type: "<codex:codex-rescue|gemini:gemini-rescue>",
60
+ description: "spec-impl: <task name>",
61
+ prompt: `<role>
62
+ ${implementerRole}
63
+ </role>
64
+
65
+ <workdir>{{WORKDIR}}</workdir>
66
+
67
+ <task>
68
+ TASK: <task description from tasks.md>
69
+ CONTEXT: <relevant code context>
70
+ CONSTRAINTS: <constraints from spec>
71
+ </task>
72
+
73
+ <action_safety>
74
+ - Stay strictly within tasks.md scope
75
+ - Do NOT introduce dependencies not in the plan
76
+ - Prefer minimal targeted changes
77
+ </action_safety>
78
+
79
+ <structured_output_contract>
80
+ Return Unified Diff Patch format ONLY (no preamble, no commentary).
81
+ The diff will be reviewed before apply; do not assume it's been applied.
82
+ </structured_output_contract>`
83
+ })
56
84
  ```
57
85
 
58
- **会话复用**:保存返回的 `SESSION_ID:`({{BACKEND_PRIMARY}} `CODEX_PROTO_SESSION`,{{FRONTEND_PRIMARY}} `GEMINI_PROTO_SESSION`),Step 7 审查时复用。
86
+ **通道 B codeagent-wrapper fallback**(plugin 未装时;保留 SESSION_ID 供 Step 7 复用):
87
+
88
+ ```
89
+ Bash({
90
+ command: "~/.claude/bin/codeagent-wrapper --progress --backend <{{BACKEND_PRIMARY}}|{{FRONTEND_PRIMARY}}> {{GEMINI_MODEL_FLAG}}- \"{{WORKDIR}}\" <<'EOF'\nTASK: <task description from tasks.md>\nCONTEXT: <relevant code context>\nCONSTRAINTS: <constraints from spec>\nOUTPUT: Unified Diff Patch format ONLY\nEOF",
91
+ run_in_background: true,
92
+ timeout: 3600000,
93
+ description: "spec-impl: <task name> (BC)"
94
+ })
95
+ ```
96
+
97
+ **会话模型差异**:
98
+ - **通道 A(plugin)**:每个 task 独立 fresh-context spawn,**无显式 SESSION_ID**。Step 7 review 时由主线把 Step 4-6 的变更摘要(diff + spec 引用)显式拼入 reviewer prompt。
99
+ - **通道 B(wrapper BC)**:保存返回的 `SESSION_ID:`({{BACKEND_PRIMARY}} → `CODEX_PROTO_SESSION`,{{FRONTEND_PRIMARY}} → `GEMINI_PROTO_SESSION`),Step 7 审查 `resume <SESSION_ID>` 复用上下文。
59
100
 
60
101
  5. **Rewrite Prototype to Production Code**
61
102
  Upon receiving diff patch, **NEVER apply directly**. Rewrite by:
@@ -75,32 +116,144 @@ description: '按规范执行 + 多模型协作 + 归档'
75
116
  If issues found, make targeted corrections.
76
117
 
77
118
  7. **Multi-Model Review (PARALLEL)**
78
- - **CRITICAL**: You MUST launch BOTH {{BACKEND_PRIMARY}} AND {{FRONTEND_PRIMARY}} in a SINGLE message with TWO Bash tool calls.
79
- - **DO NOT** call one model first and wait. Launch BOTH simultaneously with `run_in_background: true`.
80
119
 
81
- **Step 7.1**: In ONE message, make TWO parallel Bash calls:
120
+ **调用通道路由(CCG codeagent 退役,v2.2.0+)**
121
+
122
+ 双模型并行通道从 `Bash(codeagent-wrapper)` **默认切换**为 plugin spawn:
123
+
124
+ 1. **优先 plugin spawn**(默认):装了 `codex@openai-codex` + gemini plugin(推荐 `gemini@gemini-ccgx` fork;或上游 `gemini@google-gemini` 配 repatch 脚本)→ 用 `Agent(subagent_type="codex:codex-rescue")` + `Agent(subagent_type="gemini:gemini-rescue")` 并行,主线接 ≤200 token 摘要。
125
+ 2. **降级 codeagent-wrapper**(BC fallback):plugin 未装 → fallback Bash 调用,**保留 Step 4 session resume** 以维持会话上下文。
126
+
127
+ **判定**:preflight `Bash` 跑 `ls ~/.claude/plugins/` 看有无 `codex@*` / `gemini@*` 子目录。
128
+
129
+ ⚠️ spec-impl 命令在主线 context 内,**允许** `Agent(...)`——与 subagent "禁止嵌套 spawn" 约束不冲突。
130
+ ⚠️ **plugin 路径无 session resume 能力**:通道 A 不接 Step 4 的 SESSION_ID,review 任务作为独立无状态分析跑(review 是 read-only 审查,无需会话连续性)。
131
+
132
+ - **CRITICAL**: You MUST launch BOTH {{BACKEND_PRIMARY}} AND {{FRONTEND_PRIMARY}} in a SINGLE message with TWO parallel tool calls.
133
+ - **DO NOT** call one model first and wait. Launch BOTH simultaneously.
134
+
135
+ **Step 7.1**: In ONE message, spawn TWO models in parallel.
136
+
137
+ **⚠ 预备动作(spawn 前必须执行)**:`codex:codex-rescue` / `gemini:gemini-rescue` 是 thin forwarder,不会主动 Read 路径文件。主线必须在 spawn 前先 Read 两个角色提示词文件,把**内容**直接拼入下方 Agent prompt 的 `<role>` 块。
138
+
139
+ - backend role: `Read("~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/reviewer.md")` → `${backendRole}`
140
+ - frontend role: `Read("~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/reviewer.md")` → `${frontendRole}`
141
+
142
+ Prompt 结构按 `gpt-5-4-prompting` skill 推荐:`<role>` + `<task>` + `<grounding_rules>` + `<dig_deeper_nudge>` + `<structured_output_contract>`。
143
+
144
+ **通道 A — plugin spawn(默认,无 session)**:
145
+
146
+ **FIRST Agent call ({{BACKEND_PRIMARY}})**:
147
+ ```
148
+ Agent({
149
+ subagent_type: "codex:codex-rescue",
150
+ description: "spec-impl: correctness/security review",
151
+ prompt: `<role>
152
+ ${backendRole}
153
+ </role>
154
+
155
+ <workdir>{{WORKDIR}}</workdir>
156
+
157
+ <task>
158
+ Review the implementation changes along backend dimensions:
159
+ - Correctness: logic errors, edge cases
160
+ - Security: injection, auth issues
161
+ - Spec compliance: constraints satisfied
162
+
163
+ 变更摘要:<列出 Step 5/6 涉及的文件 + 关键 diff>
164
+
165
+ Read-only review. Do NOT modify any file.
166
+ </task>
167
+
168
+ <grounding_rules>
169
+ - Every finding must cite file:line in the listed diff
170
+ - If a constraint was satisfied, list it in passed_checks
171
+ - "I couldn't verify X" is acceptable; fabricating X is not
172
+ </grounding_rules>
173
+
174
+ <dig_deeper_nudge>
175
+ - For each Critical finding, check whether the same root cause appears elsewhere in the diff
176
+ - Prefer one well-cited Critical over five vague Warnings
177
+ </dig_deeper_nudge>
178
+
179
+ <structured_output_contract>
180
+ Return JSON ONLY (no preamble):
181
+ {
182
+ "findings": [{"severity": "Critical|Warning|Info", "dimension": "logic|security|spec_compliance", "file": "path", "line": N, "description": "...", "fix_suggestion": "..."}],
183
+ "passed_checks": ["..."],
184
+ "summary": "Overall assessment"
185
+ }
186
+ Return ≤200 token structured summary.
187
+ </structured_output_contract>`
188
+ })
189
+ ```
190
+
191
+ **SECOND Agent call ({{FRONTEND_PRIMARY}}) - IN THE SAME MESSAGE**:
192
+ ```
193
+ Agent({
194
+ subagent_type: "gemini:gemini-rescue",
195
+ description: "spec-impl: maintainability/patterns review",
196
+ prompt: `<role>
197
+ ${frontendRole}
198
+ </role>
199
+
200
+ <workdir>{{WORKDIR}}</workdir>
201
+
202
+ <task>
203
+ Review the implementation changes along maintainability/integration dimensions:
204
+ - Maintainability: readability, complexity
205
+ - Patterns: consistency with project style
206
+ - Integration: cross-module impacts
207
+
208
+ 变更摘要:<列出 Step 5/6 涉及的文件 + 关键 diff>
209
+
210
+ Read-only review. Do NOT modify any file.
211
+ </task>
212
+
213
+ <grounding_rules>
214
+ - Every finding must cite file:line in the listed diff
215
+ - If an aspect was clean, list it in passed_checks
216
+ </grounding_rules>
217
+
218
+ <dig_deeper_nudge>
219
+ - Check if the same pattern issue appears in adjacent files
220
+ - Prefer one well-cited Critical over five vague Warnings
221
+ </dig_deeper_nudge>
222
+
223
+ <structured_output_contract>
224
+ Return JSON ONLY (no preamble):
225
+ {
226
+ "findings": [{"severity": "Critical|Warning|Info", "dimension": "maintainability|patterns|integration", "file": "path", "line": N, "description": "...", "fix_suggestion": "..."}],
227
+ "passed_checks": ["..."],
228
+ "summary": "Overall assessment"
229
+ }
230
+ Return ≤200 token structured summary.
231
+ </structured_output_contract>`
232
+ })
233
+ ```
234
+
235
+ **通道 B — codeagent-wrapper fallback**(plugin 未装时降级,**保留 session resume**):
82
236
 
83
- **FIRST Bash call ({{BACKEND_PRIMARY}})**:
84
237
  ```
85
238
  Bash({
86
239
  command: "~/.claude/bin/codeagent-wrapper --progress --backend {{BACKEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}resume <CODEX_PROTO_SESSION> - \"{{WORKDIR}}\" <<'EOF'\nReview the implementation changes:\n- Correctness: logic errors, edge cases\n- Security: injection, auth issues\n- Spec compliance: constraints satisfied\nOUTPUT: JSON with findings\nEOF",
87
240
  run_in_background: true,
88
241
  timeout: 300000,
89
- description: "{{BACKEND_PRIMARY}}: correctness/security review"
242
+ description: "{{BACKEND_PRIMARY}}: correctness/security review (BC, resume session)"
90
243
  })
91
- ```
92
-
93
- **SECOND Bash call ({{FRONTEND_PRIMARY}}) - IN THE SAME MESSAGE**:
94
- ```
95
244
  Bash({
96
245
  command: "~/.claude/bin/codeagent-wrapper --progress --backend {{FRONTEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}resume <GEMINI_PROTO_SESSION> - \"{{WORKDIR}}\" <<'EOF'\nReview the implementation changes:\n- Maintainability: readability, complexity\n- Patterns: consistency with project style\n- Integration: cross-module impacts\nOUTPUT: JSON with findings\nEOF",
97
246
  run_in_background: true,
98
247
  timeout: 300000,
99
- description: "{{FRONTEND_PRIMARY}}: maintainability/patterns review"
248
+ description: "{{FRONTEND_PRIMARY}}: maintainability/patterns review (BC, resume session)"
100
249
  })
101
250
  ```
102
251
 
103
- **Step 7.2 (事件驱动)**: spawn 两个 Bash bg 后说明 task-id 然后 **turn end**。引擎在每个 task 完成时自动发 `<task-notification>`,主线在通知触发的新 turn 处理结果。**不调 TaskOutput**。两个 task 都收到通知后才进 step 7.3。
252
+ > ⚠️ 通道 B `codeagent-wrapper` 已标 **deprecated**,仅为不能升级 plugin 的环境保留——但本 step 仍是 wrapper 唯一能利用 Step 4 SESSION_ID 的场景。
253
+
254
+ **Step 7.2 (事件驱动)**:
255
+ - **通道 A(plugin)**:两个 Agent 同 message 内 spawn,主线接 ≤200 token 摘要。Agent 完成后自动返回结果。
256
+ - **通道 B(BC wrapper)**:spawn 两个 Bash bg 后说明 task-id 然后 **turn end**。引擎在每个 task 完成时自动发 `<task-notification>`,主线在通知触发的新 turn 处理结果。**不调 TaskOutput**。两个 task 都收到通知后才进 step 7.3。
104
257
 
105
258
  ⛔ **禁止**:调 `TaskOutput({block: true, timeout: 600000})` (旧 freeze poll 模式) / Kill task。
106
259
  ⚠️ **失败处理**:notification status=failed / exit ≠ 0 / parse 失败 → v1.7.87 标准 2-retry / 5s / 3-attempts;3 次全失败才降级单模型。