Enhance test workflow documentation with Task Attachment Model and Auto-Continue Mechanism

- Introduced Task Attachment Model to clarify how SlashCommand invocations expand workflows by attaching sub-tasks to the current TodoWrite.
- Added Auto-Continue Mechanism details to explain dynamic task management and continuous execution across phases.
- Updated TodoWrite examples to reflect task attachment and collapsing behavior during workflow execution.
- Improved execution flow diagrams for both test-fix-gen and test-gen workflows to illustrate task attachment and phase completion.
- Emphasized critical aspects of continuous execution and task management in the documentation.
This commit is contained in:
catlog22
2025-11-11 19:28:50 +08:00
parent be176ac4b3
commit 0a773b9411
4 changed files with 784 additions and 79 deletions

View File

@@ -22,11 +22,19 @@ This workflow runs **fully autonomously** once triggered. Phase 3 (conflict reso
4. **Phase 3 executes** (optional, if conflict_risk ≥ medium) → Conflict resolution → Auto-continues
5. **Phase 4 executes** → Task generation (task-generate-agent) → Reports final summary
**Task Attachment Model**:
- SlashCommand invocation **expands workflow** by attaching sub-tasks to current TodoWrite
- When a sub-command is invoked (e.g., `/workflow:tools:context-gather`), its internal tasks are attached to the orchestrator's TodoWrite
- Orchestrator **executes these attached tasks** sequentially
- After completion, attached tasks are **collapsed** back to high-level phase summary
- This is **task expansion**, not external delegation
**Auto-Continue Mechanism**:
- TodoList tracks current phase status
- TodoList tracks current phase status and dynamically manages task attachment/collapse
- When each phase finishes executing, automatically execute next pending phase
- All phases run autonomously without user interaction (clarification handled in brainstorm phase)
- Progress updates shown at each phase for visibility
- **⚠️ CONTINUOUS EXECUTION** - Do not stop until all phases complete
## Core Rules
@@ -34,8 +42,9 @@ This workflow runs **fully autonomously** once triggered. Phase 3 (conflict reso
2. **No Preliminary Analysis**: Do not read files, analyze structure, or gather context before Phase 1
3. **Parse Every Output**: Extract required data from each command/agent output for next phase
4. **Auto-Continue via TodoList**: Check TodoList status to execute next pending phase automatically
5. **Track Progress**: Update TodoWrite when each phase finishes executing
6. **Agent Delegation**: Phase 3 uses cli-execution-agent for autonomous intelligent analysis
5. **Track Progress**: Update TodoWrite dynamically with task attachment/collapse pattern
6. **Task Attachment Model**: SlashCommand invocation **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
7. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
## 5-Phase Execution
@@ -84,9 +93,11 @@ CONTEXT: Existing user database schema, REST API endpoints
- Context package path extracted
- File exists and is valid JSON
**TodoWrite**: Mark phase 2 completed, phase 3 in_progress
**TodoWrite**: Mark phase 2 completed, phase 3/4 in_progress (depending on conflict_risk)
**After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3
**Task Attachment**: SlashCommand invocation attaches 3 context-gather sub-tasks, executes them, then collapses to phase summary (see TodoWrite Pattern section for details)
**After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3/4 (depending on conflict_risk)
---
@@ -112,7 +123,9 @@ CONTEXT: Existing user database schema, REST API endpoints
- If conflict_risk is "none" or "low", skip directly to Phase 3.5
- Display: "No significant conflicts detected, proceeding to clarification"
**TodoWrite**: Mark phase 3 completed (if executed) or skipped, phase 3.5 in_progress
**TodoWrite**: If executed, mark phase 3 completed, phase 3.5/4 in_progress
**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)
**After Phase 3**: Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 3.5
@@ -173,7 +186,35 @@ SlashCommand(command="/workflow:tools:task-generate-agent --session [sessionId]
- `.workflow/[sessionId]/.task/IMPL-*.json` exists (at least one)
- `.workflow/[sessionId]/TODO_LIST.md` exists
**TodoWrite**: Mark phase 4 completed
<!-- TodoWrite: When task-generate-agent invoked, INSERT 3 task-generate-agent tasks -->
**TodoWrite Update (Phase 4 SlashCommand invoked - tasks attached)**:
```json
[
{"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"}
]
```
**Note**: SlashCommand invocation **attaches** task-generate-agent's 3 tasks. Orchestrator **executes** these tasks.
**Next Action**: Tasks attached → **Execute Phase 4.1-4.3** sequentially
<!-- TodoWrite: After Phase 4 tasks complete, REMOVE Phase 4.1-4.3, restore to orchestrator view -->
**TodoWrite Update (Phase 4 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": "completed", "activeForm": "Executing task generation"}
]
```
**Note**: Phase 4 tasks completed and collapsed to summary.
**Return to User**:
```
@@ -192,37 +233,92 @@ Quality Gate: Consider running /workflow:action-plan-verify to catch issues earl
## TodoWrite Pattern
```javascript
// Initialize (before Phase 1)
// Note: Phase 3 todo only added dynamically after Phase 2 if conflict_risk ≥ medium
// ⚠️ 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"},
// Phase 3 todo added dynamically after Phase 2 if conflict_risk ≥ medium
{"content": "Execute task generation", "status": "pending", "activeForm": "Executing task generation"}
]})
// After Phase 2 (if conflict_risk ≥ medium, insert Phase 3 todo)
// 2. PHASE 2 SlashCommand INVOCATION:
// - 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": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Resolve conflicts and apply fixes", "status": "in_progress", "activeForm": "Resolving conflicts"},
{"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"}
]})
// After Phase 2 (if conflict_risk is none/low, skip Phase 3, go directly to Phase 4)
// 3. PHASE 2 TASKS COMPLETED:
// - All 3 context-gather tasks executed and completed
// - COLLAPSE completed tasks into Phase 2 summary
// - TodoWrite becomes: Phase 1-2 (completed) + Phase 4
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": "in_progress", "activeForm": "Executing task generation"}
{"content": "Execute task generation", "status": "pending", "activeForm": "Executing task generation"}
]})
// After Phase 3 (if executed), continue to Phase 4
// 4. CONDITIONAL: IF conflict_risk ≥ medium → PHASE 3 SlashCommand INVOCATION:
// - SlashCommand(/workflow:tools:conflict-resolution) ATTACHES 3 tasks
// - TodoWrite expands to: Phase 1-2 (completed) + 3 conflict-resolution tasks + Phase 4
// - Orchestrator EXECUTES these 3 tasks sequentially (Phase 3.1 → 3.2 → 3.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 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):
// - All 3 conflict-resolution tasks executed and completed
// - COLLAPSE completed tasks into Phase 3 summary
// - TodoWrite returns to: Phase 1-3 (completed) + Phase 4
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": "in_progress", "activeForm": "Executing task generation"}
{"content": "Execute task generation", "status": "pending", "activeForm": "Executing task generation"}
]})
// 6. PHASE 4 SlashCommand INVOCATION:
// - 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
```
## Input Processing
@@ -304,6 +400,55 @@ Return summary to user
- **Traceability**: Easy to track what was requested
- **Precision**: Better context gathering and analysis
## Execution Flow Diagram
```
User triggers: /workflow:plan "Build authentication system"
[TodoWrite Init] 3 orchestrator-level tasks
Phase 1: Session Discovery
→ sessionId extracted
Phase 2: Context Gathering (SlashCommand invoked)
→ ATTACH 3 tasks: ← ATTACHED
- Phase 2.1: Analyze codebase structure
- Phase 2.2: Identify integration points
- Phase 2.3: Generate context package
→ Execute Phase 2.1-2.3
→ COLLAPSE tasks ← COLLAPSED
→ contextPath + conflict_risk extracted
Conditional Branch: Check conflict_risk
├─ IF conflict_risk ≥ medium:
│ Phase 3: Conflict Resolution (SlashCommand invoked)
│ → ATTACH 3 tasks: ← ATTACHED
│ - Phase 3.1: Detect conflicts with CLI analysis
│ - Phase 3.2: Present conflicts to user
│ - Phase 3.3: Apply resolution strategies
│ → Execute Phase 3.1-3.3
│ → COLLAPSE tasks ← COLLAPSED
└─ ELSE: Skip Phase 3, proceed to Phase 4
Phase 4: Task Generation (SlashCommand invoked)
→ ATTACH 3 tasks: ← ATTACHED
- Phase 4.1: Discovery - analyze requirements
- Phase 4.2: Planning - design tasks
- Phase 4.3: Output - generate JSONs
→ Execute Phase 4.1-4.3
→ COLLAPSE tasks ← COLLAPSED
→ Outputs: IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
Return summary to user
```
**Key Points**:
- **← ATTACHED**: Sub-tasks attached to TodoWrite when SlashCommand invoked
- **← COLLAPSED**: Sub-tasks collapsed to summary after completion
- **Conditional Branch**: Phase 3 only executes if conflict_risk ≥ medium
- **Continuous Flow**: No user intervention between phases
## Error Handling
- **Parsing Failure**: If output parsing fails, retry command once, then report error

View File

@@ -9,21 +9,35 @@ allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
## Coordinator Role
**This command is a pure orchestrator**: Execute 5 slash commands in sequence, parse outputs, pass context, and ensure complete TDD workflow creation.
**This command is a pure orchestrator**: Execute 6 slash commands in sequence, parse outputs, pass context, and ensure complete TDD workflow creation with Red-Green-Refactor task generation.
**Execution Modes**:
- **Agent Mode** (default): Use `/workflow:tools:task-generate-tdd` (autonomous agent-driven)
- **CLI Mode** (`--cli-execute`): Use `/workflow:tools:task-generate-tdd --cli-execute` (Gemini/Qwen)
**Task Attachment Model**:
- SlashCommand invocation **expands workflow** by attaching sub-tasks to current TodoWrite
- When a sub-command is invoked (e.g., `/workflow:tools:test-context-gather`), its internal tasks are attached to the orchestrator's TodoWrite
- Orchestrator **executes these attached tasks** sequentially
- After completion, attached tasks are **collapsed** back to high-level phase summary
- This is **task expansion**, not external delegation
**Auto-Continue Mechanism**:
- TodoList tracks current phase status and dynamically manages task attachment/collapse
- When each phase finishes executing, automatically execute next pending phase
- All phases run autonomously without user interaction
- **⚠️ CONTINUOUS EXECUTION** - Do not stop until all phases complete
## Core Rules
1. **Start Immediately**: First action is TodoWrite initialization, second action is Phase 1 execution
2. **No Preliminary Analysis**: Do not read files before Phase 1
3. **Parse Every Output**: Extract required data for next phase
4. **Auto-Continue via TodoList**: Check TodoList status to execute next pending phase automatically
5. **Track Progress**: Update TodoWrite when each phase finishes executing
5. **Track Progress**: Update TodoWrite dynamically with task attachment/collapse pattern
6. **TDD Context**: All descriptions include "TDD:" prefix
7. **Quality Gate**: Phase 4 conflict resolution (optional, auto-triggered) validates compatibility before task generation
7. **Task Attachment Model**: SlashCommand invocation **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
8. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
## 6-Phase Execution (with Conflict Resolution)
@@ -85,9 +99,41 @@ TEST_FOCUS: [Test scenarios]
- Prevents duplicate test creation
- Enables integration with existing tests
**TodoWrite**: Mark phase 3 completed, phase 4 in_progress
<!-- TodoWrite: When test-context-gather invoked, INSERT 3 test-context-gather tasks -->
**After Phase 3**: Return to user showing test coverage results, then auto-continue to Phase 4
**TodoWrite Update (Phase 3 SlashCommand invoked - tasks attached)**:
```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 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"}
]
```
**Note**: SlashCommand invocation **attaches** test-context-gather's 3 tasks. Orchestrator **executes** these tasks.
**Next Action**: Tasks attached → **Execute Phase 3.1-3.3** 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": "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"}
]
```
**Note**: Phase 3 tasks completed and collapsed to summary.
**After Phase 3**: Return to user showing test coverage results, then auto-continue to Phase 4/5 (depending on conflict_risk)
---
@@ -113,7 +159,41 @@ TEST_FOCUS: [Test scenarios]
- If conflict_risk is "none" or "low", skip directly to Phase 5
- Display: "No significant conflicts detected, proceeding to TDD task generation"
**TodoWrite**: Mark phase 4 completed (if executed) or skipped, phase 5 in_progress
<!-- TodoWrite: If conflict_risk ≥ medium, INSERT 3 conflict-resolution tasks -->
**TodoWrite Update (Phase 4 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": "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"}
]
```
**Note**: SlashCommand invocation **attaches** conflict-resolution's 3 tasks. Orchestrator **executes** these tasks.
**Next Action**: Tasks attached → **Execute Phase 4.1-4.3** sequentially
<!-- TodoWrite: After Phase 4 tasks complete, REMOVE Phase 4.1-4.3, restore to orchestrator view -->
**TodoWrite Update (Phase 4 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 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"}
]
```
**Note**: Phase 4 tasks completed and collapsed to summary.
**After Phase 4**: Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 5
@@ -145,6 +225,40 @@ TEST_FOCUS: [Test scenarios]
- IMPL_PLAN.md contains workflow_type: "tdd" in frontmatter
- Task count ≤10 (compliance with task limit)
<!-- TodoWrite: When task-generate-tdd invoked, INSERT 3 task-generate-tdd tasks -->
**TodoWrite Update (Phase 5 SlashCommand invoked - tasks attached)**:
```json
[
{"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"}
]
```
**Note**: SlashCommand invocation **attaches** task-generate-tdd's 3 tasks. Orchestrator **executes** these tasks. Each generated IMPL task will contain internal Red-Green-Refactor cycle.
**Next Action**: Tasks attached → **Execute Phase 5.1-5.3** sequentially
<!-- TodoWrite: After Phase 5 tasks complete, REMOVE Phase 5.1-5.3, restore to orchestrator view -->
**TodoWrite Update (Phase 5 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 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"}
]
```
**Note**: Phase 5 tasks completed and collapsed to summary. Each generated IMPL task contains complete Red-Green-Refactor cycle internally.
### Phase 6: TDD Structure Validation & Action Plan Verification (RECOMMENDED)
**Internal validation first, then recommend external verification**
@@ -203,44 +317,146 @@ Quality Gate: Consider running /workflow:action-plan-verify to validate TDD task
## TodoWrite Pattern
```javascript
// Initialize (Phase 4 added dynamically after Phase 3 if conflict_risk ≥ medium)
// ⚠️ 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"},
// Phase 4 todo added dynamically after Phase 3 if conflict_risk ≥ medium
{"content": "Execute TDD task generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Validate TDD structure", "status": "pending", "activeForm": "Validating TDD structure"}
]})
// After Phase 3 (if conflict_risk ≥ medium, insert Phase 4 todo)
// 2. PHASE 3 SlashCommand INVOCATION (test-context-gather):
// - 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": "Execute test coverage analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Execute conflict resolution", "status": "in_progress", "activeForm": "Executing conflict resolution"},
{"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"}
]})
// After Phase 3 (if conflict_risk is none/low, skip Phase 4, go directly to Phase 5)
// 3. PHASE 3 TASKS COMPLETED:
// - COLLAPSE completed tasks into Phase 3 summary
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": "in_progress", "activeForm": "Executing TDD task generation"},
{"content": "Execute TDD task generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Validate TDD structure", "status": "pending", "activeForm": "Validating TDD structure"}
]})
// After Phase 4 (if executed), continue to Phase 5
// 4. CONDITIONAL: IF conflict_risk ≥ medium → PHASE 4 SlashCommand INVOCATION:
// - SlashCommand(/workflow:tools:conflict-resolution) ATTACHES 3 tasks
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 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):
// - COLLAPSE completed tasks into Phase 4 summary
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 conflict resolution", "status": "completed", "activeForm": "Executing conflict resolution"},
{"content": "Execute TDD task generation", "status": "in_progress", "activeForm": "Executing TDD task generation"},
{"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):
// - 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
```
## Execution Flow Diagram
```
TDD Workflow Orchestrator
├─ Phase 1: Session Discovery
│ └─ /workflow:session:start --auto
│ └─ Returns: sessionId
├─ Phase 2: Context Gathering
│ └─ /workflow:tools:context-gather
│ └─ Returns: context-package.json path
├─ Phase 3: Test Coverage Analysis ← ATTACHED (3 tasks)
│ └─ /workflow:tools:test-context-gather
│ ├─ Phase 3.1: Detect test framework
│ ├─ Phase 3.2: Analyze existing test coverage
│ └─ Phase 3.3: Identify coverage gaps
│ └─ Returns: test-context-package.json ← COLLAPSED
├─ Phase 4: Conflict Resolution (conditional)
│ IF conflict_risk ≥ medium:
│ └─ /workflow:tools:conflict-resolution ← ATTACHED (3 tasks)
│ ├─ Phase 4.1: Detect conflicts with CLI
│ ├─ Phase 4.2: Present conflicts to user
│ └─ Phase 4.3: Apply resolution strategies
│ └─ Returns: CONFLICT_RESOLUTION.md ← COLLAPSED
│ ELSE:
│ └─ Skip to Phase 5
├─ Phase 5: TDD Task Generation ← ATTACHED (3 tasks)
│ └─ /workflow:tools:task-generate-tdd
│ ├─ Phase 5.1: Discovery - analyze TDD requirements
│ ├─ Phase 5.2: Planning - design Red-Green-Refactor cycles
│ └─ Phase 5.3: Output - generate IMPL tasks with internal TDD phases
│ └─ Returns: IMPL-*.json, IMPL_PLAN.md ← COLLAPSED
│ (Each IMPL task contains internal Red-Green-Refactor cycle)
└─ Phase 6: TDD Structure Validation
└─ Internal validation + summary returned
└─ Recommend: /workflow:action-plan-verify
Key Points:
• ← ATTACHED: SlashCommand attaches sub-tasks to orchestrator TodoWrite
• ← COLLAPSED: Sub-tasks executed and collapsed to phase summary
• TDD-specific: Each generated IMPL task contains complete Red-Green-Refactor cycle
```
## Input Processing

View File

@@ -58,6 +58,19 @@ This command is a **pure planning coordinator**:
- Creates independent test workflow session
- **All execution delegated to `/workflow:test-cycle-execute`**
**Task Attachment Model**:
- SlashCommand invocation **expands workflow** by attaching sub-tasks to current TodoWrite
- When a sub-command is invoked (e.g., `/workflow:tools:test-context-gather`), its internal tasks are attached to the orchestrator's TodoWrite
- Orchestrator **executes these attached tasks** sequentially
- After completion, attached tasks are **collapsed** back to high-level phase summary
- This is **task expansion**, not external delegation
**Auto-Continue Mechanism**:
- TodoList tracks current phase status and dynamically manages task attachment/collapse
- When each phase finishes executing, automatically execute next pending phase
- All phases run autonomously without user interaction
- **⚠️ CONTINUOUS EXECUTION** - Do not stop until all phases complete
---
## Usage
@@ -128,9 +141,11 @@ This command is a **pure planning coordinator**:
3. **Parse Every Output**: Extract required data from each phase for next phase
4. **Sequential Execution**: Each phase depends on previous phase's output
5. **Complete All Phases**: Do not return until Phase 5 completes
6. **Track Progress**: Update TodoWrite after every phase
6. **Track Progress**: Update TodoWrite dynamically with task attachment/collapse pattern
7. **Automatic Detection**: Mode auto-detected from input pattern
8. **Parse Flags**: Extract `--use-codex` and `--cli-execute` flags for Phase 4
9. **Task Attachment Model**: SlashCommand invocation **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
10. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
### 5-Phase Execution
@@ -326,19 +341,98 @@ CRITICAL - Next Steps:
### TodoWrite Progress Tracking
Track all 5 phases:
```javascript
// ⚠️ 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|completed", "activeForm": "Creating test session"},
{"content": "Gather test coverage context", "status": "pending|in_progress|completed", "activeForm": "Gathering test coverage context"},
{"content": "Analyze test requirements with Gemini", "status": "pending|in_progress|completed", "activeForm": "Analyzing test requirements"},
{"content": "Generate test generation and execution tasks", "status": "pending|in_progress|completed", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending|in_progress|completed", "activeForm": "Returning workflow summary"}
{"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"}
]})
```
Update status to `in_progress` when starting each phase, `completed` when done.
// 2. PHASE 2 SlashCommand INVOCATION:
// - 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:
// - COLLAPSE completed tasks into Phase 2 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": "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):
// - SlashCommand(/workflow:tools:test-concept-enhanced) ATTACHES 3 tasks
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": "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:
// - COLLAPSE completed tasks into Phase 3 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": "pending", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 6. PHASE 4 SlashCommand INVOCATION (test-task-generate):
// - 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
```
---
@@ -498,18 +592,62 @@ WFS-test-[session]/
- `workflow_type: "test_session"`
- No `source_session_id` field
### Complete Data Flow
### Execution Flow Diagram
**Example Command**: `/workflow:test-fix-gen WFS-user-auth`
```
Test-Fix-Gen Workflow Orchestrator (Dual-Mode Support)
├─ Phase 1: Create Test Session
│ ├─ Session Mode: /workflow:session:start --new (with source_session_id)
│ └─ Prompt Mode: /workflow:session:start --new (without source_session_id)
│ └─ Returns: testSessionId (WFS-test-[slug])
├─ Phase 2: Gather Context ← ATTACHED (3 tasks)
│ ├─ Session Mode: /workflow:tools:test-context-gather
│ │ └─ Load source session summaries + analyze coverage
│ └─ Prompt Mode: /workflow:tools:context-gather
│ └─ Analyze codebase from description
│ ├─ Phase 2.1: Load context and analyze coverage
│ ├─ Phase 2.2: Detect test framework and conventions
│ └─ Phase 2.3: Generate context package
│ └─ Returns: [test-]context-package.json ← COLLAPSED
├─ Phase 3: Test Generation Analysis ← ATTACHED (3 tasks)
│ └─ /workflow:tools:test-concept-enhanced
│ ├─ Phase 3.1: Analyze coverage gaps with Gemini
│ ├─ Phase 3.2: Study existing test patterns
│ └─ Phase 3.3: Generate test generation strategy
│ └─ Returns: TEST_ANALYSIS_RESULTS.md ← COLLAPSED
├─ Phase 4: Generate Test Tasks ← ATTACHED (3 tasks)
│ └─ /workflow:tools:test-task-generate
│ ├─ Phase 4.1: Parse TEST_ANALYSIS_RESULTS.md
│ ├─ Phase 4.2: Generate task JSONs (IMPL-001, IMPL-002)
│ └─ Phase 4.3: Generate IMPL_PLAN.md and TODO_LIST.md
│ └─ Returns: Task JSONs and plans ← COLLAPSED
└─ Phase 5: Return Summary
└─ Command ends, control returns to user
**Phase Execution Chain**:
1. Phase 1: `session-start``WFS-test-user-auth`
2. Phase 2: `test-context-gather``test-context-package.json`
3. Phase 3: `test-concept-enhanced``TEST_ANALYSIS_RESULTS.md`
4. Phase 4: `test-task-generate``IMPL-001.json` + `IMPL-002.json` (+ additional if needed)
5. Phase 5: Return summary
Artifacts Created:
├── .workflow/WFS-test-[session]/
│ ├── workflow-session.json
│ ├── IMPL_PLAN.md
│ ├── TODO_LIST.md
│ ├── .task/
│ │ ├── IMPL-001.json (test understanding & generation)
│ │ ├── IMPL-002.json (test execution & fix cycle)
│ │ └── IMPL-003.json (optional: test review & certification)
│ └── .process/
│ ├── [test-]context-package.json
│ └── TEST_ANALYSIS_RESULTS.md
**Command completes after Phase 5**
Key Points:
• ← ATTACHED: SlashCommand attaches sub-tasks to orchestrator TodoWrite
• ← COLLAPSED: Sub-tasks executed and collapsed to phase summary
• Dual-Mode: Session Mode and Prompt Mode share same attachment pattern
• Command Boundary: Execution delegated to /workflow:test-cycle-execute
```
---

View File

@@ -18,6 +18,19 @@ allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
- **Parameter Simplification**: Tools auto-detect test session type via metadata, no manual cross-session parameters needed
- **Manual First**: Default to manual fixes, use `--use-codex` flag for automated Codex fix application
**Task Attachment Model**:
- SlashCommand invocation **expands workflow** by attaching sub-tasks to current TodoWrite
- When a sub-command is invoked (e.g., `/workflow:tools:test-context-gather`), its internal tasks are attached to the orchestrator's TodoWrite
- Orchestrator **executes these attached tasks** sequentially
- After completion, attached tasks are **collapsed** back to high-level phase summary
- This is **task expansion**, not external delegation
**Auto-Continue Mechanism**:
- TodoList tracks current phase status and dynamically manages task attachment/collapse
- When each phase finishes executing, automatically execute next pending phase
- All phases run autonomously without user interaction
- **⚠️ CONTINUOUS EXECUTION** - Do not stop until all phases complete
**Execution Flow**:
1. Initialize TodoWrite → Create test session → Parse session ID
2. Gather cross-session context (automatic) → Parse context path
@@ -33,10 +46,12 @@ allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
3. **Parse Every Output**: Extract required data from each phase for next phase
4. **Sequential Execution**: Each phase depends on previous phase's output
5. **Complete All Phases**: Do not return to user until Phase 5 completes (summary returned)
6. **Track Progress**: Update TodoWrite when each phase finishes executing
6. **Track Progress**: Update TodoWrite dynamically with task attachment/collapse pattern
7. **Automatic Detection**: context-gather auto-detects test session and gathers source session context
8. **Parse --use-codex Flag**: Extract flag from arguments and pass to Phase 4 (test-task-generate)
9. **Command Boundary**: This command ends at Phase 5 summary. Test execution is NOT part of this command.
10. **Task Attachment Model**: SlashCommand invocation **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
11. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
## 5-Phase Execution
@@ -89,7 +104,39 @@ allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
- Test framework detected
- Test conventions documented
**TodoWrite**: Mark phase 2 completed, phase 3 in_progress
<!-- TodoWrite: When test-context-gather invoked, INSERT 3 test-context-gather tasks -->
**TodoWrite Update (Phase 2 SlashCommand invoked - tasks attached)**:
```json
[
{"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"}
]
```
**Note**: SlashCommand invocation **attaches** test-context-gather's 3 tasks. Orchestrator **executes** these tasks.
**Next Action**: Tasks attached → **Execute Phase 2.1-2.3** 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": "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": "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"}
]
```
**Note**: Phase 2 tasks completed and collapsed to summary.
---
@@ -121,7 +168,39 @@ allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
- Implementation Targets (test files to create)
- Success Criteria
**TodoWrite**: Mark phase 3 completed, phase 4 in_progress
<!-- TodoWrite: When test-concept-enhanced invoked, INSERT 3 concept-enhanced tasks -->
**TodoWrite Update (Phase 3 SlashCommand invoked - tasks attached)**:
```json
[
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"},
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"},
{"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"}
]
```
**Note**: SlashCommand invocation **attaches** test-concept-enhanced's 3 tasks. Orchestrator **executes** these tasks.
**Next Action**: Tasks attached → **Execute Phase 3.1-3.3** 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": "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": "pending", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]
```
**Note**: Phase 3 tasks completed and collapsed to summary.
---
@@ -173,7 +252,39 @@ allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
- Phase 2: Iterative Gemini diagnosis + manual/Codex fixes (based on flag)
- Phase 3: Final validation and certification
**TodoWrite**: Mark phase 4 completed, phase 5 in_progress
<!-- TodoWrite: When test-task-generate invoked, INSERT 3 test-task-generate tasks -->
**TodoWrite Update (Phase 4 SlashCommand invoked - tasks attached)**:
```json
[
{"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"}
]
```
**Note**: SlashCommand invocation **attaches** test-task-generate's 3 tasks. Orchestrator **executes** these tasks.
**Next Action**: Tasks attached → **Execute Phase 4.1-4.3** sequentially
<!-- TodoWrite: After Phase 4 tasks complete, REMOVE Phase 4.1-4.3, restore to orchestrator view -->
**TodoWrite Update (Phase 4 completed - tasks collapsed)**:
```json
[
{"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"}
]
```
**Note**: Phase 4 tasks completed and collapsed to summary.
---
@@ -214,37 +325,128 @@ Ready for execution. Use appropriate workflow commands to proceed.
## TodoWrite Pattern
Track progress through 5 phases:
```javascript
// ⚠️ 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|completed", "activeForm": "Creating test session"},
{"content": "Gather test coverage context", "status": "pending|in_progress|completed", "activeForm": "Gathering test coverage context"},
{"content": "Analyze test requirements with Gemini", "status": "pending|in_progress|completed", "activeForm": "Analyzing test requirements"},
{"content": "Generate test generation and execution tasks", "status": "pending|in_progress|completed", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending|in_progress|completed", "activeForm": "Returning workflow summary"}
{"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):
// - 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:
// - COLLAPSE completed tasks into Phase 2 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": "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):
// - SlashCommand(/workflow:tools:test-concept-enhanced) ATTACHES 3 tasks
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": "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:
// - COLLAPSE completed tasks into Phase 3 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": "pending", "activeForm": "Generating test tasks"},
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
]})
// 6. PHASE 4 SlashCommand INVOCATION (test-task-generate):
// - 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
```
Update status to `in_progress` when starting each phase, mark `completed` when done.
## Data Flow
## Execution Flow Diagram
```
┌─────────────────────────────────────────────────────────┐
│ /workflow:test-gen WFS-user-auth
├─────────────────────────────────────────────────────────┤
Phase 1: session-start → WFS-test-user-auth │
↓ │
│ Phase 2: test-context-gather → test-context-package.json
│ ↓
Phase 3: test-concept-enhanced → TEST_ANALYSIS_RESULTS.md│
↓ │
Phase 4: test-task-generate → IMPL-001.json + IMPL-002.json│
Phase 5: Return summary
└─────────────────────────────────────────────────────────┘
COMMAND ENDS - Control returns to user
Test-Gen Workflow Orchestrator
├─ Phase 1: Create Test Session
└─ /workflow:session:start --new
└─ Returns: testSessionId (WFS-test-[source])
├─ Phase 2: Gather Test Context ← ATTACHED (3 tasks)
└─ /workflow:tools:test-context-gather
├─ Phase 2.1: Load source session summaries
├─ Phase 2.2: Analyze test coverage with MCP tools
└─ Phase 2.3: Identify coverage gaps and framework
└─ Returns: test-context-package.json ← COLLAPSED
├─ Phase 3: Test Generation Analysis ← ATTACHED (3 tasks)
│ └─ /workflow:tools:test-concept-enhanced
│ ├─ Phase 3.1: Analyze coverage gaps with Gemini
│ ├─ Phase 3.2: Study existing test patterns
│ └─ Phase 3.3: Generate test generation strategy
│ └─ Returns: TEST_ANALYSIS_RESULTS.md ← COLLAPSED
├─ Phase 4: Generate Test Tasks ← ATTACHED (3 tasks)
│ └─ /workflow:tools:test-task-generate
│ ├─ Phase 4.1: Parse TEST_ANALYSIS_RESULTS.md
│ ├─ Phase 4.2: Generate IMPL-001.json and IMPL-002.json
│ └─ Phase 4.3: Generate IMPL_PLAN.md and TODO_LIST.md
│ └─ Returns: Task JSONs and plans ← COLLAPSED
└─ Phase 5: Return Summary
└─ Command ends, control returns to user
Artifacts Created:
├── .workflow/WFS-test-[session]/
@@ -257,6 +459,10 @@ Artifacts Created:
│ └── .process/
│ ├── test-context-package.json
│ └── TEST_ANALYSIS_RESULTS.md
Key Points:
• ← ATTACHED: SlashCommand attaches sub-tasks to orchestrator TodoWrite
• ← COLLAPSED: Sub-tasks executed and collapsed to phase summary
```
## Session Metadata