claude-code-workflow 6.3.37 → 6.3.39

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.
Files changed (173) hide show
  1. package/.claude/commands/workflow/lite-execute.md +2 -0
  2. package/.codex/agents/action-planning-agent.md +885 -0
  3. package/.codex/agents/ccw-loop-b-complete.md +227 -0
  4. package/.codex/agents/ccw-loop-b-debug.md +172 -0
  5. package/.codex/agents/ccw-loop-b-develop.md +147 -0
  6. package/.codex/agents/ccw-loop-b-init.md +82 -0
  7. package/.codex/agents/ccw-loop-b-validate.md +204 -0
  8. package/.codex/agents/ccw-loop-executor.md +260 -0
  9. package/.codex/agents/cli-discuss-agent.md +391 -0
  10. package/.codex/agents/cli-execution-agent.md +333 -0
  11. package/.codex/agents/cli-explore-agent.md +186 -0
  12. package/.codex/agents/cli-lite-planning-agent.md +736 -0
  13. package/.codex/agents/cli-planning-agent.md +562 -0
  14. package/.codex/agents/code-developer.md +408 -0
  15. package/.codex/agents/conceptual-planning-agent.md +321 -0
  16. package/.codex/agents/context-search-agent.md +585 -0
  17. package/.codex/agents/debug-explore-agent.md +436 -0
  18. package/.codex/agents/doc-generator.md +334 -0
  19. package/.codex/agents/issue-plan-agent.md +417 -0
  20. package/.codex/agents/issue-queue-agent.md +311 -0
  21. package/.codex/agents/memory-bridge.md +96 -0
  22. package/.codex/agents/test-context-search-agent.md +402 -0
  23. package/.codex/agents/test-fix-agent.md +359 -0
  24. package/.codex/agents/ui-design-agent.md +595 -0
  25. package/.codex/agents/universal-executor.md +135 -0
  26. package/.codex/prompts/clean.md +409 -0
  27. package/.codex/prompts/issue-discover-by-prompt.md +364 -0
  28. package/.codex/prompts/issue-discover.md +261 -0
  29. package/.codex/prompts/issue-execute.md +10 -0
  30. package/.codex/prompts/issue-new.md +285 -0
  31. package/.codex/prompts/issue-plan.md +161 -63
  32. package/.codex/prompts/issue-queue.md +298 -288
  33. package/.codex/prompts/lite-execute.md +627 -133
  34. package/.codex/prompts/lite-fix.md +670 -0
  35. package/.codex/prompts/lite-plan-a.md +337 -0
  36. package/.codex/prompts/lite-plan-b.md +485 -0
  37. package/.codex/prompts/{lite-plan.md → lite-plan-c.md} +601 -469
  38. package/.codex/skills/ccw-loop/README.md +171 -0
  39. package/.codex/skills/ccw-loop/SKILL.md +349 -0
  40. package/.codex/skills/ccw-loop/phases/actions/action-complete.md +269 -0
  41. package/.codex/skills/ccw-loop/phases/actions/action-debug.md +286 -0
  42. package/.codex/skills/ccw-loop/phases/actions/action-develop.md +183 -0
  43. package/.codex/skills/ccw-loop/phases/actions/action-init.md +164 -0
  44. package/.codex/skills/ccw-loop/phases/actions/action-menu.md +205 -0
  45. package/.codex/skills/ccw-loop/phases/actions/action-validate.md +250 -0
  46. package/.codex/skills/ccw-loop/phases/orchestrator.md +416 -0
  47. package/.codex/skills/ccw-loop/phases/state-schema.md +388 -0
  48. package/.codex/skills/ccw-loop/specs/action-catalog.md +182 -0
  49. package/.codex/skills/ccw-loop-b/README.md +301 -0
  50. package/.codex/skills/ccw-loop-b/SKILL.md +322 -0
  51. package/.codex/skills/ccw-loop-b/phases/orchestrator.md +257 -0
  52. package/.codex/skills/ccw-loop-b/phases/state-schema.md +181 -0
  53. package/.codex/skills/ccw-loop-b/specs/action-catalog.md +383 -0
  54. package/.codex/skills/parallel-dev-cycle/README.md +382 -0
  55. package/.codex/skills/parallel-dev-cycle/SKILL.md +512 -0
  56. package/.codex/skills/parallel-dev-cycle/phases/agents/code-developer.md +242 -0
  57. package/.codex/skills/parallel-dev-cycle/phases/agents/exploration-planner.md +285 -0
  58. package/.codex/skills/parallel-dev-cycle/phases/agents/requirements-analyst.md +285 -0
  59. package/.codex/skills/parallel-dev-cycle/phases/agents/validation-archivist.md +381 -0
  60. package/.codex/skills/parallel-dev-cycle/phases/orchestrator.md +696 -0
  61. package/.codex/skills/parallel-dev-cycle/phases/state-schema.md +436 -0
  62. package/.codex/skills/parallel-dev-cycle/specs/communication-optimization.md +423 -0
  63. package/.codex/skills/parallel-dev-cycle/specs/coordination-protocol.md +391 -0
  64. package/.codex/skills/parallel-dev-cycle/specs/versioning-strategy.md +330 -0
  65. package/ccw/dist/cli.d.ts.map +1 -1
  66. package/ccw/dist/cli.js +4 -0
  67. package/ccw/dist/cli.js.map +1 -1
  68. package/ccw/dist/commands/install.d.ts.map +1 -1
  69. package/ccw/dist/commands/install.js +39 -8
  70. package/ccw/dist/commands/install.js.map +1 -1
  71. package/ccw/dist/commands/issue.d.ts +3 -0
  72. package/ccw/dist/commands/issue.d.ts.map +1 -1
  73. package/ccw/dist/commands/issue.js +107 -0
  74. package/ccw/dist/commands/issue.js.map +1 -1
  75. package/ccw/dist/commands/upgrade.js +1 -1
  76. package/ccw/dist/commands/upgrade.js.map +1 -1
  77. package/ccw/dist/config/litellm-api-config-manager.d.ts.map +1 -1
  78. package/ccw/dist/config/litellm-api-config-manager.js +3 -2
  79. package/ccw/dist/config/litellm-api-config-manager.js.map +1 -1
  80. package/ccw/dist/core/memory-embedder-bridge.d.ts.map +1 -1
  81. package/ccw/dist/core/memory-embedder-bridge.js +2 -5
  82. package/ccw/dist/core/memory-embedder-bridge.js.map +1 -1
  83. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  84. package/ccw/dist/core/routes/codexlens/config-handlers.d.ts.map +1 -1
  85. package/ccw/dist/core/routes/codexlens/config-handlers.js +7 -6
  86. package/ccw/dist/core/routes/codexlens/config-handlers.js.map +1 -1
  87. package/ccw/dist/core/routes/codexlens/semantic-handlers.d.ts.map +1 -1
  88. package/ccw/dist/core/routes/codexlens/semantic-handlers.js +2 -2
  89. package/ccw/dist/core/routes/codexlens/semantic-handlers.js.map +1 -1
  90. package/ccw/dist/core/routes/graph-routes.d.ts.map +1 -1
  91. package/ccw/dist/core/routes/graph-routes.js +17 -2
  92. package/ccw/dist/core/routes/graph-routes.js.map +1 -1
  93. package/ccw/dist/core/routes/issue-routes.d.ts.map +1 -1
  94. package/ccw/dist/core/routes/issue-routes.js +280 -33
  95. package/ccw/dist/core/routes/issue-routes.js.map +1 -1
  96. package/ccw/dist/core/routes/loop-v2-routes.d.ts +9 -0
  97. package/ccw/dist/core/routes/loop-v2-routes.d.ts.map +1 -1
  98. package/ccw/dist/core/routes/loop-v2-routes.js +56 -4
  99. package/ccw/dist/core/routes/loop-v2-routes.js.map +1 -1
  100. package/ccw/dist/core/routes/system-routes.d.ts.map +1 -1
  101. package/ccw/dist/core/routes/system-routes.js +3 -2
  102. package/ccw/dist/core/routes/system-routes.js.map +1 -1
  103. package/ccw/dist/core/server.d.ts.map +1 -1
  104. package/ccw/dist/core/server.js +5 -3
  105. package/ccw/dist/core/server.js.map +1 -1
  106. package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
  107. package/ccw/dist/tools/claude-cli-tools.js +4 -3
  108. package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
  109. package/ccw/dist/tools/cli-config-manager.d.ts +1 -0
  110. package/ccw/dist/tools/cli-config-manager.d.ts.map +1 -1
  111. package/ccw/dist/tools/cli-config-manager.js +2 -1
  112. package/ccw/dist/tools/cli-config-manager.js.map +1 -1
  113. package/ccw/dist/tools/codex-lens-lsp.d.ts.map +1 -1
  114. package/ccw/dist/tools/codex-lens-lsp.js +2 -5
  115. package/ccw/dist/tools/codex-lens-lsp.js.map +1 -1
  116. package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
  117. package/ccw/dist/tools/codex-lens.js +22 -32
  118. package/ccw/dist/tools/codex-lens.js.map +1 -1
  119. package/ccw/dist/tools/litellm-client.d.ts +6 -0
  120. package/ccw/dist/tools/litellm-client.d.ts.map +1 -1
  121. package/ccw/dist/tools/litellm-client.js +15 -2
  122. package/ccw/dist/tools/litellm-client.js.map +1 -1
  123. package/ccw/dist/tools/loop-task-manager.d.ts +13 -2
  124. package/ccw/dist/tools/loop-task-manager.d.ts.map +1 -1
  125. package/ccw/dist/tools/loop-task-manager.js.map +1 -1
  126. package/ccw/dist/tools/native-session-discovery.d.ts.map +1 -1
  127. package/ccw/dist/tools/native-session-discovery.js +35 -7
  128. package/ccw/dist/tools/native-session-discovery.js.map +1 -1
  129. package/ccw/dist/utils/codexlens-path.d.ts +36 -0
  130. package/ccw/dist/utils/codexlens-path.d.ts.map +1 -0
  131. package/ccw/dist/utils/codexlens-path.js +56 -0
  132. package/ccw/dist/utils/codexlens-path.js.map +1 -0
  133. package/ccw/dist/utils/uv-manager.d.ts.map +1 -1
  134. package/ccw/dist/utils/uv-manager.js +3 -2
  135. package/ccw/dist/utils/uv-manager.js.map +1 -1
  136. package/ccw/src/cli.ts +4 -0
  137. package/ccw/src/commands/install.ts +51 -8
  138. package/ccw/src/commands/issue.ts +119 -0
  139. package/ccw/src/commands/upgrade.ts +1 -1
  140. package/ccw/src/config/litellm-api-config-manager.ts +3 -2
  141. package/ccw/src/core/memory-embedder-bridge.ts +2 -6
  142. package/ccw/src/core/routes/cli-routes.ts +1 -1
  143. package/ccw/src/core/routes/codexlens/config-handlers.ts +7 -6
  144. package/ccw/src/core/routes/codexlens/semantic-handlers.ts +2 -2
  145. package/ccw/src/core/routes/graph-routes.ts +18 -2
  146. package/ccw/src/core/routes/issue-routes.ts +308 -33
  147. package/ccw/src/core/routes/loop-v2-routes.ts +64 -6
  148. package/ccw/src/core/routes/system-routes.ts +3 -2
  149. package/ccw/src/core/server.ts +6 -3
  150. package/ccw/src/templates/dashboard-css/02-session.css +2 -0
  151. package/ccw/src/templates/dashboard-css/04-lite-tasks.css +103 -1
  152. package/ccw/src/templates/dashboard-css/32-issue-manager.css +32 -0
  153. package/ccw/src/templates/dashboard-js/components/cli-history.js +48 -48
  154. package/ccw/src/templates/dashboard-js/components/navigation.js +6 -0
  155. package/ccw/src/templates/dashboard-js/components/notifications.js +6 -0
  156. package/ccw/src/templates/dashboard-js/components/version-check.js +38 -0
  157. package/ccw/src/templates/dashboard-js/i18n.js +126 -0
  158. package/ccw/src/templates/dashboard-js/state.js +2 -0
  159. package/ccw/src/templates/dashboard-js/views/cli-manager.js +1 -1
  160. package/ccw/src/templates/dashboard-js/views/issue-manager.js +183 -1
  161. package/ccw/src/templates/dashboard-js/views/lite-tasks.js +55 -11
  162. package/ccw/src/templates/dashboard-js/views/loop-monitor.js +112 -11
  163. package/ccw/src/templates/dashboard.html +48 -2
  164. package/ccw/src/tools/claude-cli-tools.ts +4 -3
  165. package/ccw/src/tools/cli-config-manager.ts +3 -1
  166. package/ccw/src/tools/codex-lens-lsp.ts +2 -5
  167. package/ccw/src/tools/codex-lens.ts +27 -38
  168. package/ccw/src/tools/litellm-client.ts +16 -2
  169. package/ccw/src/tools/loop-task-manager.ts +13 -2
  170. package/ccw/src/tools/native-session-discovery.ts +38 -7
  171. package/ccw/src/utils/codexlens-path.ts +60 -0
  172. package/ccw/src/utils/uv-manager.ts +3 -2
  173. package/package.json +1 -1
@@ -0,0 +1,670 @@
1
+ ---
2
+ description: Lightweight bug diagnosis and fix workflow with optimized Codex subagent patterns (merged mode)
3
+ argument-hint: BUG="<bug description or error message>" [HOTFIX="true"]
4
+ ---
5
+
6
+ # Workflow Lite-Fix Command (Codex Optimized Version)
7
+
8
+ ## Overview
9
+
10
+ Intelligent lightweight bug fixing command with **optimized subagent orchestration**. Uses merged mode pattern for context preservation across diagnosis, clarification, and fix planning phases.
11
+
12
+ **Core Optimizations:**
13
+ - **Context Preservation**: Primary agent retained across phases via `send_input()`
14
+ - **Merged Mode**: Diagnosis → Merge → Clarify → Plan in single agent context
15
+ - **Reduced Agent Cycles**: Minimize spawn/close overhead
16
+ - **Dual-Role Pattern**: Single agent handles both exploration and planning (Low/Medium)
17
+
18
+ **Core capabilities:**
19
+ - Intelligent bug analysis with automatic severity detection
20
+ - Parallel code diagnosis via Codex subagents (spawn_agent + batch wait)
21
+ - **Merged clarification + fix planning** (send_input to retained agent)
22
+ - Adaptive fix planning based on severity
23
+ - Two-step confirmation: fix-plan display → user approval
24
+ - Outputs fix-plan.json file after user confirmation
25
+
26
+ ## Bug Description
27
+
28
+ **Target bug**: $BUG
29
+ **Hotfix mode**: $HOTFIX
30
+
31
+ ## Execution Modes
32
+
33
+ ### Mode Selection Based on Severity
34
+
35
+ | Severity | Mode | Pattern | Phases |
36
+ |----------|------|---------|--------|
37
+ | Low/Medium | 方案A (合并模式) | Single dual-role agent | 2-phase with send_input |
38
+ | High/Critical | 方案B (混合模式) | Multi-agent + primary merge | Parallel → Merge → Plan |
39
+
40
+ ## Execution Process
41
+
42
+ ```
43
+ Phase 0: Setup & Severity Assessment
44
+ ├─ Parse input (description, error message, or .md file)
45
+ ├─ Create session folder
46
+ ├─ Intelligent severity pre-assessment (Low/Medium/High/Critical)
47
+ └─ Select execution mode (方案A or 方案B)
48
+
49
+ ========== 方案A: Low/Medium Severity (Merged Mode) ==========
50
+
51
+ Phase 1A: Dual-Role Agent (Diagnosis + Planning)
52
+ ├─ spawn_agent with combined diagnosis + planning role
53
+ ├─ wait for initial diagnosis
54
+ └─ Agent retains context for next phase
55
+
56
+ Phase 2A: Clarification + Fix Planning (send_input)
57
+ ├─ send_input: clarification answers + "generate fix plan"
58
+ ├─ wait for fix-plan.json generation
59
+ └─ close_agent (single cleanup)
60
+
61
+ ========== 方案B: High/Critical Severity (Mixed Mode) ==========
62
+
63
+ Phase 1B: Parallel Multi-Angle Diagnosis
64
+ ├─ spawn_agent × N (primary = dual-role, others = explore-only)
65
+ ├─ wait({ ids: [...] }) for all diagnoses
66
+ └─ Collect all diagnosis results
67
+
68
+ Phase 2B: Merge + Clarify (send_input to primary)
69
+ ├─ close_agent × (N-1) non-primary agents
70
+ ├─ send_input to primary: other agents' diagnoses + "merge findings"
71
+ └─ wait for merged analysis + clarification needs
72
+
73
+ Phase 3B: Fix Planning (send_input to primary)
74
+ ├─ send_input: clarification answers + "generate fix plan"
75
+ ├─ wait for fix-plan.json generation
76
+ └─ close_agent (primary cleanup)
77
+
78
+ ========== Common Phases ==========
79
+
80
+ Phase 4: Confirmation
81
+ ├─ Display fix-plan summary (tasks, severity, risk level)
82
+ ├─ Output confirmation request
83
+ └─ STOP and wait for user approval
84
+
85
+ Phase 5: Output
86
+ └─ Confirm fix-plan.json written to session folder
87
+ ```
88
+
89
+ ## Implementation
90
+
91
+ ### Phase 0: Setup & Severity Assessment
92
+
93
+ **Session Setup** (MANDATORY):
94
+ ```javascript
95
+ // Helper: Get UTC+8 (China Standard Time) ISO string
96
+ const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
97
+
98
+ const bugSlug = "$BUG".toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 40)
99
+ const dateStr = getUtc8ISOString().substring(0, 10) // Format: 2025-11-29
100
+
101
+ const sessionId = `${bugSlug}-${dateStr}`
102
+ const sessionFolder = `.workflow/.lite-fix/${sessionId}`
103
+
104
+ // Create session folder
105
+ mkdir -p ${sessionFolder}
106
+ ```
107
+
108
+ **Hotfix Mode Check**:
109
+ ```javascript
110
+ const hotfixMode = "$HOTFIX" === "true"
111
+
112
+ if (hotfixMode) {
113
+ // Skip diagnosis, go directly to minimal fix planning
114
+ proceed_to_direct_fix()
115
+ }
116
+ ```
117
+
118
+ **Severity Assessment**:
119
+ ```javascript
120
+ // Analyze bug severity based on symptoms, scope, urgency, impact
121
+ const severity = analyzeBugSeverity("$BUG")
122
+ // Returns: 'Low' | 'Medium' | 'High' | 'Critical'
123
+
124
+ // Mode selection
125
+ const executionMode = (severity === 'Low' || severity === 'Medium') ? 'A' : 'B'
126
+
127
+ console.log(`
128
+ ## Bug Analysis
129
+
130
+ **Severity**: ${severity}
131
+ **Execution Mode**: 方案${executionMode} (${executionMode === 'A' ? '合并模式 - Single Agent' : '混合模式 - Multi-Agent'})
132
+ `)
133
+ ```
134
+
135
+ **Angle Selection** (for diagnosis):
136
+ ```javascript
137
+ const DIAGNOSIS_ANGLE_PRESETS = {
138
+ runtime_error: ['error-handling', 'dataflow', 'state-management', 'edge-cases'],
139
+ performance: ['performance', 'bottlenecks', 'caching', 'data-access'],
140
+ security: ['security', 'auth-patterns', 'dataflow', 'validation'],
141
+ data_corruption: ['data-integrity', 'state-management', 'transactions', 'validation'],
142
+ ui_bug: ['state-management', 'event-handling', 'rendering', 'data-binding'],
143
+ integration: ['api-contracts', 'error-handling', 'timeouts', 'fallbacks']
144
+ }
145
+
146
+ function selectDiagnosisAngles(bugDescription, count) {
147
+ const text = bugDescription.toLowerCase()
148
+ let preset = 'runtime_error'
149
+
150
+ if (/slow|timeout|performance|lag|hang/.test(text)) preset = 'performance'
151
+ else if (/security|auth|permission|access|token/.test(text)) preset = 'security'
152
+ else if (/corrupt|data|lost|missing|inconsistent/.test(text)) preset = 'data_corruption'
153
+ else if (/ui|display|render|style|click|button/.test(text)) preset = 'ui_bug'
154
+ else if (/api|integration|connect|request|response/.test(text)) preset = 'integration'
155
+
156
+ return DIAGNOSIS_ANGLE_PRESETS[preset].slice(0, count)
157
+ }
158
+
159
+ const angleCount = severity === 'Critical' ? 4 : (severity === 'High' ? 3 : (severity === 'Medium' ? 2 : 1))
160
+ const selectedAngles = selectDiagnosisAngles("$BUG", angleCount)
161
+ ```
162
+
163
+ ---
164
+
165
+ ## 方案A: Low/Medium Severity (合并模式)
166
+
167
+ **Pattern**: Single dual-role agent handles diagnosis + clarification + fix planning with context preserved via `send_input()`.
168
+
169
+ ### Phase 1A: Dual-Role Agent (Diagnosis + Planning)
170
+
171
+ ```javascript
172
+ // ==================== MERGED MODE ====================
173
+
174
+ // Step 1: Spawn single dual-role agent (角色文件由 agent 自己读取)
175
+ const dualAgent = spawn_agent({
176
+ message: `
177
+ ## PHASE 1: DIAGNOSIS
178
+
179
+ ### Task Objective
180
+ Execute comprehensive diagnosis for bug root cause analysis. You have combined diagnosis + planning capabilities.
181
+
182
+ ### Bug Description
183
+ $BUG
184
+
185
+ ### Diagnosis Angles (analyze all)
186
+ ${selectedAngles.map((angle, i) => `${i + 1}. ${angle}`).join('\n')}
187
+
188
+ ### MANDATORY FIRST STEPS (Agent Execute)
189
+ 1. **Read diagnosis role**: ~/.codex/agents/cli-explore-agent.md (MUST read first)
190
+ 2. **Read planning role**: ~/.codex/agents/cli-lite-planning-agent.md (for Phase 2)
191
+ 3. Run: ccw tool exec get_modules_by_depth '{}' (project structure)
192
+ 4. Run: rg -l "{error_keyword_from_bug}" --type ts (locate relevant files)
193
+ 5. Execute: cat ~/.claude/workflows/cli-templates/schemas/diagnosis-json-schema.json
194
+ 6. Read: .workflow/project-tech.json
195
+ 7. Read: .workflow/project-guidelines.json
196
+
197
+ ### Diagnosis Tasks
198
+ For each angle (${selectedAngles.join(', ')}):
199
+ 1. **Error Tracing**: rg for error messages, stack traces
200
+ 2. **Root Cause Analysis**: Identify code paths, edge cases
201
+ 3. **Affected Files**: List with relevance scores
202
+
203
+ ### Expected Output
204
+ 1. Write diagnosis to: ${sessionFolder}/diagnosis-merged.json
205
+ 2. List any clarification needs (questions + options)
206
+ 3. **DO NOT proceed to fix planning yet** - wait for Phase 2 input
207
+
208
+ ### Clarification Format (if needed)
209
+ If you need clarification, output:
210
+ \`\`\`json
211
+ {
212
+ "clarification_needs": [
213
+ {
214
+ "question": "...",
215
+ "context": "...",
216
+ "options": ["Option 1", "Option 2", "Option 3"],
217
+ "recommended": 0
218
+ }
219
+ ]
220
+ }
221
+ \`\`\`
222
+
223
+ ### Deliverables for Phase 1
224
+ - Write: ${sessionFolder}/diagnosis-merged.json
225
+ - Return: Diagnosis summary + clarification needs (if any)
226
+ `
227
+ })
228
+
229
+ // Step 3: Wait for diagnosis
230
+ const diagnosisResult = wait({
231
+ ids: [dualAgent],
232
+ timeout_ms: 600000 // 10 minutes
233
+ })
234
+
235
+ // Extract clarification needs from result
236
+ const clarificationNeeds = extractClarificationNeeds(diagnosisResult.status[dualAgent].completed)
237
+ ```
238
+
239
+ **Handle Clarification (if needed)**:
240
+ ```javascript
241
+ if (clarificationNeeds.length > 0) {
242
+ console.log(`
243
+ ## Clarification Needed
244
+
245
+ ${clarificationNeeds.map((need, index) => `
246
+ ### Question ${index + 1}
247
+
248
+ **${need.question}**
249
+
250
+ Context: ${need.context}
251
+
252
+ Options:
253
+ ${need.options.map((opt, i) => ` ${i + 1}. ${opt}${need.recommended === i ? ' ★ (Recommended)' : ''}`).join('\n')}
254
+ `).join('\n')}
255
+
256
+ ---
257
+
258
+ **Please reply with your choices** (e.g., "Q1: 2, Q2: 1") to continue.
259
+
260
+ **WAITING FOR USER INPUT...**
261
+ `)
262
+ // STOP - Wait for user reply
263
+ return
264
+ }
265
+ ```
266
+
267
+ ### Phase 2A: Clarification + Fix Planning (send_input)
268
+
269
+ ```javascript
270
+ // After user replies with clarification answers...
271
+ const clarificationAnswers = /* user's answers */
272
+
273
+ // Step 4: send_input for fix planning (CONTEXT PRESERVED)
274
+ send_input({
275
+ id: dualAgent,
276
+ message: `
277
+ ## PHASE 2: FIX PLANNING
278
+
279
+ ### User Clarifications
280
+ ${clarificationAnswers || "No clarifications needed"}
281
+
282
+ ### Schema Reference
283
+ Execute: cat ~/.claude/workflows/cli-templates/schemas/fix-plan-json-schema.json
284
+
285
+ ### Generate Fix Plan
286
+ Based on your diagnosis, generate a comprehensive fix plan:
287
+
288
+ 1. Read your diagnosis file: ${sessionFolder}/diagnosis-merged.json
289
+ 2. Synthesize root cause from all analyzed angles
290
+ 3. Generate fix-plan.json with:
291
+ - summary: 2-3 sentence overview
292
+ - root_cause: Consolidated from diagnosis
293
+ - strategy: "immediate_patch" | "comprehensive_fix" | "refactor"
294
+ - tasks: 1-3 structured fix tasks (group by fix area)
295
+ - severity: ${severity}
296
+ - risk_level: based on analysis
297
+
298
+ ### Task Grouping Rules
299
+ 1. Group by fix area (all changes for one fix = one task)
300
+ 2. Avoid file-per-task pattern
301
+ 3. Each task = 10-30 minutes of work
302
+ 4. Prefer parallel tasks (minimal dependencies)
303
+
304
+ ### Deliverables
305
+ - Write: ${sessionFolder}/fix-plan.json
306
+ - Return: Brief fix plan summary
307
+ `
308
+ })
309
+
310
+ // Step 5: Wait for fix planning
311
+ const planResult = wait({
312
+ ids: [dualAgent],
313
+ timeout_ms: 600000 // 10 minutes
314
+ })
315
+
316
+ // Step 6: Cleanup (single close)
317
+ close_agent({ id: dualAgent })
318
+ ```
319
+
320
+ ---
321
+
322
+ ## 方案B: High/Critical Severity (混合模式)
323
+
324
+ **Pattern**: Parallel multi-angle diagnosis → keep primary agent → send_input for merge + clarify + plan.
325
+
326
+ ### Phase 1B: Parallel Multi-Angle Diagnosis
327
+
328
+ ```javascript
329
+ // ==================== MIXED MODE ====================
330
+
331
+ // Step 1: Spawn parallel diagnosis agents (角色文件由 agent 自己读取)
332
+ // primary = dual-role (diagnosis + planning)
333
+ const diagnosisAgents = selectedAngles.map((angle, index) => {
334
+ const isPrimary = index === 0
335
+
336
+ return spawn_agent({
337
+ message: `
338
+ ## TASK ASSIGNMENT
339
+
340
+ ### Agent Type
341
+ ${isPrimary ? '**PRIMARY** (Dual-role: Diagnosis + Planning)' : `Secondary (Diagnosis only - angle: ${angle})`}
342
+
343
+ ### Task Objective
344
+ Execute **${angle}** diagnosis for bug root cause analysis.
345
+
346
+ ### Bug Description
347
+ $BUG
348
+
349
+ ### Diagnosis Angle
350
+ ${angle}
351
+
352
+ ### Output File
353
+ ${sessionFolder}/diagnosis-${angle}.json
354
+
355
+ ### MANDATORY FIRST STEPS (Agent Execute)
356
+ 1. **Read diagnosis role**: ~/.codex/agents/cli-explore-agent.md (MUST read first)
357
+ ${isPrimary ? '2. **Read planning role**: ~/.codex/agents/cli-lite-planning-agent.md (for Phase 2 & 3)\n3.' : '2.'} Run: ccw tool exec get_modules_by_depth '{}'
358
+ ${isPrimary ? '4.' : '3.'} Run: rg -l "{error_keyword_from_bug}" --type ts
359
+ ${isPrimary ? '5.' : '4.'} Execute: cat ~/.claude/workflows/cli-templates/schemas/diagnosis-json-schema.json
360
+ ${isPrimary ? '6.' : '5.'} Read: .workflow/project-tech.json
361
+ ${isPrimary ? '7.' : '6.'} Read: .workflow/project-guidelines.json
362
+
363
+ ### Diagnosis Strategy (${angle} focus)
364
+ 1. **Error Tracing**: rg for error messages, stack traces
365
+ 2. **Root Cause Analysis**: Code paths, edge cases for ${angle}
366
+ 3. **Affected Files**: List with ${angle} relevance
367
+
368
+ ### Expected Output
369
+ Write: ${sessionFolder}/diagnosis-${angle}.json
370
+ Return: 2-3 sentence summary of ${angle} findings
371
+
372
+ ${isPrimary ? `
373
+ ### PRIMARY AGENT NOTE
374
+ You will receive follow-up tasks via send_input:
375
+ - Phase 2: Merge other agents' diagnoses
376
+ - Phase 3: Generate fix plan
377
+ Keep your context ready for continuation.
378
+ ` : ''}
379
+ `
380
+ })
381
+ })
382
+
383
+ // Step 3: Batch wait for ALL diagnosis agents
384
+ const diagnosisResults = wait({
385
+ ids: diagnosisAgents,
386
+ timeout_ms: 600000 // 10 minutes
387
+ })
388
+
389
+ // Step 4: Collect all diagnosis results
390
+ const allDiagnoses = selectedAngles.map((angle, index) => ({
391
+ angle,
392
+ agentId: diagnosisAgents[index],
393
+ result: diagnosisResults.status[diagnosisAgents[index]].completed,
394
+ file: `${sessionFolder}/diagnosis-${angle}.json`
395
+ }))
396
+
397
+ console.log(`
398
+ ## Phase 1B Complete
399
+
400
+ Diagnoses collected:
401
+ ${allDiagnoses.map(d => `- ${d.angle}: ${d.file}`).join('\n')}
402
+ `)
403
+ ```
404
+
405
+ ### Phase 2B: Merge + Clarify (send_input to primary)
406
+
407
+ ```javascript
408
+ // Step 5: Close non-primary agents, keep primary
409
+ const primaryAgent = diagnosisAgents[0]
410
+ const primaryAngle = selectedAngles[0]
411
+
412
+ diagnosisAgents.slice(1).forEach(id => close_agent({ id }))
413
+
414
+ console.log(`
415
+ ## Phase 2B: Merge Analysis
416
+
417
+ Closed ${diagnosisAgents.length - 1} secondary agents.
418
+ Sending merge task to primary agent (${primaryAngle})...
419
+ `)
420
+
421
+ // Step 6: send_input for merge + clarification
422
+ send_input({
423
+ id: primaryAgent,
424
+ message: `
425
+ ## PHASE 2: MERGE + CLARIFY
426
+
427
+ ### Task
428
+ Merge all diagnosis findings and identify clarification needs.
429
+
430
+ ### Your Diagnosis (${primaryAngle})
431
+ Already in your context from Phase 1.
432
+
433
+ ### Other Agents' Diagnoses to Merge
434
+ ${allDiagnoses.slice(1).map(d => `
435
+ #### Diagnosis: ${d.angle}
436
+ File: ${d.file}
437
+ Summary: ${d.result}
438
+ `).join('\n')}
439
+
440
+ ### Merge Instructions
441
+ 1. Read all diagnosis files:
442
+ ${allDiagnoses.map(d => ` - ${d.file}`).join('\n')}
443
+
444
+ 2. Synthesize findings:
445
+ - Identify common root causes across angles
446
+ - Note conflicting findings
447
+ - Rank confidence levels
448
+
449
+ 3. Write merged analysis: ${sessionFolder}/diagnosis-merged.json
450
+
451
+ 4. List clarification needs (if any):
452
+ - Questions that need user input
453
+ - Options with recommendations
454
+
455
+ ### Expected Output
456
+ - Write: ${sessionFolder}/diagnosis-merged.json
457
+ - Return: Merged findings summary + clarification needs
458
+ `
459
+ })
460
+
461
+ // Step 7: Wait for merge
462
+ const mergeResult = wait({
463
+ ids: [primaryAgent],
464
+ timeout_ms: 300000 // 5 minutes
465
+ })
466
+
467
+ // Extract clarification needs
468
+ const clarificationNeeds = extractClarificationNeeds(mergeResult.status[primaryAgent].completed)
469
+ ```
470
+
471
+ **Handle Clarification (if needed)**:
472
+ ```javascript
473
+ if (clarificationNeeds.length > 0) {
474
+ console.log(`
475
+ ## Clarification Needed
476
+
477
+ ${clarificationNeeds.map((need, index) => `
478
+ ### Question ${index + 1}
479
+
480
+ **${need.question}**
481
+
482
+ Context: ${need.context}
483
+
484
+ Options:
485
+ ${need.options.map((opt, i) => ` ${i + 1}. ${opt}${need.recommended === i ? ' ★ (Recommended)' : ''}`).join('\n')}
486
+ `).join('\n')}
487
+
488
+ ---
489
+
490
+ **Please reply with your choices** to continue.
491
+
492
+ **WAITING FOR USER INPUT...**
493
+ `)
494
+ return
495
+ }
496
+ ```
497
+
498
+ ### Phase 3B: Fix Planning (send_input to primary)
499
+
500
+ ```javascript
501
+ // After user replies with clarification answers...
502
+ const clarificationAnswers = /* user's answers */
503
+
504
+ // Step 8: send_input for fix planning (CONTEXT PRESERVED)
505
+ send_input({
506
+ id: primaryAgent,
507
+ message: `
508
+ ## PHASE 3: FIX PLANNING
509
+
510
+ ### User Clarifications
511
+ ${clarificationAnswers || "No clarifications needed"}
512
+
513
+ ### Schema Reference
514
+ Execute: cat ~/.claude/workflows/cli-templates/schemas/fix-plan-json-schema.json
515
+
516
+ ### Generate Fix Plan
517
+ Based on your merged diagnosis, generate a comprehensive fix plan:
518
+
519
+ 1. Read merged diagnosis: ${sessionFolder}/diagnosis-merged.json
520
+ 2. Consider all ${selectedAngles.length} diagnosis angles
521
+ 3. Generate fix-plan.json with:
522
+ - summary: 2-3 sentence overview
523
+ - root_cause: Consolidated from all diagnoses
524
+ - strategy: "immediate_patch" | "comprehensive_fix" | "refactor"
525
+ - tasks: 1-5 structured fix tasks
526
+ - severity: ${severity}
527
+ - risk_level: based on analysis
528
+
529
+ ### High/Critical Complexity Fields (REQUIRED)
530
+ For each task:
531
+ - rationale: Why this fix approach
532
+ - verification: How to verify success
533
+ - risks: Potential issues with fix
534
+
535
+ ### Task Grouping Rules
536
+ 1. Group by fix area (all changes for one fix = one task)
537
+ 2. Avoid file-per-task pattern
538
+ 3. Each task = 10-45 minutes of work
539
+ 4. True dependencies only (prefer parallel)
540
+
541
+ ### Deliverables
542
+ - Write: ${sessionFolder}/fix-plan.json
543
+ - Return: Brief fix plan summary
544
+ `
545
+ })
546
+
547
+ // Step 9: Wait for fix planning
548
+ const planResult = wait({
549
+ ids: [primaryAgent],
550
+ timeout_ms: 600000 // 10 minutes
551
+ })
552
+
553
+ // Step 10: Cleanup primary agent
554
+ close_agent({ id: primaryAgent })
555
+ ```
556
+
557
+ ---
558
+
559
+ ## Common Phases (Both Modes)
560
+
561
+ ### Phase 4: Confirmation
562
+
563
+ ```javascript
564
+ const fixPlan = JSON.parse(Read(`${sessionFolder}/fix-plan.json`))
565
+
566
+ console.log(`
567
+ ## Fix Plan
568
+
569
+ **Summary**: ${fixPlan.summary}
570
+ **Root Cause**: ${fixPlan.root_cause}
571
+ **Strategy**: ${fixPlan.strategy}
572
+
573
+ **Tasks** (${fixPlan.tasks.length}):
574
+ ${fixPlan.tasks.map((t, i) => `
575
+ ### Task ${i+1}: ${t.title}
576
+ - **Description**: ${t.description}
577
+ - **Scope**: ${t.scope}
578
+ - **Action**: ${t.action}
579
+ - **Complexity**: ${t.complexity}
580
+ - **Dependencies**: ${t.depends_on?.join(', ') || 'None'}
581
+ `).join('\n')}
582
+
583
+ **Severity**: ${fixPlan.severity}
584
+ **Risk Level**: ${fixPlan.risk_level}
585
+ **Estimated Time**: ${fixPlan.estimated_time}
586
+
587
+ ---
588
+
589
+ ## Confirmation Required
590
+
591
+ Please review the fix plan above and reply with:
592
+
593
+ - **"Allow"** - Proceed with this fix plan
594
+ - **"Modify"** - Describe what changes you want
595
+ - **"Cancel"** - Abort the workflow
596
+
597
+ **WAITING FOR USER CONFIRMATION...**
598
+ `)
599
+
600
+ return
601
+ ```
602
+
603
+ ### Phase 5: Output
604
+
605
+ ```javascript
606
+ // After User Confirms "Allow"
607
+ console.log(`
608
+ ## Fix Plan Output Complete
609
+
610
+ **Fix plan file**: ${sessionFolder}/fix-plan.json
611
+ **Session folder**: ${sessionFolder}
612
+
613
+ **Contents**:
614
+ - diagnosis-merged.json (or diagnosis-{angle}.json files)
615
+ - fix-plan.json
616
+
617
+ ---
618
+
619
+ You can now use this fix plan with your preferred execution method.
620
+ `)
621
+ ```
622
+
623
+ ---
624
+
625
+ ## Mode Comparison
626
+
627
+ | Aspect | 方案A (合并模式) | 方案B (混合模式) |
628
+ |--------|-----------------|-----------------|
629
+ | **Severity** | Low/Medium | High/Critical |
630
+ | **Agents** | 1 (dual-role) | N (parallel) → 1 (primary kept) |
631
+ | **Phases** | 2 (diagnosis → plan) | 3 (diagnose → merge → plan) |
632
+ | **Context** | Fully preserved | Merged via send_input |
633
+ | **Overhead** | Minimal | Higher (parallel coordination) |
634
+ | **Coverage** | Single comprehensive | Multi-angle deep dive |
635
+
636
+ ## Optimization Benefits
637
+
638
+ | Aspect | Before (Original) | After (Optimized) |
639
+ |--------|-------------------|-------------------|
640
+ | **Agent Cycles** | spawn × N → close all → spawn new | spawn → send_input → close once |
641
+ | **Context Loss** | Diagnosis context lost before planning | Context preserved via send_input |
642
+ | **Merge Process** | None (separate planning agent) | Explicit merge phase (方案B) |
643
+ | **Low/Medium** | Same as High/Critical | Simplified single-agent path |
644
+
645
+ ## Session Folder Structure
646
+
647
+ ```
648
+ .workflow/.lite-fix/{bug-slug}-{YYYY-MM-DD}/
649
+ ├── diagnosis-merged.json # 方案A or merged 方案B
650
+ ├── diagnosis-{angle1}.json # 方案B only
651
+ ├── diagnosis-{angle2}.json # 方案B only
652
+ ├── diagnosis-{angle3}.json # 方案B only (if applicable)
653
+ ├── diagnosis-{angle4}.json # 方案B only (if applicable)
654
+ └── fix-plan.json # Fix plan (after confirmation)
655
+ ```
656
+
657
+ ## Error Handling
658
+
659
+ | Error | Resolution |
660
+ |-------|------------|
661
+ | spawn_agent failure | Fallback to direct diagnosis |
662
+ | wait() timeout | Use completed results, continue |
663
+ | send_input failure | Re-spawn agent with context summary |
664
+ | Clarification timeout | Use diagnosis findings as-is |
665
+ | Confirmation timeout | Save context, display resume instructions |
666
+ | Root cause unclear | Extend diagnosis or escalate to 方案B |
667
+
668
+ ---
669
+
670
+ **Now execute the lite-fix workflow for bug**: $BUG