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,485 @@
1
+ ---
2
+ description: Lightweight interactive planning workflow with hybrid mode - multi-agent parallel exploration + primary agent merge/clarify/plan
3
+ argument-hint: TASK="<task description or file.md path>"
4
+ ---
5
+
6
+ # Workflow Lite-Plan-B (Hybrid Mode)
7
+
8
+ ## Overview
9
+
10
+ Hybrid mode for complex planning tasks. Multiple agents explore in parallel from different angles, then the primary agent merges findings, handles clarification, and generates the implementation plan while retaining its exploration context.
11
+
12
+ **Core capabilities:**
13
+ - **Parallel multi-angle exploration** via multiple subagents
14
+ - **Primary agent reuse** for merge, clarification, and planning (context preserved)
15
+ - Intelligent deduplication and conflict resolution during merge
16
+ - Best for High complexity tasks requiring cross-module analysis
17
+
18
+ ## Applicable Scenarios
19
+
20
+ - **High complexity tasks**
21
+ - Multi-angle parallel exploration required
22
+ - Cross-module or architecture-level changes
23
+ - Complex dependencies requiring multiple perspectives
24
+
25
+ ## Core Advantages
26
+
27
+ | Metric | Traditional Separated Mode | Plan-B Hybrid Mode |
28
+ |--------|---------------------------|-------------------|
29
+ | Agent creation count | N + 1 (fully independent) | **N → 1** (reuse primary agent) |
30
+ | Context transfer | Full serialization | **Primary agent retained + incremental merge** |
31
+ | Merge quality | Simple concatenation | **Intelligent agent merge** |
32
+ | Planning coherence | Low (new agent) | **High (reuses exploration agent)** |
33
+
34
+ ## Task Description
35
+
36
+ **Target task**: $TASK
37
+
38
+ ## Execution Process
39
+
40
+ ```
41
+ ┌─────────────────────────────────────────────────────────────────┐
42
+ │ Phase 1: Parallel Exploration │
43
+ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
44
+ │ │Agent 0 │ │Agent 1 │ │Agent 2 │ │Agent 3 │ │
45
+ │ │(primary)│ │(explore)│ │(explore)│ │(explore)│ │
46
+ │ │angle-0 │ │angle-1 │ │angle-2 │ │angle-3 │ │
47
+ │ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
48
+ │ │ │ │ │ │
49
+ │ └───────────┴───────────┴───────────┘ │
50
+ │ ↓ │
51
+ │ wait({ ids: all }) │
52
+ │ ↓ │
53
+ ├─────────────────────────────────────────────────────────────────┤
54
+ │ Phase 2: Merge + Clarify │
55
+ │ ↓ │
56
+ │ close(Agent 1, 2, 3) ← close non-primary agents │
57
+ │ ↓ │
58
+ │ send_input(Agent 0, { │
59
+ │ other_explorations: [Agent 1,2,3 results], │
60
+ │ task: "MERGE + CLARIFY" │
61
+ │ }) │
62
+ │ ↓ │
63
+ │ wait() → get merged results + clarification questions │
64
+ │ ↓ │
65
+ │ [Collect user answers] │
66
+ │ ↓ │
67
+ ├─────────────────────────────────────────────────────────────────┤
68
+ │ Phase 3: Planning │
69
+ │ ↓ │
70
+ │ send_input(Agent 0, { │
71
+ │ clarification_answers: [...], │
72
+ │ task: "GENERATE PLAN" │
73
+ │ }) │
74
+ │ ↓ │
75
+ │ wait() → get plan.json │
76
+ │ ↓ │
77
+ │ close(Agent 0) │
78
+ └─────────────────────────────────────────────────────────────────┘
79
+ ```
80
+
81
+ ## Implementation
82
+
83
+ ### Session Setup
84
+
85
+ **Session Setup** (MANDATORY - follow exactly):
86
+ ```javascript
87
+ // Helper: Get UTC+8 (China Standard Time) ISO string
88
+ const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
89
+
90
+ const taskSlug = "$TASK".toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 40)
91
+ const dateStr = getUtc8ISOString().substring(0, 10) // Format: 2025-11-29
92
+
93
+ const sessionId = `${taskSlug}-${dateStr}` // e.g., "implement-jwt-refresh-2025-11-29"
94
+ const sessionFolder = `.workflow/.lite-plan/${sessionId}`
95
+
96
+ // Create session folder
97
+ mkdir -p ${sessionFolder}
98
+ ```
99
+
100
+ ### Complexity Assessment & Multi-Angle Selection
101
+
102
+ ```javascript
103
+ const complexity = analyzeTaskComplexity("$TASK")
104
+ // Plan-B is suitable for High complexity
105
+
106
+ const ANGLE_PRESETS = {
107
+ architecture: ['architecture', 'dependencies', 'modularity', 'integration-points'],
108
+ security: ['security', 'auth-patterns', 'dataflow', 'validation'],
109
+ performance: ['performance', 'bottlenecks', 'caching', 'data-access'],
110
+ bugfix: ['error-handling', 'dataflow', 'state-management', 'edge-cases'],
111
+ feature: ['patterns', 'integration-points', 'testing', 'dependencies']
112
+ }
113
+
114
+ // Plan-B selects 3-4 angles for parallel exploration
115
+ const selectedAngles = selectAngles("$TASK", 4) // e.g., ['architecture', 'patterns', 'testing', 'dependencies']
116
+ ```
117
+
118
+ ---
119
+
120
+ ### Phase 1: Parallel Exploration (Primary Agent Has Planning Capability)
121
+
122
+ ```javascript
123
+ // ==================== PLAN-B: HYBRID MODE ====================
124
+
125
+ // Step 1: Create parallel exploration agents (role files read by agents themselves)
126
+ // First agent is primary, has merge + planning capability
127
+ const explorationAgents = selectedAngles.map((angle, index) => {
128
+ const isPrimary = index === 0
129
+
130
+ return spawn_agent({
131
+ message: `
132
+ ## TASK ASSIGNMENT (Phase 1: Exploration)
133
+
134
+ ### Task Description
135
+ ${task_description}
136
+
137
+ ### Your Exploration Angle
138
+ **Angle**: ${angle}
139
+ **Index**: ${index + 1} of ${selectedAngles.length}
140
+ **Output File**: ${sessionFolder}/exploration-${angle}.json
141
+ ${isPrimary ? '\n**Note**: You are the PRIMARY agent. After Phase 1, you will receive other agents\' results for merging and planning.' : ''}
142
+
143
+ ### MANDATORY FIRST STEPS (Agent Execute)
144
+ 1. **Read explorer role**: ~/.codex/agents/cli-explore-agent.md (MUST read first)
145
+ ${isPrimary ? '2. **Read planner role**: ~/.codex/agents/cli-lite-planning-agent.md (for Phase 2 & 3)\n3.' : '2.'} Run: ccw tool exec get_modules_by_depth '{}'
146
+ ${isPrimary ? '4.' : '3.'} Run: rg -l "{keyword}" --type ts
147
+ ${isPrimary ? '5.' : '4.'} Read: .workflow/project-tech.json
148
+ ${isPrimary ? '6.' : '5.'} Read: .workflow/project-guidelines.json
149
+
150
+ ### Exploration Focus: ${angle}
151
+
152
+ **Structural Analysis**:
153
+ - Identify modules and files related to ${angle}
154
+ - Map imports/exports and dependencies
155
+ - Locate entry points and integration surfaces
156
+
157
+ **Semantic Analysis**:
158
+ - How does existing code handle ${angle} concerns?
159
+ - What patterns are established for ${angle}?
160
+ - Where would new code integrate from ${angle} viewpoint?
161
+
162
+ ### Output Format
163
+
164
+ Write to ${sessionFolder}/exploration-${angle}.json:
165
+ \`\`\`json
166
+ {
167
+ "angle": "${angle}",
168
+ "project_structure": [...],
169
+ "relevant_files": [
170
+ {"path": "src/file.ts", "relevance": 0.9, "rationale": "..."}
171
+ ],
172
+ "patterns": [...],
173
+ "dependencies": [...],
174
+ "integration_points": [
175
+ {"location": "file:line", "description": "..."}
176
+ ],
177
+ "constraints": [...],
178
+ "clarification_needs": [
179
+ {"question": "...", "options": ["A", "B"], "recommended": 0, "context": "..."}
180
+ ],
181
+ "_metadata": {
182
+ "exploration_angle": "${angle}",
183
+ "exploration_index": ${index + 1},
184
+ "timestamp": "..."
185
+ }
186
+ }
187
+ \`\`\`
188
+
189
+ ### Return
190
+ 2-3 sentence summary of ${angle} findings
191
+ `
192
+ })
193
+ })
194
+
195
+ // Step 2: Batch wait for ALL explorations to complete (KEY ADVANTAGE of Codex)
196
+ const exploreResults = wait({
197
+ ids: explorationAgents,
198
+ timeout_ms: 600000 // 10 minutes
199
+ })
200
+
201
+ // Step 3: Collect all exploration results
202
+ const allExplorations = selectedAngles.map((angle, index) => ({
203
+ angle: angle,
204
+ agentId: explorationAgents[index],
205
+ result: exploreResults.status[explorationAgents[index]].completed,
206
+ file: `${sessionFolder}/exploration-${angle}.json`
207
+ }))
208
+
209
+ console.log(`
210
+ ## Phase 1 Complete
211
+
212
+ Explorations completed:
213
+ ${allExplorations.map(e => `- ${e.angle}: ${e.result.substring(0, 100)}...`).join('\n')}
214
+ `)
215
+ ```
216
+
217
+ ---
218
+
219
+ ### Phase 2: Merge + Clarify (Reuse Primary Agent)
220
+
221
+ ```javascript
222
+ // Step 4: Close non-primary agents, keep primary agent (index=0)
223
+ const primaryAgent = explorationAgents[0]
224
+ const primaryAngle = selectedAngles[0]
225
+
226
+ explorationAgents.slice(1).forEach(id => close_agent({ id }))
227
+
228
+ // Step 5: Send merge task to primary agent
229
+ send_input({
230
+ id: primaryAgent,
231
+ message: `
232
+ ## PHASE 2: MERGE + CLARIFY
233
+
234
+ You are now in **Merger** role. Combine your ${primaryAngle} findings with other explorations below.
235
+
236
+ ### Other Explorations to Merge
237
+
238
+ ${allExplorations.slice(1).map(e => `
239
+ #### ${e.angle} Exploration
240
+ **File**: ${e.file}
241
+ **Summary**: ${e.result}
242
+
243
+ Read the full exploration: Read("${e.file}")
244
+ `).join('\n')}
245
+
246
+ ### Merge Instructions
247
+
248
+ 1. **Read All Exploration Files**
249
+ ${allExplorations.map(e => `- Read("${e.file}")`).join('\n ')}
250
+
251
+ 2. **Consolidate Findings**
252
+ - **relevant_files**: Deduplicate, keep highest relevance score for each file
253
+ - **patterns**: Merge unique patterns, note which angle discovered each
254
+ - **integration_points**: Combine all, group by module
255
+ - **constraints**: Merge and categorize (hard vs soft constraints)
256
+ - **clarification_needs**: Deduplicate similar questions
257
+
258
+ 3. **Write Merged Exploration**
259
+ Write to: ${sessionFolder}/exploration-merged.json
260
+
261
+ 4. **Output Clarification Questions**
262
+
263
+ Format:
264
+ \`\`\`
265
+ MERGED_EXPLORATION_COMPLETE
266
+
267
+ Files consolidated: [count]
268
+ Patterns identified: [count]
269
+ Integration points: [count]
270
+
271
+ CLARIFICATION_NEEDED:
272
+ Q1: [merged question] | Options: [A, B, C] | Recommended: [X] | Source: [angles]
273
+ Q2: [merged question] | Options: [A, B] | Recommended: [Y] | Source: [angles]
274
+ \`\`\`
275
+
276
+ If no clarification needed:
277
+ \`\`\`
278
+ CLARIFICATION_NEEDED: NONE
279
+
280
+ Ready for Phase 3 (Planning). Send clarification answers or "PROCEED_TO_PLANNING".
281
+ \`\`\`
282
+ `
283
+ })
284
+
285
+ // Step 6: Wait for merge result
286
+ const mergeResult = wait({ ids: [primaryAgent], timeout_ms: 300000 })
287
+ const mergeOutput = mergeResult.status[primaryAgent].completed
288
+
289
+ // Step 7: Handle clarification
290
+ let clarificationAnswers = null
291
+
292
+ if (mergeOutput.includes('CLARIFICATION_NEEDED:') && !mergeOutput.includes('CLARIFICATION_NEEDED: NONE')) {
293
+ const questions = parseClarificationQuestions(mergeOutput)
294
+
295
+ console.log(`
296
+ ## Clarification Needed (Merged from ${selectedAngles.length} angles)
297
+
298
+ ${questions.map((q, i) => `
299
+ ### Q${i+1}: ${q.question}
300
+ Options: ${q.options.join(', ')}
301
+ Recommended: ${q.recommended}
302
+ Source angles: ${q.source}
303
+ `).join('\n')}
304
+
305
+ **Please provide your answers...**
306
+ `)
307
+
308
+ clarificationAnswers = collectUserAnswers(questions)
309
+ }
310
+ ```
311
+
312
+ ---
313
+
314
+ ### Phase 3: Planning (Continue Reusing Primary Agent)
315
+
316
+ ```javascript
317
+ // Step 8: Send planning task
318
+ send_input({
319
+ id: primaryAgent,
320
+ message: `
321
+ ## PHASE 3: GENERATE PLAN
322
+
323
+ You are now in **Planner** role. Generate implementation plan based on merged explorations.
324
+
325
+ ${clarificationAnswers ? `
326
+ ### Clarification Answers
327
+ ${clarificationAnswers.map(a => `Q: ${a.question}\nA: ${a.answer}`).join('\n\n')}
328
+ ` : '### No clarification needed'}
329
+
330
+ ### Planning Instructions
331
+
332
+ 1. **Read Schema**
333
+ Execute: cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json
334
+
335
+ 2. **Read Merged Exploration**
336
+ Read: ${sessionFolder}/exploration-merged.json
337
+
338
+ 3. **Generate Plan**
339
+ Based on consolidated findings from ${selectedAngles.length} exploration angles:
340
+ - ${selectedAngles.join('\n - ')}
341
+
342
+ 4. **Plan Requirements**
343
+ - Summary: 2-3 sentence overview
344
+ - Approach: High-level strategy referencing multiple angles
345
+ - Tasks: 2-7 tasks grouped by feature (NOT by file)
346
+ - Each task: id, title, scope, action, description, modification_points, implementation, acceptance, depends_on
347
+ - Reference exploration angles in task descriptions
348
+
349
+ 5. **Task Grouping Rules**
350
+ - Group by feature: All changes for one feature = one task (even if spanning angles)
351
+ - Substantial tasks: 15-60 minutes each
352
+ - True dependencies only
353
+ - Prefer parallel execution
354
+
355
+ 6. **Write Output**
356
+ Write: ${sessionFolder}/plan.json
357
+
358
+ ### Metadata
359
+ Include in _metadata:
360
+ - exploration_angles: ${JSON.stringify(selectedAngles)}
361
+ - planning_mode: "merged-multi-angle"
362
+ - source_explorations: ${allExplorations.length}
363
+
364
+ ### Return
365
+ Brief completion summary
366
+ `
367
+ })
368
+
369
+ // Step 9: Wait for planning to complete
370
+ const planResult = wait({ ids: [primaryAgent], timeout_ms: 600000 })
371
+
372
+ // Step 10: Final cleanup
373
+ close_agent({ id: primaryAgent })
374
+ ```
375
+
376
+ ---
377
+
378
+ ### Phase 4: Confirmation
379
+
380
+ ```javascript
381
+ const plan = JSON.parse(Read(`${sessionFolder}/plan.json`))
382
+
383
+ console.log(`
384
+ ## Implementation Plan (Multi-Angle: ${selectedAngles.join(', ')})
385
+
386
+ **Summary**: ${plan.summary}
387
+ **Approach**: ${plan.approach}
388
+ **Complexity**: ${plan.complexity}
389
+
390
+ **Tasks** (${plan.tasks.length}):
391
+ ${plan.tasks.map((t, i) => `${i+1}. ${t.title} (${t.scope})`).join('\n')}
392
+
393
+ **Estimated Time**: ${plan.estimated_time}
394
+ **Exploration Angles**: ${plan._metadata.exploration_angles.join(', ')}
395
+
396
+ ---
397
+
398
+ ## Confirmation Required
399
+
400
+ Please review the plan above and reply with one of the following:
401
+
402
+ - **"Allow"** - Confirm and finalize plan.json
403
+ - **"Modify"** - Describe what changes you want to make
404
+ - **"Cancel"** - Abort the planning workflow
405
+
406
+ **WAITING FOR USER CONFIRMATION...**
407
+ `)
408
+ ```
409
+
410
+ ---
411
+
412
+ ## Codex vs Claude Comparison (for hybrid mode)
413
+
414
+ | Aspect | Claude Code Task | Codex Subagent (Plan-B) |
415
+ |--------|------------------|------------------------|
416
+ | **Creation** | `Task({ subagent_type, prompt })` | `spawn_agent({ message: role + task })` |
417
+ | **Role Loading** | Auto via `subagent_type` | Manual: Agent reads `~/.codex/agents/*.md` |
418
+ | **Parallel Wait** | Multiple `Task()` calls | **Batch `wait({ ids: [...] })`** |
419
+ | **Result Retrieval** | Sync return or `TaskOutput` | `wait({ ids }).status[id].completed` |
420
+ | **Agent Reuse** | `resume` parameter | **`send_input` to continue** |
421
+ | **Cleanup** | Automatic | **Explicit `close_agent({ id })`** |
422
+
423
+ **Plan-B Advantages**:
424
+ - True parallel exploration with batch `wait`
425
+ - Primary agent retains context across all phases
426
+ - Fine-grained lifecycle control
427
+
428
+ ---
429
+
430
+ ## Agent Lifecycle Comparison
431
+
432
+ ```
433
+ Traditional Mode:
434
+ Agent 1 ──────● close
435
+ Agent 2 ──────● close
436
+ Agent 3 ──────● close
437
+ Agent 4 ──────● close
438
+ Planning Agent ────────────● close
439
+
440
+ Plan-B Hybrid Mode:
441
+ Agent 0 ─────────────────────────────────● close (reused until end)
442
+ Agent 1 ──────● close
443
+ Agent 2 ──────● close
444
+ Agent 3 ──────● close
445
+ ↑ ↑ ↑
446
+ Phase1 Phase2 Phase3
447
+ (parallel) (merge+clarify) (planning)
448
+ ```
449
+
450
+ ---
451
+
452
+ ## Session Folder Structure
453
+
454
+ ```
455
+ .workflow/.lite-plan/{task-slug}-{YYYY-MM-DD}/
456
+ ├── exploration-architecture.json # Angle 1 (primary agent)
457
+ ├── exploration-patterns.json # Angle 2
458
+ ├── exploration-testing.json # Angle 3
459
+ ├── exploration-dependencies.json # Angle 4
460
+ ├── exploration-merged.json # Merged by primary agent
461
+ └── plan.json # Final plan
462
+ ```
463
+
464
+ ## Workflow States
465
+
466
+ | State | Action | Next |
467
+ |-------|--------|------|
468
+ | Phase 1 Complete | All explorations done | → Phase 2 (Merge) |
469
+ | Phase 2 Output | Merged + questions | → Wait for user reply |
470
+ | User Replied | Answers received | → send_input to Phase 3 |
471
+ | Phase 3 Output | Plan generated | → Phase 4 (Confirmation) |
472
+ | User: "Allow" | Confirmed | → Output complete |
473
+ | User: "Modify" | Changes requested | → send_input with revisions |
474
+ | User: "Cancel" | Aborted | → close all agents, end workflow |
475
+
476
+ ## Error Handling
477
+
478
+ | Error | Resolution |
479
+ |-------|------------|
480
+ | Partial exploration timeout | Use completed results, note missing angles in merge |
481
+ | Primary agent unexpectedly closed | Re-spawn, paste existing exploration results in message |
482
+ | Merge phase timeout | send_input to request current merge progress |
483
+ | Planning phase timeout | send_input requesting partial plan output |
484
+
485
+ **Execute task**: $TASK