ccgx-workflow 2.2.0 → 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.k6gRMX3r.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.k6gRMX3r.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.k6gRMX3r.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.2.0";
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.2.0",
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:
@@ -93,6 +134,13 @@ description: '按规范执行 + 多模型协作 + 归档'
93
134
 
94
135
  **Step 7.1**: In ONE message, spawn TWO models in parallel.
95
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
+
96
144
  **通道 A — plugin spawn(默认,无 session)**:
97
145
 
98
146
  **FIRST Agent call ({{BACKEND_PRIMARY}})**:
@@ -100,21 +148,43 @@ description: '按规范执行 + 多模型协作 + 归档'
100
148
  Agent({
101
149
  subagent_type: "codex:codex-rescue",
102
150
  description: "spec-impl: correctness/security review",
103
- prompt: `ROLE_FILE: ~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/reviewer.md
151
+ prompt: `<role>
152
+ ${backendRole}
153
+ </role>
104
154
 
105
- WORKDIR: {{WORKDIR}}
155
+ <workdir>{{WORKDIR}}</workdir>
106
156
 
107
- <TASK>
108
- Review the implementation changes:
157
+ <task>
158
+ Review the implementation changes along backend dimensions:
109
159
  - Correctness: logic errors, edge cases
110
160
  - Security: injection, auth issues
111
161
  - Spec compliance: constraints satisfied
112
162
 
113
163
  变更摘要:<列出 Step 5/6 涉及的文件 + 关键 diff>
114
- </TASK>
115
164
 
116
- OUTPUT: JSON with findings.
117
- Return ≤200 token structured summary (plugin-native protocol).`
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>`
118
188
  })
119
189
  ```
120
190
 
@@ -123,21 +193,42 @@ Return ≤200 token structured summary (plugin-native protocol).`
123
193
  Agent({
124
194
  subagent_type: "gemini:gemini-rescue",
125
195
  description: "spec-impl: maintainability/patterns review",
126
- prompt: `ROLE_FILE: ~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/reviewer.md
196
+ prompt: `<role>
197
+ ${frontendRole}
198
+ </role>
127
199
 
128
- WORKDIR: {{WORKDIR}}
200
+ <workdir>{{WORKDIR}}</workdir>
129
201
 
130
- <TASK>
131
- Review the implementation changes:
202
+ <task>
203
+ Review the implementation changes along maintainability/integration dimensions:
132
204
  - Maintainability: readability, complexity
133
205
  - Patterns: consistency with project style
134
206
  - Integration: cross-module impacts
135
207
 
136
208
  变更摘要:<列出 Step 5/6 涉及的文件 + 关键 diff>
137
- </TASK>
138
209
 
139
- OUTPUT: JSON with findings.
140
- Return ≤200 token structured summary (plugin-native protocol).`
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>`
141
232
  })
142
233
  ```
143
234
 
@@ -42,6 +42,13 @@ description: '多模型分析 → 消除歧义 → 零决策可执行计划'
42
42
 
43
43
  **Step 2.1**: In ONE message, spawn TWO models in parallel.
44
44
 
45
+ **⚠ 预备动作(spawn 前必须执行)**:`codex:codex-rescue` / `gemini:gemini-rescue` 是 thin forwarder,不会主动 Read 路径文件。主线必须在 spawn 前先 Read 两个角色提示词文件,把**内容**直接拼入下方 Agent prompt 的 `<role>` 块。
46
+
47
+ - backend role: `Read("~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/analyzer.md")` → `${backendRole}`
48
+ - frontend role: `Read("~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/analyzer.md")` → `${frontendRole}`
49
+
50
+ Prompt 结构按 `gpt-5-4-prompting` skill 推荐:`<role>` + `<task>` + `<grounding_rules>` + `<structured_output_contract>`。
51
+
45
52
  **通道 A — plugin spawn(默认)**:
46
53
 
47
54
  **FIRST Agent call ({{BACKEND_PRIMARY}})**:
@@ -49,20 +56,37 @@ description: '多模型分析 → 消除歧义 → 零决策可执行计划'
49
56
  Agent({
50
57
  subagent_type: "codex:codex-rescue",
51
58
  description: "spec-plan: backend analysis",
52
- prompt: `ROLE_FILE: ~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/analyzer.md
59
+ prompt: `<role>
60
+ ${backendRole}
61
+ </role>
53
62
 
54
- WORKDIR: {{WORKDIR}}
63
+ <workdir>{{WORKDIR}}</workdir>
55
64
 
56
- <TASK>
65
+ <task>
57
66
  Analyze change <change_id> from backend perspective:
58
67
  - Implementation approach
59
68
  - Technical risks
60
69
  - Alternative architectures
61
70
  - Edge cases and failure modes
62
- </TASK>
63
-
64
- OUTPUT: JSON with analysis.
65
- Return ≤200 token structured summary (plugin-native protocol).`
71
+ </task>
72
+
73
+ <grounding_rules>
74
+ - Cite file:line for claims about existing code
75
+ - Mark hypotheses; don't state guesses as facts
76
+ - For risks, distinguish "observed" (specific code path) vs "potential" (theoretical)
77
+ </grounding_rules>
78
+
79
+ <structured_output_contract>
80
+ Return JSON ONLY (no preamble):
81
+ {
82
+ "approach": "selected implementation strategy with rationale",
83
+ "alternatives_rejected": [{"alt": "...", "reason": "..."}],
84
+ "technical_risks": [{"risk": "...", "severity": "high|medium|low", "mitigation": "..."}],
85
+ "edge_cases": ["..."],
86
+ "failure_modes": ["..."]
87
+ }
88
+ Return ≤200 token structured summary.
89
+ </structured_output_contract>`
66
90
  })
67
91
  ```
68
92
 
@@ -71,19 +95,33 @@ Return ≤200 token structured summary (plugin-native protocol).`
71
95
  Agent({
72
96
  subagent_type: "gemini:gemini-rescue",
73
97
  description: "spec-plan: frontend analysis",
74
- prompt: `ROLE_FILE: ~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/analyzer.md
98
+ prompt: `<role>
99
+ ${frontendRole}
100
+ </role>
75
101
 
76
- WORKDIR: {{WORKDIR}}
102
+ <workdir>{{WORKDIR}}</workdir>
77
103
 
78
- <TASK>
104
+ <task>
79
105
  Analyze change <change_id> from frontend/integration perspective:
80
106
  - Maintainability assessment
81
107
  - Scalability considerations
82
108
  - Integration conflicts
83
- </TASK>
84
-
85
- OUTPUT: JSON with analysis.
86
- Return ≤200 token structured summary (plugin-native protocol).`
109
+ </task>
110
+
111
+ <grounding_rules>
112
+ - Cite file:line for claims about existing code
113
+ - Mark hypotheses; don't state guesses as facts
114
+ </grounding_rules>
115
+
116
+ <structured_output_contract>
117
+ Return JSON ONLY (no preamble):
118
+ {
119
+ "maintainability": {"score": "good|moderate|concerning", "factors": ["..."]},
120
+ "scalability": [{"dimension": "...", "consideration": "..."}],
121
+ "integration_conflicts": [{"target": "...", "conflict": "...", "resolution": "..."}]
122
+ }
123
+ Return ≤200 token structured summary.
124
+ </structured_output_contract>`
87
125
  })
88
126
  ```
89
127
 
@@ -81,6 +81,13 @@ description: '需求 → 约束集(并行探索 + OPSX 提案)'
81
81
 
82
82
  **Step 4.1**: In ONE message, spawn TWO models in parallel.
83
83
 
84
+ **⚠ 预备动作(spawn 前必须执行)**:`codex:codex-rescue` / `gemini:gemini-rescue` 是 thin forwarder(一行 `Bash node companion.mjs task <prompt>` 转发),**不会**主动 Read 路径文件。主线必须在 spawn 前先 Read 两个角色提示词文件,把**内容**直接拼入下方 Agent prompt 的 `<role>` 块——不是写路径。
85
+
86
+ - backend role: `Read("~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/analyzer.md")` → `${backendRole}`
87
+ - frontend role: `Read("~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/analyzer.md")` → `${frontendRole}`
88
+
89
+ Prompt 结构按 `gpt-5-4-prompting` skill 推荐(XML 块、紧凑、操作性):`<role>` + `<task>` + `<grounding_rules>` + `<structured_output_contract>`。
90
+
84
91
  **通道 A — plugin spawn(默认)**:
85
92
 
86
93
  **FIRST Agent call ({{BACKEND_PRIMARY}} — backend boundaries)**:
@@ -88,20 +95,40 @@ description: '需求 → 约束集(并行探索 + OPSX 提案)'
88
95
  Agent({
89
96
  subagent_type: "codex:codex-rescue",
90
97
  description: "spec-research: backend boundary exploration",
91
- prompt: `ROLE_FILE: ~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/analyzer.md
98
+ prompt: `<role>
99
+ ${backendRole}
100
+ </role>
92
101
 
93
- WORKDIR: {{WORKDIR}}
102
+ <workdir>{{WORKDIR}}</workdir>
94
103
 
95
- <TASK>
104
+ <task>
96
105
  Explore backend context boundaries for <change description>:
97
106
  - Existing structures and patterns
98
107
  - Conventions in use
99
108
  - Hard constraints limiting solution space
100
109
  - Dependencies and risks
101
- </TASK>
102
-
103
- OUTPUT: JSON using the output template above.
104
- Return ≤200 token structured summary (plugin-native protocol).`
110
+ </task>
111
+
112
+ <grounding_rules>
113
+ - Cite file:line for every claim about existing code
114
+ - Mark hypotheses explicitly; don't state guesses as facts
115
+ - If a question can't be answered from the repo, list it in open_questions
116
+ </grounding_rules>
117
+
118
+ <structured_output_contract>
119
+ Return JSON ONLY (no preamble, no commentary):
120
+ {
121
+ "module_name": "context boundary explored",
122
+ "existing_structures": ["key patterns found"],
123
+ "existing_conventions": ["standards in use"],
124
+ "constraints_discovered": ["hard constraints limiting solution space"],
125
+ "open_questions": ["ambiguities requiring user input"],
126
+ "dependencies": ["cross-module dependencies"],
127
+ "risks": ["potential blockers"],
128
+ "success_criteria_hints": ["observable success behaviors"]
129
+ }
130
+ Return ≤200 token structured summary.
131
+ </structured_output_contract>`
105
132
  })
106
133
  ```
107
134
 
@@ -110,20 +137,40 @@ Return ≤200 token structured summary (plugin-native protocol).`
110
137
  Agent({
111
138
  subagent_type: "gemini:gemini-rescue",
112
139
  description: "spec-research: frontend boundary exploration",
113
- prompt: `ROLE_FILE: ~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/analyzer.md
140
+ prompt: `<role>
141
+ ${frontendRole}
142
+ </role>
114
143
 
115
- WORKDIR: {{WORKDIR}}
144
+ <workdir>{{WORKDIR}}</workdir>
116
145
 
117
- <TASK>
146
+ <task>
118
147
  Explore frontend context boundaries for <change description>:
119
148
  - Existing structures and patterns
120
149
  - Conventions in use
121
150
  - Hard constraints limiting solution space
122
151
  - Dependencies and risks
123
- </TASK>
124
-
125
- OUTPUT: JSON using the output template above.
126
- Return ≤200 token structured summary (plugin-native protocol).`
152
+ </task>
153
+
154
+ <grounding_rules>
155
+ - Cite file:line for every claim about existing code
156
+ - Mark hypotheses explicitly; don't state guesses as facts
157
+ - If a question can't be answered from the repo, list it in open_questions
158
+ </grounding_rules>
159
+
160
+ <structured_output_contract>
161
+ Return JSON ONLY (no preamble, no commentary):
162
+ {
163
+ "module_name": "context boundary explored",
164
+ "existing_structures": ["key patterns found"],
165
+ "existing_conventions": ["standards in use"],
166
+ "constraints_discovered": ["hard constraints limiting solution space"],
167
+ "open_questions": ["ambiguities requiring user input"],
168
+ "dependencies": ["cross-module dependencies"],
169
+ "risks": ["potential blockers"],
170
+ "success_criteria_hints": ["observable success behaviors"]
171
+ }
172
+ Return ≤200 token structured summary.
173
+ </structured_output_contract>`
127
174
  })
128
175
  ```
129
176
 
@@ -43,6 +43,13 @@ description: '双模型交叉审查(独立工具,随时可用)'
43
43
 
44
44
  **Step 3.1**: In ONE message, spawn TWO models in parallel.
45
45
 
46
+ **⚠ 预备动作(spawn 前必须执行)**:`codex:codex-rescue` / `gemini:gemini-rescue` 是 thin forwarder,不会主动 Read 路径文件。主线必须在 spawn 前先 Read 两个角色提示词文件,把**内容**直接拼入下方 Agent prompt 的 `<role>` 块。
47
+
48
+ - backend role: `Read("~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/reviewer.md")` → `${backendRole}`
49
+ - frontend role: `Read("~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/reviewer.md")` → `${frontendRole}`
50
+
51
+ Prompt 结构按 `gpt-5-4-prompting` skill 推荐(review 类任务额外加 `<grounding_rules>` + `<dig_deeper_nudge>`)。
52
+
46
53
  **通道 A — plugin spawn(默认)**:
47
54
 
48
55
  **FIRST Agent call ({{BACKEND_PRIMARY}})**:
@@ -50,22 +57,37 @@ description: '双模型交叉审查(独立工具,随时可用)'
50
57
  Agent({
51
58
  subagent_type: "codex:codex-rescue",
52
59
  description: "spec-review: backend/logic review",
53
- prompt: `ROLE_FILE: ~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/reviewer.md
54
-
55
- WORKDIR: {{WORKDIR}}
56
-
57
- <TASK>
58
- Review proposal <proposal_id> implementation:
59
-
60
- ## {{BACKEND_PRIMARY}} Review Dimensions
61
- 1. **Spec Compliance**: Verify ALL constraints from spec are satisfied
62
- 2. **PBT Properties**: Check invariants, idempotency, bounds are correctly implemented
63
- 3. **Logic Correctness**: Edge cases, error handling, algorithm correctness
64
- 4. **Backend Security**: Injection vulnerabilities, auth checks, input validation
65
- 5. **Regression Risk**: Interface compatibility, type safety, breaking changes
66
- </TASK>
67
-
68
- OUTPUT (JSON):
60
+ prompt: `<role>
61
+ ${backendRole}
62
+ </role>
63
+
64
+ <workdir>{{WORKDIR}}</workdir>
65
+
66
+ <task>
67
+ Review proposal <proposal_id> implementation along backend dimensions:
68
+ 1. Spec Compliance Verify ALL constraints from spec are satisfied
69
+ 2. PBT Properties Check invariants, idempotency, bounds correctly implemented
70
+ 3. Logic Correctness Edge cases, error handling, algorithm correctness
71
+ 4. Backend Security Injection vulnerabilities, auth checks, input validation
72
+ 5. Regression Risk Interface compatibility, type safety, breaking changes
73
+
74
+ Read-only review. Do NOT modify any file.
75
+ </task>
76
+
77
+ <grounding_rules>
78
+ - Every finding must cite file:line
79
+ - If a constraint was satisfied, list it in passed_checks (don't omit positives)
80
+ - "I couldn't verify X" is acceptable; fabricating X is not
81
+ - Distinguish bug (observable failure path) from concern (style/maintainability preference)
82
+ </grounding_rules>
83
+
84
+ <dig_deeper_nudge>
85
+ - For each Critical finding, check whether the same root cause appears elsewhere in the diff
86
+ - Prefer one well-cited Critical over five vague Warnings
87
+ </dig_deeper_nudge>
88
+
89
+ <structured_output_contract>
90
+ Return JSON ONLY (no preamble):
69
91
  {
70
92
  "findings": [
71
93
  {
@@ -81,8 +103,8 @@ OUTPUT (JSON):
81
103
  "passed_checks": ["List of verified constraints/properties"],
82
104
  "summary": "Overall assessment"
83
105
  }
84
-
85
- Return ≤200 token structured summary (plugin-native protocol).`
106
+ Return ≤200 token structured summary.
107
+ </structured_output_contract>`
86
108
  })
87
109
  ```
88
110
 
@@ -91,22 +113,36 @@ Return ≤200 token structured summary (plugin-native protocol).`
91
113
  Agent({
92
114
  subagent_type: "gemini:gemini-rescue",
93
115
  description: "spec-review: patterns/integration review",
94
- prompt: `ROLE_FILE: ~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/reviewer.md
95
-
96
- WORKDIR: {{WORKDIR}}
97
-
98
- <TASK>
99
- Review proposal <proposal_id> implementation:
100
-
101
- ## {{FRONTEND_PRIMARY}} Review Dimensions
102
- 1. **Pattern Consistency**: Naming conventions, code style, project patterns
103
- 2. **Maintainability**: Readability, complexity, documentation adequacy
104
- 3. **Integration Risk**: Dependency changes, cross-module impacts
105
- 4. **Frontend Security**: XSS, CSRF, sensitive data exposure
106
- 5. **Spec Alignment**: Implementation matches spec intent (not just letter)
107
- </TASK>
108
-
109
- OUTPUT (JSON):
116
+ prompt: `<role>
117
+ ${frontendRole}
118
+ </role>
119
+
120
+ <workdir>{{WORKDIR}}</workdir>
121
+
122
+ <task>
123
+ Review proposal <proposal_id> implementation along frontend/integration dimensions:
124
+ 1. Pattern Consistency Naming conventions, code style, project patterns
125
+ 2. Maintainability Readability, complexity, documentation adequacy
126
+ 3. Integration Risk Dependency changes, cross-module impacts
127
+ 4. Frontend Security XSS, CSRF, sensitive data exposure
128
+ 5. Spec Alignment Implementation matches spec intent (not just letter)
129
+
130
+ Read-only review. Do NOT modify any file.
131
+ </task>
132
+
133
+ <grounding_rules>
134
+ - Every finding must cite file:line
135
+ - If an aspect was clean, list it in passed_checks
136
+ - "I couldn't verify X" is acceptable; fabricating X is not
137
+ </grounding_rules>
138
+
139
+ <dig_deeper_nudge>
140
+ - For each Critical finding, check whether the same pattern issue appears in adjacent files
141
+ - Prefer one well-cited Critical over five vague Warnings
142
+ </dig_deeper_nudge>
143
+
144
+ <structured_output_contract>
145
+ Return JSON ONLY (no preamble):
110
146
  {
111
147
  "findings": [
112
148
  {
@@ -122,8 +158,8 @@ OUTPUT (JSON):
122
158
  "passed_checks": ["List of verified aspects"],
123
159
  "summary": "Overall assessment"
124
160
  }
125
-
126
- Return ≤200 token structured summary (plugin-native protocol).`
161
+ Return ≤200 token structured summary.
162
+ </structured_output_contract>`
127
163
  })
128
164
  ```
129
165
 
@@ -168,6 +168,11 @@ Phase 8: INTEGRATION → Lead 全量验证 + 报告 + 清理
168
168
 
169
169
  - **CRITICAL**: 必须在一条消息中同时发起两个并行调用。
170
170
 
171
+ **⚠ 预备动作(spawn 前必须执行)**:`codex:codex-rescue` / `gemini:gemini-rescue` 是 thin forwarder,不会主动 Read 路径文件。主线必须在 spawn 前先 Read 两个角色提示词文件,把**内容**直接拼入下方 Agent prompt 的 `<role>` 块。
172
+
173
+ - backend role: `Read("~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/architect.md")` → `${backendRole}`
174
+ - frontend role: `Read("~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/architect.md")` → `${frontendRole}`
175
+
171
176
  **通道 A — plugin spawn(默认)**:
172
177
 
173
178
  **FIRST Agent call ({{BACKEND_PRIMARY}})**:
@@ -175,16 +180,38 @@ Phase 8: INTEGRATION → Lead 全量验证 + 报告 + 清理
175
180
  Agent({
176
181
  subagent_type: "codex:codex-rescue",
177
182
  description: "team Phase 2: 后端架构分析",
178
- prompt: `ROLE_FILE: ~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/architect.md
183
+ prompt: `<role>
184
+ ${backendRole}
185
+ </role>
186
+
187
+ <workdir>{{WORKDIR}}</workdir>
179
188
 
180
- WORKDIR: {{WORKDIR}}
189
+ <task>
190
+ PRD:<PRD 内容>
181
191
 
182
- <TASK>
183
- 需求:<PRD 内容>
184
- 请分析后端架构:模块边界、API 设计、数据模型、依赖关系、实施建议。
185
- </TASK>
192
+ 请分析后端架构:
193
+ - 模块边界、API 设计、数据模型
194
+ - 依赖关系、关键算法选择
195
+ - 实施风险与建议
196
+ </task>
186
197
 
187
- Return ≤200 token structured summary (plugin-native protocol).`
198
+ <grounding_rules>
199
+ - 引用 file:line 标注现有代码模式
200
+ - 区分「现有模式已支持」vs「需要新建」
201
+ - 不要捏造未观察到的依赖
202
+ </grounding_rules>
203
+
204
+ <structured_output_contract>
205
+ Return JSON ONLY:
206
+ {
207
+ "module_boundaries": [{"name": "...", "responsibility": "...", "files_involved": []}],
208
+ "api_design": [{"endpoint": "...", "verb": "...", "purpose": "..."}],
209
+ "data_model": [{"entity": "...", "fields": [], "relations": []}],
210
+ "dependencies": [{"from": "...", "to": "...", "reason": "..."}],
211
+ "implementation_risks": [{"risk": "...", "mitigation": "..."}]
212
+ }
213
+ Return ≤200 token structured summary.
214
+ </structured_output_contract>`
188
215
  })
189
216
  ```
190
217
 
@@ -193,16 +220,38 @@ Return ≤200 token structured summary (plugin-native protocol).`
193
220
  Agent({
194
221
  subagent_type: "gemini:gemini-rescue",
195
222
  description: "team Phase 2: 前端架构分析",
196
- prompt: `ROLE_FILE: ~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/architect.md
223
+ prompt: `<role>
224
+ ${frontendRole}
225
+ </role>
226
+
227
+ <workdir>{{WORKDIR}}</workdir>
228
+
229
+ <task>
230
+ PRD:<PRD 内容>
197
231
 
198
- WORKDIR: {{WORKDIR}}
232
+ 请分析前端架构:
233
+ - 组件拆分、状态管理、路由设计
234
+ - UI/UX 关键流程、无障碍考量
235
+ - 实施风险与建议
236
+ </task>
199
237
 
200
- <TASK>
201
- 需求:<PRD 内容>
202
- 请分析前端架构:组件拆分、状态管理、路由设计、UI/UX 要点、实施建议。
203
- </TASK>
238
+ <grounding_rules>
239
+ - 引用 file:line 标注现有组件 / 设计 token
240
+ - 区分「现有组件复用」vs「需新建」
241
+ - 不要捏造未观察到的设计系统约定
242
+ </grounding_rules>
204
243
 
205
- Return ≤200 token structured summary (plugin-native protocol).`
244
+ <structured_output_contract>
245
+ Return JSON ONLY:
246
+ {
247
+ "component_decomposition": [{"component": "...", "purpose": "...", "reuses": []}],
248
+ "state_management": {"approach": "...", "stores": []},
249
+ "routing": [{"path": "...", "screen": "..."}],
250
+ "ux_flows": [{"flow": "...", "steps": []}],
251
+ "implementation_risks": [{"risk": "...", "mitigation": "..."}]
252
+ }
253
+ Return ≤200 token structured summary.
254
+ </structured_output_contract>`
206
255
  })
207
256
  ```
208
257
 
@@ -357,7 +406,12 @@ Return ≤200 token structured summary (plugin-native protocol).`
357
406
  - `Bash: git diff` 获取完整变更内容。
358
407
 
359
408
  2. **{{BACKEND_PRIMARY}} + {{FRONTEND_PRIMARY}} 并行审查(PARALLEL)**
360
- - 模式与 Phase 2 相同(plugin 优先 + wrapper BC fallback),使用 reviewer prompt
409
+ - 模式与 Phase 2 相同(plugin 优先 + wrapper BC fallback),使用 reviewer prompt
410
+
411
+ **⚠ 预备动作(spawn 前必须执行)**:主线先 Read 角色提示词,把内容拼入 `<role>` 块。
412
+
413
+ - backend role: `Read("~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/reviewer.md")` → `${backendRole}`
414
+ - frontend role: `Read("~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/reviewer.md")` → `${frontendRole}`
361
415
 
362
416
  **通道 A — plugin spawn(默认)**:
363
417
 
@@ -366,23 +420,39 @@ Return ≤200 token structured summary (plugin-native protocol).`
366
420
  Agent({
367
421
  subagent_type: "codex:codex-rescue",
368
422
  description: "team Phase 6: 后端审查",
369
- prompt: `ROLE_FILE: ~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/reviewer.md
423
+ prompt: `<role>
424
+ ${backendRole}
425
+ </role>
370
426
 
371
- WORKDIR: {{WORKDIR}}
427
+ <workdir>{{WORKDIR}}</workdir>
372
428
 
373
- <TASK>
374
- 审查以下变更:
429
+ <task>
430
+ 审查以下变更(后端维度:逻辑 / 安全 / 性能 / 错误处理):
375
431
  <git diff 输出或变更文件列表>
376
- </TASK>
377
432
 
378
- OUTPUT (JSON):
433
+ Read-only review. Do NOT modify any file.
434
+ </task>
435
+
436
+ <grounding_rules>
437
+ - 每条 finding 必须含 file:line
438
+ - 区分 bug(可触发失败路径)与 concern(风格/可维护性偏好)
439
+ - 检查过但没问题的项放进 passed_checks
440
+ </grounding_rules>
441
+
442
+ <dig_deeper_nudge>
443
+ - 同根因可能扩散到其他文件——抽样验证
444
+ - 一条精准 Critical > 五条模糊 Warning
445
+ </dig_deeper_nudge>
446
+
447
+ <structured_output_contract>
448
+ Return JSON ONLY:
379
449
  {
380
450
  "findings": [{"severity": "Critical|Warning|Info", "dimension": "logic|security|performance|error_handling", "file": "path", "line": N, "description": "描述", "fix_suggestion": "修复建议"}],
381
451
  "passed_checks": ["检查项"],
382
452
  "summary": "总体评估"
383
453
  }
384
-
385
- Return ≤200 token structured summary (plugin-native protocol).`
454
+ Return ≤200 token structured summary.
455
+ </structured_output_contract>`
386
456
  })
387
457
  ```
388
458
 
@@ -391,23 +461,38 @@ Return ≤200 token structured summary (plugin-native protocol).`
391
461
  Agent({
392
462
  subagent_type: "gemini:gemini-rescue",
393
463
  description: "team Phase 6: 前端审查",
394
- prompt: `ROLE_FILE: ~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/reviewer.md
464
+ prompt: `<role>
465
+ ${frontendRole}
466
+ </role>
395
467
 
396
- WORKDIR: {{WORKDIR}}
468
+ <workdir>{{WORKDIR}}</workdir>
397
469
 
398
- <TASK>
399
- 审查以下变更:
470
+ <task>
471
+ 审查以下变更(前端维度:模式一致性 / 可维护性 / 无障碍 / UX / 前端安全):
400
472
  <git diff 输出或变更文件列表>
401
- </TASK>
402
473
 
403
- OUTPUT (JSON):
474
+ Read-only review. Do NOT modify any file.
475
+ </task>
476
+
477
+ <grounding_rules>
478
+ - 每条 finding 必须含 file:line
479
+ - 检查过但没问题的项放进 passed_checks
480
+ </grounding_rules>
481
+
482
+ <dig_deeper_nudge>
483
+ - 同模式问题可能扩散到相邻文件——抽样验证
484
+ - 一条精准 Critical > 五条模糊 Warning
485
+ </dig_deeper_nudge>
486
+
487
+ <structured_output_contract>
488
+ Return JSON ONLY:
404
489
  {
405
490
  "findings": [{"severity": "Critical|Warning|Info", "dimension": "patterns|maintainability|accessibility|ux|frontend_security", "file": "path", "line": N, "description": "描述", "fix_suggestion": "修复建议"}],
406
491
  "passed_checks": ["检查项"],
407
492
  "summary": "总体评估"
408
493
  }
409
-
410
- Return ≤200 token structured summary (plugin-native protocol).`
494
+ Return ≤200 token structured summary.
495
+ </structured_output_contract>`
411
496
  })
412
497
  ```
413
498
 
@@ -39,41 +39,74 @@ subagent_freshness: required
39
39
  - 如果用户通过 `/add-dir` 添加了多个工作区,先用 Glob/Grep 确定任务相关的工作区
40
40
  - 如果无法确定,用 `AskUserQuestion` 询问用户选择目标工作区
41
41
 
42
- **调用语法**(并行用 `run_in_background: true`,串行用 `false`):
42
+ **调用通道路由(CCG codeagent 退役,v2.2.0+)**
43
+
44
+ 1. **优先 plugin spawn**(默认):plugin 已装 → `Agent(subagent_type="<codex:codex-rescue|gemini:gemini-rescue>")`。session 复用通过 prompt 内 `--resume` flag 表达(subagent 映射为 codex/gemini `--resume-last`,**注意是 last,不是 by-id**)。
45
+ 2. **降级 codeagent-wrapper**(BC fallback):plugin 未装 → Bash 调用,保留 `resume <SESSION_ID>` 显式会话管理。
46
+
47
+ **判定**:preflight `Bash` 跑 `ls ~/.claude/plugins/` 看有无 `codex@*` / `gemini@*` 子目录。
48
+
49
+ ---
50
+
51
+ **通道 A — plugin spawn(默认)**:
52
+
53
+ **预备动作**:spawn 前主线先 Read 对应阶段的角色提示词(见下方表),把内容拼入 `<role>` 块。
43
54
 
44
55
  ```
45
56
  # 新会话调用
46
- Bash({
47
- command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend <{{BACKEND_PRIMARY}}|{{FRONTEND_PRIMARY}}> {{GEMINI_MODEL_FLAG}}- \"{{WORKDIR}}\" <<'EOF'
48
- ROLE_FILE: <角色提示词路径>
49
- <TASK>
57
+ Agent({
58
+ subagent_type: "<codex:codex-rescue|gemini:gemini-rescue>",
59
+ description: "简短描述",
60
+ prompt: `<role>
61
+ ${roleContent} // 主线 Read 后的角色提示词内容
62
+ </role>
63
+
64
+ <workdir>{{WORKDIR}}</workdir>
65
+
66
+ <task>
50
67
  需求:<增强后的需求(如未增强则用 $ARGUMENTS)>
51
68
  上下文:<前序阶段收集的项目上下文、分析结果等>
52
- </TASK>
53
- OUTPUT: 期望输出格式
54
- EOF",
69
+ </task>
70
+
71
+ <structured_output_contract>
72
+ <期望输出格式 / JSON schema>
73
+ Return ≤200 token structured summary.
74
+ </structured_output_contract>`
75
+ })
76
+
77
+ # 复用会话(同一 Claude session 内的连续阶段)
78
+ Agent({
79
+ subagent_type: "<codex:codex-rescue|gemini:gemini-rescue>",
80
+ description: "简短描述",
81
+ prompt: `--resume
82
+
83
+ <task>
84
+ <delta 指令(仅本阶段变化,不重述前序上下文,由 codex/gemini thread 自带历史)>
85
+ </task>`
86
+ })
87
+ ```
88
+
89
+ **通道 B — wrapper BC fallback**(plugin 未装时):
90
+
91
+ ```
92
+ # 新会话
93
+ Bash({
94
+ command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend <{{BACKEND_PRIMARY}}|{{FRONTEND_PRIMARY}}> {{GEMINI_MODEL_FLAG}}- \"{{WORKDIR}}\" <<'EOF'\nROLE_FILE: <角色提示词路径>\n<TASK>\n需求:<增强后的需求>\n上下文:<前序阶段上下文>\n</TASK>\nOUTPUT: 期望输出格式\nEOF",
55
95
  run_in_background: true,
56
96
  timeout: 3600000,
57
- description: "简短描述"
97
+ description: "简短描述 (BC)"
58
98
  })
59
99
 
60
- # 复用会话调用
100
+ # 复用会话(显式 SESSION_ID)
61
101
  Bash({
62
- command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend <{{BACKEND_PRIMARY}}|{{FRONTEND_PRIMARY}}> {{GEMINI_MODEL_FLAG}}resume <SESSION_ID> - \"{{WORKDIR}}\" <<'EOF'
63
- ROLE_FILE: <角色提示词路径>
64
- <TASK>
65
- 需求:<增强后的需求(如未增强则用 $ARGUMENTS)>
66
- 上下文:<前序阶段收集的项目上下文、分析结果等>
67
- </TASK>
68
- OUTPUT: 期望输出格式
69
- EOF",
102
+ command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend <{{BACKEND_PRIMARY}}|{{FRONTEND_PRIMARY}}> {{GEMINI_MODEL_FLAG}}resume <SESSION_ID> - \"{{WORKDIR}}\" <<'EOF'\nROLE_FILE: <角色提示词路径>\n<TASK>\n需求:<增强后的需求>\n上下文:<前序阶段上下文>\n</TASK>\nEOF",
70
103
  run_in_background: true,
71
104
  timeout: 3600000,
72
- description: "简短描述"
105
+ description: "简短描述 (BC, resume)"
73
106
  })
74
107
  ```
75
108
 
76
- **角色提示词**:
109
+ **角色提示词路径**(通道 A 主线 Read 后拼入 `<role>` 块;通道 B 仍用 `ROLE_FILE:` 写在 EOF 内):
77
110
 
78
111
  | 阶段 | 后端 | 前端 |
79
112
  |------|-------|--------|
@@ -81,7 +114,9 @@ EOF",
81
114
  | 规划 | `~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/architect.md` | `~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/architect.md` |
82
115
  | 审查 | `~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/reviewer.md` | `~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/reviewer.md` |
83
116
 
84
- **会话复用**:每次调用返回 `SESSION_ID: xxx`,后续阶段用 `resume xxx` 复用上下文(注意:是 `resume`,不是 `--resume`)。
117
+ **会话复用模型差异**:
118
+ - **通道 A(plugin)**:同 Claude session 内连续阶段用 `--resume`,自动接上一次同 backend 的 thread(codex/gemini 各自独立的 `--resume-last` 行为)。**不支持跨任务跳点 resume by ID**——若中间插了其他 codex 调用会串。
119
+ - **通道 B(wrapper)**:每次 spawn 返回 `SESSION_ID: xxx`,后续 `resume xxx` 任意复用(注意:是 `resume`,不是 `--resume`)。
85
120
 
86
121
  **并行调用 + 事件驱动等待**:
87
122