refactor(workflow): enhance TodoWrite patterns for plan, tdd-plan, test-fix-gen, and test-gen commands with dynamic task attachment and collapse strategies

This commit is contained in:
catlog22
2025-11-11 19:37:11 +08:00
parent 0a773b9411
commit 7d77b0e6f7
4 changed files with 235 additions and 340 deletions

View File

@@ -93,9 +93,33 @@ CONTEXT: Existing user database schema, REST API endpoints
- Context package path extracted - Context package path extracted
- File exists and is valid JSON - File exists and is valid JSON
**TodoWrite**: Mark phase 2 completed, phase 3/4 in_progress (depending on conflict_risk) <!-- TodoWrite: When context-gather invoked, INSERT 3 context-gather tasks, mark first as in_progress -->
**Task Attachment**: SlashCommand invocation attaches 3 context-gather sub-tasks, executes them, then collapses to phase summary (see TodoWrite Pattern section for details) **TodoWrite Update (Phase 2 SlashCommand invoked - tasks attached)**:
```json
[
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2.1: Analyze codebase structure (context-gather)", "status": "in_progress", "activeForm": "Analyzing codebase structure"},
{"content": "Phase 2.2: Identify integration points (context-gather)", "status": "pending", "activeForm": "Identifying integration points"},
{"content": "Phase 2.3: Generate context package (context-gather)", "status": "pending", "activeForm": "Generating context package"},
{"content": "Execute task generation", "status": "pending", "activeForm": "Executing task generation"}
]
```
**Note**: SlashCommand invocation **attaches** context-gather's 3 tasks. Orchestrator **executes** these tasks sequentially.
<!-- TodoWrite: After Phase 2 tasks complete, REMOVE Phase 2.1-2.3, restore to orchestrator view -->
**TodoWrite Update (Phase 2 completed - tasks collapsed)**:
```json
[
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Execute task generation", "status": "pending", "activeForm": "Executing task generation"}
]
```
**Note**: Phase 2 tasks completed and collapsed to summary.
**After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3/4 (depending on conflict_risk) **After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3/4 (depending on conflict_risk)
@@ -123,9 +147,35 @@ CONTEXT: Existing user database schema, REST API endpoints
- If conflict_risk is "none" or "low", skip directly to Phase 3.5 - If conflict_risk is "none" or "low", skip directly to Phase 3.5
- Display: "No significant conflicts detected, proceeding to clarification" - Display: "No significant conflicts detected, proceeding to clarification"
**TodoWrite**: If executed, mark phase 3 completed, phase 3.5/4 in_progress <!-- TodoWrite: If conflict_risk ≥ medium, INSERT 3 conflict-resolution tasks -->
**Task Attachment**: If conflict_risk ≥ medium, SlashCommand invocation attaches 3 conflict-resolution sub-tasks, executes them, then collapses to phase summary (see TodoWrite Pattern section for details) **TodoWrite Update (Phase 3 SlashCommand invoked - tasks attached, if conflict_risk ≥ medium)**:
```json
[
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3.1: Detect conflicts with CLI analysis (conflict-resolution)", "status": "in_progress", "activeForm": "Detecting conflicts"},
{"content": "Phase 3.2: Present conflicts to user (conflict-resolution)", "status": "pending", "activeForm": "Presenting conflicts"},
{"content": "Phase 3.3: Apply resolution strategies (conflict-resolution)", "status": "pending", "activeForm": "Applying resolution strategies"},
{"content": "Execute task generation", "status": "pending", "activeForm": "Executing task generation"}
]
```
**Note**: SlashCommand invocation **attaches** conflict-resolution's 3 tasks. Orchestrator **executes** these tasks sequentially.
<!-- TodoWrite: After Phase 3 tasks complete, REMOVE Phase 3.1-3.3, restore to orchestrator view -->
**TodoWrite Update (Phase 3 completed - tasks collapsed)**:
```json
[
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Resolve conflicts and apply fixes", "status": "completed", "activeForm": "Resolving conflicts"},
{"content": "Execute task generation", "status": "pending", "activeForm": "Executing task generation"}
]
```
**Note**: Phase 3 tasks completed and collapsed to summary.
**After Phase 3**: Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 3.5 **After Phase 3**: Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 3.5
@@ -232,94 +282,47 @@ Quality Gate: Consider running /workflow:action-plan-verify to catch issues earl
## TodoWrite Pattern ## TodoWrite Pattern
```javascript **Core Concept**: Dynamic task attachment and collapse for real-time visibility into workflow execution.
// ⚠️ CRITICAL: Dynamic TodoWrite task attachment strategy:
//
// **Key Concept**: SlashCommand invocation ATTACHES tasks to current workflow.
// Orchestrator EXECUTES these attached tasks itself, then COLLAPSES them.
//
// 1. INITIAL STATE: 3 orchestrator-level tasks (or 4 if conflict_risk ≥ medium added later)
TodoWrite({todos: [
{"content": "Execute session discovery", "status": "in_progress", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "pending", "activeForm": "Executing context gathering"},
{"content": "Execute task generation", "status": "pending", "activeForm": "Executing task generation"}
]})
// 2. PHASE 2 SlashCommand INVOCATION: ### Key Principles
// - SlashCommand(/workflow:tools:context-gather) ATTACHES 3 tasks
// - TodoWrite expands to: Phase 1 (completed) + 3 context-gather tasks + Phase 4
// - Orchestrator EXECUTES these 3 tasks sequentially (Phase 2.1 → 2.2 → 2.3)
// - First attached task marked as in_progress
TodoWrite({todos: [
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2.1: Analyze codebase structure (context-gather)", "status": "in_progress", "activeForm": "Analyzing codebase structure"},
{"content": "Phase 2.2: Identify integration points (context-gather)", "status": "pending", "activeForm": "Identifying integration points"},
{"content": "Phase 2.3: Generate context package (context-gather)", "status": "pending", "activeForm": "Generating context package"},
{"content": "Execute task generation", "status": "pending", "activeForm": "Executing task generation"}
]})
// 3. PHASE 2 TASKS COMPLETED: 1. **Task Attachment** (when SlashCommand invoked):
// - All 3 context-gather tasks executed and completed - Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
// - COLLAPSE completed tasks into Phase 2 summary - Example: `/workflow:tools:context-gather` attaches 3 sub-tasks (Phase 2.1, 2.2, 2.3)
// - TodoWrite becomes: Phase 1-2 (completed) + Phase 4 - First attached task marked as `in_progress`, others as `pending`
TodoWrite({todos: [ - Orchestrator **executes** these attached tasks sequentially
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Execute task generation", "status": "pending", "activeForm": "Executing task generation"}
]})
// 4. CONDITIONAL: IF conflict_risk ≥ medium → PHASE 3 SlashCommand INVOCATION: 2. **Task Collapse** (after sub-tasks complete):
// - SlashCommand(/workflow:tools:conflict-resolution) ATTACHES 3 tasks - Remove detailed sub-tasks from TodoWrite
// - TodoWrite expands to: Phase 1-2 (completed) + 3 conflict-resolution tasks + Phase 4 - **Collapse** to high-level phase summary
// - Orchestrator EXECUTES these 3 tasks sequentially (Phase 3.1 → 3.2 → 3.3) - Example: Phase 2.1-2.3 collapse to "Execute context gathering: completed"
TodoWrite({todos: [ - Maintains clean orchestrator-level view
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3.1: Detect conflicts with CLI analysis (conflict-resolution)", "status": "in_progress", "activeForm": "Detecting conflicts"},
{"content": "Phase 3.2: Present conflicts to user (conflict-resolution)", "status": "pending", "activeForm": "Presenting conflicts"},
{"content": "Phase 3.3: Apply resolution strategies (conflict-resolution)", "status": "pending", "activeForm": "Applying resolution strategies"},
{"content": "Execute task generation", "status": "pending", "activeForm": "Executing task generation"}
]})
// 5. PHASE 3 TASKS COMPLETED (if executed): 3. **Continuous Execution**:
// - All 3 conflict-resolution tasks executed and completed - After collapse, automatically proceed to next pending phase
// - COLLAPSE completed tasks into Phase 3 summary - No user intervention required between phases
// - TodoWrite returns to: Phase 1-3 (completed) + Phase 4 - TodoWrite dynamically reflects current execution state
TodoWrite({todos: [
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Resolve conflicts and apply fixes", "status": "completed", "activeForm": "Resolving conflicts"},
{"content": "Execute task generation", "status": "pending", "activeForm": "Executing task generation"}
]})
// 6. PHASE 4 SlashCommand INVOCATION: ### Lifecycle Pattern
// - SlashCommand(/workflow:tools:task-generate-agent) ATTACHES 3 tasks
// - TodoWrite expands to: Phase 1-2-3 (completed) + 3 task-generate-agent tasks
// - Orchestrator EXECUTES these 3 tasks sequentially (Phase 4.1 → 4.2 → 4.3)
TodoWrite({todos: [
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 4.1: Discovery - analyze requirements (task-generate-agent)", "status": "in_progress", "activeForm": "Analyzing requirements"},
{"content": "Phase 4.2: Planning - design tasks (task-generate-agent)", "status": "pending", "activeForm": "Designing tasks"},
{"content": "Phase 4.3: Output - generate JSONs (task-generate-agent)", "status": "pending", "activeForm": "Generating task JSONs"}
]})
// 7. PHASE 4 TASKS COMPLETED:
// - All 3 task-generate-agent tasks executed and completed
// - COLLAPSE completed tasks into Phase 4 summary
// - Final state: All orchestrator tasks completed
TodoWrite({todos: [
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Execute task generation", "status": "completed", "activeForm": "Executing task generation"}
]})
// Benefits:
// ✓ Real-time visibility into attached tasks during execution
// ✓ Clean orchestrator-level summary after tasks complete
// ✓ Clear mental model: SlashCommand = attach tasks, not delegate work
// ✓ Dynamic attachment/collapse maintains clarity
``` ```
Initial: [Phase 1: pending] [Phase 2: pending] [Phase 3: pending]
Phase 2 Invoked (ATTACHED):
[Phase 1: completed] [Phase 2.1: in_progress] [Phase 2.2: pending] [Phase 2.3: pending] [Phase 3: pending]
Phase 2 Completed (COLLAPSED):
[Phase 1: completed] [Phase 2: completed] [Phase 3: pending]
```
### Benefits
- ✓ Real-time visibility into sub-task execution
- ✓ Clear mental model: SlashCommand = attach → execute → collapse
- ✓ Clean summary after completion
- ✓ Easy to track workflow progress
**Note**: See individual Phase descriptions (Phase 2, 3, 4) for detailed TodoWrite Update examples with full JSON structures.
## Input Processing ## Input Processing

View File

@@ -316,100 +316,59 @@ Quality Gate: Consider running /workflow:action-plan-verify to validate TDD task
## TodoWrite Pattern ## TodoWrite Pattern
```javascript **Core Concept**: Dynamic task attachment and collapse for TDD workflow with test coverage analysis and Red-Green-Refactor cycle generation.
// ⚠️ CRITICAL: Dynamic TodoWrite task attachment strategy for TDD workflow:
//
// **Key Concept**: SlashCommand invocation ATTACHES tasks to current workflow.
// Orchestrator EXECUTES these attached tasks itself, then COLLAPSES them.
// TDD-specific: Generated IMPL tasks contain internal Red-Green-Refactor cycles.
//
// 1. INITIAL STATE: 5 orchestrator-level tasks (or 6 if conflict_risk ≥ medium added later)
TodoWrite({todos: [
{"content": "Execute session discovery", "status": "in_progress", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "pending", "activeForm": "Executing context gathering"},
{"content": "Execute test coverage analysis", "status": "pending", "activeForm": "Executing test coverage analysis"},
{"content": "Execute TDD task generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Validate TDD structure", "status": "pending", "activeForm": "Validating TDD structure"}
]})
// 2. PHASE 3 SlashCommand INVOCATION (test-context-gather): ### Key Principles
// - SlashCommand(/workflow:tools:test-context-gather) ATTACHES 3 tasks
// - Orchestrator EXECUTES these 3 tasks sequentially
TodoWrite({todos: [
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3.1: Detect test framework and conventions (test-context-gather)", "status": "in_progress", "activeForm": "Detecting test framework"},
{"content": "Phase 3.2: Analyze existing test coverage (test-context-gather)", "status": "pending", "activeForm": "Analyzing test coverage"},
{"content": "Phase 3.3: Identify coverage gaps (test-context-gather)", "status": "pending", "activeForm": "Identifying coverage gaps"},
{"content": "Execute TDD task generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Validate TDD structure", "status": "pending", "activeForm": "Validating TDD structure"}
]})
// 3. PHASE 3 TASKS COMPLETED: 1. **Task Attachment** (when SlashCommand invoked):
// - COLLAPSE completed tasks into Phase 3 summary - Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
TodoWrite({todos: [ - Example: `/workflow:tools:test-context-gather` attaches 3 sub-tasks (Phase 3.1, 3.2, 3.3)
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"}, - First attached task marked as `in_progress`, others as `pending`
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"}, - Orchestrator **executes** these attached tasks sequentially
{"content": "Execute test coverage analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Execute TDD task generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Validate TDD structure", "status": "pending", "activeForm": "Validating TDD structure"}
]})
// 4. CONDITIONAL: IF conflict_risk ≥ medium → PHASE 4 SlashCommand INVOCATION: 2. **Task Collapse** (after sub-tasks complete):
// - SlashCommand(/workflow:tools:conflict-resolution) ATTACHES 3 tasks - Remove detailed sub-tasks from TodoWrite
TodoWrite({todos: [ - **Collapse** to high-level phase summary
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"}, - Example: Phase 3.1-3.3 collapse to "Execute test coverage analysis: completed"
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"}, - Maintains clean orchestrator-level view
{"content": "Execute test coverage analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 4.1: Detect conflicts with CLI analysis (conflict-resolution)", "status": "in_progress", "activeForm": "Detecting conflicts"},
{"content": "Phase 4.2: Present conflicts to user (conflict-resolution)", "status": "pending", "activeForm": "Presenting conflicts"},
{"content": "Phase 4.3: Apply resolution strategies (conflict-resolution)", "status": "pending", "activeForm": "Applying resolution strategies"},
{"content": "Execute TDD task generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Validate TDD structure", "status": "pending", "activeForm": "Validating TDD structure"}
]})
// 5. PHASE 4 TASKS COMPLETED (if executed): 3. **Continuous Execution**:
// - COLLAPSE completed tasks into Phase 4 summary - After collapse, automatically proceed to next pending phase
TodoWrite({todos: [ - No user intervention required between phases
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"}, - TodoWrite dynamically reflects current execution state
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Execute test coverage analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Execute conflict resolution", "status": "completed", "activeForm": "Executing conflict resolution"},
{"content": "Execute TDD task generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Validate TDD structure", "status": "pending", "activeForm": "Validating TDD structure"}
]})
// 6. PHASE 5 SlashCommand INVOCATION (task-generate-tdd): ### Lifecycle Pattern
// - SlashCommand(/workflow:tools:task-generate-tdd) ATTACHES 3 tasks
// - Generates IMPL tasks with internal Red-Green-Refactor cycles
TodoWrite({todos: [
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Execute test coverage analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 5.1: Discovery - analyze TDD requirements (task-generate-tdd)", "status": "in_progress", "activeForm": "Analyzing TDD requirements"},
{"content": "Phase 5.2: Planning - design Red-Green-Refactor cycles (task-generate-tdd)", "status": "pending", "activeForm": "Designing TDD cycles"},
{"content": "Phase 5.3: Output - generate IMPL tasks with internal TDD phases (task-generate-tdd)", "status": "pending", "activeForm": "Generating TDD tasks"},
{"content": "Validate TDD structure", "status": "pending", "activeForm": "Validating TDD structure"}
]})
// 7. PHASE 5 TASKS COMPLETED:
// - COLLAPSE completed tasks into Phase 5 summary
// - Each generated IMPL task contains internal Red-Green-Refactor cycle
TodoWrite({todos: [
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Execute test coverage analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Execute TDD task generation", "status": "completed", "activeForm": "Executing TDD task generation"},
{"content": "Validate TDD structure", "status": "in_progress", "activeForm": "Validating TDD structure"}
]})
// Benefits:
// ✓ Real-time visibility into attached tasks during execution
// ✓ Clean orchestrator-level summary after tasks complete
// ✓ Clear mental model: SlashCommand = attach tasks, not delegate work
// ✓ TDD-specific: Shows Red-Green-Refactor cycle generation in Phase 5
// ✓ Dynamic attachment/collapse maintains clarity
``` ```
Initial: [Phase 1: pending] [Phase 2: pending] [Phase 3: pending] [Phase 5: pending]
Phase 3 Invoked (ATTACHED):
[Phase 1-2: completed] [Phase 3.1: in_progress] [Phase 3.2: pending] [Phase 3.3: pending] [Phase 5: pending]
Phase 3 Completed (COLLAPSED):
[Phase 1-2: completed] [Phase 3: completed] [Phase 5: pending]
Phase 5 Invoked (ATTACHED, generates TDD tasks):
[Phase 1-3: completed] [Phase 5.1: in_progress] [Phase 5.2: pending] [Phase 5.3: pending]
Phase 5 Completed (COLLAPSED, each IMPL task contains Red-Green-Refactor cycle):
[Phase 1-3: completed] [Phase 5: completed] [Phase 6: in_progress]
```
### TDD-Specific Features
- **Phase 3**: Test coverage analysis detects existing patterns and gaps
- **Phase 5**: Generated IMPL tasks contain internal Red-Green-Refactor cycles
- **Conditional Phase 4**: Conflict resolution only if conflict_risk ≥ medium
### Benefits
- ✓ Real-time visibility into TDD workflow execution
- ✓ Clear mental model: SlashCommand = attach → execute → collapse
- ✓ Test-aware planning with coverage analysis
- ✓ Self-contained TDD cycles within each IMPL task
**Note**: See individual Phase descriptions (Phase 3, 4, 5) for detailed TodoWrite Update examples with full JSON structures.
## Execution Flow Diagram ## Execution Flow Diagram

View File

@@ -339,100 +339,67 @@ CRITICAL - Next Steps:
--- ---
### TodoWrite Progress Tracking ### TodoWrite Pattern
```javascript **Core Concept**: Dynamic task attachment and collapse for test-fix-gen workflow with dual-mode support (Session Mode and Prompt Mode).
// ⚠️ CRITICAL: Dynamic TodoWrite task attachment strategy for test-fix-gen workflow:
//
// **Key Concept**: SlashCommand invocation ATTACHES tasks to current workflow.
// Orchestrator EXECUTES these attached tasks itself, then COLLAPSES them.
// **Dual-Mode Support**: Both Session Mode and Prompt Mode follow same attachment pattern.
//
// 1. INITIAL STATE: 5 orchestrator-level tasks
TodoWrite({todos: [
{"content": "Create independent test session", "status": "in_progress", "activeForm": "Creating test session"},
{"content": "Gather test coverage context", "status": "pending", "activeForm": "Gathering test coverage context"},
{"content": "Analyze test requirements with Gemini", "status": "pending", "activeForm": "Analyzing test requirements"},
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 2. PHASE 2 SlashCommand INVOCATION: #### Key Principles
// - Session Mode: SlashCommand(/workflow:tools:test-context-gather) ATTACHES 3 tasks
// - Prompt Mode: SlashCommand(/workflow:tools:context-gather) ATTACHES 3 tasks
// - Orchestrator EXECUTES these 3 tasks sequentially
TodoWrite({todos: [
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"},
{"content": "Phase 2.1: Load context and analyze coverage (context-gather)", "status": "in_progress", "activeForm": "Loading context"},
{"content": "Phase 2.2: Detect test framework and conventions (context-gather)", "status": "pending", "activeForm": "Detecting test framework"},
{"content": "Phase 2.3: Generate context package (context-gather)", "status": "pending", "activeForm": "Generating context package"},
{"content": "Analyze test requirements with Gemini", "status": "pending", "activeForm": "Analyzing test requirements"},
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 3. PHASE 2 TASKS COMPLETED: 1. **Task Attachment** (when SlashCommand invoked):
// - COLLAPSE completed tasks into Phase 2 summary - Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
TodoWrite({todos: [ - Example: `/workflow:tools:test-context-gather` (Session Mode) or `/workflow:tools:context-gather` (Prompt Mode) attaches 3 sub-tasks (Phase 2.1, 2.2, 2.3)
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"}, - First attached task marked as `in_progress`, others as `pending`
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"}, - Orchestrator **executes** these attached tasks sequentially
{"content": "Analyze test requirements with Gemini", "status": "pending", "activeForm": "Analyzing test requirements"},
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 4. PHASE 3 SlashCommand INVOCATION (test-concept-enhanced): 2. **Task Collapse** (after sub-tasks complete):
// - SlashCommand(/workflow:tools:test-concept-enhanced) ATTACHES 3 tasks - Remove detailed sub-tasks from TodoWrite
TodoWrite({todos: [ - **Collapse** to high-level phase summary
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"}, - Example: Phase 2.1-2.3 collapse to "Gather test coverage context: completed"
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"}, - Maintains clean orchestrator-level view
{"content": "Phase 3.1: Analyze coverage gaps with Gemini (test-concept-enhanced)", "status": "in_progress", "activeForm": "Analyzing coverage gaps"},
{"content": "Phase 3.2: Study existing test patterns (test-concept-enhanced)", "status": "pending", "activeForm": "Studying test patterns"},
{"content": "Phase 3.3: Generate test generation strategy (test-concept-enhanced)", "status": "pending", "activeForm": "Generating test strategy"},
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 5. PHASE 3 TASKS COMPLETED: 3. **Continuous Execution**:
// - COLLAPSE completed tasks into Phase 3 summary - After collapse, automatically proceed to next pending phase
TodoWrite({todos: [ - No user intervention required between phases
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"}, - TodoWrite dynamically reflects current execution state
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"},
{"content": "Analyze test requirements with Gemini", "status": "completed", "activeForm": "Analyzing test requirements"},
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 6. PHASE 4 SlashCommand INVOCATION (test-task-generate): #### Lifecycle Pattern
// - SlashCommand(/workflow:tools:test-task-generate) ATTACHES 3 tasks
// - Generates IMPL-001.json, IMPL-002.json, and optionally IMPL-003.json
TodoWrite({todos: [
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"},
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"},
{"content": "Analyze test requirements with Gemini", "status": "completed", "activeForm": "Analyzing test requirements"},
{"content": "Phase 4.1: Parse TEST_ANALYSIS_RESULTS.md (test-task-generate)", "status": "in_progress", "activeForm": "Parsing test analysis"},
{"content": "Phase 4.2: Generate task JSONs (IMPL-001, IMPL-002) (test-task-generate)", "status": "pending", "activeForm": "Generating task JSONs"},
{"content": "Phase 4.3: Generate IMPL_PLAN.md and TODO_LIST.md (test-task-generate)", "status": "pending", "activeForm": "Generating plan documents"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 7. PHASE 4 TASKS COMPLETED:
// - COLLAPSE completed tasks into Phase 4 summary
TodoWrite({todos: [
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"},
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"},
{"content": "Analyze test requirements with Gemini", "status": "completed", "activeForm": "Analyzing test requirements"},
{"content": "Generate test generation and execution tasks", "status": "completed", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "in_progress", "activeForm": "Returning workflow summary"}
]})
// Benefits:
// ✓ Real-time visibility into attached tasks during execution
// ✓ Clean orchestrator-level summary after tasks complete
// ✓ Clear mental model: SlashCommand = attach tasks, not delegate work
// ✓ Dual-mode support: Both Session Mode and Prompt Mode use same attachment pattern
// ✓ Dynamic attachment/collapse maintains clarity
``` ```
Initial: [Phase 1: pending] [Phase 2: pending] [Phase 3: pending] [Phase 4: pending] [Phase 5: pending]
Phase 2 Invoked (ATTACHED - mode-specific context gathering):
[Phase 1: completed] [Phase 2.1: in_progress] [Phase 2.2: pending] [Phase 2.3: pending] [Phase 3: pending] [Phase 4: pending] [Phase 5: pending]
Phase 2 Completed (COLLAPSED):
[Phase 1: completed] [Phase 2: completed] [Phase 3: pending] [Phase 4: pending] [Phase 5: pending]
Phase 3 Invoked (ATTACHED):
[Phase 1: completed] [Phase 2: completed] [Phase 3.1: in_progress] [Phase 3.2: pending] [Phase 3.3: pending] [Phase 4: pending] [Phase 5: pending]
Phase 3 Completed (COLLAPSED):
[Phase 1: completed] [Phase 2: completed] [Phase 3: completed] [Phase 4: pending] [Phase 5: pending]
[Continue pattern through Phase 4 and Phase 5...]
```
#### Test-Fix-Gen Specific Features
- **Dual-Mode Support**: Automatic mode detection based on input pattern
- **Session Mode**: Input pattern `WFS-*` → uses `test-context-gather` for cross-session context
- **Prompt Mode**: Text or file path → uses `context-gather` for direct codebase analysis
- **Phase 2**: Mode-specific context gathering (session summaries vs codebase analysis)
- **Phase 3**: Multi-layered test requirements analysis (L0: Static, L1: Unit, L2: Integration, L3: E2E)
- **Phase 4**: Multi-task generation with quality gate (IMPL-001, IMPL-001.5-review, IMPL-002)
- **Fix Mode Configuration**: `--use-codex` flag controls IMPL-002 fix mode (manual vs automated)
**Benefits**:
- Real-time visibility into attached tasks during execution
- Clean orchestrator-level summary after tasks complete
- Clear mental model: SlashCommand = attach tasks, not delegate work
- Dual-mode support: Both Session Mode and Prompt Mode use same attachment pattern
- Dynamic attachment/collapse maintains clarity
**Note**: Unlike other workflow orchestrators, this file consolidates TodoWrite examples in this section rather than distributing them across Phase descriptions for better dual-mode clarity.
--- ---

View File

@@ -325,95 +325,61 @@ Ready for execution. Use appropriate workflow commands to proceed.
## TodoWrite Pattern ## TodoWrite Pattern
```javascript **Core Concept**: Dynamic task attachment and collapse for test-gen workflow with cross-session context gathering and test generation strategy.
// ⚠️ CRITICAL: Dynamic TodoWrite task attachment strategy for test-gen workflow:
//
// **Key Concept**: SlashCommand invocation ATTACHES tasks to current workflow.
// Orchestrator EXECUTES these attached tasks itself, then COLLAPSES them.
//
// 1. INITIAL STATE: 5 orchestrator-level tasks
TodoWrite({todos: [
{"content": "Create independent test session", "status": "in_progress", "activeForm": "Creating test session"},
{"content": "Gather test coverage context", "status": "pending", "activeForm": "Gathering test coverage context"},
{"content": "Analyze test requirements with Gemini", "status": "pending", "activeForm": "Analyzing test requirements"},
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 2. PHASE 2 SlashCommand INVOCATION (test-context-gather): ### Key Principles
// - SlashCommand(/workflow:tools:test-context-gather) ATTACHES 3 tasks
// - Orchestrator EXECUTES these 3 tasks sequentially
TodoWrite({todos: [
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"},
{"content": "Phase 2.1: Load source session summaries (test-context-gather)", "status": "in_progress", "activeForm": "Loading source session summaries"},
{"content": "Phase 2.2: Analyze test coverage with MCP tools (test-context-gather)", "status": "pending", "activeForm": "Analyzing test coverage"},
{"content": "Phase 2.3: Identify coverage gaps and framework (test-context-gather)", "status": "pending", "activeForm": "Identifying coverage gaps"},
{"content": "Analyze test requirements with Gemini", "status": "pending", "activeForm": "Analyzing test requirements"},
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 3. PHASE 2 TASKS COMPLETED: 1. **Task Attachment** (when SlashCommand invoked):
// - COLLAPSE completed tasks into Phase 2 summary - Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
TodoWrite({todos: [ - Example: `/workflow:tools:test-context-gather` attaches 3 sub-tasks (Phase 2.1, 2.2, 2.3)
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"}, - First attached task marked as `in_progress`, others as `pending`
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"}, - Orchestrator **executes** these attached tasks sequentially
{"content": "Analyze test requirements with Gemini", "status": "pending", "activeForm": "Analyzing test requirements"},
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 4. PHASE 3 SlashCommand INVOCATION (test-concept-enhanced): 2. **Task Collapse** (after sub-tasks complete):
// - SlashCommand(/workflow:tools:test-concept-enhanced) ATTACHES 3 tasks - Remove detailed sub-tasks from TodoWrite
TodoWrite({todos: [ - **Collapse** to high-level phase summary
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"}, - Example: Phase 2.1-2.3 collapse to "Gather test coverage context: completed"
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"}, - Maintains clean orchestrator-level view
{"content": "Phase 3.1: Analyze coverage gaps with Gemini (test-concept-enhanced)", "status": "in_progress", "activeForm": "Analyzing coverage gaps"},
{"content": "Phase 3.2: Study existing test patterns (test-concept-enhanced)", "status": "pending", "activeForm": "Studying test patterns"},
{"content": "Phase 3.3: Generate test generation strategy (test-concept-enhanced)", "status": "pending", "activeForm": "Generating test strategy"},
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 5. PHASE 3 TASKS COMPLETED: 3. **Continuous Execution**:
// - COLLAPSE completed tasks into Phase 3 summary - After collapse, automatically proceed to next pending phase
TodoWrite({todos: [ - No user intervention required between phases
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"}, - TodoWrite dynamically reflects current execution state
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"},
{"content": "Analyze test requirements with Gemini", "status": "completed", "activeForm": "Analyzing test requirements"},
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 6. PHASE 4 SlashCommand INVOCATION (test-task-generate): ### Lifecycle Pattern
// - SlashCommand(/workflow:tools:test-task-generate) ATTACHES 3 tasks
// - Generates IMPL-001.json and IMPL-002.json
TodoWrite({todos: [
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"},
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"},
{"content": "Analyze test requirements with Gemini", "status": "completed", "activeForm": "Analyzing test requirements"},
{"content": "Phase 4.1: Parse TEST_ANALYSIS_RESULTS.md (test-task-generate)", "status": "in_progress", "activeForm": "Parsing test analysis"},
{"content": "Phase 4.2: Generate IMPL-001.json and IMPL-002.json (test-task-generate)", "status": "pending", "activeForm": "Generating task JSONs"},
{"content": "Phase 4.3: Generate IMPL_PLAN.md and TODO_LIST.md (test-task-generate)", "status": "pending", "activeForm": "Generating plan documents"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 7. PHASE 4 TASKS COMPLETED:
// - COLLAPSE completed tasks into Phase 4 summary
TodoWrite({todos: [
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"},
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"},
{"content": "Analyze test requirements with Gemini", "status": "completed", "activeForm": "Analyzing test requirements"},
{"content": "Generate test generation and execution tasks", "status": "completed", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "in_progress", "activeForm": "Returning workflow summary"}
]})
// Benefits:
// ✓ Real-time visibility into attached tasks during execution
// ✓ Clean orchestrator-level summary after tasks complete
// ✓ Clear mental model: SlashCommand = attach tasks, not delegate work
// ✓ Dynamic attachment/collapse maintains clarity
``` ```
Initial: [Phase 1: pending] [Phase 2: pending] [Phase 3: pending] [Phase 4: pending] [Phase 5: pending]
Phase 2 Invoked (ATTACHED):
[Phase 1: completed] [Phase 2.1: in_progress] [Phase 2.2: pending] [Phase 2.3: pending] [Phase 3: pending] [Phase 4: pending] [Phase 5: pending]
Phase 2 Completed (COLLAPSED):
[Phase 1: completed] [Phase 2: completed] [Phase 3: pending] [Phase 4: pending] [Phase 5: pending]
Phase 3 Invoked (ATTACHED):
[Phase 1: completed] [Phase 2: completed] [Phase 3.1: in_progress] [Phase 3.2: pending] [Phase 3.3: pending] [Phase 4: pending] [Phase 5: pending]
Phase 3 Completed (COLLAPSED):
[Phase 1: completed] [Phase 2: completed] [Phase 3: completed] [Phase 4: pending] [Phase 5: pending]
[Continue pattern through Phase 4 and Phase 5...]
```
### Test-Gen Specific Features
- **Phase 2**: Cross-session context gathering from source implementation session
- **Phase 3**: Test requirements analysis with Gemini for generation strategy
- **Phase 4**: Dual-task generation (IMPL-001 for test generation, IMPL-002 for test execution)
- **Fix Mode Configuration**: `--use-codex` flag controls IMPL-002 fix mode (manual vs automated)
**Benefits**:
- Real-time visibility into attached tasks during execution
- Clean orchestrator-level summary after tasks complete
- Clear mental model: SlashCommand = attach tasks, not delegate work
- Dynamic attachment/collapse maintains clarity
**Note**: See individual Phase descriptions (Phase 2, 3, 4) for detailed TodoWrite Update examples with full JSON structures.
## Execution Flow Diagram ## Execution Flow Diagram