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
@@ -1,469 +1,601 @@
1
- ---
2
- description: Lightweight interactive planning workflow with direct exploration, outputs plan.json after user confirmation
3
- argument-hint: TASK="<task description or file.md path>" [EXPLORE="true"]
4
- ---
5
-
6
- # Workflow Lite-Plan Command
7
-
8
- ## Overview
9
-
10
- Intelligent lightweight planning command with dynamic workflow adaptation based on task complexity. Focuses on planning phases (exploration, clarification, planning, confirmation) and outputs plan.json for subsequent execution.
11
-
12
- **Core capabilities:**
13
- - Intelligent task analysis with automatic exploration detection
14
- - Direct code exploration (grep, find, file reading) when codebase understanding needed
15
- - Interactive clarification after exploration to gather missing information
16
- - Adaptive planning strategy based on complexity
17
- - Two-step confirmation: plan display → user approval
18
- - Outputs plan.json file after user confirmation
19
-
20
- ## Task Description
21
-
22
- **Target task**: $TASK
23
- **Force exploration**: $EXPLORE
24
-
25
- ## Execution Process
26
-
27
- ```
28
- Phase 1: Task Analysis & Exploration
29
- ├─ Parse input (description or .md file)
30
- ├─ Intelligent complexity assessment (Low/Medium/High)
31
- ├─ Exploration decision (auto-detect or EXPLORE="true")
32
- └─ Decision:
33
- ├─ needsExploration=true → Direct exploration using grep/find/read
34
- └─ needsExploration=false → Skip to Phase 2/3
35
-
36
- Phase 2: Clarification (optional)
37
- ├─ Aggregate clarification needs from exploration
38
- ├─ Output questions to user
39
- └─ STOP and wait for user reply
40
-
41
- Phase 3: Planning (NO CODE EXECUTION - planning only)
42
- └─ Generate plan.json following schema
43
- └─ MUST proceed to Phase 4
44
-
45
- Phase 4: Confirmation
46
- ├─ Display plan summary (tasks, complexity, estimated time)
47
- ├─ Output confirmation request
48
- └─ STOP and wait for user approval
49
-
50
- Phase 5: Output
51
- └─ Write plan.json to session folder
52
- ```
53
-
54
- ## Implementation
55
-
56
- ### Phase 1: Intelligent Direct Exploration
57
-
58
- **Session Setup** (MANDATORY - follow exactly):
59
- ```javascript
60
- // Helper: Get UTC+8 (China Standard Time) ISO string
61
- const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
62
-
63
- const taskSlug = "$TASK".toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 40)
64
- const dateStr = getUtc8ISOString().substring(0, 10) // Format: 2025-11-29
65
-
66
- const sessionId = `${taskSlug}-${dateStr}` // e.g., "implement-jwt-refresh-2025-11-29"
67
- const sessionFolder = `.workflow/.lite-plan/${sessionId}`
68
-
69
- // Create session folder
70
- mkdir -p ${sessionFolder}
71
- ```
72
-
73
- **Exploration Decision Logic**:
74
- ```javascript
75
- needsExploration = (
76
- "$EXPLORE" === "true" ||
77
- task.mentions_specific_files ||
78
- task.requires_codebase_context ||
79
- task.needs_architecture_understanding ||
80
- task.modifies_existing_code
81
- )
82
-
83
- if (!needsExploration) {
84
- // Skip to Phase 2 (Clarification) or Phase 3 (Planning)
85
- proceed_to_next_phase()
86
- }
87
- ```
88
-
89
- **Complexity Assessment** (Intelligent Analysis):
90
- ```javascript
91
- // Analyzes task complexity based on:
92
- // - Scope: How many systems/modules are affected?
93
- // - Depth: Surface change vs architectural impact?
94
- // - Risk: Potential for breaking existing functionality?
95
- // - Dependencies: How interconnected is the change?
96
-
97
- const complexity = analyzeTaskComplexity("$TASK")
98
- // Returns: 'Low' | 'Medium' | 'High'
99
- // Low: Single file, isolated change, minimal risk
100
- // Medium: Multiple files, some dependencies, moderate risk
101
- // High: Cross-module, architectural, high risk
102
-
103
- // Angle assignment based on task type
104
- const ANGLE_PRESETS = {
105
- architecture: ['architecture', 'dependencies', 'modularity', 'integration-points'],
106
- security: ['security', 'auth-patterns', 'dataflow', 'validation'],
107
- performance: ['performance', 'bottlenecks', 'caching', 'data-access'],
108
- bugfix: ['error-handling', 'dataflow', 'state-management', 'edge-cases'],
109
- feature: ['patterns', 'integration-points', 'testing', 'dependencies']
110
- }
111
-
112
- function selectAngles(taskDescription, count) {
113
- const text = taskDescription.toLowerCase()
114
- let preset = 'feature' // default
115
-
116
- if (/refactor|architect|restructure|modular/.test(text)) preset = 'architecture'
117
- else if (/security|auth|permission|access/.test(text)) preset = 'security'
118
- else if (/performance|slow|optimi|cache/.test(text)) preset = 'performance'
119
- else if (/fix|bug|error|issue|broken/.test(text)) preset = 'bugfix'
120
-
121
- return ANGLE_PRESETS[preset].slice(0, count)
122
- }
123
-
124
- const selectedAngles = selectAngles("$TASK", complexity === 'High' ? 4 : (complexity === 'Medium' ? 3 : 1))
125
-
126
- console.log(`
127
- ## Exploration Plan
128
-
129
- Task Complexity: ${complexity}
130
- Selected Angles: ${selectedAngles.join(', ')}
131
-
132
- Starting direct exploration...
133
- `)
134
- ```
135
-
136
- **Direct Exploration** (No Agent - Use grep/find/read directly):
137
-
138
- ```javascript
139
- // For each selected angle, perform direct exploration
140
-
141
- selectedAngles.forEach((angle, index) => {
142
- console.log(`\n### Exploring: ${angle} (${index + 1}/${selectedAngles.length})`)
143
-
144
- // Step 1: Structural Scan
145
- // - Find relevant files using grep/rg
146
- // - Analyze directory structure
147
- // - Identify modules related to the angle
148
-
149
- // Example commands:
150
- // rg -l "keyword_from_task" --type ts
151
- // find . -name "*.ts" -path "*auth*"
152
- // tree -L 3 src/
153
-
154
- // Step 2: Content Analysis
155
- // - Read key files identified
156
- // - Analyze patterns and conventions
157
- // - Identify integration points
158
-
159
- // Step 3: Document Findings
160
- const explorationResult = {
161
- angle: angle,
162
- project_structure: [], // Modules/architecture relevant to angle
163
- relevant_files: [], // Files affected from angle perspective
164
- patterns: [], // Angle-related patterns to follow
165
- dependencies: [], // Dependencies relevant to angle
166
- integration_points: [], // Where to integrate from angle viewpoint
167
- constraints: [], // Angle-specific limitations/conventions
168
- clarification_needs: [], // Angle-related ambiguities
169
- _metadata: {
170
- exploration_angle: angle,
171
- exploration_index: index + 1,
172
- timestamp: getUtc8ISOString()
173
- }
174
- }
175
-
176
- // Write exploration result
177
- Write(`${sessionFolder}/exploration-${angle}.json`, JSON.stringify(explorationResult, null, 2))
178
- })
179
- ```
180
-
181
- **Build Exploration Manifest**:
182
- ```javascript
183
- // After all explorations complete, build manifest
184
- const explorationFiles = find(`${sessionFolder}`, "-name", "exploration-*.json")
185
-
186
- const explorationManifest = {
187
- session_id: sessionId,
188
- task_description: "$TASK",
189
- timestamp: getUtc8ISOString(),
190
- complexity: complexity,
191
- exploration_count: selectedAngles.length,
192
- explorations: explorationFiles.map(file => {
193
- const data = JSON.parse(Read(file))
194
- return {
195
- angle: data._metadata.exploration_angle,
196
- file: path.basename(file),
197
- path: file,
198
- index: data._metadata.exploration_index
199
- }
200
- })
201
- }
202
-
203
- Write(`${sessionFolder}/explorations-manifest.json`, JSON.stringify(explorationManifest, null, 2))
204
-
205
- console.log(`
206
- ## Exploration Complete
207
-
208
- Generated exploration files in ${sessionFolder}:
209
- ${explorationManifest.explorations.map(e => `- exploration-${e.angle}.json (angle: ${e.angle})`).join('\n')}
210
-
211
- Manifest: explorations-manifest.json
212
- Angles explored: ${explorationManifest.explorations.map(e => e.angle).join(', ')}
213
- `)
214
- ```
215
-
216
- **Output**:
217
- - `${sessionFolder}/exploration-{angle1}.json`
218
- - `${sessionFolder}/exploration-{angle2}.json`
219
- - ... (1-4 files based on complexity)
220
- - `${sessionFolder}/explorations-manifest.json`
221
-
222
- ---
223
-
224
- ### Phase 2: Clarification (Optional)
225
-
226
- **Skip if**: No exploration or `clarification_needs` is empty across all explorations
227
-
228
- **Aggregate clarification needs from all exploration angles**:
229
- ```javascript
230
- // Load manifest and all exploration files
231
- const manifest = JSON.parse(Read(`${sessionFolder}/explorations-manifest.json`))
232
- const explorations = manifest.explorations.map(exp => ({
233
- angle: exp.angle,
234
- data: JSON.parse(Read(exp.path))
235
- }))
236
-
237
- // Aggregate clarification needs from all explorations
238
- const allClarifications = []
239
- explorations.forEach(exp => {
240
- if (exp.data.clarification_needs?.length > 0) {
241
- exp.data.clarification_needs.forEach(need => {
242
- allClarifications.push({
243
- ...need,
244
- source_angle: exp.angle
245
- })
246
- })
247
- }
248
- })
249
-
250
- // Intelligent deduplication: analyze allClarifications by intent
251
- // - Identify questions with similar intent across different angles
252
- // - Merge similar questions: combine options, consolidate context
253
- // - Produce dedupedClarifications with unique intents only
254
- const dedupedClarifications = intelligentMerge(allClarifications)
255
- ```
256
-
257
- **Output Questions and Wait for User Reply**:
258
- ```javascript
259
- if (dedupedClarifications.length > 0) {
260
- console.log(`
261
- ## Clarification Needed
262
-
263
- Based on exploration, the following questions need your input:
264
-
265
- ${dedupedClarifications.map((need, index) => `
266
- ### Question ${index + 1}: [${need.source_angle}]
267
-
268
- **${need.question}**
269
-
270
- Context: ${need.context}
271
-
272
- Options:
273
- ${need.options.map((opt, i) => ` ${i + 1}. ${opt}${need.recommended === i ? ' ★ (Recommended)' : ''}`).join('\n')}
274
- `).join('\n')}
275
-
276
- ---
277
-
278
- **Please reply with your choices** (e.g., "Q1: 2, Q2: 1, Q3: 3") to continue planning.
279
-
280
- **WAITING FOR USER INPUT...**
281
- `)
282
-
283
- // STOP HERE - Wait for user reply before continuing to Phase 3
284
- return
285
- }
286
- ```
287
-
288
- **After User Reply**: Store responses in `clarificationContext` and proceed to Phase 3.
289
-
290
- ---
291
-
292
- ### Phase 3: Planning
293
-
294
- **IMPORTANT**: Phase 3 is **planning only** - NO code execution.
295
-
296
- **Read Schema**:
297
- ```javascript
298
- // Read plan schema for reference
299
- const schema = Read("~/.claude/workflows/cli-templates/schemas/plan-json-schema.json")
300
- ```
301
-
302
- **Read All Exploration Files**:
303
- ```javascript
304
- // MANDATORY - Read and review ALL exploration files
305
- const manifest = JSON.parse(Read(`${sessionFolder}/explorations-manifest.json`))
306
- manifest.explorations.forEach(exp => {
307
- const explorationData = Read(exp.path)
308
- console.log(`\n### Exploration: ${exp.angle}\n${explorationData}`)
309
- })
310
- ```
311
-
312
- **Generate Plan**:
313
- ```javascript
314
- // Generate plan following schema
315
- // Plan MUST incorporate insights from exploration files
316
- const plan = {
317
- summary: "Brief description of what will be implemented",
318
- approach: "High-level approach and strategy",
319
- tasks: [
320
- // Each task: { id, title, description, scope, files, depends_on, execution_group, complexity }
321
- // Group by feature/module, NOT by file
322
- // 2-7 tasks recommended
323
- ],
324
- estimated_time: "Total estimated time",
325
- complexity: complexity, // Low | Medium | High
326
- _metadata: {
327
- timestamp: getUtc8ISOString(),
328
- source: "lite-plan",
329
- planning_mode: "direct",
330
- exploration_angles: manifest.explorations.map(e => e.angle)
331
- }
332
- }
333
- ```
334
-
335
- **Task Grouping Rules**:
336
- 1. **Group by feature**: All changes for one feature = one task (even if 3-5 files)
337
- 2. **Group by context**: Tasks with similar context or related functional changes can be grouped together
338
- 3. **Minimize task count**: Simple, unrelated tasks can also be grouped to reduce overhead
339
- 4. **Avoid file-per-task**: Do NOT create separate tasks for each file
340
- 5. **Substantial tasks**: Each task should represent 15-60 minutes of work
341
- 6. **True dependencies only**: Only use depends_on when Task B cannot start without Task A's output
342
- 7. **Prefer parallel**: Most tasks should be independent (no depends_on)
343
-
344
- **Proceed to Phase 4** - DO NOT execute code here.
345
-
346
- ---
347
-
348
- ### Phase 4: Task Confirmation
349
-
350
- **Display Plan Summary**:
351
- ```javascript
352
- const plan = JSON.parse(Read(`${sessionFolder}/plan.json`))
353
-
354
- console.log(`
355
- ## Implementation Plan
356
-
357
- **Summary**: ${plan.summary}
358
- **Approach**: ${plan.approach}
359
-
360
- **Tasks** (${plan.tasks.length}):
361
- ${plan.tasks.map((t, i) => `
362
- ### Task ${i+1}: ${t.title}
363
- - **Description**: ${t.description}
364
- - **Scope**: ${t.scope}
365
- - **Files**: ${t.files.join(', ')}
366
- - **Complexity**: ${t.complexity}
367
- - **Dependencies**: ${t.depends_on?.join(', ') || 'None'}
368
- `).join('\n')}
369
-
370
- **Overall Complexity**: ${plan.complexity}
371
- **Estimated Time**: ${plan.estimated_time}
372
-
373
- ---
374
-
375
- ## Confirmation Required
376
-
377
- Please review the plan above and reply with one of the following:
378
-
379
- - **"Allow"** - Proceed with this plan, output plan.json
380
- - **"Modify"** - Describe what changes you want to make
381
- - **"Cancel"** - Abort the planning workflow
382
-
383
- **WAITING FOR USER CONFIRMATION...**
384
- `)
385
-
386
- // STOP HERE - Wait for user confirmation before writing plan.json
387
- return
388
- ```
389
-
390
- ---
391
-
392
- ### Phase 5: Output Plan File
393
-
394
- **After User Confirms "Allow"**:
395
- ```javascript
396
- // Write final plan.json to session folder
397
- Write(`${sessionFolder}/plan.json`, JSON.stringify(plan, null, 2))
398
-
399
- console.log(`
400
- ## Plan Output Complete
401
-
402
- **Plan file written**: ${sessionFolder}/plan.json
403
-
404
- **Session folder**: ${sessionFolder}
405
-
406
- **Contents**:
407
- - explorations-manifest.json
408
- ${manifest.explorations.map(e => `- exploration-${e.angle}.json`).join('\n')}
409
- - plan.json
410
-
411
- ---
412
-
413
- You can now use this plan with your preferred execution method:
414
- - Manual implementation following the tasks
415
- - Pass to another tool/agent for execution
416
- - Import into project management system
417
- `)
418
- ```
419
-
420
- ---
421
-
422
- ## Session Folder Structure
423
-
424
- ```
425
- .workflow/.lite-plan/{task-slug}-{YYYY-MM-DD}/
426
- ├── exploration-{angle1}.json # Exploration angle 1
427
- ├── exploration-{angle2}.json # Exploration angle 2
428
- ├── exploration-{angle3}.json # Exploration angle 3 (if applicable)
429
- ├── exploration-{angle4}.json # Exploration angle 4 (if applicable)
430
- ├── explorations-manifest.json # Exploration index
431
- └── plan.json # Implementation plan (after confirmation)
432
- ```
433
-
434
- **Example**:
435
- ```
436
- .workflow/.lite-plan/implement-jwt-refresh-2025-11-25/
437
- ├── exploration-architecture.json
438
- ├── exploration-auth-patterns.json
439
- ├── exploration-security.json
440
- ├── explorations-manifest.json
441
- └── plan.json
442
- ```
443
-
444
- ## Workflow States
445
-
446
- | State | Action | Next |
447
- |-------|--------|------|
448
- | Phase 1 Complete | Exploration done | → Phase 2 or 3 |
449
- | Phase 2 Output | Questions displayed | → Wait for user reply |
450
- | User Replied | Clarifications received | → Phase 3 |
451
- | Phase 3 Complete | Plan generated | → Phase 4 |
452
- | Phase 4 Output | Plan displayed | → Wait for user confirmation |
453
- | User: "Allow" | Confirmed | → Phase 5 (Write plan.json) |
454
- | User: "Modify" | Changes requested | → Revise plan, back to Phase 4 |
455
- | User: "Cancel" | Aborted | → End workflow |
456
-
457
- ## Error Handling
458
-
459
- | Error | Resolution |
460
- |-------|------------|
461
- | Exploration failure | Skip exploration, continue with task description only |
462
- | No relevant files found | Broaden search scope or proceed with minimal context |
463
- | Clarification timeout | Use exploration findings as-is |
464
- | Confirmation timeout | Save context, display resume instructions |
465
- | Modify loop > 3 times | Suggest breaking task into smaller pieces |
466
-
467
- ---
468
-
469
- **Now execute the lite-plan workflow for task**: $TASK
1
+ ---
2
+ description: Lightweight interactive planning workflow with Codex subagent orchestration, outputs plan.json after user confirmation
3
+ argument-hint: TASK="<task description or file.md path>" [EXPLORE="true"]
4
+ ---
5
+
6
+ # Workflow Lite-Plan Command (Codex Subagent Version)
7
+
8
+ ## Overview
9
+
10
+ Intelligent lightweight planning command with dynamic workflow adaptation based on task complexity. Uses Codex subagent API for parallel exploration and planning phases.
11
+
12
+ **Core capabilities:**
13
+ - Intelligent task analysis with automatic exploration detection
14
+ - **Parallel code exploration via Codex subagents** (spawn_agent + batch wait)
15
+ - Interactive clarification after exploration to gather missing information
16
+ - Adaptive planning: Low complexity Direct; Medium/High → cli-lite-planning-agent subagent
17
+ - Two-step confirmation: plan display → user approval
18
+ - Outputs plan.json file after user confirmation
19
+
20
+ ## Task Description
21
+
22
+ **Target task**: $TASK
23
+ **Force exploration**: $EXPLORE
24
+
25
+ ## Execution Process
26
+
27
+ ```
28
+ Phase 1: Task Analysis & Exploration (Subagent Orchestration)
29
+ ├─ Parse input (description or .md file)
30
+ ├─ Intelligent complexity assessment (Low/Medium/High)
31
+ ├─ Exploration decision (auto-detect or EXPLORE="true")
32
+ └─ Decision:
33
+ ├─ needsExploration=true → Spawn parallel cli-explore-agent subagents
34
+ └─ needsExploration=false → Skip to Phase 2/3
35
+
36
+ Phase 2: Clarification (optional)
37
+ ├─ Aggregate clarification needs from exploration results
38
+ ├─ Output questions to user
39
+ └─ STOP and wait for user reply
40
+
41
+ Phase 3: Planning (NO CODE EXECUTION - planning only)
42
+ └─ Decision (based on complexity):
43
+ ├─ Low Direct planning following schema
44
+ └─ Medium/High → Spawn cli-lite-planning-agent subagent → plan.json
45
+
46
+ Phase 4: Confirmation
47
+ ├─ Display plan summary (tasks, complexity, estimated time)
48
+ ├─ Output confirmation request
49
+ └─ STOP and wait for user approval
50
+
51
+ Phase 5: Output
52
+ └─ Write plan.json to session folder
53
+ ```
54
+
55
+ ## Implementation
56
+
57
+ ### Phase 1: Intelligent Multi-Angle Exploration (Subagent Orchestration)
58
+
59
+ **Session Setup** (MANDATORY - follow exactly):
60
+ ```javascript
61
+ // Helper: Get UTC+8 (China Standard Time) ISO string
62
+ const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
63
+
64
+ const taskSlug = "$TASK".toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 40)
65
+ const dateStr = getUtc8ISOString().substring(0, 10) // Format: 2025-11-29
66
+
67
+ const sessionId = `${taskSlug}-${dateStr}` // e.g., "implement-jwt-refresh-2025-11-29"
68
+ const sessionFolder = `.workflow/.lite-plan/${sessionId}`
69
+
70
+ // Create session folder
71
+ mkdir -p ${sessionFolder}
72
+ ```
73
+
74
+ **Exploration Decision Logic**:
75
+ ```javascript
76
+ needsExploration = (
77
+ "$EXPLORE" === "true" ||
78
+ task.mentions_specific_files ||
79
+ task.requires_codebase_context ||
80
+ task.needs_architecture_understanding ||
81
+ task.modifies_existing_code
82
+ )
83
+
84
+ if (!needsExploration) {
85
+ // Skip to Phase 2 (Clarification) or Phase 3 (Planning)
86
+ proceed_to_next_phase()
87
+ }
88
+ ```
89
+
90
+ **Context Protection**: File reading >=50k chars → force `needsExploration=true`
91
+
92
+ **Complexity Assessment** (Intelligent Analysis):
93
+ ```javascript
94
+ // Analyzes task complexity based on:
95
+ // - Scope: How many systems/modules are affected?
96
+ // - Depth: Surface change vs architectural impact?
97
+ // - Risk: Potential for breaking existing functionality?
98
+ // - Dependencies: How interconnected is the change?
99
+
100
+ const complexity = analyzeTaskComplexity("$TASK")
101
+ // Returns: 'Low' | 'Medium' | 'High'
102
+
103
+ // Angle assignment based on task type
104
+ const ANGLE_PRESETS = {
105
+ architecture: ['architecture', 'dependencies', 'modularity', 'integration-points'],
106
+ security: ['security', 'auth-patterns', 'dataflow', 'validation'],
107
+ performance: ['performance', 'bottlenecks', 'caching', 'data-access'],
108
+ bugfix: ['error-handling', 'dataflow', 'state-management', 'edge-cases'],
109
+ feature: ['patterns', 'integration-points', 'testing', 'dependencies']
110
+ }
111
+
112
+ function selectAngles(taskDescription, count) {
113
+ const text = taskDescription.toLowerCase()
114
+ let preset = 'feature' // default
115
+
116
+ if (/refactor|architect|restructure|modular/.test(text)) preset = 'architecture'
117
+ else if (/security|auth|permission|access/.test(text)) preset = 'security'
118
+ else if (/performance|slow|optimi|cache/.test(text)) preset = 'performance'
119
+ else if (/fix|bug|error|issue|broken/.test(text)) preset = 'bugfix'
120
+
121
+ return ANGLE_PRESETS[preset].slice(0, count)
122
+ }
123
+
124
+ const selectedAngles = selectAngles("$TASK", complexity === 'High' ? 4 : (complexity === 'Medium' ? 3 : 1))
125
+
126
+ console.log(`
127
+ ## Exploration Plan
128
+
129
+ Task Complexity: ${complexity}
130
+ Selected Angles: ${selectedAngles.join(', ')}
131
+
132
+ Launching ${selectedAngles.length} parallel subagent explorations...
133
+ `)
134
+ ```
135
+
136
+ **Launch Parallel Exploration Subagents** (Codex Pattern):
137
+
138
+ ```javascript
139
+ // ==================== CODEX SUBAGENT PATTERN ====================
140
+
141
+ // Step 1: Spawn parallel exploration subagents (角色文件由 agent 自己读取)
142
+ const explorationAgents = selectedAngles.map((angle, index) => {
143
+ return spawn_agent({
144
+ message: `
145
+ ## TASK ASSIGNMENT
146
+
147
+ ### Task Objective
148
+ Execute **${angle}** exploration for task planning context. Analyze codebase from this specific angle to discover relevant structure, patterns, and constraints.
149
+
150
+ ### Assigned Context
151
+ - **Exploration Angle**: ${angle}
152
+ - **Task Description**: $TASK
153
+ - **Exploration Index**: ${index + 1} of ${selectedAngles.length}
154
+ - **Output File**: ${sessionFolder}/exploration-${angle}.json
155
+
156
+ ### MANDATORY FIRST STEPS (Agent Execute)
157
+ 1. **Read role definition**: ~/.codex/agents/cli-explore-agent.md (MUST read first)
158
+ 2. Run: ccw tool exec get_modules_by_depth '{}' (project structure)
159
+ 3. Run: rg -l "{keyword_from_task}" --type ts (locate relevant files)
160
+ 4. Execute: cat ~/.claude/workflows/cli-templates/schemas/explore-json-schema.json (get output schema reference)
161
+ 5. Read: .workflow/project-tech.json (technology stack and architecture context)
162
+ 6. Read: .workflow/project-guidelines.json (user-defined constraints and conventions)
163
+
164
+ ### Exploration Strategy (${angle} focus)
165
+
166
+ **Step 1: Structural Scan** (Bash)
167
+ - get_modules_by_depth.sh identify modules related to ${angle}
168
+ - find/rg locate files relevant to ${angle} aspect
169
+ - Analyze imports/dependencies from ${angle} perspective
170
+
171
+ **Step 2: Semantic Analysis** (Gemini CLI)
172
+ - How does existing code handle ${angle} concerns?
173
+ - What patterns are used for ${angle}?
174
+ - Where would new code integrate from ${angle} viewpoint?
175
+
176
+ **Step 3: Write Output**
177
+ - Consolidate ${angle} findings into JSON
178
+ - Identify ${angle}-specific clarification needs
179
+
180
+ ### Expected Output
181
+
182
+ **File**: ${sessionFolder}/exploration-${angle}.json
183
+
184
+ **Schema Reference**: Schema obtained in MANDATORY FIRST STEPS step 3, follow schema exactly
185
+
186
+ **Required Fields** (all ${angle} focused):
187
+ - project_structure: Modules/architecture relevant to ${angle}
188
+ - relevant_files: Files affected from ${angle} perspective
189
+ **IMPORTANT**: Use object format with relevance scores:
190
+ \`[{path: "src/file.ts", relevance: 0.85, rationale: "Core ${angle} logic"}]\`
191
+ - patterns: ${angle}-related patterns to follow
192
+ - dependencies: Dependencies relevant to ${angle}
193
+ - integration_points: Where to integrate from ${angle} viewpoint (include file:line locations)
194
+ - constraints: ${angle}-specific limitations/conventions
195
+ - clarification_needs: ${angle}-related ambiguities (options array + recommended index)
196
+ - _metadata.exploration_angle: "${angle}"
197
+
198
+ ### Success Criteria
199
+ - [ ] Schema obtained via cat explore-json-schema.json
200
+ - [ ] get_modules_by_depth.sh executed
201
+ - [ ] At least 3 relevant files identified with ${angle} rationale
202
+ - [ ] Patterns are actionable (code examples, not generic advice)
203
+ - [ ] Integration points include file:line locations
204
+ - [ ] JSON output follows schema exactly
205
+ - [ ] clarification_needs includes options + recommended
206
+
207
+ ### Deliverables
208
+ Write: ${sessionFolder}/exploration-${angle}.json
209
+ Return: 2-3 sentence summary of ${angle} findings
210
+ `
211
+ })
212
+ })
213
+
214
+ // Step 3: Batch wait for ALL exploration subagents (KEY ADVANTAGE of Codex)
215
+ const explorationResults = wait({
216
+ ids: explorationAgents,
217
+ timeout_ms: 600000 // 10 minutes
218
+ })
219
+
220
+ // Step 4: Handle timeout
221
+ if (explorationResults.timed_out) {
222
+ console.log('部分探索超时,继续使用已完成结果')
223
+ }
224
+
225
+ // Step 5: Collect results from completed agents
226
+ const completedExplorations = {}
227
+ explorationAgents.forEach((agentId, index) => {
228
+ const angle = selectedAngles[index]
229
+ if (explorationResults.status[agentId].completed) {
230
+ completedExplorations[angle] = explorationResults.status[agentId].completed
231
+ }
232
+ })
233
+
234
+ // Step 6: Cleanup - close all exploration agents
235
+ explorationAgents.forEach(id => close_agent({ id }))
236
+ ```
237
+
238
+ **Build Exploration Manifest**:
239
+ ```javascript
240
+ // After all explorations complete, auto-discover all exploration-*.json files
241
+ const explorationFiles = find(`${sessionFolder}`, "-name", "exploration-*.json")
242
+
243
+ const explorationManifest = {
244
+ session_id: sessionId,
245
+ task_description: "$TASK",
246
+ timestamp: getUtc8ISOString(),
247
+ complexity: complexity,
248
+ exploration_count: selectedAngles.length,
249
+ explorations: explorationFiles.map(file => {
250
+ const data = JSON.parse(Read(file))
251
+ return {
252
+ angle: data._metadata.exploration_angle,
253
+ file: path.basename(file),
254
+ path: file,
255
+ index: data._metadata.exploration_index
256
+ }
257
+ })
258
+ }
259
+
260
+ Write(`${sessionFolder}/explorations-manifest.json`, JSON.stringify(explorationManifest, null, 2))
261
+
262
+ console.log(`
263
+ ## Exploration Complete
264
+
265
+ Generated exploration files in ${sessionFolder}:
266
+ ${explorationManifest.explorations.map(e => `- exploration-${e.angle}.json (angle: ${e.angle})`).join('\n')}
267
+
268
+ Manifest: explorations-manifest.json
269
+ Angles explored: ${explorationManifest.explorations.map(e => e.angle).join(', ')}
270
+ `)
271
+ ```
272
+
273
+ **Output**:
274
+ - `${sessionFolder}/exploration-{angle1}.json`
275
+ - `${sessionFolder}/exploration-{angle2}.json`
276
+ - ... (1-4 files based on complexity)
277
+ - `${sessionFolder}/explorations-manifest.json`
278
+
279
+ ---
280
+
281
+ ### Phase 2: Clarification (Optional)
282
+
283
+ **Skip if**: No exploration or `clarification_needs` is empty across all explorations
284
+
285
+ **Aggregate clarification needs from all exploration angles**:
286
+ ```javascript
287
+ // Load manifest and all exploration files
288
+ const manifest = JSON.parse(Read(`${sessionFolder}/explorations-manifest.json`))
289
+ const explorations = manifest.explorations.map(exp => ({
290
+ angle: exp.angle,
291
+ data: JSON.parse(Read(exp.path))
292
+ }))
293
+
294
+ // Aggregate clarification needs from all explorations
295
+ const allClarifications = []
296
+ explorations.forEach(exp => {
297
+ if (exp.data.clarification_needs?.length > 0) {
298
+ exp.data.clarification_needs.forEach(need => {
299
+ allClarifications.push({
300
+ ...need,
301
+ source_angle: exp.angle
302
+ })
303
+ })
304
+ }
305
+ })
306
+
307
+ // Intelligent deduplication: analyze allClarifications by intent
308
+ const dedupedClarifications = intelligentMerge(allClarifications)
309
+ ```
310
+
311
+ **Output Questions and Wait for User Reply**:
312
+ ```javascript
313
+ if (dedupedClarifications.length > 0) {
314
+ console.log(`
315
+ ## Clarification Needed
316
+
317
+ Based on exploration, the following questions need your input:
318
+
319
+ ${dedupedClarifications.map((need, index) => `
320
+ ### Question ${index + 1}: [${need.source_angle}]
321
+
322
+ **${need.question}**
323
+
324
+ Context: ${need.context}
325
+
326
+ Options:
327
+ ${need.options.map((opt, i) => ` ${i + 1}. ${opt}${need.recommended === i ? ' ★ (Recommended)' : ''}`).join('\n')}
328
+ `).join('\n')}
329
+
330
+ ---
331
+
332
+ **Please reply with your choices** (e.g., "Q1: 2, Q2: 1, Q3: 3") to continue planning.
333
+
334
+ **WAITING FOR USER INPUT...**
335
+ `)
336
+
337
+ // STOP HERE - Wait for user reply before continuing to Phase 3
338
+ return
339
+ }
340
+ ```
341
+
342
+ **After User Reply**: Store responses in `clarificationContext` and proceed to Phase 3.
343
+
344
+ ---
345
+
346
+ ### Phase 3: Planning
347
+
348
+ **IMPORTANT**: Phase 3 is **planning only** - NO code execution.
349
+
350
+ **Planning Strategy Selection** (based on Phase 1 complexity):
351
+
352
+ **Low Complexity** - Direct Planning:
353
+ ```javascript
354
+ // Step 1: Read schema
355
+ const schema = Read("~/.claude/workflows/cli-templates/schemas/plan-json-schema.json")
356
+
357
+ // Step 2: Read all exploration files for context
358
+ const manifest = JSON.parse(Read(`${sessionFolder}/explorations-manifest.json`))
359
+ manifest.explorations.forEach(exp => {
360
+ const explorationData = Read(exp.path)
361
+ console.log(`\n### Exploration: ${exp.angle}\n${explorationData}`)
362
+ })
363
+
364
+ // Step 3: Generate plan following schema (direct, no subagent)
365
+ const plan = {
366
+ summary: "Brief description of what will be implemented",
367
+ approach: "High-level approach and strategy",
368
+ tasks: [
369
+ // Each task: { id, title, description, scope, files, depends_on, execution_group, complexity }
370
+ // Group by feature/module, NOT by file
371
+ // 2-7 tasks recommended
372
+ ],
373
+ estimated_time: "Total estimated time",
374
+ complexity: complexity,
375
+ _metadata: {
376
+ timestamp: getUtc8ISOString(),
377
+ source: "lite-plan",
378
+ planning_mode: "direct",
379
+ exploration_angles: manifest.explorations.map(e => e.angle)
380
+ }
381
+ }
382
+
383
+ // Step 4: Write plan
384
+ Write(`${sessionFolder}/plan.json`, JSON.stringify(plan, null, 2))
385
+
386
+ // Step 5: Proceed to Phase 4 (Confirmation)
387
+ ```
388
+
389
+ **Medium/High Complexity** - Spawn cli-lite-planning-agent Subagent:
390
+
391
+ ```javascript
392
+ // ==================== CODEX SUBAGENT PATTERN ====================
393
+
394
+ // Step 1: Create planning subagent (角色文件由 agent 自己读取)
395
+ const planningAgent = spawn_agent({
396
+ message: `
397
+ ## TASK ASSIGNMENT
398
+
399
+ ### Objective
400
+ Generate implementation plan and write plan.json.
401
+
402
+ ### MANDATORY FIRST STEPS (Agent Execute)
403
+ 1. **Read role definition**: ~/.codex/agents/cli-lite-planning-agent.md (MUST read first)
404
+ 2. Execute: cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json (get schema reference)
405
+ 3. Read: .workflow/project-tech.json (technology stack, architecture, key components)
406
+ 4. Read: .workflow/project-guidelines.json (user-defined constraints and conventions)
407
+
408
+ **CRITICAL**: All generated tasks MUST comply with constraints in project-guidelines.json
409
+
410
+ ### Task Description
411
+ $TASK
412
+
413
+ ### Multi-Angle Exploration Context
414
+
415
+ ${manifest.explorations.map(exp => `#### Exploration: ${exp.angle} (${exp.file})
416
+ Path: ${exp.path}
417
+
418
+ Read this file for detailed ${exp.angle} analysis.`).join('\n\n')}
419
+
420
+ Total explorations: ${manifest.exploration_count}
421
+ Angles covered: ${manifest.explorations.map(e => e.angle).join(', ')}
422
+
423
+ Manifest: ${sessionFolder}/explorations-manifest.json
424
+
425
+ ### User Clarifications
426
+ ${JSON.stringify(clarificationContext) || "None"}
427
+
428
+ ### Complexity Level
429
+ ${complexity}
430
+
431
+ ### Requirements
432
+ Generate plan.json following the schema obtained above. Key constraints:
433
+ - tasks: 2-7 structured tasks (**group by feature/module, NOT by file**)
434
+ - _metadata.exploration_angles: ${JSON.stringify(manifest.explorations.map(e => e.angle))}
435
+
436
+ ### Task Grouping Rules
437
+ 1. **Group by feature**: All changes for one feature = one task (even if 3-5 files)
438
+ 2. **Group by context**: Tasks with similar context or related functional changes can be grouped together
439
+ 3. **Minimize agent count**: Simple, unrelated tasks can also be grouped to reduce agent execution overhead
440
+ 4. **Avoid file-per-task**: Do NOT create separate tasks for each file
441
+ 5. **Substantial tasks**: Each task should represent 15-60 minutes of work
442
+ 6. **True dependencies only**: Only use depends_on when Task B cannot start without Task A's output
443
+ 7. **Prefer parallel**: Most tasks should be independent (no depends_on)
444
+
445
+ ### Execution
446
+ 1. Read schema file (cat command above)
447
+ 2. Execute CLI planning using Gemini (Qwen fallback)
448
+ 3. Read ALL exploration files for comprehensive context
449
+ 4. Synthesize findings and generate plan following schema
450
+ 5. Write JSON: Write('${sessionFolder}/plan.json', jsonContent)
451
+ 6. Return brief completion summary
452
+
453
+ ### Deliverables
454
+ Write: ${sessionFolder}/plan.json
455
+ Return: Brief plan summary
456
+ `
457
+ })
458
+
459
+ // Step 3: Wait for planning subagent to complete
460
+ const planResult = wait({
461
+ ids: [planningAgent],
462
+ timeout_ms: 900000 // 15 minutes
463
+ })
464
+
465
+ // Step 4: Cleanup
466
+ close_agent({ id: planningAgent })
467
+ ```
468
+
469
+ **Output**: `${sessionFolder}/plan.json`
470
+
471
+ ---
472
+
473
+ ### Phase 4: Task Confirmation
474
+
475
+ **Display Plan Summary**:
476
+ ```javascript
477
+ const plan = JSON.parse(Read(`${sessionFolder}/plan.json`))
478
+
479
+ console.log(`
480
+ ## Implementation Plan
481
+
482
+ **Summary**: ${plan.summary}
483
+ **Approach**: ${plan.approach}
484
+
485
+ **Tasks** (${plan.tasks.length}):
486
+ ${plan.tasks.map((t, i) => `
487
+ ### Task ${i+1}: ${t.title}
488
+ - **Description**: ${t.description}
489
+ - **Scope**: ${t.scope}
490
+ - **Files**: ${t.files?.join(', ') || 'N/A'}
491
+ - **Complexity**: ${t.complexity}
492
+ - **Dependencies**: ${t.depends_on?.join(', ') || 'None'}
493
+ `).join('\n')}
494
+
495
+ **Overall Complexity**: ${plan.complexity}
496
+ **Estimated Time**: ${plan.estimated_time}
497
+
498
+ ---
499
+
500
+ ## Confirmation Required
501
+
502
+ Please review the plan above and reply with one of the following:
503
+
504
+ - **"Allow"** - Proceed with this plan, output plan.json
505
+ - **"Modify"** - Describe what changes you want to make
506
+ - **"Cancel"** - Abort the planning workflow
507
+
508
+ **WAITING FOR USER CONFIRMATION...**
509
+ `)
510
+
511
+ // STOP HERE - Wait for user confirmation before writing plan.json
512
+ return
513
+ ```
514
+
515
+ ---
516
+
517
+ ### Phase 5: Output Plan File
518
+
519
+ **After User Confirms "Allow"**:
520
+ ```javascript
521
+ // Final plan.json already written in Phase 3
522
+ console.log(`
523
+ ## Plan Output Complete
524
+
525
+ **Plan file written**: ${sessionFolder}/plan.json
526
+
527
+ **Session folder**: ${sessionFolder}
528
+
529
+ **Contents**:
530
+ - explorations-manifest.json
531
+ ${manifest.explorations.map(e => `- exploration-${e.angle}.json`).join('\n')}
532
+ - plan.json
533
+
534
+ ---
535
+
536
+ You can now use this plan with your preferred execution method:
537
+ - Manual implementation following the tasks
538
+ - Pass to another tool/agent for execution
539
+ - Import into project management system
540
+ `)
541
+ ```
542
+
543
+ ---
544
+
545
+ ## Codex vs Claude Comparison (for this workflow)
546
+
547
+ | Aspect | Claude Code Task | Codex Subagent |
548
+ |--------|------------------|----------------|
549
+ | **Creation** | `Task({ subagent_type, prompt })` | `spawn_agent({ message: role + task })` |
550
+ | **Role Loading** | Auto via `subagent_type` | Manual: Read `~/.codex/agents/*.md` |
551
+ | **Parallel Wait** | Multiple `Task()` calls | **Batch `wait({ ids: [...] })`** |
552
+ | **Result Retrieval** | Sync return or `TaskOutput` | `wait({ ids }).status[id].completed` |
553
+ | **Follow-up** | `resume` parameter | `send_input({ id, message })` |
554
+ | **Cleanup** | Automatic | **Explicit `close_agent({ id })`** |
555
+
556
+ **Codex Advantages for lite-plan**:
557
+ - True parallel exploration with batch `wait`
558
+ - Fine-grained lifecycle control
559
+ - Efficient multi-agent coordination
560
+
561
+ ---
562
+
563
+ ## Session Folder Structure
564
+
565
+ ```
566
+ .workflow/.lite-plan/{task-slug}-{YYYY-MM-DD}/
567
+ ├── exploration-{angle1}.json # Exploration angle 1
568
+ ├── exploration-{angle2}.json # Exploration angle 2
569
+ ├── exploration-{angle3}.json # Exploration angle 3 (if applicable)
570
+ ├── exploration-{angle4}.json # Exploration angle 4 (if applicable)
571
+ ├── explorations-manifest.json # Exploration index
572
+ └── plan.json # Implementation plan (after confirmation)
573
+ ```
574
+
575
+ ## Workflow States
576
+
577
+ | State | Action | Next |
578
+ |-------|--------|------|
579
+ | Phase 1 Complete | Exploration done | → Phase 2 or 3 |
580
+ | Phase 2 Output | Questions displayed | → Wait for user reply |
581
+ | User Replied | Clarifications received | → Phase 3 |
582
+ | Phase 3 Complete | Plan generated | → Phase 4 |
583
+ | Phase 4 Output | Plan displayed | → Wait for user confirmation |
584
+ | User: "Allow" | Confirmed | → Phase 5 (Write plan.json) |
585
+ | User: "Modify" | Changes requested | → Revise plan, back to Phase 4 |
586
+ | User: "Cancel" | Aborted | → End workflow |
587
+
588
+ ## Error Handling
589
+
590
+ | Error | Resolution |
591
+ |-------|------------|
592
+ | Subagent spawn failure | Fallback to direct exploration |
593
+ | wait() timeout | Use completed results, log partial status |
594
+ | Planning subagent failure | Fallback to direct planning |
595
+ | Clarification timeout | Use exploration findings as-is |
596
+ | Confirmation timeout | Save context, display resume instructions |
597
+ | Modify loop > 3 times | Suggest breaking task into smaller pieces |
598
+
599
+ ---
600
+
601
+ **Now execute the lite-plan workflow for task**: $TASK