claude-code-workflow 6.0.4 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/.claude/agents/action-planning-agent.md +1 -1
  2. package/.claude/agents/cli-execution-agent.md +269 -269
  3. package/.claude/agents/cli-explore-agent.md +182 -182
  4. package/.claude/agents/context-search-agent.md +582 -582
  5. package/.claude/agents/memory-bridge.md +93 -93
  6. package/.claude/commands/cli/cli-init.md +1 -1
  7. package/.claude/commands/memory/docs-full-cli.md +471 -471
  8. package/.claude/commands/memory/docs-related-cli.md +386 -386
  9. package/.claude/commands/memory/docs.md +615 -615
  10. package/.claude/commands/memory/load.md +1 -1
  11. package/.claude/commands/memory/update-full.md +332 -332
  12. package/.claude/commands/memory/update-related.md +5 -5
  13. package/.claude/commands/workflow/init.md +1 -1
  14. package/.claude/commands/workflow/lite-fix.md +621 -621
  15. package/.claude/commands/workflow/lite-plan.md +592 -592
  16. package/.claude/commands/workflow/tools/context-gather.md +434 -434
  17. package/.claude/commands/workflow/ui-design/generate.md +504 -504
  18. package/.claude/commands/workflow/ui-design/import-from-code.md +537 -537
  19. package/.claude/scripts/classify-folders.sh +4 -0
  20. package/.claude/scripts/convert_tokens_to_css.sh +4 -0
  21. package/.claude/scripts/detect_changed_modules.sh +5 -1
  22. package/.claude/scripts/discover-design-files.sh +87 -83
  23. package/.claude/scripts/generate_module_docs.sh +717 -713
  24. package/.claude/scripts/get_modules_by_depth.sh +5 -1
  25. package/.claude/scripts/ui-generate-preview.sh +4 -0
  26. package/.claude/scripts/ui-instantiate-prototypes.sh +4 -0
  27. package/.claude/scripts/update_module_claude.sh +4 -0
  28. package/.claude/skills/command-guide/index/all-commands.json +1 -12
  29. package/.claude/skills/command-guide/index/by-category.json +1 -12
  30. package/.claude/skills/command-guide/index/by-use-case.json +1 -12
  31. package/.claude/skills/command-guide/index/essential-commands.json +1 -12
  32. package/.claude/skills/command-guide/reference/agents/action-planning-agent.md +127 -71
  33. package/.claude/skills/command-guide/reference/agents/cli-execution-agent.md +269 -269
  34. package/.claude/skills/command-guide/reference/agents/cli-explore-agent.md +182 -182
  35. package/.claude/skills/command-guide/reference/agents/conceptual-planning-agent.md +18 -38
  36. package/.claude/skills/command-guide/reference/agents/context-search-agent.md +582 -577
  37. package/.claude/skills/command-guide/reference/agents/memory-bridge.md +93 -93
  38. package/.claude/skills/command-guide/reference/commands/cli/cli-init.md +1 -1
  39. package/.claude/skills/command-guide/reference/commands/memory/docs-full-cli.md +471 -471
  40. package/.claude/skills/command-guide/reference/commands/memory/docs-related-cli.md +386 -386
  41. package/.claude/skills/command-guide/reference/commands/memory/docs.md +615 -610
  42. package/.claude/skills/command-guide/reference/commands/memory/load.md +1 -1
  43. package/.claude/skills/command-guide/reference/commands/memory/update-full.md +332 -332
  44. package/.claude/skills/command-guide/reference/commands/memory/update-related.md +5 -5
  45. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/artifacts.md +299 -451
  46. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/auto-parallel.md +14 -37
  47. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/synthesis.md +252 -350
  48. package/.claude/skills/command-guide/reference/commands/workflow/init.md +2 -2
  49. package/.claude/skills/command-guide/reference/commands/workflow/lite-execute.md +52 -0
  50. package/.claude/skills/command-guide/reference/commands/workflow/lite-fix.md +621 -602
  51. package/.claude/skills/command-guide/reference/commands/workflow/lite-plan.md +46 -36
  52. package/.claude/skills/command-guide/reference/commands/workflow/review-fix.md +18 -58
  53. package/.claude/skills/command-guide/reference/commands/workflow/review-module-cycle.md +22 -52
  54. package/.claude/skills/command-guide/reference/commands/workflow/review-session-cycle.md +19 -48
  55. package/.claude/skills/command-guide/reference/commands/workflow/session/start.md +25 -5
  56. package/.claude/skills/command-guide/reference/commands/workflow/tdd-plan.md +1 -1
  57. package/.claude/skills/command-guide/reference/commands/workflow/test-fix-gen.md +7 -7
  58. package/.claude/skills/command-guide/reference/commands/workflow/tools/context-gather.md +434 -434
  59. package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-agent.md +151 -11
  60. package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-tdd.md +4 -4
  61. package/.claude/skills/command-guide/reference/commands/workflow/tools/test-task-generate.md +1 -1
  62. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/generate.md +504 -504
  63. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/import-from-code.md +537 -537
  64. package/.claude/workflows/context-search-strategy.md +77 -77
  65. package/.claude/workflows/tool-strategy.md +90 -71
  66. package/.claude/workflows/workflow-architecture.md +1 -1
  67. package/ccw/package.json +6 -6
  68. package/ccw/src/cli.js +16 -0
  69. package/ccw/src/commands/stop.js +101 -0
  70. package/ccw/src/commands/tool.js +181 -0
  71. package/ccw/src/core/dashboard-generator.js +18 -3
  72. package/ccw/src/core/lite-scanner.js +35 -11
  73. package/ccw/src/core/server.js +583 -17
  74. package/ccw/src/templates/dashboard-css/01-base.css +161 -0
  75. package/ccw/src/templates/dashboard-css/02-session.css +726 -0
  76. package/ccw/src/templates/dashboard-css/03-tasks.css +512 -0
  77. package/ccw/src/templates/dashboard-css/04-lite-tasks.css +843 -0
  78. package/ccw/src/templates/dashboard-css/05-context.css +2206 -0
  79. package/ccw/src/templates/dashboard-css/06-cards.css +1570 -0
  80. package/ccw/src/templates/dashboard-css/07-managers.css +936 -0
  81. package/ccw/src/templates/dashboard-css/08-review.css +1266 -0
  82. package/ccw/src/templates/dashboard-css/09-explorer.css +1397 -0
  83. package/ccw/src/templates/dashboard-js/components/global-notifications.js +219 -0
  84. package/ccw/src/templates/dashboard-js/components/hook-manager.js +10 -0
  85. package/ccw/src/templates/dashboard-js/components/mcp-manager.js +24 -2
  86. package/ccw/src/templates/dashboard-js/components/navigation.js +11 -5
  87. package/ccw/src/templates/dashboard-js/components/tabs-context.js +20 -20
  88. package/ccw/src/templates/dashboard-js/components/tabs-other.js +11 -11
  89. package/ccw/src/templates/dashboard-js/components/theme.js +29 -1
  90. package/ccw/src/templates/dashboard-js/main.js +4 -0
  91. package/ccw/src/templates/dashboard-js/state.js +5 -0
  92. package/ccw/src/templates/dashboard-js/views/explorer.js +852 -0
  93. package/ccw/src/templates/dashboard-js/views/home.js +13 -9
  94. package/ccw/src/templates/dashboard-js/views/hook-manager.js +8 -5
  95. package/ccw/src/templates/dashboard-js/views/lite-tasks.js +21 -16
  96. package/ccw/src/templates/dashboard-js/views/mcp-manager.js +148 -8
  97. package/ccw/src/templates/dashboard-js/views/project-overview.js +15 -11
  98. package/ccw/src/templates/dashboard-js/views/review-session.js +3 -3
  99. package/ccw/src/templates/dashboard-js/views/session-detail.js +38 -28
  100. package/ccw/src/templates/dashboard.html +129 -28
  101. package/ccw/src/tools/classify-folders.js +204 -0
  102. package/ccw/src/tools/convert-tokens-to-css.js +250 -0
  103. package/ccw/src/tools/detect-changed-modules.js +288 -0
  104. package/ccw/src/tools/discover-design-files.js +134 -0
  105. package/ccw/src/tools/edit-file.js +266 -0
  106. package/ccw/src/tools/generate-module-docs.js +416 -0
  107. package/ccw/src/tools/get-modules-by-depth.js +308 -0
  108. package/ccw/src/tools/index.js +176 -0
  109. package/ccw/src/tools/ui-generate-preview.js +327 -0
  110. package/ccw/src/tools/ui-instantiate-prototypes.js +301 -0
  111. package/ccw/src/tools/update-module-claude.js +380 -0
  112. package/ccw/src/utils/browser-launcher.js +15 -4
  113. package/package.json +1 -1
  114. package/.claude/skills/command-guide/reference/commands/workflow/status.md +0 -352
  115. package/ccw/src/core/server.js.bak +0 -385
  116. package/ccw/src/core/server_original.bak +0 -385
  117. package/ccw/src/templates/dashboard.css +0 -8114
  118. package/ccw/src/templates/dashboard_tailwind.html +0 -42
  119. package/ccw/src/templates/dashboard_test.html +0 -37
  120. package/ccw/src/templates/tailwind-base.css +0 -212
@@ -1,592 +1,592 @@
1
- ---
2
- name: lite-plan
3
- description: Lightweight interactive planning workflow with in-memory planning, code exploration, and execution dispatch to lite-execute after user confirmation
4
- argument-hint: "[-e|--explore] \"task description\"|file.md"
5
- allowed-tools: TodoWrite(*), Task(*), SlashCommand(*), AskUserQuestion(*)
6
- ---
7
-
8
- # Workflow Lite-Plan Command (/workflow:lite-plan)
9
-
10
- ## Overview
11
-
12
- Intelligent lightweight planning command with dynamic workflow adaptation based on task complexity. Focuses on planning phases (exploration, clarification, planning, confirmation) and delegates execution to `/workflow:lite-execute`.
13
-
14
- **Core capabilities:**
15
- - Intelligent task analysis with automatic exploration detection
16
- - Dynamic code exploration (cli-explore-agent) when codebase understanding needed
17
- - Interactive clarification after exploration to gather missing information
18
- - Adaptive planning strategy (direct Claude vs cli-lite-planning-agent) based on complexity
19
- - Two-step confirmation: plan display → multi-dimensional input collection
20
- - Execution dispatch with complete context handoff to lite-execute
21
-
22
- ## Usage
23
-
24
- ```bash
25
- /workflow:lite-plan [FLAGS] <TASK_DESCRIPTION>
26
-
27
- # Flags
28
- -e, --explore Force code exploration phase (overrides auto-detection)
29
-
30
- # Arguments
31
- <task-description> Task description or path to .md file (required)
32
- ```
33
-
34
- ## Execution Process
35
-
36
- ```
37
- Phase 1: Task Analysis & Exploration
38
- ├─ Parse input (description or .md file)
39
- ├─ intelligent complexity assessment (Low/Medium/High)
40
- ├─ Exploration decision (auto-detect or --explore flag)
41
- ├─ ⚠️ Context protection: If file reading ≥50k chars → force cli-explore-agent
42
- └─ Decision:
43
- ├─ needsExploration=true → Launch parallel cli-explore-agents (1-4 based on complexity)
44
- └─ needsExploration=false → Skip to Phase 2/3
45
-
46
- Phase 2: Clarification (optional, multi-round)
47
- ├─ Aggregate clarification_needs from all exploration angles
48
- ├─ Deduplicate similar questions
49
- └─ Decision:
50
- ├─ Has clarifications → AskUserQuestion (max 4 questions per round, multiple rounds allowed)
51
- └─ No clarifications → Skip to Phase 3
52
-
53
- Phase 3: Planning (NO CODE EXECUTION - planning only)
54
- └─ Decision (based on Phase 1 complexity):
55
- ├─ Low → Load schema: cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json → Direct Claude planning (following schema) → plan.json → MUST proceed to Phase 4
56
- └─ Medium/High → cli-lite-planning-agent → plan.json → MUST proceed to Phase 4
57
-
58
- Phase 4: Confirmation & Selection
59
- ├─ Display plan summary (tasks, complexity, estimated time)
60
- └─ AskUserQuestion:
61
- ├─ Confirm: Allow / Modify / Cancel
62
- ├─ Execution: Agent / Codex / Auto
63
- └─ Review: Gemini / Agent / Skip
64
-
65
- Phase 5: Dispatch
66
- ├─ Build executionContext (plan + explorations + clarifications + selections)
67
- └─ SlashCommand("/workflow:lite-execute --in-memory")
68
- ```
69
-
70
- ## Implementation
71
-
72
- ### Phase 1: Intelligent Multi-Angle Exploration
73
-
74
- **Session Setup** (MANDATORY - follow exactly):
75
- ```javascript
76
- // Helper: Get UTC+8 (China Standard Time) ISO string
77
- const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
78
-
79
- const taskSlug = task_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 40)
80
- const dateStr = getUtc8ISOString().substring(0, 10) // Format: 2025-11-29
81
-
82
- const sessionId = `${taskSlug}-${dateStr}` // e.g., "implement-jwt-refresh-2025-11-29"
83
- const sessionFolder = `.workflow/.lite-plan/${sessionId}`
84
-
85
- bash(`mkdir -p ${sessionFolder} && test -d ${sessionFolder} && echo "SUCCESS: ${sessionFolder}" || echo "FAILED: ${sessionFolder}"`)
86
- ```
87
-
88
- **Exploration Decision Logic**:
89
- ```javascript
90
- needsExploration = (
91
- flags.includes('--explore') || flags.includes('-e') ||
92
- task.mentions_specific_files ||
93
- task.requires_codebase_context ||
94
- task.needs_architecture_understanding ||
95
- task.modifies_existing_code
96
- )
97
-
98
- if (!needsExploration) {
99
- // Skip to Phase 2 (Clarification) or Phase 3 (Planning)
100
- proceed_to_next_phase()
101
- }
102
- ```
103
-
104
- **⚠️ Context Protection**: File reading ≥50k chars → force `needsExploration=true` (delegate to cli-explore-agent)
105
-
106
- **Complexity Assessment** (Intelligent Analysis):
107
- ```javascript
108
- // analyzes task complexity based on:
109
- // - Scope: How many systems/modules are affected?
110
- // - Depth: Surface change vs architectural impact?
111
- // - Risk: Potential for breaking existing functionality?
112
- // - Dependencies: How interconnected is the change?
113
-
114
- const complexity = analyzeTaskComplexity(task_description)
115
- // Returns: 'Low' | 'Medium' | 'High'
116
- // Low: Single file, isolated change, minimal risk
117
- // Medium: Multiple files, some dependencies, moderate risk
118
- // High: Cross-module, architectural, high risk
119
-
120
- // Angle assignment based on task type (orchestrator decides, not agent)
121
- const ANGLE_PRESETS = {
122
- architecture: ['architecture', 'dependencies', 'modularity', 'integration-points'],
123
- security: ['security', 'auth-patterns', 'dataflow', 'validation'],
124
- performance: ['performance', 'bottlenecks', 'caching', 'data-access'],
125
- bugfix: ['error-handling', 'dataflow', 'state-management', 'edge-cases'],
126
- feature: ['patterns', 'integration-points', 'testing', 'dependencies']
127
- }
128
-
129
- function selectAngles(taskDescription, count) {
130
- const text = taskDescription.toLowerCase()
131
- let preset = 'feature' // default
132
-
133
- if (/refactor|architect|restructure|modular/.test(text)) preset = 'architecture'
134
- else if (/security|auth|permission|access/.test(text)) preset = 'security'
135
- else if (/performance|slow|optimi|cache/.test(text)) preset = 'performance'
136
- else if (/fix|bug|error|issue|broken/.test(text)) preset = 'bugfix'
137
-
138
- return ANGLE_PRESETS[preset].slice(0, count)
139
- }
140
-
141
- const selectedAngles = selectAngles(task_description, complexity === 'High' ? 4 : (complexity === 'Medium' ? 3 : 1))
142
-
143
- console.log(`
144
- ## Exploration Plan
145
-
146
- Task Complexity: ${complexity}
147
- Selected Angles: ${selectedAngles.join(', ')}
148
-
149
- Launching ${selectedAngles.length} parallel explorations...
150
- `)
151
- ```
152
-
153
- **Launch Parallel Explorations** - Orchestrator assigns angle to each agent:
154
-
155
- ```javascript
156
- // Launch agents with pre-assigned angles
157
- const explorationTasks = selectedAngles.map((angle, index) =>
158
- Task(
159
- subagent_type="cli-explore-agent",
160
- description=`Explore: ${angle}`,
161
- prompt=`
162
- ## Task Objective
163
- Execute **${angle}** exploration for task planning context. Analyze codebase from this specific angle to discover relevant structure, patterns, and constraints.
164
-
165
- ## Assigned Context
166
- - **Exploration Angle**: ${angle}
167
- - **Task Description**: ${task_description}
168
- - **Exploration Index**: ${index + 1} of ${selectedAngles.length}
169
- - **Output File**: ${sessionFolder}/exploration-${angle}.json
170
-
171
- ## MANDATORY FIRST STEPS (Execute by Agent)
172
- **You (cli-explore-agent) MUST execute these steps in order:**
173
- 1. Run: ~/.claude/scripts/get_modules_by_depth.sh (project structure)
174
- 2. Run: rg -l "{keyword_from_task}" --type ts (locate relevant files)
175
- 3. Execute: cat ~/.claude/workflows/cli-templates/schemas/explore-json-schema.json (get output schema reference)
176
-
177
- ## Exploration Strategy (${angle} focus)
178
-
179
- **Step 1: Structural Scan** (Bash)
180
- - get_modules_by_depth.sh → identify modules related to ${angle}
181
- - find/rg → locate files relevant to ${angle} aspect
182
- - Analyze imports/dependencies from ${angle} perspective
183
-
184
- **Step 2: Semantic Analysis** (Gemini CLI)
185
- - How does existing code handle ${angle} concerns?
186
- - What patterns are used for ${angle}?
187
- - Where would new code integrate from ${angle} viewpoint?
188
-
189
- **Step 3: Write Output**
190
- - Consolidate ${angle} findings into JSON
191
- - Identify ${angle}-specific clarification needs
192
-
193
- ## Expected Output
194
-
195
- **File**: ${sessionFolder}/exploration-${angle}.json
196
-
197
- **Schema Reference**: Schema obtained in MANDATORY FIRST STEPS step 3, follow schema exactly
198
-
199
- **Required Fields** (all ${angle} focused):
200
- - project_structure: Modules/architecture relevant to ${angle}
201
- - relevant_files: Files affected from ${angle} perspective
202
- **IMPORTANT**: Use object format with relevance scores for synthesis:
203
- \`[{path: "src/file.ts", relevance: 0.85, rationale: "Core ${angle} logic"}]\`
204
- Scores: 0.7+ high priority, 0.5-0.7 medium, <0.5 low
205
- - patterns: ${angle}-related patterns to follow
206
- - dependencies: Dependencies relevant to ${angle}
207
- - integration_points: Where to integrate from ${angle} viewpoint (include file:line locations)
208
- - constraints: ${angle}-specific limitations/conventions
209
- - clarification_needs: ${angle}-related ambiguities (options array + recommended index)
210
- - _metadata.exploration_angle: "${angle}"
211
-
212
- ## Success Criteria
213
- - [ ] Schema obtained via cat explore-json-schema.json
214
- - [ ] get_modules_by_depth.sh executed
215
- - [ ] At least 3 relevant files identified with ${angle} rationale
216
- - [ ] Patterns are actionable (code examples, not generic advice)
217
- - [ ] Integration points include file:line locations
218
- - [ ] Constraints are project-specific to ${angle}
219
- - [ ] JSON output follows schema exactly
220
- - [ ] clarification_needs includes options + recommended
221
-
222
- ## Output
223
- Write: ${sessionFolder}/exploration-${angle}.json
224
- Return: 2-3 sentence summary of ${angle} findings
225
- `
226
- )
227
- )
228
-
229
- // Execute all exploration tasks in parallel
230
- ```
231
-
232
- **Auto-discover Generated Exploration Files**:
233
- ```javascript
234
- // After explorations complete, auto-discover all exploration-*.json files
235
- const explorationFiles = bash(`find ${sessionFolder} -name "exploration-*.json" -type f`)
236
- .split('\n')
237
- .filter(f => f.trim())
238
-
239
- // Read metadata to build manifest
240
- const explorationManifest = {
241
- session_id: sessionId,
242
- task_description: task_description,
243
- timestamp: getUtc8ISOString(),
244
- complexity: complexity,
245
- exploration_count: explorationCount,
246
- explorations: explorationFiles.map(file => {
247
- const data = JSON.parse(Read(file))
248
- const filename = path.basename(file)
249
- return {
250
- angle: data._metadata.exploration_angle,
251
- file: filename,
252
- path: file,
253
- index: data._metadata.exploration_index
254
- }
255
- })
256
- }
257
-
258
- Write(`${sessionFolder}/explorations-manifest.json`, JSON.stringify(explorationManifest, null, 2))
259
-
260
- console.log(`
261
- ## Exploration Complete
262
-
263
- Generated exploration files in ${sessionFolder}:
264
- ${explorationManifest.explorations.map(e => `- exploration-${e.angle}.json (angle: ${e.angle})`).join('\n')}
265
-
266
- Manifest: explorations-manifest.json
267
- Angles explored: ${explorationManifest.explorations.map(e => e.angle).join(', ')}
268
- `)
269
- ```
270
-
271
- **Output**:
272
- - `${sessionFolder}/exploration-{angle1}.json`
273
- - `${sessionFolder}/exploration-{angle2}.json`
274
- - ... (1-4 files based on complexity)
275
- - `${sessionFolder}/explorations-manifest.json`
276
-
277
- ---
278
-
279
- ### Phase 2: Clarification (Optional, Multi-Round)
280
-
281
- **Skip if**: No exploration or `clarification_needs` is empty across all explorations
282
-
283
- **⚠️ CRITICAL**: AskUserQuestion tool limits max 4 questions per call. **MUST execute multiple rounds** to exhaust all clarification needs - do NOT stop at round 1.
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
- // Deduplicate exact same questions only
308
- const seen = new Set()
309
- const dedupedClarifications = allClarifications.filter(c => {
310
- const key = c.question.toLowerCase()
311
- if (seen.has(key)) return false
312
- seen.add(key)
313
- return true
314
- })
315
-
316
- // Multi-round clarification: batch questions (max 4 per round)
317
- if (dedupedClarifications.length > 0) {
318
- const BATCH_SIZE = 4
319
- const totalRounds = Math.ceil(dedupedClarifications.length / BATCH_SIZE)
320
-
321
- for (let i = 0; i < dedupedClarifications.length; i += BATCH_SIZE) {
322
- const batch = dedupedClarifications.slice(i, i + BATCH_SIZE)
323
- const currentRound = Math.floor(i / BATCH_SIZE) + 1
324
-
325
- console.log(`### Clarification Round ${currentRound}/${totalRounds}`)
326
-
327
- AskUserQuestion({
328
- questions: batch.map(need => ({
329
- question: `[${need.source_angle}] ${need.question}\n\nContext: ${need.context}`,
330
- header: need.source_angle.substring(0, 12),
331
- multiSelect: false,
332
- options: need.options.map((opt, index) => ({
333
- label: need.recommended === index ? `${opt} ★` : opt,
334
- description: need.recommended === index ? `Recommended` : `Use ${opt}`
335
- }))
336
- }))
337
- })
338
-
339
- // Store batch responses in clarificationContext before next round
340
- }
341
- }
342
- ```
343
-
344
- **Output**: `clarificationContext` (in-memory)
345
-
346
- ---
347
-
348
- ### Phase 3: Planning
349
-
350
- **Planning Strategy Selection** (based on Phase 1 complexity):
351
-
352
- **IMPORTANT**: Phase 3 is **planning only** - NO code execution. All execution happens in Phase 5 via lite-execute.
353
-
354
- **Low Complexity** - Direct planning by Claude:
355
- ```javascript
356
- // Step 1: Read schema
357
- const schema = Bash(`cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json`)
358
-
359
- // Step 2: Generate plan following schema (Claude directly, no agent)
360
- const plan = {
361
- summary: "...",
362
- approach: "...",
363
- tasks: [...], // Each task: { id, title, scope, ..., depends_on, execution_group, complexity }
364
- estimated_time: "...",
365
- recommended_execution: "Agent",
366
- complexity: "Low",
367
- _metadata: { timestamp: getUtc8ISOString(), source: "direct-planning", planning_mode: "direct" }
368
- }
369
-
370
- // Step 3: Write plan to session folder
371
- Write(`${sessionFolder}/plan.json`, JSON.stringify(plan, null, 2))
372
-
373
- // Step 4: MUST continue to Phase 4 (Confirmation) - DO NOT execute code here
374
- ```
375
-
376
- **Medium/High Complexity** - Invoke cli-lite-planning-agent:
377
-
378
- ```javascript
379
- Task(
380
- subagent_type="cli-lite-planning-agent",
381
- description="Generate detailed implementation plan",
382
- prompt=`
383
- Generate implementation plan and write plan.json.
384
-
385
- ## Output Schema Reference
386
- Execute: cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json (get schema reference before generating plan)
387
-
388
- ## Task Description
389
- ${task_description}
390
-
391
- ## Multi-Angle Exploration Context
392
-
393
- ${manifest.explorations.map(exp => `### Exploration: ${exp.angle} (${exp.file})
394
- Path: ${exp.path}
395
-
396
- Read this file for detailed ${exp.angle} analysis.`).join('\n\n')}
397
-
398
- Total explorations: ${manifest.exploration_count}
399
- Angles covered: ${manifest.explorations.map(e => e.angle).join(', ')}
400
-
401
- Manifest: ${sessionFolder}/explorations-manifest.json
402
-
403
- ## User Clarifications
404
- ${JSON.stringify(clarificationContext) || "None"}
405
-
406
- ## Complexity Level
407
- ${complexity}
408
-
409
- ## Requirements
410
- Generate plan.json with:
411
- - summary: 2-3 sentence overview
412
- - approach: High-level implementation strategy (incorporating insights from all exploration angles)
413
- - tasks: 2-7 structured tasks (**IMPORTANT: group by feature/module, NOT by file**)
414
- - **Task Granularity Principle**: Each task = one complete feature unit or module
415
- - title: action verb + target module/feature (e.g., "Implement auth token refresh")
416
- - scope: module path (src/auth/) or feature name, prefer module-level over single file
417
- - action, description
418
- - modification_points: ALL files to modify for this feature (group related changes)
419
- - implementation (3-7 steps covering all modification_points)
420
- - reference (pattern, files, examples)
421
- - acceptance (2-4 criteria for the entire feature)
422
- - depends_on: task IDs this task depends on (use sparingly, only for true dependencies)
423
- - estimated_time, recommended_execution, complexity
424
- - _metadata:
425
- - timestamp, source, planning_mode
426
- - exploration_angles: ${JSON.stringify(manifest.explorations.map(e => e.angle))}
427
-
428
- ## Task Grouping Rules
429
- 1. **Group by feature**: All changes for one feature = one task (even if 3-5 files)
430
- 2. **Group by context**: Tasks with similar context or related functional changes can be grouped together
431
- 3. **Minimize agent count**: Simple, unrelated tasks can also be grouped to reduce agent execution overhead
432
- 4. **Avoid file-per-task**: Do NOT create separate tasks for each file
433
- 5. **Substantial tasks**: Each task should represent 15-60 minutes of work
434
- 6. **True dependencies only**: Only use depends_on when Task B cannot start without Task A's output
435
- 7. **Prefer parallel**: Most tasks should be independent (no depends_on)
436
-
437
- ## Execution
438
- 1. Read ALL exploration files for comprehensive context
439
- 2. Execute CLI planning using Gemini (Qwen fallback)
440
- 3. Synthesize findings from multiple exploration angles
441
- 4. Parse output and structure plan
442
- 5. Write JSON: Write('${sessionFolder}/plan.json', jsonContent)
443
- 6. Return brief completion summary
444
- `
445
- )
446
- ```
447
-
448
- **Output**: `${sessionFolder}/plan.json`
449
-
450
- ---
451
-
452
- ### Phase 4: Task Confirmation & Execution Selection
453
-
454
- **Step 4.1: Display Plan**
455
- ```javascript
456
- const plan = JSON.parse(Read(`${sessionFolder}/plan.json`))
457
-
458
- console.log(`
459
- ## Implementation Plan
460
-
461
- **Summary**: ${plan.summary}
462
- **Approach**: ${plan.approach}
463
-
464
- **Tasks** (${plan.tasks.length}):
465
- ${plan.tasks.map((t, i) => `${i+1}. ${t.title} (${t.file})`).join('\n')}
466
-
467
- **Complexity**: ${plan.complexity}
468
- **Estimated Time**: ${plan.estimated_time}
469
- **Recommended**: ${plan.recommended_execution}
470
- `)
471
- ```
472
-
473
- **Step 4.2: Collect Confirmation**
474
- ```javascript
475
- AskUserQuestion({
476
- questions: [
477
- {
478
- question: `Confirm plan? (${plan.tasks.length} tasks, ${plan.complexity})`,
479
- header: "Confirm",
480
- multiSelect: true,
481
- options: [
482
- { label: "Allow", description: "Proceed as-is" },
483
- { label: "Modify", description: "Adjust before execution" },
484
- { label: "Cancel", description: "Abort workflow" }
485
- ]
486
- },
487
- {
488
- question: "Execution method:",
489
- header: "Execution",
490
- multiSelect: false,
491
- options: [
492
- { label: "Agent", description: "@code-developer agent" },
493
- { label: "Codex", description: "codex CLI tool" },
494
- { label: "Auto", description: `Auto: ${plan.complexity === 'Low' ? 'Agent' : 'Codex'}` }
495
- ]
496
- },
497
- {
498
- question: "Code review after execution?",
499
- header: "Review",
500
- multiSelect: false,
501
- options: [
502
- { label: "Gemini Review", description: "Gemini CLI" },
503
- { label: "Agent Review", description: "@code-reviewer" },
504
- { label: "Skip", description: "No review" }
505
- ]
506
- }
507
- ]
508
- })
509
- ```
510
-
511
- ---
512
-
513
- ### Phase 5: Dispatch to Execution
514
-
515
- **CRITICAL**: lite-plan NEVER executes code directly. ALL execution MUST go through lite-execute.
516
-
517
- **Step 5.1: Build executionContext**
518
-
519
- ```javascript
520
- // Load manifest and all exploration files
521
- const manifest = JSON.parse(Read(`${sessionFolder}/explorations-manifest.json`))
522
- const explorations = {}
523
-
524
- manifest.explorations.forEach(exp => {
525
- if (file_exists(exp.path)) {
526
- explorations[exp.angle] = JSON.parse(Read(exp.path))
527
- }
528
- })
529
-
530
- const plan = JSON.parse(Read(`${sessionFolder}/plan.json`))
531
-
532
- executionContext = {
533
- planObject: plan,
534
- explorationsContext: explorations,
535
- explorationAngles: manifest.explorations.map(e => e.angle),
536
- explorationManifest: manifest,
537
- clarificationContext: clarificationContext || null,
538
- executionMethod: userSelection.execution_method,
539
- codeReviewTool: userSelection.code_review_tool,
540
- originalUserInput: task_description,
541
- session: {
542
- id: sessionId,
543
- folder: sessionFolder,
544
- artifacts: {
545
- explorations: manifest.explorations.map(exp => ({
546
- angle: exp.angle,
547
- path: exp.path
548
- })),
549
- explorations_manifest: `${sessionFolder}/explorations-manifest.json`,
550
- plan: `${sessionFolder}/plan.json`
551
- }
552
- }
553
- }
554
- ```
555
-
556
- **Step 5.2: Dispatch**
557
-
558
- ```javascript
559
- SlashCommand(command="/workflow:lite-execute --in-memory")
560
- ```
561
-
562
- ## Session Folder Structure
563
-
564
- ```
565
- .workflow/.lite-plan/{task-slug}-{YYYY-MM-DD}/
566
- ├── exploration-{angle1}.json # Exploration angle 1
567
- ├── exploration-{angle2}.json # Exploration angle 2
568
- ├── exploration-{angle3}.json # Exploration angle 3 (if applicable)
569
- ├── exploration-{angle4}.json # Exploration angle 4 (if applicable)
570
- ├── explorations-manifest.json # Exploration index
571
- └── plan.json # Implementation plan
572
- ```
573
-
574
- **Example**:
575
- ```
576
- .workflow/.lite-plan/implement-jwt-refresh-2025-11-25-14-30-25/
577
- ├── exploration-architecture.json
578
- ├── exploration-auth-patterns.json
579
- ├── exploration-security.json
580
- ├── explorations-manifest.json
581
- └── plan.json
582
- ```
583
-
584
- ## Error Handling
585
-
586
- | Error | Resolution |
587
- |-------|------------|
588
- | Exploration agent failure | Skip exploration, continue with task description only |
589
- | Planning agent failure | Fallback to direct planning by Claude |
590
- | Clarification timeout | Use exploration findings as-is |
591
- | Confirmation timeout | Save context, display resume instructions |
592
- | Modify loop > 3 times | Suggest breaking task or using /workflow:plan |
1
+ ---
2
+ name: lite-plan
3
+ description: Lightweight interactive planning workflow with in-memory planning, code exploration, and execution dispatch to lite-execute after user confirmation
4
+ argument-hint: "[-e|--explore] \"task description\"|file.md"
5
+ allowed-tools: TodoWrite(*), Task(*), SlashCommand(*), AskUserQuestion(*)
6
+ ---
7
+
8
+ # Workflow Lite-Plan Command (/workflow:lite-plan)
9
+
10
+ ## Overview
11
+
12
+ Intelligent lightweight planning command with dynamic workflow adaptation based on task complexity. Focuses on planning phases (exploration, clarification, planning, confirmation) and delegates execution to `/workflow:lite-execute`.
13
+
14
+ **Core capabilities:**
15
+ - Intelligent task analysis with automatic exploration detection
16
+ - Dynamic code exploration (cli-explore-agent) when codebase understanding needed
17
+ - Interactive clarification after exploration to gather missing information
18
+ - Adaptive planning strategy (direct Claude vs cli-lite-planning-agent) based on complexity
19
+ - Two-step confirmation: plan display → multi-dimensional input collection
20
+ - Execution dispatch with complete context handoff to lite-execute
21
+
22
+ ## Usage
23
+
24
+ ```bash
25
+ /workflow:lite-plan [FLAGS] <TASK_DESCRIPTION>
26
+
27
+ # Flags
28
+ -e, --explore Force code exploration phase (overrides auto-detection)
29
+
30
+ # Arguments
31
+ <task-description> Task description or path to .md file (required)
32
+ ```
33
+
34
+ ## Execution Process
35
+
36
+ ```
37
+ Phase 1: Task Analysis & Exploration
38
+ ├─ Parse input (description or .md file)
39
+ ├─ intelligent complexity assessment (Low/Medium/High)
40
+ ├─ Exploration decision (auto-detect or --explore flag)
41
+ ├─ ⚠️ Context protection: If file reading ≥50k chars → force cli-explore-agent
42
+ └─ Decision:
43
+ ├─ needsExploration=true → Launch parallel cli-explore-agents (1-4 based on complexity)
44
+ └─ needsExploration=false → Skip to Phase 2/3
45
+
46
+ Phase 2: Clarification (optional, multi-round)
47
+ ├─ Aggregate clarification_needs from all exploration angles
48
+ ├─ Deduplicate similar questions
49
+ └─ Decision:
50
+ ├─ Has clarifications → AskUserQuestion (max 4 questions per round, multiple rounds allowed)
51
+ └─ No clarifications → Skip to Phase 3
52
+
53
+ Phase 3: Planning (NO CODE EXECUTION - planning only)
54
+ └─ Decision (based on Phase 1 complexity):
55
+ ├─ Low → Load schema: cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json → Direct Claude planning (following schema) → plan.json → MUST proceed to Phase 4
56
+ └─ Medium/High → cli-lite-planning-agent → plan.json → MUST proceed to Phase 4
57
+
58
+ Phase 4: Confirmation & Selection
59
+ ├─ Display plan summary (tasks, complexity, estimated time)
60
+ └─ AskUserQuestion:
61
+ ├─ Confirm: Allow / Modify / Cancel
62
+ ├─ Execution: Agent / Codex / Auto
63
+ └─ Review: Gemini / Agent / Skip
64
+
65
+ Phase 5: Dispatch
66
+ ├─ Build executionContext (plan + explorations + clarifications + selections)
67
+ └─ SlashCommand("/workflow:lite-execute --in-memory")
68
+ ```
69
+
70
+ ## Implementation
71
+
72
+ ### Phase 1: Intelligent Multi-Angle Exploration
73
+
74
+ **Session Setup** (MANDATORY - follow exactly):
75
+ ```javascript
76
+ // Helper: Get UTC+8 (China Standard Time) ISO string
77
+ const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
78
+
79
+ const taskSlug = task_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 40)
80
+ const dateStr = getUtc8ISOString().substring(0, 10) // Format: 2025-11-29
81
+
82
+ const sessionId = `${taskSlug}-${dateStr}` // e.g., "implement-jwt-refresh-2025-11-29"
83
+ const sessionFolder = `.workflow/.lite-plan/${sessionId}`
84
+
85
+ bash(`mkdir -p ${sessionFolder} && test -d ${sessionFolder} && echo "SUCCESS: ${sessionFolder}" || echo "FAILED: ${sessionFolder}"`)
86
+ ```
87
+
88
+ **Exploration Decision Logic**:
89
+ ```javascript
90
+ needsExploration = (
91
+ flags.includes('--explore') || flags.includes('-e') ||
92
+ task.mentions_specific_files ||
93
+ task.requires_codebase_context ||
94
+ task.needs_architecture_understanding ||
95
+ task.modifies_existing_code
96
+ )
97
+
98
+ if (!needsExploration) {
99
+ // Skip to Phase 2 (Clarification) or Phase 3 (Planning)
100
+ proceed_to_next_phase()
101
+ }
102
+ ```
103
+
104
+ **⚠️ Context Protection**: File reading ≥50k chars → force `needsExploration=true` (delegate to cli-explore-agent)
105
+
106
+ **Complexity Assessment** (Intelligent Analysis):
107
+ ```javascript
108
+ // analyzes task complexity based on:
109
+ // - Scope: How many systems/modules are affected?
110
+ // - Depth: Surface change vs architectural impact?
111
+ // - Risk: Potential for breaking existing functionality?
112
+ // - Dependencies: How interconnected is the change?
113
+
114
+ const complexity = analyzeTaskComplexity(task_description)
115
+ // Returns: 'Low' | 'Medium' | 'High'
116
+ // Low: Single file, isolated change, minimal risk
117
+ // Medium: Multiple files, some dependencies, moderate risk
118
+ // High: Cross-module, architectural, high risk
119
+
120
+ // Angle assignment based on task type (orchestrator decides, not agent)
121
+ const ANGLE_PRESETS = {
122
+ architecture: ['architecture', 'dependencies', 'modularity', 'integration-points'],
123
+ security: ['security', 'auth-patterns', 'dataflow', 'validation'],
124
+ performance: ['performance', 'bottlenecks', 'caching', 'data-access'],
125
+ bugfix: ['error-handling', 'dataflow', 'state-management', 'edge-cases'],
126
+ feature: ['patterns', 'integration-points', 'testing', 'dependencies']
127
+ }
128
+
129
+ function selectAngles(taskDescription, count) {
130
+ const text = taskDescription.toLowerCase()
131
+ let preset = 'feature' // default
132
+
133
+ if (/refactor|architect|restructure|modular/.test(text)) preset = 'architecture'
134
+ else if (/security|auth|permission|access/.test(text)) preset = 'security'
135
+ else if (/performance|slow|optimi|cache/.test(text)) preset = 'performance'
136
+ else if (/fix|bug|error|issue|broken/.test(text)) preset = 'bugfix'
137
+
138
+ return ANGLE_PRESETS[preset].slice(0, count)
139
+ }
140
+
141
+ const selectedAngles = selectAngles(task_description, complexity === 'High' ? 4 : (complexity === 'Medium' ? 3 : 1))
142
+
143
+ console.log(`
144
+ ## Exploration Plan
145
+
146
+ Task Complexity: ${complexity}
147
+ Selected Angles: ${selectedAngles.join(', ')}
148
+
149
+ Launching ${selectedAngles.length} parallel explorations...
150
+ `)
151
+ ```
152
+
153
+ **Launch Parallel Explorations** - Orchestrator assigns angle to each agent:
154
+
155
+ ```javascript
156
+ // Launch agents with pre-assigned angles
157
+ const explorationTasks = selectedAngles.map((angle, index) =>
158
+ Task(
159
+ subagent_type="cli-explore-agent",
160
+ description=`Explore: ${angle}`,
161
+ prompt=`
162
+ ## Task Objective
163
+ Execute **${angle}** exploration for task planning context. Analyze codebase from this specific angle to discover relevant structure, patterns, and constraints.
164
+
165
+ ## Assigned Context
166
+ - **Exploration Angle**: ${angle}
167
+ - **Task Description**: ${task_description}
168
+ - **Exploration Index**: ${index + 1} of ${selectedAngles.length}
169
+ - **Output File**: ${sessionFolder}/exploration-${angle}.json
170
+
171
+ ## MANDATORY FIRST STEPS (Execute by Agent)
172
+ **You (cli-explore-agent) MUST execute these steps in order:**
173
+ 1. Run: ccw tool exec get_modules_by_depth '{}' (project structure)
174
+ 2. Run: rg -l "{keyword_from_task}" --type ts (locate relevant files)
175
+ 3. Execute: cat ~/.claude/workflows/cli-templates/schemas/explore-json-schema.json (get output schema reference)
176
+
177
+ ## Exploration Strategy (${angle} focus)
178
+
179
+ **Step 1: Structural Scan** (Bash)
180
+ - get_modules_by_depth.sh → identify modules related to ${angle}
181
+ - find/rg → locate files relevant to ${angle} aspect
182
+ - Analyze imports/dependencies from ${angle} perspective
183
+
184
+ **Step 2: Semantic Analysis** (Gemini CLI)
185
+ - How does existing code handle ${angle} concerns?
186
+ - What patterns are used for ${angle}?
187
+ - Where would new code integrate from ${angle} viewpoint?
188
+
189
+ **Step 3: Write Output**
190
+ - Consolidate ${angle} findings into JSON
191
+ - Identify ${angle}-specific clarification needs
192
+
193
+ ## Expected Output
194
+
195
+ **File**: ${sessionFolder}/exploration-${angle}.json
196
+
197
+ **Schema Reference**: Schema obtained in MANDATORY FIRST STEPS step 3, follow schema exactly
198
+
199
+ **Required Fields** (all ${angle} focused):
200
+ - project_structure: Modules/architecture relevant to ${angle}
201
+ - relevant_files: Files affected from ${angle} perspective
202
+ **IMPORTANT**: Use object format with relevance scores for synthesis:
203
+ \`[{path: "src/file.ts", relevance: 0.85, rationale: "Core ${angle} logic"}]\`
204
+ Scores: 0.7+ high priority, 0.5-0.7 medium, <0.5 low
205
+ - patterns: ${angle}-related patterns to follow
206
+ - dependencies: Dependencies relevant to ${angle}
207
+ - integration_points: Where to integrate from ${angle} viewpoint (include file:line locations)
208
+ - constraints: ${angle}-specific limitations/conventions
209
+ - clarification_needs: ${angle}-related ambiguities (options array + recommended index)
210
+ - _metadata.exploration_angle: "${angle}"
211
+
212
+ ## Success Criteria
213
+ - [ ] Schema obtained via cat explore-json-schema.json
214
+ - [ ] get_modules_by_depth.sh executed
215
+ - [ ] At least 3 relevant files identified with ${angle} rationale
216
+ - [ ] Patterns are actionable (code examples, not generic advice)
217
+ - [ ] Integration points include file:line locations
218
+ - [ ] Constraints are project-specific to ${angle}
219
+ - [ ] JSON output follows schema exactly
220
+ - [ ] clarification_needs includes options + recommended
221
+
222
+ ## Output
223
+ Write: ${sessionFolder}/exploration-${angle}.json
224
+ Return: 2-3 sentence summary of ${angle} findings
225
+ `
226
+ )
227
+ )
228
+
229
+ // Execute all exploration tasks in parallel
230
+ ```
231
+
232
+ **Auto-discover Generated Exploration Files**:
233
+ ```javascript
234
+ // After explorations complete, auto-discover all exploration-*.json files
235
+ const explorationFiles = bash(`find ${sessionFolder} -name "exploration-*.json" -type f`)
236
+ .split('\n')
237
+ .filter(f => f.trim())
238
+
239
+ // Read metadata to build manifest
240
+ const explorationManifest = {
241
+ session_id: sessionId,
242
+ task_description: task_description,
243
+ timestamp: getUtc8ISOString(),
244
+ complexity: complexity,
245
+ exploration_count: explorationCount,
246
+ explorations: explorationFiles.map(file => {
247
+ const data = JSON.parse(Read(file))
248
+ const filename = path.basename(file)
249
+ return {
250
+ angle: data._metadata.exploration_angle,
251
+ file: filename,
252
+ path: file,
253
+ index: data._metadata.exploration_index
254
+ }
255
+ })
256
+ }
257
+
258
+ Write(`${sessionFolder}/explorations-manifest.json`, JSON.stringify(explorationManifest, null, 2))
259
+
260
+ console.log(`
261
+ ## Exploration Complete
262
+
263
+ Generated exploration files in ${sessionFolder}:
264
+ ${explorationManifest.explorations.map(e => `- exploration-${e.angle}.json (angle: ${e.angle})`).join('\n')}
265
+
266
+ Manifest: explorations-manifest.json
267
+ Angles explored: ${explorationManifest.explorations.map(e => e.angle).join(', ')}
268
+ `)
269
+ ```
270
+
271
+ **Output**:
272
+ - `${sessionFolder}/exploration-{angle1}.json`
273
+ - `${sessionFolder}/exploration-{angle2}.json`
274
+ - ... (1-4 files based on complexity)
275
+ - `${sessionFolder}/explorations-manifest.json`
276
+
277
+ ---
278
+
279
+ ### Phase 2: Clarification (Optional, Multi-Round)
280
+
281
+ **Skip if**: No exploration or `clarification_needs` is empty across all explorations
282
+
283
+ **⚠️ CRITICAL**: AskUserQuestion tool limits max 4 questions per call. **MUST execute multiple rounds** to exhaust all clarification needs - do NOT stop at round 1.
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
+ // Deduplicate exact same questions only
308
+ const seen = new Set()
309
+ const dedupedClarifications = allClarifications.filter(c => {
310
+ const key = c.question.toLowerCase()
311
+ if (seen.has(key)) return false
312
+ seen.add(key)
313
+ return true
314
+ })
315
+
316
+ // Multi-round clarification: batch questions (max 4 per round)
317
+ if (dedupedClarifications.length > 0) {
318
+ const BATCH_SIZE = 4
319
+ const totalRounds = Math.ceil(dedupedClarifications.length / BATCH_SIZE)
320
+
321
+ for (let i = 0; i < dedupedClarifications.length; i += BATCH_SIZE) {
322
+ const batch = dedupedClarifications.slice(i, i + BATCH_SIZE)
323
+ const currentRound = Math.floor(i / BATCH_SIZE) + 1
324
+
325
+ console.log(`### Clarification Round ${currentRound}/${totalRounds}`)
326
+
327
+ AskUserQuestion({
328
+ questions: batch.map(need => ({
329
+ question: `[${need.source_angle}] ${need.question}\n\nContext: ${need.context}`,
330
+ header: need.source_angle.substring(0, 12),
331
+ multiSelect: false,
332
+ options: need.options.map((opt, index) => ({
333
+ label: need.recommended === index ? `${opt} ★` : opt,
334
+ description: need.recommended === index ? `Recommended` : `Use ${opt}`
335
+ }))
336
+ }))
337
+ })
338
+
339
+ // Store batch responses in clarificationContext before next round
340
+ }
341
+ }
342
+ ```
343
+
344
+ **Output**: `clarificationContext` (in-memory)
345
+
346
+ ---
347
+
348
+ ### Phase 3: Planning
349
+
350
+ **Planning Strategy Selection** (based on Phase 1 complexity):
351
+
352
+ **IMPORTANT**: Phase 3 is **planning only** - NO code execution. All execution happens in Phase 5 via lite-execute.
353
+
354
+ **Low Complexity** - Direct planning by Claude:
355
+ ```javascript
356
+ // Step 1: Read schema
357
+ const schema = Bash(`cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json`)
358
+
359
+ // Step 2: Generate plan following schema (Claude directly, no agent)
360
+ const plan = {
361
+ summary: "...",
362
+ approach: "...",
363
+ tasks: [...], // Each task: { id, title, scope, ..., depends_on, execution_group, complexity }
364
+ estimated_time: "...",
365
+ recommended_execution: "Agent",
366
+ complexity: "Low",
367
+ _metadata: { timestamp: getUtc8ISOString(), source: "direct-planning", planning_mode: "direct" }
368
+ }
369
+
370
+ // Step 3: Write plan to session folder
371
+ Write(`${sessionFolder}/plan.json`, JSON.stringify(plan, null, 2))
372
+
373
+ // Step 4: MUST continue to Phase 4 (Confirmation) - DO NOT execute code here
374
+ ```
375
+
376
+ **Medium/High Complexity** - Invoke cli-lite-planning-agent:
377
+
378
+ ```javascript
379
+ Task(
380
+ subagent_type="cli-lite-planning-agent",
381
+ description="Generate detailed implementation plan",
382
+ prompt=`
383
+ Generate implementation plan and write plan.json.
384
+
385
+ ## Output Schema Reference
386
+ Execute: cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json (get schema reference before generating plan)
387
+
388
+ ## Task Description
389
+ ${task_description}
390
+
391
+ ## Multi-Angle Exploration Context
392
+
393
+ ${manifest.explorations.map(exp => `### Exploration: ${exp.angle} (${exp.file})
394
+ Path: ${exp.path}
395
+
396
+ Read this file for detailed ${exp.angle} analysis.`).join('\n\n')}
397
+
398
+ Total explorations: ${manifest.exploration_count}
399
+ Angles covered: ${manifest.explorations.map(e => e.angle).join(', ')}
400
+
401
+ Manifest: ${sessionFolder}/explorations-manifest.json
402
+
403
+ ## User Clarifications
404
+ ${JSON.stringify(clarificationContext) || "None"}
405
+
406
+ ## Complexity Level
407
+ ${complexity}
408
+
409
+ ## Requirements
410
+ Generate plan.json with:
411
+ - summary: 2-3 sentence overview
412
+ - approach: High-level implementation strategy (incorporating insights from all exploration angles)
413
+ - tasks: 2-7 structured tasks (**IMPORTANT: group by feature/module, NOT by file**)
414
+ - **Task Granularity Principle**: Each task = one complete feature unit or module
415
+ - title: action verb + target module/feature (e.g., "Implement auth token refresh")
416
+ - scope: module path (src/auth/) or feature name, prefer module-level over single file
417
+ - action, description
418
+ - modification_points: ALL files to modify for this feature (group related changes)
419
+ - implementation (3-7 steps covering all modification_points)
420
+ - reference (pattern, files, examples)
421
+ - acceptance (2-4 criteria for the entire feature)
422
+ - depends_on: task IDs this task depends on (use sparingly, only for true dependencies)
423
+ - estimated_time, recommended_execution, complexity
424
+ - _metadata:
425
+ - timestamp, source, planning_mode
426
+ - exploration_angles: ${JSON.stringify(manifest.explorations.map(e => e.angle))}
427
+
428
+ ## Task Grouping Rules
429
+ 1. **Group by feature**: All changes for one feature = one task (even if 3-5 files)
430
+ 2. **Group by context**: Tasks with similar context or related functional changes can be grouped together
431
+ 3. **Minimize agent count**: Simple, unrelated tasks can also be grouped to reduce agent execution overhead
432
+ 4. **Avoid file-per-task**: Do NOT create separate tasks for each file
433
+ 5. **Substantial tasks**: Each task should represent 15-60 minutes of work
434
+ 6. **True dependencies only**: Only use depends_on when Task B cannot start without Task A's output
435
+ 7. **Prefer parallel**: Most tasks should be independent (no depends_on)
436
+
437
+ ## Execution
438
+ 1. Read ALL exploration files for comprehensive context
439
+ 2. Execute CLI planning using Gemini (Qwen fallback)
440
+ 3. Synthesize findings from multiple exploration angles
441
+ 4. Parse output and structure plan
442
+ 5. Write JSON: Write('${sessionFolder}/plan.json', jsonContent)
443
+ 6. Return brief completion summary
444
+ `
445
+ )
446
+ ```
447
+
448
+ **Output**: `${sessionFolder}/plan.json`
449
+
450
+ ---
451
+
452
+ ### Phase 4: Task Confirmation & Execution Selection
453
+
454
+ **Step 4.1: Display Plan**
455
+ ```javascript
456
+ const plan = JSON.parse(Read(`${sessionFolder}/plan.json`))
457
+
458
+ console.log(`
459
+ ## Implementation Plan
460
+
461
+ **Summary**: ${plan.summary}
462
+ **Approach**: ${plan.approach}
463
+
464
+ **Tasks** (${plan.tasks.length}):
465
+ ${plan.tasks.map((t, i) => `${i+1}. ${t.title} (${t.file})`).join('\n')}
466
+
467
+ **Complexity**: ${plan.complexity}
468
+ **Estimated Time**: ${plan.estimated_time}
469
+ **Recommended**: ${plan.recommended_execution}
470
+ `)
471
+ ```
472
+
473
+ **Step 4.2: Collect Confirmation**
474
+ ```javascript
475
+ AskUserQuestion({
476
+ questions: [
477
+ {
478
+ question: `Confirm plan? (${plan.tasks.length} tasks, ${plan.complexity})`,
479
+ header: "Confirm",
480
+ multiSelect: true,
481
+ options: [
482
+ { label: "Allow", description: "Proceed as-is" },
483
+ { label: "Modify", description: "Adjust before execution" },
484
+ { label: "Cancel", description: "Abort workflow" }
485
+ ]
486
+ },
487
+ {
488
+ question: "Execution method:",
489
+ header: "Execution",
490
+ multiSelect: false,
491
+ options: [
492
+ { label: "Agent", description: "@code-developer agent" },
493
+ { label: "Codex", description: "codex CLI tool" },
494
+ { label: "Auto", description: `Auto: ${plan.complexity === 'Low' ? 'Agent' : 'Codex'}` }
495
+ ]
496
+ },
497
+ {
498
+ question: "Code review after execution?",
499
+ header: "Review",
500
+ multiSelect: false,
501
+ options: [
502
+ { label: "Gemini Review", description: "Gemini CLI" },
503
+ { label: "Agent Review", description: "@code-reviewer" },
504
+ { label: "Skip", description: "No review" }
505
+ ]
506
+ }
507
+ ]
508
+ })
509
+ ```
510
+
511
+ ---
512
+
513
+ ### Phase 5: Dispatch to Execution
514
+
515
+ **CRITICAL**: lite-plan NEVER executes code directly. ALL execution MUST go through lite-execute.
516
+
517
+ **Step 5.1: Build executionContext**
518
+
519
+ ```javascript
520
+ // Load manifest and all exploration files
521
+ const manifest = JSON.parse(Read(`${sessionFolder}/explorations-manifest.json`))
522
+ const explorations = {}
523
+
524
+ manifest.explorations.forEach(exp => {
525
+ if (file_exists(exp.path)) {
526
+ explorations[exp.angle] = JSON.parse(Read(exp.path))
527
+ }
528
+ })
529
+
530
+ const plan = JSON.parse(Read(`${sessionFolder}/plan.json`))
531
+
532
+ executionContext = {
533
+ planObject: plan,
534
+ explorationsContext: explorations,
535
+ explorationAngles: manifest.explorations.map(e => e.angle),
536
+ explorationManifest: manifest,
537
+ clarificationContext: clarificationContext || null,
538
+ executionMethod: userSelection.execution_method,
539
+ codeReviewTool: userSelection.code_review_tool,
540
+ originalUserInput: task_description,
541
+ session: {
542
+ id: sessionId,
543
+ folder: sessionFolder,
544
+ artifacts: {
545
+ explorations: manifest.explorations.map(exp => ({
546
+ angle: exp.angle,
547
+ path: exp.path
548
+ })),
549
+ explorations_manifest: `${sessionFolder}/explorations-manifest.json`,
550
+ plan: `${sessionFolder}/plan.json`
551
+ }
552
+ }
553
+ }
554
+ ```
555
+
556
+ **Step 5.2: Dispatch**
557
+
558
+ ```javascript
559
+ SlashCommand(command="/workflow:lite-execute --in-memory")
560
+ ```
561
+
562
+ ## Session Folder Structure
563
+
564
+ ```
565
+ .workflow/.lite-plan/{task-slug}-{YYYY-MM-DD}/
566
+ ├── exploration-{angle1}.json # Exploration angle 1
567
+ ├── exploration-{angle2}.json # Exploration angle 2
568
+ ├── exploration-{angle3}.json # Exploration angle 3 (if applicable)
569
+ ├── exploration-{angle4}.json # Exploration angle 4 (if applicable)
570
+ ├── explorations-manifest.json # Exploration index
571
+ └── plan.json # Implementation plan
572
+ ```
573
+
574
+ **Example**:
575
+ ```
576
+ .workflow/.lite-plan/implement-jwt-refresh-2025-11-25-14-30-25/
577
+ ├── exploration-architecture.json
578
+ ├── exploration-auth-patterns.json
579
+ ├── exploration-security.json
580
+ ├── explorations-manifest.json
581
+ └── plan.json
582
+ ```
583
+
584
+ ## Error Handling
585
+
586
+ | Error | Resolution |
587
+ |-------|------------|
588
+ | Exploration agent failure | Skip exploration, continue with task description only |
589
+ | Planning agent failure | Fallback to direct planning by Claude |
590
+ | Clarification timeout | Use exploration findings as-is |
591
+ | Confirmation timeout | Save context, display resume instructions |
592
+ | Modify loop > 3 times | Suggest breaking task or using /workflow:plan |