mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-15 02:42:45 +08:00
feat: Implement workflow phases for test generation and execution
- Added Phase 1: Session Start to detect input mode and create test workflow session. - Added Phase 2: Test Context Gather to gather test context via coverage analysis or codebase scan. - Added Phase 3: Test Concept Enhanced to analyze test requirements using Gemini and generate multi-layered test requirements. - Added Phase 4: Test Task Generate to create test-specific tasks based on analysis results. - Added Phase 5: Test Cycle Execute to manage iterative test execution and fix cycles with adaptive strategies. - Introduced BottomPanel component for terminal dashboard with Queue and Inspector tabs.
This commit is contained in:
@@ -1,631 +0,0 @@
|
||||
---
|
||||
name: tdd-plan
|
||||
description: TDD workflow planning with Red-Green-Refactor task chain generation, test-first development structure, and cycle tracking
|
||||
argument-hint: "\"feature description\"|file.md"
|
||||
allowed-tools: Skill(*), TodoWrite(*), Read(*), Bash(*)
|
||||
---
|
||||
|
||||
# TDD Workflow Plan Command (/workflow:tdd-plan)
|
||||
|
||||
## Coordinator Role
|
||||
|
||||
**This command is a pure orchestrator**: Executes 6 slash commands in sequence, parse outputs, pass context, and ensure complete TDD workflow creation with Red-Green-Refactor task generation.
|
||||
|
||||
**CLI Tool Selection**: CLI tool usage is determined semantically from user's task description. Include "use Codex/Gemini/Qwen" in your request for CLI execution.
|
||||
|
||||
**Task Attachment Model**:
|
||||
- Skill execute **expands workflow** by attaching sub-tasks to current TodoWrite
|
||||
- When executing a sub-command (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 execute Phase 1
|
||||
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 dynamically with task attachment/collapse pattern
|
||||
6. **TDD Context**: All descriptions include "TDD:" prefix
|
||||
7. **Task Attachment Model**: Skill execute **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
|
||||
|
||||
## TDD Compliance Requirements
|
||||
|
||||
### The Iron Law
|
||||
|
||||
```
|
||||
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
|
||||
```
|
||||
|
||||
**Enforcement Method**:
|
||||
- Phase 5: `implementation` includes test-first steps (Red → Green → Refactor)
|
||||
- Green phase: Includes test-fix-cycle configuration (max 3 iterations)
|
||||
- Auto-revert: Triggered when max iterations reached without passing tests
|
||||
|
||||
**Verification**: Phase 6 validates Red-Green-Refactor structure in all generated tasks
|
||||
|
||||
### TDD Compliance Checkpoint
|
||||
|
||||
| Checkpoint | Validation Phase | Evidence Required |
|
||||
|------------|------------------|-------------------|
|
||||
| Test-first structure | Phase 5 | `implementation` has 3 steps |
|
||||
| Red phase exists | Phase 6 | Step 1: `tdd_phase: "red"` |
|
||||
| Green phase with test-fix | Phase 6 | Step 2: `tdd_phase: "green"` + test-fix-cycle |
|
||||
| Refactor phase exists | Phase 6 | Step 3: `tdd_phase: "refactor"` |
|
||||
|
||||
### Core TDD Principles (from ref skills)
|
||||
|
||||
**Red Flags - STOP and Reassess**:
|
||||
- Code written before test
|
||||
- Test passes immediately (no Red phase witnessed)
|
||||
- Cannot explain why test should fail
|
||||
- "Just this once" rationalization
|
||||
- "Tests after achieve same goals" thinking
|
||||
|
||||
**Why Order Matters**:
|
||||
- Tests written after code pass immediately → proves nothing
|
||||
- Test-first forces edge case discovery before implementation
|
||||
- Tests-after verify what was built, not what's required
|
||||
|
||||
## 6-Phase Execution (with Conflict Resolution)
|
||||
|
||||
### Phase 1: Session Discovery
|
||||
|
||||
**Step 1.1: Execute** - Session discovery and initialization
|
||||
|
||||
```javascript
|
||||
Skill(skill="workflow:session:start", args="--type tdd --auto \"TDD: [structured-description]\"")
|
||||
```
|
||||
|
||||
**TDD Structured Format**:
|
||||
```
|
||||
TDD: [Feature Name]
|
||||
GOAL: [Objective]
|
||||
SCOPE: [Included/excluded]
|
||||
CONTEXT: [Background]
|
||||
TEST_FOCUS: [Test scenarios]
|
||||
```
|
||||
|
||||
**Parse**: Extract sessionId
|
||||
|
||||
**TodoWrite**: Mark phase 1 completed, phase 2 in_progress
|
||||
|
||||
**After Phase 1**: Return to user showing Phase 1 results, then auto-continue to Phase 2
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Context Gathering
|
||||
|
||||
**Step 2.1: Execute** - Context gathering and analysis
|
||||
|
||||
```javascript
|
||||
Skill(skill="workflow:tools:context-gather", args="--session [sessionId] \"TDD: [structured-description]\"")
|
||||
```
|
||||
|
||||
**Use Same Structured Description**: Pass the same structured format from Phase 1
|
||||
|
||||
**Input**: `sessionId` from Phase 1
|
||||
|
||||
**Parse Output**:
|
||||
- Extract: context-package.json path (store as `contextPath`)
|
||||
- Typical pattern: `.workflow/active/[sessionId]/.process/context-package.json`
|
||||
|
||||
**Validation**:
|
||||
- Context package path extracted
|
||||
- File exists and is valid JSON
|
||||
|
||||
**TodoWrite**: Mark phase 2 completed, phase 3 in_progress
|
||||
|
||||
**After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Test Coverage Analysis
|
||||
|
||||
**Step 3.1: Execute** - Test coverage analysis and framework detection
|
||||
|
||||
```javascript
|
||||
Skill(skill="workflow:tools:test-context-gather", args="--session [sessionId]")
|
||||
```
|
||||
|
||||
**Purpose**: Analyze existing codebase for:
|
||||
- Existing test patterns and conventions
|
||||
- Current test coverage
|
||||
- Related components and integration points
|
||||
- Test framework detection
|
||||
|
||||
**Parse**: Extract testContextPath (`.workflow/active/[sessionId]/.process/test-context-package.json`)
|
||||
|
||||
|
||||
|
||||
<!-- TodoWrite: When test-context-gather executed, INSERT 3 test-context-gather tasks -->
|
||||
|
||||
**TodoWrite Update (Phase 3 Skill executed - tasks attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "in_progress", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": " → Detect test framework and conventions", "status": "in_progress", "activeForm": "Detecting test framework"},
|
||||
{"content": " → Analyze existing test coverage", "status": "pending", "activeForm": "Analyzing test coverage"},
|
||||
{"content": " → Identify coverage gaps", "status": "pending", "activeForm": "Identifying coverage gaps"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: Skill execute **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": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "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)
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Conflict Resolution (Optional - auto-triggered by conflict risk)
|
||||
|
||||
**Trigger**: Only execute when context-package.json indicates conflict_risk is "medium" or "high"
|
||||
|
||||
**Step 4.1: Execute** - Conflict detection and resolution
|
||||
|
||||
```javascript
|
||||
Skill(skill="workflow:tools:conflict-resolution", args="--session [sessionId] --context [contextPath]")
|
||||
```
|
||||
|
||||
**Input**:
|
||||
- sessionId from Phase 1
|
||||
- contextPath from Phase 2
|
||||
- conflict_risk from context-package.json
|
||||
|
||||
**Parse Output**:
|
||||
- Extract: Execution status (success/skipped/failed)
|
||||
- Verify: conflict-resolution.json file path (if executed)
|
||||
|
||||
**Validation**:
|
||||
- File `.workflow/active/[sessionId]/.process/conflict-resolution.json` exists (if executed)
|
||||
|
||||
**Skip Behavior**:
|
||||
- If conflict_risk is "none" or "low", skip directly to Phase 5
|
||||
- Display: "No significant conflicts detected, proceeding to TDD task generation"
|
||||
|
||||
<!-- TodoWrite: If conflict_risk ≥ medium, INSERT 3 conflict-resolution tasks when executed -->
|
||||
|
||||
**TodoWrite Update (Phase 4 Skill executed - tasks attached, if conflict_risk ≥ medium)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": "Phase 4: Conflict Resolution", "status": "in_progress", "activeForm": "Executing conflict resolution"},
|
||||
{"content": " → Detect conflicts with CLI analysis", "status": "in_progress", "activeForm": "Detecting conflicts"},
|
||||
{"content": " → Log and analyze detected conflicts", "status": "pending", "activeForm": "Analyzing conflicts"},
|
||||
{"content": " → Apply resolution strategies", "status": "pending", "activeForm": "Applying resolution strategies"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: Skill execute **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": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": "Phase 4: Conflict Resolution", "status": "completed", "activeForm": "Executing conflict resolution"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "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
|
||||
|
||||
**Memory State Check**:
|
||||
- Evaluate current context window usage and memory state
|
||||
- If memory usage is high (>110K tokens or approaching context limits):
|
||||
|
||||
**Step 4.5: Execute** - Memory compaction
|
||||
|
||||
```javascript
|
||||
Skill(skill="compact")
|
||||
```
|
||||
|
||||
- This optimizes memory before proceeding to Phase 5
|
||||
- Memory compaction is particularly important after analysis phase which may generate extensive documentation
|
||||
- Ensures optimal performance and prevents context overflow
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: TDD Task Generation
|
||||
|
||||
**Step 5.1: Execute** - TDD task generation via action-planning-agent with Phase 0 user configuration
|
||||
|
||||
```javascript
|
||||
Skill(skill="workflow:tools:task-generate-tdd", args="--session [sessionId]")
|
||||
```
|
||||
|
||||
**Note**: Phase 0 now includes:
|
||||
- Supplementary materials collection (file paths or inline content)
|
||||
- Execution method preference (Agent/Hybrid/CLI)
|
||||
- CLI tool preference (Codex/Gemini/Qwen/Auto)
|
||||
- These preferences are passed to agent for task generation
|
||||
|
||||
**Parse**: Extract feature count, task count (not chain count - tasks now contain internal TDD cycles), CLI execution IDs assigned
|
||||
|
||||
**Validate**:
|
||||
- plan.json exists (structured plan overview with `_metadata.plan_type: "tdd"`)
|
||||
- IMPL_PLAN.md exists (unified plan with TDD Implementation Tasks section)
|
||||
- IMPL-*.json files exist (one per feature, or container + subtasks for complex features)
|
||||
- TODO_LIST.md exists with internal TDD phase indicators
|
||||
- Each IMPL task includes:
|
||||
- `meta.tdd_workflow: true`
|
||||
- `cli_execution.id: {session_id}-{task_id}`
|
||||
- `cli_execution: { "strategy": "new|resume|fork|merge_fork", ... }`
|
||||
- `implementation` with exactly 3 steps (red/green/refactor)
|
||||
- Green phase includes test-fix-cycle configuration
|
||||
- `focus_paths`: absolute or clear relative paths (enhanced with exploration critical_files)
|
||||
- `pre_analysis`: includes exploration integration_points analysis
|
||||
- IMPL_PLAN.md contains workflow_type: "tdd" in frontmatter
|
||||
- User configuration applied:
|
||||
- If executionMethod == "cli" or "hybrid": command field added to steps
|
||||
- CLI tool preference reflected in execution guidance
|
||||
- Task count ≤18 (compliance with hard limit)
|
||||
|
||||
**Red Flag Detection** (Non-Blocking Warnings):
|
||||
- Task count >18: `⚠️ Task count exceeds hard limit - request re-scope`
|
||||
- Missing cli_execution.id: `⚠️ Task lacks CLI execution ID for resume support`
|
||||
- Missing test-fix-cycle: `⚠️ Green phase lacks auto-revert configuration`
|
||||
- Generic task names: `⚠️ Vague task names suggest unclear TDD cycles`
|
||||
- Missing focus_paths: `⚠️ Task lacks clear file scope for implementation`
|
||||
|
||||
**Action**: Log warnings to `.workflow/active/[sessionId]/.process/tdd-warnings.log` (non-blocking)
|
||||
|
||||
<!-- TodoWrite: When task-generate-tdd executed, INSERT 3 task-generate-tdd tasks -->
|
||||
|
||||
**TodoWrite Update (Phase 5 Skill executed - tasks attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "in_progress", "activeForm": "Executing TDD task generation"},
|
||||
{"content": " → Discovery - analyze TDD requirements", "status": "in_progress", "activeForm": "Analyzing TDD requirements"},
|
||||
{"content": " → Planning - design Red-Green-Refactor cycles", "status": "pending", "activeForm": "Designing TDD cycles"},
|
||||
{"content": " → Output - generate IMPL tasks with internal TDD phases", "status": "pending", "activeForm": "Generating TDD tasks"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: Skill execute **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": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "completed", "activeForm": "Executing TDD task generation"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "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**
|
||||
|
||||
**Internal Validation**:
|
||||
1. Each task contains complete TDD workflow (Red-Green-Refactor internally)
|
||||
2. Task structure validation:
|
||||
- `meta.tdd_workflow: true` in all IMPL tasks
|
||||
- `cli_execution.id` present (format: {session_id}-{task_id})
|
||||
- `cli_execution` strategy assigned (new/resume/fork/merge_fork)
|
||||
- `implementation` has exactly 3 steps
|
||||
- Each step has correct `tdd_phase`: "red", "green", "refactor"
|
||||
- `focus_paths` are absolute or clear relative paths
|
||||
- `pre_analysis` includes exploration integration analysis
|
||||
3. Dependency validation:
|
||||
- Sequential features: IMPL-N depends_on ["IMPL-(N-1)"] if needed
|
||||
- Complex features: IMPL-N.M depends_on ["IMPL-N.(M-1)"] for subtasks
|
||||
- CLI execution strategies correctly assigned based on dependency graph
|
||||
4. Agent assignment: All IMPL tasks use @code-developer
|
||||
5. Test-fix cycle: Green phase step includes test-fix-cycle logic with max_iterations
|
||||
6. Task count: Total tasks ≤18 (simple + subtasks hard limit)
|
||||
7. User configuration:
|
||||
- Execution method choice reflected in task structure
|
||||
- CLI tool preference documented in implementation guidance (if CLI selected)
|
||||
|
||||
**Red Flag Checklist** (from TDD best practices):
|
||||
- [ ] No tasks skip Red phase (`tdd_phase: "red"` exists in step 1)
|
||||
- [ ] Test files referenced in Red phase (explicit paths, not placeholders)
|
||||
- [ ] Green phase has test-fix-cycle with `max_iterations` configured
|
||||
- [ ] Refactor phase has clear completion criteria
|
||||
|
||||
**Non-Compliance Warning Format**:
|
||||
```
|
||||
⚠️ TDD Red Flag: [issue description]
|
||||
Task: [IMPL-N]
|
||||
Recommendation: [action to fix]
|
||||
```
|
||||
|
||||
**Evidence Gathering** (Before Completion Claims):
|
||||
|
||||
```bash
|
||||
# Verify session artifacts exist
|
||||
ls -la .workflow/active/[sessionId]/{IMPL_PLAN.md,TODO_LIST.md}
|
||||
ls -la .workflow/active/[sessionId]/.task/IMPL-*.json
|
||||
|
||||
# Count generated artifacts
|
||||
echo "IMPL tasks: $(ls .workflow/active/[sessionId]/.task/IMPL-*.json 2>/dev/null | wc -l)"
|
||||
|
||||
# Sample task structure verification (first task)
|
||||
jq '{id, tdd: .meta.tdd_workflow, cli_id: .cli_execution.id, phases: [.implementation[].tdd_phase]}' \
|
||||
"$(ls .workflow/active/[sessionId]/.task/IMPL-*.json | head -1)"
|
||||
```
|
||||
|
||||
**Evidence Required Before Summary**:
|
||||
| Evidence Type | Verification Method | Pass Criteria |
|
||||
|---------------|---------------------|---------------|
|
||||
| File existence | `ls -la` artifacts | All files present |
|
||||
| Task count | Count IMPL-*.json | Count matches claims (≤18) |
|
||||
| TDD structure | jq sample extraction | Shows red/green/refactor + cli_execution.id |
|
||||
| CLI execution IDs | jq extraction | All tasks have cli_execution.id assigned |
|
||||
| Warning log | Check tdd-warnings.log | Logged (may be empty) |
|
||||
|
||||
**Return Summary**:
|
||||
```
|
||||
TDD Planning complete for session: [sessionId]
|
||||
|
||||
Features analyzed: [N]
|
||||
Total tasks: [M] (1 task per simple feature + subtasks for complex features)
|
||||
|
||||
Task breakdown:
|
||||
- Simple features: [K] tasks (IMPL-1 to IMPL-K)
|
||||
- Complex features: [L] features with [P] subtasks
|
||||
- Total task count: [M] (within 18-task hard limit)
|
||||
|
||||
Structure:
|
||||
- IMPL-1: {Feature 1 Name} (Internal: Red → Green → Refactor)
|
||||
- IMPL-2: {Feature 2 Name} (Internal: Red → Green → Refactor)
|
||||
- IMPL-3: {Complex Feature} (Container)
|
||||
- IMPL-3.1: {Sub-feature A} (Internal: Red → Green → Refactor)
|
||||
- IMPL-3.2: {Sub-feature B} (Internal: Red → Green → Refactor)
|
||||
[...]
|
||||
|
||||
Plans generated:
|
||||
- Unified Implementation Plan: .workflow/active/[sessionId]/IMPL_PLAN.md
|
||||
(includes TDD Implementation Tasks section with workflow_type: "tdd")
|
||||
- Task List: .workflow/active/[sessionId]/TODO_LIST.md
|
||||
(with internal TDD phase indicators and CLI execution strategies)
|
||||
- Task JSONs: .workflow/active/[sessionId]/.task/IMPL-*.json
|
||||
(with cli_execution.id and execution strategies for resume support)
|
||||
|
||||
TDD Configuration:
|
||||
- Each task contains complete Red-Green-Refactor cycle
|
||||
- Green phase includes test-fix cycle (max 3 iterations)
|
||||
- Auto-revert on max iterations reached
|
||||
- CLI execution strategies: new/resume/fork/merge_fork based on dependency graph
|
||||
|
||||
User Configuration Applied:
|
||||
- Execution Method: [agent|hybrid|cli]
|
||||
- CLI Tool Preference: [codex|gemini|qwen|auto]
|
||||
- Supplementary Materials: [included|none]
|
||||
- Task generation follows cli-tools-usage.md guidelines
|
||||
|
||||
⚠️ ACTION REQUIRED: Before execution, ensure you understand WHY each Red phase test is expected to fail.
|
||||
This is crucial for valid TDD - if you don't know why the test fails, you can't verify it tests the right thing.
|
||||
|
||||
Recommended Next Steps:
|
||||
1. /workflow:plan-verify --session [sessionId] # Verify TDD plan quality and dependencies
|
||||
2. /workflow:execute --session [sessionId] # Start TDD execution with CLI strategies
|
||||
3. /workflow:tdd-verify [sessionId] # Post-execution TDD compliance check
|
||||
|
||||
Quality Gate: Consider running /workflow:plan-verify to validate TDD task structure, dependencies, and CLI execution strategies
|
||||
```
|
||||
|
||||
## TodoWrite Pattern
|
||||
|
||||
**Core Concept**: Dynamic task attachment and collapse for TDD workflow with test coverage analysis and Red-Green-Refactor cycle generation.
|
||||
|
||||
### Key Principles
|
||||
|
||||
1. **Task Attachment** (when Skill executed):
|
||||
- Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
|
||||
- Example: `/workflow:tools:test-context-gather` attaches 3 sub-tasks (Phase 3.1, 3.2, 3.3)
|
||||
- First attached task marked as `in_progress`, others as `pending`
|
||||
- Orchestrator **executes** these attached tasks sequentially
|
||||
|
||||
2. **Task Collapse** (after sub-tasks complete):
|
||||
- Remove detailed sub-tasks from TodoWrite
|
||||
- **Collapse** to high-level phase summary
|
||||
- Example: Phase 3.1-3.3 collapse to "Execute test coverage analysis: completed"
|
||||
- Maintains clean orchestrator-level view
|
||||
|
||||
3. **Continuous Execution**:
|
||||
- After collapse, automatically proceed to next pending phase
|
||||
- No user intervention required between phases
|
||||
- TodoWrite dynamically reflects current execution state
|
||||
|
||||
**Lifecycle Summary**: Initial pending tasks → Phase executed (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary) → Next phase begins (conditional Phase 4 if conflict_risk ≥ medium) → Repeat until all phases complete.
|
||||
|
||||
### 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
|
||||
|
||||
|
||||
|
||||
**Note**: See individual Phase descriptions (Phase 3, 4, 5) for detailed TodoWrite Update examples with full JSON structures.
|
||||
|
||||
## 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: Log and analyze detected conflicts
|
||||
│ └─ Phase 4.3: Apply resolution strategies
|
||||
│ └─ Returns: conflict-resolution.json ← 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:plan-verify
|
||||
|
||||
Key Points:
|
||||
• ← ATTACHED: Skill 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
|
||||
|
||||
Convert user input to TDD-structured format:
|
||||
|
||||
**Simple text** → Add TDD context
|
||||
**Detailed text** → Extract components with TEST_FOCUS
|
||||
**File/Issue** → Read and structure with TDD
|
||||
|
||||
## Error Handling
|
||||
|
||||
- **Parsing failure**: Retry once, then report
|
||||
- **Validation failure**: Report missing/invalid data
|
||||
- **Command failure**: Keep phase in_progress, report error
|
||||
- **TDD validation failure**: Report incomplete chains or wrong dependencies
|
||||
|
||||
### TDD Warning Patterns
|
||||
|
||||
| Pattern | Warning Message | Recommended Action |
|
||||
|---------|----------------|-------------------|
|
||||
| Task count >10 | High task count detected | Consider splitting into multiple sessions |
|
||||
| Missing test-fix-cycle | Green phase lacks auto-revert | Add `max_iterations: 3` to task config |
|
||||
| Red phase missing test path | Test file path not specified | Add explicit test file paths |
|
||||
| Generic task names | Vague names like "Add feature" | Use specific behavior descriptions |
|
||||
| No refactor criteria | Refactor phase lacks completion criteria | Define clear refactor scope |
|
||||
|
||||
### Non-Blocking Warning Policy
|
||||
|
||||
**All warnings are advisory** - they do not halt execution:
|
||||
1. Warnings logged to `.process/tdd-warnings.log`
|
||||
2. Summary displayed in Phase 6 output
|
||||
3. User decides whether to address before `/workflow:execute`
|
||||
|
||||
### Error Handling Quick Reference
|
||||
|
||||
| Error Type | Detection | Recovery Action |
|
||||
|------------|-----------|-----------------|
|
||||
| Parsing failure | Empty/malformed output | Retry once, then report |
|
||||
| Missing context-package | File read error | Re-run `/workflow:tools:context-gather` |
|
||||
| Invalid task JSON | jq parse error | Report malformed file path |
|
||||
| Task count exceeds 18 | Count validation ≥19 | Request re-scope, split into multiple sessions |
|
||||
| Missing cli_execution.id | All tasks lack ID | Regenerate tasks with phase 0 user config |
|
||||
| Test-context missing | File not found | Re-run `/workflow:tools:test-context-gather` |
|
||||
| Phase timeout | No response | Retry phase, check CLI connectivity |
|
||||
| CLI tool not available | Tool not in cli-tools.json | Fall back to alternative preferred tool |
|
||||
|
||||
## Related Commands
|
||||
|
||||
**Prerequisite Commands**:
|
||||
- None - TDD planning is self-contained (can optionally run brainstorm commands before)
|
||||
|
||||
**Called by This Command** (6 phases):
|
||||
- `/workflow:session:start` - Phase 1: Create or discover TDD workflow session
|
||||
- `/workflow:tools:context-gather` - Phase 2: Gather project context and analyze codebase
|
||||
- `/workflow:tools:test-context-gather` - Phase 3: Analyze existing test patterns and coverage
|
||||
- `/workflow:tools:conflict-resolution` - Phase 4: Detect and resolve conflicts (auto-triggered if conflict_risk ≥ medium)
|
||||
- `/compact` - Phase 4: Memory optimization (if context approaching limits)
|
||||
- `/workflow:tools:task-generate-tdd` - Phase 5: Generate TDD tasks (CLI tool usage determined semantically)
|
||||
|
||||
**Follow-up Commands**:
|
||||
- `/workflow:plan-verify` - Recommended: Verify TDD plan quality and structure before execution
|
||||
- `/workflow:status` - Review TDD task breakdown
|
||||
- `/workflow:execute` - Begin TDD implementation
|
||||
- `/workflow:tdd-verify` - Post-execution: Verify TDD compliance and generate quality report
|
||||
|
||||
## Next Steps Decision Table
|
||||
|
||||
| Situation | Recommended Command | Purpose |
|
||||
|-----------|---------------------|---------|
|
||||
| First time planning | `/workflow:plan-verify` | Validate task structure before execution |
|
||||
| Warnings in tdd-warnings.log | Review log, refine tasks | Address Red Flags before proceeding |
|
||||
| High task count warning | Consider `/workflow:session:start` | Split into focused sub-sessions |
|
||||
| Ready to implement | `/workflow:execute` | Begin TDD Red-Green-Refactor cycles |
|
||||
| After implementation | `/workflow:tdd-verify` | Generate TDD compliance report |
|
||||
| Need to review tasks | `/workflow:status --session [id]` | Inspect current task breakdown |
|
||||
| Plan needs changes | `/task:replan` | Update task JSON with new requirements |
|
||||
|
||||
### TDD Workflow State Transitions
|
||||
|
||||
```
|
||||
/workflow:tdd-plan
|
||||
↓
|
||||
[Planning Complete] ──→ /workflow:plan-verify (recommended)
|
||||
↓
|
||||
[Verified/Ready] ─────→ /workflow:execute
|
||||
↓
|
||||
[Implementation] ─────→ /workflow:tdd-verify (post-execution)
|
||||
↓
|
||||
[Quality Report] ─────→ Done or iterate
|
||||
```
|
||||
@@ -1,504 +0,0 @@
|
||||
---
|
||||
name: test-cycle-execute
|
||||
description: Execute test-fix workflow with dynamic task generation and iterative fix cycles until test pass rate >= 95% or max iterations reached. Uses @cli-planning-agent for failure analysis and task generation.
|
||||
argument-hint: "[--resume-session=\"session-id\"] [--max-iterations=N]"
|
||||
allowed-tools: Skill(*), TodoWrite(*), Read(*), Bash(*), Task(*)
|
||||
---
|
||||
|
||||
# Workflow Test-Cycle-Execute Command
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Execute test-fix workflow (auto-discovers active session)
|
||||
/workflow:test-cycle-execute
|
||||
|
||||
# Resume interrupted session
|
||||
/workflow:test-cycle-execute --resume-session="WFS-test-user-auth"
|
||||
|
||||
# Custom iteration limit (default: 10)
|
||||
/workflow:test-cycle-execute --max-iterations=15
|
||||
```
|
||||
|
||||
**Quality Gate**: Test pass rate >= 95% (criticality-aware) or 100%
|
||||
**Max Iterations**: 10 (default, adjustable)
|
||||
**CLI Tools**: Gemini → Qwen → Codex (fallback chain)
|
||||
|
||||
## What & Why
|
||||
|
||||
### Core Concept
|
||||
Dynamic test-fix orchestrator with **adaptive task generation** based on runtime analysis.
|
||||
|
||||
**vs Standard Execute**:
|
||||
- **Standard**: Pre-defined tasks → Execute sequentially → Done
|
||||
- **Test-Cycle**: Initial tasks → **Test → Analyze failures → Generate fix tasks → Fix → Re-test** → Repeat until pass
|
||||
|
||||
### Value Proposition
|
||||
1. **Automatic Problem Solving**: No manual intervention needed until 95% pass rate
|
||||
2. **Intelligent Adaptation**: Strategy adjusts based on progress (conservative → aggressive → surgical)
|
||||
3. **Fast Feedback**: Progressive testing runs only affected tests (70-90% faster)
|
||||
|
||||
### Orchestrator Boundary (CRITICAL)
|
||||
- **ONLY command** handling test failures - always delegate here
|
||||
- Manages: iteration loop, strategy selection, pass rate validation
|
||||
- Delegates: CLI analysis to @cli-planning-agent, execution to @test-fix-agent
|
||||
|
||||
## How It Works
|
||||
|
||||
### Execution Flow
|
||||
|
||||
```
|
||||
1. Discovery
|
||||
└─ Load session, tasks, iteration state
|
||||
|
||||
2. Main Loop (for each task):
|
||||
├─ Execute → Test → Calculate pass_rate
|
||||
├─ Decision:
|
||||
│ ├─ 100% → SUCCESS: Next task
|
||||
│ ├─ 95-99% + low criticality → PARTIAL SUCCESS: Approve with note
|
||||
│ └─ <95% or critical failures → Fix Loop ↓
|
||||
└─ Fix Loop:
|
||||
├─ Detect: stuck tests, regression, progress trend
|
||||
├─ Select strategy: conservative/aggressive/surgical
|
||||
├─ Generate fix task via @cli-planning-agent (IMPL-fix-N.json)
|
||||
├─ Execute fix via @test-fix-agent
|
||||
└─ Re-test → Back to step 2
|
||||
|
||||
3. Completion
|
||||
└─ Final validation → Generate summary → Auto-complete session
|
||||
```
|
||||
|
||||
### Agent Roles
|
||||
|
||||
| Agent | Responsibility |
|
||||
|-------|---------------|
|
||||
| **Orchestrator** | Loop control, strategy selection, pass rate calculation, threshold decisions |
|
||||
| **@cli-planning-agent** | CLI analysis (Gemini/Qwen/Codex), root cause extraction, task generation, affected test detection |
|
||||
| **@test-fix-agent** | Test execution, code fixes, criticality assignment, result reporting |
|
||||
|
||||
## Enhanced Features
|
||||
|
||||
### 1. Intelligent Strategy Engine
|
||||
|
||||
**Auto-selects optimal strategy based on iteration context:**
|
||||
|
||||
| Strategy | Trigger | Behavior |
|
||||
|----------|---------|----------|
|
||||
| **Conservative** | Iteration 1-2 (default) | Single targeted fix, full validation |
|
||||
| **Aggressive** | Pass rate >80% + similar failures | Batch fix related issues |
|
||||
| **Surgical** | Regression detected (pass rate drops >10%) | Minimal changes, rollback focus |
|
||||
|
||||
**Selection Logic** (in orchestrator):
|
||||
```javascript
|
||||
if (iteration <= 2) return "conservative";
|
||||
if (passRate > 80 && failurePattern.similarity > 0.7) return "aggressive";
|
||||
if (regressionDetected) return "surgical";
|
||||
return "conservative";
|
||||
```
|
||||
|
||||
**Integration**: Strategy passed to @cli-planning-agent in prompt for tailored analysis.
|
||||
|
||||
### 2. Progressive Testing
|
||||
|
||||
**Runs affected tests during iterations, full suite only for final validation.**
|
||||
|
||||
**How It Works**:
|
||||
1. @cli-planning-agent analyzes fix_strategy.modification_points
|
||||
2. Maps modified files to test files (via imports + integration patterns)
|
||||
3. Returns `affected_tests[]` in task JSON
|
||||
4. @test-fix-agent runs: `npm test -- ${affected_tests.join(' ')}`
|
||||
5. Final validation: `npm test` (full suite)
|
||||
|
||||
|
||||
**Benefits**: 70-90% iteration speed improvement, instant feedback on fix effectiveness.
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
### Orchestrator
|
||||
- Session discovery, task queue management
|
||||
- Pass rate calculation: `(passed / total) * 100` from test-results.json
|
||||
- Criticality assessment (high/medium/low)
|
||||
- Strategy selection based on context
|
||||
- **Runtime Calculations** (from iteration-state.json):
|
||||
- Current iteration: `iterations.length + 1`
|
||||
- Stuck tests: Tests appearing in `failed_tests` for 3+ consecutive iterations
|
||||
- Regression: Compare consecutive `pass_rate` values (>10% drop)
|
||||
- Max iterations: Read from `task.meta.max_iterations`
|
||||
- Iteration control (max 10, default)
|
||||
- CLI tool fallback chain: Gemini → Qwen → Codex
|
||||
- TodoWrite progress tracking
|
||||
- Session auto-complete (pass rate >= 95%)
|
||||
|
||||
### @cli-planning-agent
|
||||
- Execute CLI analysis with bug diagnosis template
|
||||
- Parse output for root causes and fix strategy
|
||||
- Generate IMPL-fix-N.json task definition
|
||||
- Detect affected tests for progressive testing
|
||||
- Save: analysis.md, cli-output.txt
|
||||
|
||||
### @test-fix-agent
|
||||
- Execute tests, save results to test-results.json
|
||||
- Apply fixes from task.context.fix_strategy
|
||||
- Assign criticality to failures
|
||||
- Update task status
|
||||
|
||||
## Reference
|
||||
|
||||
### CLI Tool Configuration
|
||||
|
||||
**Fallback Chain**: Gemini → Qwen → Codex
|
||||
**Template**: `~/.ccw/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt`
|
||||
**Timeout**: 40min (2400000ms)
|
||||
|
||||
**Tool Details**:
|
||||
1. **Gemini** (primary): `gemini-2.5-pro`
|
||||
2. **Qwen** (fallback): `coder-model`
|
||||
3. **Codex** (fallback): `gpt-5.1-codex`
|
||||
|
||||
**When to Fallback**: HTTP 429, timeout, analysis quality degraded
|
||||
|
||||
### Session File Structure
|
||||
|
||||
```
|
||||
.workflow/active/WFS-test-{session}/
|
||||
├── workflow-session.json # Session metadata
|
||||
├── IMPL_PLAN.md, TODO_LIST.md
|
||||
├── .task/
|
||||
│ ├── IMPL-{001,002}.json # Initial tasks
|
||||
│ └── IMPL-fix-{N}.json # Generated fix tasks
|
||||
├── .process/
|
||||
│ ├── iteration-state.json # Current iteration + strategy + stuck tests
|
||||
│ ├── test-results.json # Latest results (pass_rate, criticality)
|
||||
│ ├── test-output.log # Full test output
|
||||
│ ├── fix-history.json # All fix attempts
|
||||
│ ├── iteration-{N}-analysis.md # CLI analysis report
|
||||
│ └── iteration-{N}-cli-output.txt
|
||||
└── .summaries/iteration-summaries/
|
||||
```
|
||||
|
||||
### Iteration State JSON
|
||||
|
||||
**Purpose**: Persisted state machine for iteration loop - enables Resume and historical analysis.
|
||||
|
||||
```json
|
||||
{
|
||||
"current_task": "IMPL-002",
|
||||
"selected_strategy": "aggressive",
|
||||
"next_action": "execute_fix_task",
|
||||
"iterations": [
|
||||
{
|
||||
"iteration": 1,
|
||||
"pass_rate": 70,
|
||||
"strategy": "conservative",
|
||||
"failed_tests": ["test_auth_flow", "test_user_permissions"]
|
||||
},
|
||||
{
|
||||
"iteration": 2,
|
||||
"pass_rate": 82,
|
||||
"strategy": "conservative",
|
||||
"failed_tests": ["test_user_permissions", "test_token_expiry"]
|
||||
},
|
||||
{
|
||||
"iteration": 3,
|
||||
"pass_rate": 89,
|
||||
"strategy": "aggressive",
|
||||
"failed_tests": ["test_auth_edge_case"]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Field Descriptions**:
|
||||
- `current_task`: Pointer to active task (essential for Resume)
|
||||
- `selected_strategy`: Current iteration strategy (runtime state)
|
||||
- `next_action`: State machine next step (`execute_fix_task` | `retest` | `complete`)
|
||||
- `iterations[]`: Historical log of all iterations (source of truth for trends)
|
||||
|
||||
|
||||
### Agent Invocation Template
|
||||
|
||||
**@cli-planning-agent** (failure analysis):
|
||||
```javascript
|
||||
Task(
|
||||
subagent_type="cli-planning-agent",
|
||||
run_in_background=false,
|
||||
description=`Analyze test failures (iteration ${N}) - ${strategy} strategy`,
|
||||
prompt=`
|
||||
## Task Objective
|
||||
Analyze test failures and generate fix task JSON for iteration ${N}
|
||||
|
||||
## Strategy
|
||||
${selectedStrategy} - ${strategyDescription}
|
||||
|
||||
## MANDATORY FIRST STEPS
|
||||
1. Read test results: ${session.test_results_path}
|
||||
2. Read test output: ${session.test_output_path}
|
||||
3. Read iteration state: ${session.iteration_state_path}
|
||||
|
||||
## Context Metadata (Orchestrator-Calculated)
|
||||
- Session ID: ${sessionId} (from file path)
|
||||
- Current Iteration: ${N} (= iterations.length + 1)
|
||||
- Max Iterations: ${maxIterations} (from task.meta.max_iterations)
|
||||
- Current Pass Rate: ${passRate}%
|
||||
- Selected Strategy: ${selectedStrategy} (from iteration-state.json)
|
||||
- Stuck Tests: ${stuckTests} (calculated from iterations[].failed_tests history)
|
||||
|
||||
## CLI Configuration
|
||||
- Tool Priority: gemini & codex
|
||||
- Template: 01-diagnose-bug-root-cause.txt
|
||||
- Timeout: 2400000ms
|
||||
|
||||
## Expected Deliverables
|
||||
1. Task JSON: ${session.task_dir}/IMPL-fix-${N}.json
|
||||
- Must include: fix_strategy.test_execution.affected_tests[]
|
||||
- Must include: fix_strategy.confidence_score
|
||||
2. Analysis report: ${session.process_dir}/iteration-${N}-analysis.md
|
||||
3. CLI output: ${session.process_dir}/iteration-${N}-cli-output.txt
|
||||
|
||||
## Strategy-Specific Requirements
|
||||
- Conservative: Single targeted fix, high confidence required
|
||||
- Aggressive: Batch fix similar failures, pattern-based approach
|
||||
- Surgical: Minimal changes, focus on rollback safety
|
||||
|
||||
## Success Criteria
|
||||
- Concrete fix strategy with modification points (file:function:lines)
|
||||
- Affected tests list for progressive testing
|
||||
- Root cause analysis (not just symptoms)
|
||||
`
|
||||
)
|
||||
```
|
||||
|
||||
**@test-fix-agent** (execution):
|
||||
```javascript
|
||||
Task(
|
||||
subagent_type="test-fix-agent",
|
||||
run_in_background=false,
|
||||
description=`Execute ${task.meta.type}: ${task.title}`,
|
||||
prompt=`
|
||||
## Task Objective
|
||||
${taskTypeObjective[task.meta.type]}
|
||||
|
||||
## MANDATORY FIRST STEPS
|
||||
1. Read task JSON: ${session.task_json_path}
|
||||
2. Read iteration state: ${session.iteration_state_path}
|
||||
3. ${taskTypeSpecificReads[task.meta.type]}
|
||||
|
||||
## CRITICAL: Syntax Check Priority
|
||||
**Before any code modification or test execution:**
|
||||
- Run project syntax checker (TypeScript: tsc --noEmit, ESLint, etc.)
|
||||
- Verify zero syntax errors before proceeding
|
||||
- If syntax errors found: Fix immediately before other work
|
||||
- Syntax validation is MANDATORY gate - no exceptions
|
||||
|
||||
## Session Paths
|
||||
- Workflow Dir: ${session.workflow_dir}
|
||||
- Task JSON: ${session.task_json_path}
|
||||
- Test Results Output: ${session.test_results_path}
|
||||
- Test Output Log: ${session.test_output_path}
|
||||
- Iteration State: ${session.iteration_state_path}
|
||||
|
||||
## Task Type: ${task.meta.type}
|
||||
${taskTypeGuidance[task.meta.type]}
|
||||
|
||||
## Expected Deliverables
|
||||
${taskTypeDeliverables[task.meta.type]}
|
||||
|
||||
## Success Criteria
|
||||
- ${taskTypeSuccessCriteria[task.meta.type]}
|
||||
- Update task status in task JSON
|
||||
- Save all outputs to specified paths
|
||||
- Report completion to orchestrator
|
||||
`
|
||||
)
|
||||
|
||||
// Task Type Configurations
|
||||
const taskTypeObjective = {
|
||||
"test-gen": "Generate comprehensive tests based on requirements",
|
||||
"test-fix": "Execute test suite and report results with criticality assessment",
|
||||
"test-fix-iteration": "Apply fixes from strategy and validate with tests"
|
||||
};
|
||||
|
||||
const taskTypeSpecificReads = {
|
||||
"test-gen": "Read test context: ${session.test_context_path}",
|
||||
"test-fix": "Read previous results (if exists): ${session.test_results_path}",
|
||||
"test-fix-iteration": "Read fix strategy: ${session.analysis_path}, fix history: ${session.fix_history_path}"
|
||||
};
|
||||
|
||||
const taskTypeGuidance = {
|
||||
"test-gen": `
|
||||
- Review task.context.requirements for test scenarios
|
||||
- Analyze codebase to understand implementation
|
||||
- Generate tests covering: happy paths, edge cases, error handling
|
||||
- Follow existing test patterns and framework conventions
|
||||
`,
|
||||
"test-fix": `
|
||||
- Run test command from task.context or project config
|
||||
- Capture: pass/fail counts, error messages, stack traces
|
||||
- Assess criticality for each failure:
|
||||
* high: core functionality broken, security issues
|
||||
* medium: feature degradation, data integrity issues
|
||||
* low: edge cases, flaky tests, env-specific issues
|
||||
- Save structured results to test-results.json
|
||||
`,
|
||||
"test-fix-iteration": `
|
||||
- Load fix_strategy from task.context.fix_strategy
|
||||
- Identify modification_points: ${task.context.fix_strategy.modification_points}
|
||||
- Apply surgical fixes (minimal changes)
|
||||
- Test execution mode: ${task.context.fix_strategy.test_execution.mode}
|
||||
* affected_only: Run ${task.context.fix_strategy.test_execution.affected_tests}
|
||||
* full_suite: Run complete test suite
|
||||
- If failures persist: Document in test-results.json, DO NOT analyze (orchestrator handles)
|
||||
`
|
||||
};
|
||||
|
||||
const taskTypeDeliverables = {
|
||||
"test-gen": "- Test files in target directories\n - Test coverage report\n - Summary in .summaries/",
|
||||
"test-fix": "- test-results.json (pass_rate, criticality, failures)\n - test-output.log (full test output)\n - Summary in .summaries/",
|
||||
"test-fix-iteration": "- Modified source files\n - test-results.json (updated pass_rate)\n - test-output.log\n - Summary in .summaries/"
|
||||
};
|
||||
|
||||
const taskTypeSuccessCriteria = {
|
||||
"test-gen": "All test files created, executable without errors, coverage documented",
|
||||
"test-fix": "Test results saved with accurate pass_rate and criticality, all failures documented",
|
||||
"test-fix-iteration": "Fixes applied per strategy, tests executed, results reported (pass/fail to orchestrator)"
|
||||
};
|
||||
```
|
||||
|
||||
### Completion Conditions
|
||||
|
||||
**Full Success**:
|
||||
- All tasks completed
|
||||
- Pass rate === 100%
|
||||
- Action: Auto-complete session
|
||||
|
||||
**Partial Success**:
|
||||
- All tasks completed
|
||||
- Pass rate >= 95% and < 100%
|
||||
- All failures are "low" criticality
|
||||
- Action: Auto-approve with review note
|
||||
|
||||
**Failure**:
|
||||
- Max iterations (10) reached without 95% pass rate
|
||||
- Pass rate < 95% after max iterations
|
||||
- Action: Generate failure report, mark blocked, return to user
|
||||
|
||||
### Error Handling
|
||||
|
||||
| Scenario | Action |
|
||||
|----------|--------|
|
||||
| Test execution error | Log, retry with error context |
|
||||
| CLI analysis failure | Fallback: Gemini → Qwen → Codex → manual |
|
||||
| Agent execution error | Save state, retry with simplified context |
|
||||
| Max iterations reached | Generate failure report, mark blocked |
|
||||
| Regression detected | Rollback last fix, switch to surgical strategy |
|
||||
| Stuck tests detected | Continue with alternative strategy, document in failure report |
|
||||
|
||||
**CLI Fallback Triggers** (Gemini → Qwen → Codex → manual):
|
||||
|
||||
Fallback is triggered when any of these conditions occur:
|
||||
|
||||
1. **Invalid Output**:
|
||||
- CLI tool fails to generate valid `IMPL-fix-N.json` (JSON parse error)
|
||||
- Missing required fields: `fix_strategy.modification_points` or `fix_strategy.affected_tests`
|
||||
|
||||
2. **Low Confidence**:
|
||||
- `fix_strategy.confidence_score < 0.4` (indicates uncertain analysis)
|
||||
|
||||
3. **Technical Failures**:
|
||||
- HTTP 429 (rate limit) or 5xx errors
|
||||
- Timeout (exceeds 2400000ms / 40min)
|
||||
- Connection errors
|
||||
|
||||
4. **Quality Degradation**:
|
||||
- Analysis report < 100 words (too brief, likely incomplete)
|
||||
- No concrete modification points provided (only general suggestions)
|
||||
- Same root cause identified 3+ consecutive times (stuck analysis)
|
||||
|
||||
**Fallback Sequence**:
|
||||
- Try primary tool (Gemini)
|
||||
- If trigger detected → Try fallback (Qwen)
|
||||
- If trigger detected again → Try final fallback (Codex)
|
||||
- If all fail → Mark as degraded, use basic pattern matching from fix-history.json, notify user
|
||||
|
||||
### TodoWrite Structure
|
||||
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Execute IMPL-001: Generate tests [code-developer]",
|
||||
status: "completed",
|
||||
activeForm: "Executing test generation"
|
||||
},
|
||||
{
|
||||
content: "Execute IMPL-002: Test & Fix Cycle [ITERATION]",
|
||||
status: "in_progress",
|
||||
activeForm: "Running test-fix iteration cycle"
|
||||
},
|
||||
{
|
||||
content: " → Iteration 1: Initial test (pass: 70%, conservative)",
|
||||
status: "completed",
|
||||
activeForm: "Running initial tests"
|
||||
},
|
||||
{
|
||||
content: " → Iteration 2: Fix validation (pass: 82%, conservative)",
|
||||
status: "completed",
|
||||
activeForm: "Fixing validation issues"
|
||||
},
|
||||
{
|
||||
content: " → Iteration 3: Batch fix auth (pass: 89%, aggressive)",
|
||||
status: "in_progress",
|
||||
activeForm: "Fixing authentication issues"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
**Update Rules**:
|
||||
- Add iteration item with: strategy, pass rate
|
||||
- Mark completed after each iteration
|
||||
- Update parent task when all complete
|
||||
|
||||
## Commit Strategy
|
||||
|
||||
**Automatic Commits** (orchestrator-managed):
|
||||
|
||||
The orchestrator automatically creates git commits at key checkpoints to enable safe rollback:
|
||||
|
||||
1. **After Successful Iteration** (pass rate increased):
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "test-cycle: iteration ${N} - ${strategy} strategy (pass: ${oldRate}% → ${newRate}%)"
|
||||
```
|
||||
|
||||
2. **Before Rollback** (regression detected):
|
||||
```bash
|
||||
# Current state preserved, then:
|
||||
git revert HEAD
|
||||
git commit -m "test-cycle: rollback iteration ${N} - regression detected (pass: ${newRate}% < ${oldRate}%)"
|
||||
```
|
||||
|
||||
**Commit Content**:
|
||||
- Modified source files from fix application
|
||||
- Updated test-results.json, iteration-state.json
|
||||
- Excludes: temporary files, logs
|
||||
|
||||
**Benefits**:
|
||||
- **Rollback Safety**: Each iteration is a revert point
|
||||
- **Progress Tracking**: Git history shows iteration evolution
|
||||
- **Audit Trail**: Clear record of which strategy/iteration caused issues
|
||||
- **Resume Capability**: Can resume from any checkpoint
|
||||
|
||||
**Note**: Final session completion creates additional commit with full summary.
|
||||
|
||||
## Post-Completion Expansion
|
||||
|
||||
完成后询问用户是否扩展为issue(test/enhance/refactor/doc),选中项调用 `/issue:new "{summary} - {dimension}"`
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Default Settings Work**: 10 iterations sufficient for most cases
|
||||
2. **Automatic Commits**: Orchestrator commits after each successful iteration - no manual intervention needed
|
||||
3. **Trust Strategy Engine**: Auto-selection based on proven heuristics
|
||||
4. **Monitor Logs**: Check `.process/iteration-N-analysis.md` for CLI analysis insights
|
||||
5. **Progressive Testing**: Saves 70-90% iteration time automatically
|
||||
@@ -1,477 +0,0 @@
|
||||
---
|
||||
name: test-fix-gen
|
||||
description: Create test-fix workflow session with progressive test layers (L0-L3), AI code validation, and test task generation
|
||||
argument-hint: "(source-session-id | \"feature description\" | /path/to/file.md)"
|
||||
allowed-tools: Skill(*), TodoWrite(*), Read(*), Bash(*)
|
||||
group: workflow
|
||||
---
|
||||
|
||||
# Workflow Test-Fix Generation Command (/workflow:test-fix-gen)
|
||||
|
||||
## Coordinator Role
|
||||
|
||||
**This command is a pure orchestrator**: Execute 5 slash commands in sequence, parse their outputs, pass context between them, and ensure complete execution through **automatic continuation**.
|
||||
|
||||
**Execution Model - Auto-Continue Workflow**:
|
||||
|
||||
This workflow runs **fully autonomously** once triggered. Phase 3 (test analysis) and Phase 4 (task generation) are delegated to specialized agents.
|
||||
|
||||
1. **User triggers**: `/workflow:test-fix-gen "task"` or `/workflow:test-fix-gen WFS-source-session`
|
||||
2. **Phase 1 executes** → Test session created → Auto-continues
|
||||
3. **Phase 2 executes** → Context gathering → Auto-continues
|
||||
4. **Phase 3 executes** → Test generation analysis (Gemini) → Auto-continues
|
||||
5. **Phase 4 executes** → Task generation (test-task-generate) → Reports final summary
|
||||
|
||||
**Task Attachment Model**:
|
||||
- Skill execute **expands workflow** by attaching sub-tasks to current TodoWrite
|
||||
- When a sub-command is executed, 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 command execution
|
||||
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 output for next phase
|
||||
4. **Auto-Continue via TodoList**: Check TodoList status to execute next pending phase automatically
|
||||
5. **Track Progress**: Update TodoWrite dynamically with task attachment/collapse pattern
|
||||
6. **Task Attachment Model**: Skill execute **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
|
||||
|
||||
---
|
||||
|
||||
## Test Strategy Overview
|
||||
|
||||
This workflow generates tests using **Progressive Test Layers (L0-L3)**:
|
||||
|
||||
| Layer | Name | Focus |
|
||||
|-------|------|-------|
|
||||
| **L0** | Static Analysis | Compilation, imports, types, AI code issues |
|
||||
| **L1** | Unit Tests | Function/class behavior (happy/negative/edge cases) |
|
||||
| **L2** | Integration Tests | Component interactions, API contracts, failure modes |
|
||||
| **L3** | E2E Tests | User journeys, critical paths (optional) |
|
||||
|
||||
**Key Features**:
|
||||
- **AI Code Issue Detection** - Validates against common AI-generated code problems (hallucinated imports, placeholder code, mock leakage, etc.)
|
||||
- **Project Type Detection** - Applies appropriate test templates (React, Node API, CLI, Library, etc.)
|
||||
- **Quality Gates** - IMPL-001.3 (code validation) and IMPL-001.5 (test quality) ensure high standards
|
||||
|
||||
**Detailed specifications**: See `/workflow:tools:test-task-generate` for complete L0-L3 requirements and quality thresholds.
|
||||
|
||||
---
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Input Parsing:
|
||||
├─ Detect input type: Session ID (WFS-*) | Description | File path
|
||||
└─ Set MODE: session | prompt
|
||||
|
||||
Phase 1: Create Test Session
|
||||
└─ /workflow:session:start --type test --new "structured-description"
|
||||
└─ Output: testSessionId (WFS-test-xxx)
|
||||
|
||||
Phase 2: Gather Test Context
|
||||
├─ MODE=session → /workflow:tools:test-context-gather --session testSessionId
|
||||
└─ MODE=prompt → /workflow:tools:context-gather --session testSessionId "description"
|
||||
└─ Output: contextPath (context-package.json)
|
||||
|
||||
Phase 3: Test Generation Analysis
|
||||
└─ /workflow:tools:test-concept-enhanced --session testSessionId --context contextPath
|
||||
└─ Output: TEST_ANALYSIS_RESULTS.md (L0-L3 requirements)
|
||||
|
||||
Phase 4: Generate Test Tasks
|
||||
└─ /workflow:tools:test-task-generate --session testSessionId
|
||||
└─ Output: IMPL_PLAN.md, IMPL-*.json (4+ tasks), TODO_LIST.md
|
||||
|
||||
Phase 5: Return Summary
|
||||
└─ Summary with next steps → /workflow:test-cycle-execute
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5-Phase Execution
|
||||
|
||||
### Phase 1: Create Test Session
|
||||
|
||||
**Step 1.0: Detect Input Mode**
|
||||
|
||||
```
|
||||
// Automatic mode detection based on input pattern
|
||||
if (input.startsWith("WFS-")) {
|
||||
MODE = "session"
|
||||
// Load source session to preserve original task description
|
||||
Read(".workflow/active/[sourceSessionId]/workflow-session.json")
|
||||
} else {
|
||||
MODE = "prompt"
|
||||
}
|
||||
```
|
||||
|
||||
**Step 1.1: Execute** - Create test workflow session
|
||||
|
||||
```
|
||||
// Session Mode - preserve original task description
|
||||
Skill(skill="workflow:session:start", args="--type test --new \"Test validation for [sourceSessionId]: [originalTaskDescription]\"")
|
||||
|
||||
// Prompt Mode - use user's description directly
|
||||
Skill(skill="workflow:session:start", args="--type test --new \"Test generation for: [description]\"")
|
||||
```
|
||||
|
||||
**Parse Output**:
|
||||
- Extract: `SESSION_ID: WFS-test-[slug]` (store as `testSessionId`)
|
||||
|
||||
**Validation**:
|
||||
- Session Mode: Source session `.workflow/active/[sourceSessionId]/` exists with completed IMPL tasks
|
||||
- Both Modes: New test session directory created with metadata
|
||||
|
||||
**TodoWrite**: Mark phase 1 completed, phase 2 in_progress
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Gather Test Context
|
||||
|
||||
**Step 2.1: Execute** - Gather context based on mode
|
||||
|
||||
```
|
||||
// Session Mode - gather from source session
|
||||
Skill(skill="workflow:tools:test-context-gather", args="--session [testSessionId]")
|
||||
|
||||
// Prompt Mode - gather from codebase
|
||||
Skill(skill="workflow:tools:context-gather", args="--session [testSessionId] \"[task_description]\"")
|
||||
```
|
||||
|
||||
**Input**: `testSessionId` from Phase 1
|
||||
|
||||
**Parse Output**:
|
||||
- Extract: context package path (store as `contextPath`)
|
||||
- Pattern: `.workflow/active/[testSessionId]/.process/[test-]context-package.json`
|
||||
|
||||
**Validation**:
|
||||
- Context package file exists and is valid JSON
|
||||
- Contains coverage analysis (session mode) or codebase analysis (prompt mode)
|
||||
- Test framework detected
|
||||
|
||||
**TodoWrite Update (tasks attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Create Test Session", "status": "completed"},
|
||||
{"content": "Phase 2: Gather Test Context", "status": "in_progress"},
|
||||
{"content": " → Load source/codebase context", "status": "in_progress"},
|
||||
{"content": " → Analyze test coverage", "status": "pending"},
|
||||
{"content": " → Generate context package", "status": "pending"},
|
||||
{"content": "Phase 3: Test Generation Analysis", "status": "pending"},
|
||||
{"content": "Phase 4: Generate Test Tasks", "status": "pending"},
|
||||
{"content": "Phase 5: Return Summary", "status": "pending"}
|
||||
]
|
||||
```
|
||||
|
||||
**TodoWrite Update (tasks collapsed)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Create Test Session", "status": "completed"},
|
||||
{"content": "Phase 2: Gather Test Context", "status": "completed"},
|
||||
{"content": "Phase 3: Test Generation Analysis", "status": "pending"},
|
||||
{"content": "Phase 4: Generate Test Tasks", "status": "pending"},
|
||||
{"content": "Phase 5: Return Summary", "status": "pending"}
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Test Generation Analysis
|
||||
|
||||
**Step 3.1: Execute** - Analyze test requirements with Gemini
|
||||
|
||||
```
|
||||
Skill(skill="workflow:tools:test-concept-enhanced", args="--session [testSessionId] --context [contextPath]")
|
||||
```
|
||||
|
||||
**Input**:
|
||||
- `testSessionId` from Phase 1
|
||||
- `contextPath` from Phase 2
|
||||
|
||||
**Expected Behavior**:
|
||||
- Use Gemini to analyze coverage gaps
|
||||
- Detect project type and apply appropriate test templates
|
||||
- Generate **multi-layered test requirements** (L0-L3)
|
||||
- Scan for AI code issues
|
||||
- Generate `TEST_ANALYSIS_RESULTS.md`
|
||||
|
||||
**Output**: `.workflow/[testSessionId]/.process/TEST_ANALYSIS_RESULTS.md`
|
||||
|
||||
**Validation** - TEST_ANALYSIS_RESULTS.md must include:
|
||||
- Project Type Detection (with confidence)
|
||||
- Coverage Assessment (current vs target)
|
||||
- Test Framework & Conventions
|
||||
- Multi-Layered Test Plan (L0-L3)
|
||||
- AI Issue Scan Results
|
||||
- Test Requirements by File (with layer annotations)
|
||||
- Quality Assurance Criteria
|
||||
- Success Criteria
|
||||
|
||||
**Note**: Detailed specifications for project types, L0-L3 layers, and AI issue detection are defined in `/workflow:tools:test-concept-enhanced`.
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Generate Test Tasks
|
||||
|
||||
**Step 4.1: Execute** - Generate test planning documents
|
||||
|
||||
```
|
||||
Skill(skill="workflow:tools:test-task-generate", args="--session [testSessionId]")
|
||||
```
|
||||
|
||||
**Input**: `testSessionId` from Phase 1
|
||||
|
||||
**Note**: test-task-generate invokes action-planning-agent to generate test-specific IMPL_PLAN.md and task JSONs based on TEST_ANALYSIS_RESULTS.md.
|
||||
|
||||
**Expected Output** (minimum 4 tasks):
|
||||
|
||||
| Task | Type | Agent | Purpose |
|
||||
|------|------|-------|---------|
|
||||
| IMPL-001 | test-gen | @code-developer | Test understanding & generation (L1-L3) |
|
||||
| IMPL-001.3 | code-validation | @test-fix-agent | Code validation gate (L0 + AI issues) |
|
||||
| IMPL-001.5 | test-quality-review | @test-fix-agent | Test quality gate |
|
||||
| IMPL-002 | test-fix | @test-fix-agent | Test execution & fix cycle |
|
||||
|
||||
**Validation**:
|
||||
- `.workflow/active/[testSessionId]/.task/IMPL-001.json` exists
|
||||
- `.workflow/active/[testSessionId]/.task/IMPL-001.3-validation.json` exists
|
||||
- `.workflow/active/[testSessionId]/.task/IMPL-001.5-review.json` exists
|
||||
- `.workflow/active/[testSessionId]/.task/IMPL-002.json` exists
|
||||
- `.workflow/active/[testSessionId]/IMPL_PLAN.md` exists
|
||||
- `.workflow/active/[testSessionId]/TODO_LIST.md` exists
|
||||
|
||||
**TodoWrite Update (agent task attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Create Test Session", "status": "completed"},
|
||||
{"content": "Phase 2: Gather Test Context", "status": "completed"},
|
||||
{"content": "Phase 3: Test Generation Analysis", "status": "completed"},
|
||||
{"content": "Phase 4: Generate Test Tasks", "status": "in_progress"},
|
||||
{"content": "Phase 5: Return Summary", "status": "pending"}
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Return Summary
|
||||
|
||||
**Return to User**:
|
||||
```
|
||||
Test-fix workflow created successfully!
|
||||
|
||||
Input: [original input]
|
||||
Mode: [Session|Prompt]
|
||||
Test Session: [testSessionId]
|
||||
|
||||
Tasks Created:
|
||||
- IMPL-001: Test Understanding & Generation (@code-developer)
|
||||
- IMPL-001.3: Code Validation Gate - AI Error Detection (@test-fix-agent)
|
||||
- IMPL-001.5: Test Quality Gate - Static Analysis & Coverage (@test-fix-agent)
|
||||
- IMPL-002: Test Execution & Fix Cycle (@test-fix-agent)
|
||||
|
||||
Quality Thresholds:
|
||||
- Code Validation: Zero CRITICAL issues, zero compilation errors
|
||||
- Minimum Coverage: 80% line, 70% branch
|
||||
- Static Analysis: Zero critical anti-patterns
|
||||
- Max Fix Iterations: 5
|
||||
|
||||
Review artifacts:
|
||||
- Test plan: .workflow/[testSessionId]/IMPL_PLAN.md
|
||||
- Task list: .workflow/[testSessionId]/TODO_LIST.md
|
||||
- Analysis: .workflow/[testSessionId]/.process/TEST_ANALYSIS_RESULTS.md
|
||||
|
||||
CRITICAL - Next Step:
|
||||
/workflow:test-cycle-execute --session [testSessionId]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Data Flow
|
||||
|
||||
```
|
||||
User Input (session ID | description | file path)
|
||||
↓
|
||||
[Detect Mode: session | prompt]
|
||||
↓
|
||||
Phase 1: session:start --type test --new "description"
|
||||
↓ Output: testSessionId
|
||||
↓
|
||||
Phase 2: test-context-gather | context-gather
|
||||
↓ Input: testSessionId
|
||||
↓ Output: contextPath (context-package.json)
|
||||
↓
|
||||
Phase 3: test-concept-enhanced
|
||||
↓ Input: testSessionId + contextPath
|
||||
↓ Output: TEST_ANALYSIS_RESULTS.md (L0-L3 requirements + AI issues)
|
||||
↓
|
||||
Phase 4: test-task-generate
|
||||
↓ Input: testSessionId + TEST_ANALYSIS_RESULTS.md
|
||||
↓ Output: IMPL_PLAN.md, IMPL-*.json (4+), TODO_LIST.md
|
||||
↓
|
||||
Phase 5: Return summary to user
|
||||
↓
|
||||
Next: /workflow:test-cycle-execute
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Execution Flow Diagram
|
||||
|
||||
```
|
||||
User triggers: /workflow:test-fix-gen "Test user authentication"
|
||||
↓
|
||||
[Input Detection] → MODE: prompt
|
||||
↓
|
||||
[TodoWrite Init] 5 orchestrator-level tasks
|
||||
↓
|
||||
Phase 1: Create Test Session
|
||||
→ /workflow:session:start --type test
|
||||
→ testSessionId extracted (WFS-test-user-auth)
|
||||
↓
|
||||
Phase 2: Gather Test Context (Skill executed)
|
||||
→ ATTACH 3 sub-tasks: ← ATTACHED
|
||||
- → Load codebase context
|
||||
- → Analyze test coverage
|
||||
- → Generate context package
|
||||
→ Execute sub-tasks sequentially
|
||||
→ COLLAPSE tasks ← COLLAPSED
|
||||
→ contextPath extracted
|
||||
↓
|
||||
Phase 3: Test Generation Analysis (Skill executed)
|
||||
→ ATTACH 3 sub-tasks: ← ATTACHED
|
||||
- → Analyze coverage gaps with Gemini
|
||||
- → Detect AI code issues (L0.5)
|
||||
- → Generate L0-L3 test requirements
|
||||
→ Execute sub-tasks sequentially
|
||||
→ COLLAPSE tasks ← COLLAPSED
|
||||
→ TEST_ANALYSIS_RESULTS.md created
|
||||
↓
|
||||
Phase 4: Generate Test Tasks (Skill executed)
|
||||
→ Single agent task (test-task-generate → action-planning-agent)
|
||||
→ Agent autonomously generates:
|
||||
- IMPL-001.json (test generation)
|
||||
- IMPL-001.3-validation.json (code validation)
|
||||
- IMPL-001.5-review.json (test quality)
|
||||
- IMPL-002.json (test execution)
|
||||
- IMPL_PLAN.md
|
||||
- TODO_LIST.md
|
||||
↓
|
||||
Phase 5: Return Summary
|
||||
→ Display summary with next steps
|
||||
→ Command ends
|
||||
|
||||
Task Pipeline (for execution):
|
||||
┌──────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
|
||||
│ IMPL-001 │───→│ IMPL-001.3 │───→│ IMPL-001.5 │───→│ IMPL-002 │
|
||||
│ Test Gen │ │ Code Validate │ │ Quality Gate │ │ Test & Fix │
|
||||
│ L1-L3 │ │ L0 + AI Issues │ │ Coverage 80%+ │ │ Max 5 iter │
|
||||
│@code-developer│ │ @test-fix-agent │ │ @test-fix-agent │ │@test-fix-agent│
|
||||
└──────────────┘ └─────────────────┘ └─────────────────┘ └──────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
### Directory Structure
|
||||
|
||||
```
|
||||
.workflow/active/WFS-test-[session]/
|
||||
├── workflow-session.json # Session metadata
|
||||
├── IMPL_PLAN.md # Test generation and execution strategy
|
||||
├── TODO_LIST.md # Task checklist
|
||||
├── .task/
|
||||
│ ├── IMPL-001.json # Test understanding & generation
|
||||
│ ├── IMPL-001.3-validation.json # Code validation gate
|
||||
│ ├── IMPL-001.5-review.json # Test quality gate
|
||||
│ ├── IMPL-002.json # Test execution & fix cycle
|
||||
│ └── IMPL-*.json # Additional tasks (if applicable)
|
||||
└── .process/
|
||||
├── [test-]context-package.json # Context and coverage analysis
|
||||
└── TEST_ANALYSIS_RESULTS.md # Test requirements and strategy (L0-L3)
|
||||
```
|
||||
|
||||
### Session Metadata
|
||||
|
||||
**File**: `workflow-session.json`
|
||||
|
||||
| Mode | Fields |
|
||||
|------|--------|
|
||||
| **Session** | `type: "test"`, `source_session_id: "[sourceId]"` |
|
||||
| **Prompt** | `type: "test"` (no source_session_id) |
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Phase | Error Condition | Action |
|
||||
|-------|----------------|--------|
|
||||
| 1 | Source session not found (session mode) | Return error with session ID |
|
||||
| 1 | No completed IMPL tasks (session mode) | Return error, source incomplete |
|
||||
| 2 | Context gathering failed | Return error, check source artifacts |
|
||||
| 3 | Gemini analysis failed | Return error, check context package |
|
||||
| 4 | Task generation failed | Retry once, then return error |
|
||||
|
||||
---
|
||||
|
||||
## Coordinator Checklist
|
||||
|
||||
- Detect input type (session ID / description / file path)
|
||||
- Initialize TodoWrite before any command
|
||||
- Execute Phase 1 immediately with structured description
|
||||
- Parse test session ID from Phase 1 output, store in memory
|
||||
- Execute Phase 2 with appropriate context-gather command based on mode
|
||||
- Parse context path from Phase 2 output, store in memory
|
||||
- Execute Phase 3 test-concept-enhanced with session and context
|
||||
- Verify TEST_ANALYSIS_RESULTS.md created with L0-L3 requirements
|
||||
- Execute Phase 4 test-task-generate with session ID
|
||||
- Verify all Phase 4 outputs (4 task JSONs, IMPL_PLAN.md, TODO_LIST.md)
|
||||
- Return summary with next step: `/workflow:test-cycle-execute`
|
||||
- Update TodoWrite after each phase
|
||||
|
||||
---
|
||||
|
||||
## Usage Examples
|
||||
|
||||
```bash
|
||||
# Session Mode - test validation for completed implementation
|
||||
/workflow:test-fix-gen WFS-user-auth-v2
|
||||
|
||||
# Prompt Mode - text description
|
||||
/workflow:test-fix-gen "Test the user authentication API endpoints in src/auth/api.ts"
|
||||
|
||||
# Prompt Mode - file reference
|
||||
/workflow:test-fix-gen ./docs/api-requirements.md
|
||||
|
||||
# With CLI tool preference (semantic detection)
|
||||
/workflow:test-fix-gen "Test user registration, use Codex for automated fixes"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Related Commands
|
||||
|
||||
**Prerequisite Commands**:
|
||||
- `/workflow:plan` or `/workflow:execute` - Complete implementation (Session Mode)
|
||||
- None for Prompt Mode
|
||||
|
||||
**Called by This Command** (5 phases):
|
||||
- `/workflow:session:start` - Phase 1: Create test workflow session
|
||||
- `/workflow:tools:test-context-gather` - Phase 2 (Session Mode): Analyze test coverage
|
||||
- `/workflow:tools:context-gather` - Phase 2 (Prompt Mode): Analyze codebase
|
||||
- `/workflow:tools:test-concept-enhanced` - Phase 3: Generate test requirements with Gemini
|
||||
- `/workflow:tools:test-task-generate` - Phase 4: Generate test task JSONs via action-planning-agent
|
||||
|
||||
**Follow-up Commands**:
|
||||
- `/workflow:status` - Review generated tasks
|
||||
- `/workflow:test-cycle-execute` - Execute test workflow (REQUIRED next step)
|
||||
- `/workflow:execute` - Alternative: Standard task execution
|
||||
459
.claude/skills/workflow-tdd/SKILL.md
Normal file
459
.claude/skills/workflow-tdd/SKILL.md
Normal file
@@ -0,0 +1,459 @@
|
||||
---
|
||||
name: workflow-tdd
|
||||
description: Unified TDD workflow skill combining 6-phase TDD planning with Red-Green-Refactor task chain generation, and 4-phase TDD verification with compliance reporting. Triggers on "workflow:tdd-plan", "workflow:tdd-verify".
|
||||
allowed-tools: Skill, Task, AskUserQuestion, TaskCreate, TaskUpdate, TaskList, Read, Write, Edit, Bash, Glob, Grep
|
||||
---
|
||||
|
||||
# Workflow TDD
|
||||
|
||||
Unified TDD workflow skill combining TDD planning (Red-Green-Refactor task chain generation with test-first development structure) and TDD verification (compliance validation with quality gate reporting). Produces IMPL_PLAN.md, task JSONs with internal TDD cycles, and TDD_COMPLIANCE_REPORT.md.
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────────────┐
|
||||
│ Workflow TDD Orchestrator (SKILL.md) │
|
||||
│ → Route by mode: plan | verify │
|
||||
│ → Pure coordinator: Execute phases, parse outputs, pass context │
|
||||
└──────────────────────────────┬───────────────────────────────────┘
|
||||
│
|
||||
┌───────────────────────┴───────────────────────┐
|
||||
↓ ↓
|
||||
┌─────────────┐ ┌───────────┐
|
||||
│ Plan Mode │ │ Verify │
|
||||
│ (default) │ │ Mode │
|
||||
│ Phase 1-6 │ │ Phase 7 │
|
||||
└──────┬──────┘ └───────────┘
|
||||
│
|
||||
┌─────┼─────┬─────┬─────┬─────┐
|
||||
↓ ↓ ↓ ↓ ↓ ↓
|
||||
┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐
|
||||
│ 1 │ │ 2 │ │ 3 │ │ 4 │ │ 5 │ │ 6 │
|
||||
│Ses│ │Ctx│ │Tst│ │Con│ │Gen│ │Val│
|
||||
└───┘ └───┘ └───┘ └───┘ └─┬─┘ └───┘
|
||||
↓
|
||||
┌───────────┐
|
||||
│ Confirm │─── Verify ──→ Phase 7
|
||||
│ (choice) │─── Execute ─→ Skill("workflow-execute")
|
||||
└───────────┘─── Review ──→ /workflow:status
|
||||
```
|
||||
|
||||
## Key Design Principles
|
||||
|
||||
1. **Pure Orchestrator**: SKILL.md routes and coordinates only; execution detail lives in phase files
|
||||
2. **Progressive Phase Loading**: Read phase docs ONLY when that phase is about to execute
|
||||
3. **Multi-Mode Routing**: Single skill handles plan/verify via mode detection
|
||||
4. **Task Attachment Model**: Sub-command tasks are ATTACHED, executed sequentially, then COLLAPSED
|
||||
5. **Auto-Continue**: After each phase completes, automatically execute next pending phase
|
||||
6. **TDD Iron Law**: NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST - enforced in task structure
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-continue all phases (skip confirmations), use recommended conflict resolutions, auto-select "Verify Plan Quality" after plan completion.
|
||||
|
||||
## Mode Detection
|
||||
|
||||
```javascript
|
||||
const args = $ARGUMENTS
|
||||
const mode = detectMode(args)
|
||||
|
||||
function detectMode(args) {
|
||||
// Skill trigger determines mode
|
||||
if (skillName === 'workflow:tdd-verify') return 'verify'
|
||||
return 'plan' // default: workflow:tdd-plan
|
||||
}
|
||||
```
|
||||
|
||||
## Execution Flow
|
||||
|
||||
### Plan Mode (default)
|
||||
|
||||
```
|
||||
Input Parsing:
|
||||
└─ Convert user input to TDD structured format (GOAL/SCOPE/CONTEXT/TEST_FOCUS)
|
||||
|
||||
Phase 1: Session Discovery
|
||||
└─ Ref: phases/01-session-discovery.md
|
||||
└─ Output: sessionId (WFS-xxx)
|
||||
|
||||
Phase 2: Context Gathering
|
||||
└─ Ref: phases/02-context-gathering.md
|
||||
├─ Tasks attached: Analyze structure → Identify integration → Generate package
|
||||
└─ Output: contextPath + conflictRisk
|
||||
|
||||
Phase 3: Test Coverage Analysis
|
||||
└─ Ref: phases/03-test-coverage-analysis.md
|
||||
├─ Tasks attached: Detect framework → Analyze coverage → Identify gaps
|
||||
└─ Output: testContextPath
|
||||
|
||||
Phase 4: Conflict Resolution (conditional: conflictRisk ≥ medium)
|
||||
└─ Decision (conflictRisk check):
|
||||
├─ conflictRisk ≥ medium → Ref: phases/04-conflict-resolution.md
|
||||
│ ├─ Tasks attached: Detect conflicts → Log analysis → Apply strategies
|
||||
│ └─ Output: conflict-resolution.json
|
||||
└─ conflictRisk < medium → Skip to Phase 5
|
||||
|
||||
Phase 5: TDD Task Generation
|
||||
└─ Ref: phases/05-tdd-task-generation.md
|
||||
├─ Tasks attached: Discovery → Planning → Output
|
||||
└─ Output: IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
|
||||
|
||||
Phase 6: TDD Structure Validation
|
||||
└─ Ref: phases/06-tdd-structure-validation.md
|
||||
└─ Output: Validation report + Plan Confirmation Gate
|
||||
|
||||
Plan Confirmation (User Decision Gate):
|
||||
└─ Decision (user choice):
|
||||
├─ "Verify TDD Compliance" (Recommended) → Route to Phase 7 (tdd-verify)
|
||||
├─ "Start Execution" → Skill(skill="workflow-execute")
|
||||
└─ "Review Status Only" → Route to /workflow:status
|
||||
```
|
||||
|
||||
### Verify Mode
|
||||
|
||||
```
|
||||
Phase 7: TDD Verification
|
||||
└─ Ref: phases/07-tdd-verify.md
|
||||
└─ Output: TDD_COMPLIANCE_REPORT.md with quality gate recommendation
|
||||
```
|
||||
|
||||
**Phase Reference Documents** (read on-demand when phase executes):
|
||||
|
||||
| Phase | Document | Purpose | Mode |
|
||||
|-------|----------|---------|------|
|
||||
| 1 | [phases/01-session-discovery.md](phases/01-session-discovery.md) | Create or discover TDD workflow session | plan |
|
||||
| 2 | [phases/02-context-gathering.md](phases/02-context-gathering.md) | Gather project context and analyze codebase | plan |
|
||||
| 3 | [phases/03-test-coverage-analysis.md](phases/03-test-coverage-analysis.md) | Analyze test coverage and framework detection | plan |
|
||||
| 4 | [phases/04-conflict-resolution.md](phases/04-conflict-resolution.md) | Detect and resolve conflicts (conditional) | plan |
|
||||
| 5 | [phases/05-tdd-task-generation.md](phases/05-tdd-task-generation.md) | Generate TDD tasks with Red-Green-Refactor cycles | plan |
|
||||
| 6 | [phases/06-tdd-structure-validation.md](phases/06-tdd-structure-validation.md) | Validate TDD structure and present confirmation gate | plan |
|
||||
| 7 | [phases/07-tdd-verify.md](phases/07-tdd-verify.md) | Full TDD compliance verification with quality gate | verify |
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Start Immediately**: First action is mode detection + TaskCreate initialization, second action is phase execution
|
||||
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 phase output for next phase
|
||||
4. **Auto-Continue via TaskList**: Check TaskList status to execute next pending phase automatically
|
||||
5. **Track Progress**: Update TaskCreate/TaskUpdate dynamically with task attachment/collapse pattern
|
||||
6. **Task Attachment Model**: Skill execute **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
|
||||
7. **Progressive Phase Loading**: Read phase docs ONLY when that phase is about to execute
|
||||
8. **DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
|
||||
9. **TDD Context**: All descriptions include "TDD:" prefix
|
||||
|
||||
## TDD Compliance Requirements
|
||||
|
||||
### The Iron Law
|
||||
|
||||
```
|
||||
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
|
||||
```
|
||||
|
||||
**Enforcement Method**:
|
||||
- Phase 5: `implementation` includes test-first steps (Red → Green → Refactor)
|
||||
- Green phase: Includes test-fix-cycle configuration (max 3 iterations)
|
||||
- Auto-revert: Triggered when max iterations reached without passing tests
|
||||
|
||||
**Verification**: Phase 6 validates Red-Green-Refactor structure in all generated tasks
|
||||
|
||||
### TDD Compliance Checkpoint
|
||||
|
||||
| Checkpoint | Validation Phase | Evidence Required |
|
||||
|------------|------------------|-------------------|
|
||||
| Test-first structure | Phase 5 | `implementation` has 3 steps |
|
||||
| Red phase exists | Phase 6 | Step 1: `tdd_phase: "red"` |
|
||||
| Green phase with test-fix | Phase 6 | Step 2: `tdd_phase: "green"` + test-fix-cycle |
|
||||
| Refactor phase exists | Phase 6 | Step 3: `tdd_phase: "refactor"` |
|
||||
|
||||
### Core TDD Principles
|
||||
|
||||
**Red Flags - STOP and Reassess**:
|
||||
- Code written before test
|
||||
- Test passes immediately (no Red phase witnessed)
|
||||
- Cannot explain why test should fail
|
||||
- "Just this once" rationalization
|
||||
- "Tests after achieve same goals" thinking
|
||||
|
||||
**Why Order Matters**:
|
||||
- Tests written after code pass immediately → proves nothing
|
||||
- Test-first forces edge case discovery before implementation
|
||||
- Tests-after verify what was built, not what's required
|
||||
|
||||
## Input Processing
|
||||
|
||||
**Convert User Input to TDD Structured Format**:
|
||||
|
||||
1. **Simple text** → Add TDD context:
|
||||
```
|
||||
User: "Build authentication system"
|
||||
|
||||
Structured:
|
||||
TDD: Authentication System
|
||||
GOAL: Build authentication system
|
||||
SCOPE: Core authentication features
|
||||
CONTEXT: New implementation
|
||||
TEST_FOCUS: Authentication scenarios
|
||||
```
|
||||
|
||||
2. **Detailed text** → Extract components with TEST_FOCUS:
|
||||
```
|
||||
User: "Add JWT authentication with email/password login and token refresh"
|
||||
|
||||
Structured:
|
||||
TDD: JWT Authentication
|
||||
GOAL: Implement JWT-based authentication
|
||||
SCOPE: Email/password login, token generation, token refresh endpoints
|
||||
CONTEXT: JWT token-based security, refresh token rotation
|
||||
TEST_FOCUS: Login flow, token validation, refresh rotation, error cases
|
||||
```
|
||||
|
||||
3. **File/Issue** → Read and structure with TDD
|
||||
|
||||
## Data Flow
|
||||
|
||||
### Plan Mode
|
||||
|
||||
```
|
||||
User Input (task description)
|
||||
↓
|
||||
[Convert to TDD Structured Format]
|
||||
↓ Structured Description:
|
||||
↓ TDD: [Feature Name]
|
||||
↓ GOAL: [objective]
|
||||
↓ SCOPE: [boundaries]
|
||||
↓ CONTEXT: [background]
|
||||
↓ TEST_FOCUS: [test scenarios]
|
||||
↓
|
||||
Phase 1: session:start --auto "TDD: structured-description"
|
||||
↓ Output: sessionId
|
||||
↓
|
||||
Phase 2: context-gather --session sessionId "structured-description"
|
||||
↓ Input: sessionId + structured description
|
||||
↓ Output: contextPath (context-package.json) + conflictRisk
|
||||
↓
|
||||
Phase 3: test-context-gather --session sessionId
|
||||
↓ Input: sessionId
|
||||
↓ Output: testContextPath (test-context-package.json)
|
||||
↓
|
||||
Phase 4: conflict-resolution [conditional: conflictRisk ≥ medium]
|
||||
↓ Input: sessionId + contextPath + conflictRisk
|
||||
↓ Output: conflict-resolution.json
|
||||
↓ Skip if conflictRisk is none/low → proceed directly to Phase 5
|
||||
↓
|
||||
Phase 5: task-generate-tdd --session sessionId
|
||||
↓ Input: sessionId + all accumulated context
|
||||
↓ Output: IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
|
||||
↓
|
||||
Phase 6: TDD Structure Validation (internal)
|
||||
↓ Validate Red-Green-Refactor structure
|
||||
↓ Present Plan Confirmation Gate
|
||||
↓
|
||||
Plan Confirmation (User Decision Gate):
|
||||
├─ "Verify TDD Compliance" (Recommended) → Route to Phase 7
|
||||
├─ "Start Execution" → Skill(skill="workflow-execute")
|
||||
└─ "Review Status Only" → Route to /workflow:status
|
||||
```
|
||||
|
||||
### Verify Mode
|
||||
|
||||
```
|
||||
Input: --session sessionId (or auto-detect)
|
||||
↓
|
||||
Phase 7: Session discovery → Chain validation → Coverage analysis → Report
|
||||
↓ Output: TDD_COMPLIANCE_REPORT.md with quality gate
|
||||
```
|
||||
|
||||
**Session Memory Flow**: Each phase receives session ID, which provides access to:
|
||||
- Previous task summaries
|
||||
- Existing context and analysis
|
||||
- Session-specific configuration
|
||||
|
||||
## TodoWrite Pattern
|
||||
|
||||
**Core Concept**: Dynamic task attachment and collapse for real-time visibility into TDD workflow execution.
|
||||
|
||||
> **Implementation Note**: Phase files use `TodoWrite` syntax to describe the conceptual tracking pattern. At runtime, these are implemented via `TaskCreate/TaskUpdate/TaskList` tools. Map as follows:
|
||||
> - Initial list creation → `TaskCreate` for each item
|
||||
> - Status changes → `TaskUpdate({ taskId, status })`
|
||||
> - Sub-task attachment → `TaskCreate` + `TaskUpdate({ addBlockedBy })`
|
||||
> - Sub-task collapse → `TaskUpdate({ status: "completed" })` + `TaskUpdate({ status: "deleted" })` for collapsed sub-items
|
||||
|
||||
### Key Principles
|
||||
|
||||
1. **Task Attachment** (when phase executed):
|
||||
- Sub-tasks are **attached** to orchestrator's TodoWrite
|
||||
- **Phase 3, 4, 5**: Multiple sub-tasks attached
|
||||
- **Phase 1, 2, 6**: Single task (atomic)
|
||||
- First attached task marked as `in_progress`, others as `pending`
|
||||
- Orchestrator **executes** these attached tasks sequentially
|
||||
|
||||
2. **Task Collapse** (after sub-tasks complete):
|
||||
- **Applies to Phase 3, 4, 5**: Remove detailed sub-tasks from TodoWrite
|
||||
- **Collapse** to high-level phase summary
|
||||
- **Phase 1, 2, 6**: No collapse needed (single task, just mark completed)
|
||||
- Maintains clean orchestrator-level view
|
||||
|
||||
3. **Continuous Execution**: After completion, automatically proceed to next pending phase
|
||||
|
||||
**Lifecycle**: Initial pending → Phase executed (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED for 3/4/5, marked completed for 1/2/6) → Next phase → Repeat
|
||||
|
||||
### Initial State (Plan Mode):
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "in_progress", "activeForm": "Executing session discovery"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "pending", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "pending", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: Phase 4 (Conflict Resolution) is added dynamically after Phase 2 if conflictRisk ≥ medium.
|
||||
|
||||
### Phase 3 (Tasks Attached):
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "in_progress"},
|
||||
{"content": " → Detect test framework and conventions", "status": "in_progress"},
|
||||
{"content": " → Analyze existing test coverage", "status": "pending"},
|
||||
{"content": " → Identify coverage gaps", "status": "pending"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "pending"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "status": "pending"}
|
||||
]
|
||||
```
|
||||
|
||||
### Phase 3 (Collapsed):
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "completed"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "pending"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "status": "pending"}
|
||||
]
|
||||
```
|
||||
|
||||
### Phase 5 (Tasks Attached):
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "completed"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "in_progress"},
|
||||
{"content": " → Discovery - analyze TDD requirements", "status": "in_progress"},
|
||||
{"content": " → Planning - design Red-Green-Refactor cycles", "status": "pending"},
|
||||
{"content": " → Output - generate IMPL tasks with internal TDD phases", "status": "pending"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "status": "pending"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: See individual Phase descriptions for detailed TodoWrite Update examples.
|
||||
|
||||
## Post-Phase Updates
|
||||
|
||||
### Memory State Check
|
||||
|
||||
After heavy phases (Phase 2-3), evaluate context window usage:
|
||||
- If memory usage is high (>110K tokens or approaching context limits):
|
||||
```javascript
|
||||
Skill(skill="compact")
|
||||
```
|
||||
- Memory compaction is particularly important after analysis phases
|
||||
|
||||
### Planning Notes (Optional)
|
||||
|
||||
Similar to workflow-plan, a `planning-notes.md` can accumulate context across phases if needed. See Phase 1 for initialization.
|
||||
|
||||
## Error Handling
|
||||
|
||||
- **Parsing Failure**: If output parsing fails, retry command once, then report error
|
||||
- **Validation Failure**: Report which file/data is missing or invalid
|
||||
- **Command Failure**: Keep phase `in_progress`, report error to user, do not proceed
|
||||
- **TDD Validation Failure**: Report incomplete chains or wrong dependencies
|
||||
- **Session Not Found** (verify mode): Report error with available sessions list
|
||||
|
||||
### Error Handling Quick Reference
|
||||
|
||||
| Error Type | Detection | Recovery Action |
|
||||
|------------|-----------|-----------------|
|
||||
| Parsing failure | Empty/malformed output | Retry once, then report |
|
||||
| Missing context-package | File read error | Re-run `/workflow:tools:context-gather` |
|
||||
| Invalid task JSON | jq parse error | Report malformed file path |
|
||||
| Task count exceeds 18 | Count validation ≥19 | Request re-scope, split into multiple sessions |
|
||||
| Missing cli_execution.id | All tasks lack ID | Regenerate tasks with phase 0 user config |
|
||||
| Test-context missing | File not found | Re-run `/workflow:tools:test-context-gather` |
|
||||
| Phase timeout | No response | Retry phase, check CLI connectivity |
|
||||
| CLI tool not available | Tool not in cli-tools.json | Fall back to alternative preferred tool |
|
||||
|
||||
### TDD Warning Patterns
|
||||
|
||||
| Pattern | Warning Message | Recommended Action |
|
||||
|---------|----------------|-------------------|
|
||||
| Task count >10 | High task count detected | Consider splitting into multiple sessions |
|
||||
| Missing test-fix-cycle | Green phase lacks auto-revert | Add `max_iterations: 3` to task config |
|
||||
| Red phase missing test path | Test file path not specified | Add explicit test file paths |
|
||||
| Generic task names | Vague names like "Add feature" | Use specific behavior descriptions |
|
||||
| No refactor criteria | Refactor phase lacks completion criteria | Define clear refactor scope |
|
||||
|
||||
### Non-Blocking Warning Policy
|
||||
|
||||
**All warnings are advisory** - they do not halt execution:
|
||||
1. Warnings logged to `.process/tdd-warnings.log`
|
||||
2. Summary displayed in Phase 6 output
|
||||
3. User decides whether to address before `/workflow:execute`
|
||||
|
||||
## Coordinator Checklist
|
||||
|
||||
### Plan Mode
|
||||
- **Pre-Phase**: Convert user input to TDD structured format (TDD/GOAL/SCOPE/CONTEXT/TEST_FOCUS)
|
||||
- Initialize TaskCreate before any command (Phase 4 added dynamically after Phase 2)
|
||||
- Execute Phase 1 immediately with structured description
|
||||
- Parse session ID from Phase 1 output, store in memory
|
||||
- Pass session ID and structured description to Phase 2 command
|
||||
- Parse context path from Phase 2 output, store in memory
|
||||
- **Extract conflictRisk from context-package.json**: Determine Phase 4 execution
|
||||
- Execute Phase 3 (test coverage analysis) with sessionId
|
||||
- Parse testContextPath from Phase 3 output, store in memory
|
||||
- **If conflictRisk ≥ medium**: Launch Phase 4 conflict-resolution with sessionId and contextPath
|
||||
- Wait for Phase 4 to finish executing (if executed), verify conflict-resolution.json created
|
||||
- **If conflictRisk is none/low**: Skip Phase 4, proceed directly to Phase 5
|
||||
- Pass session ID to Phase 5 command (TDD task generation)
|
||||
- Verify all Phase 5 outputs (IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md)
|
||||
- Execute Phase 6 (internal TDD structure validation)
|
||||
- **Plan Confirmation Gate**: Present user with choice (Verify → Phase 7 / Execute / Review Status)
|
||||
- **If user selects Verify**: Read phases/07-tdd-verify.md, execute Phase 7 in-process
|
||||
- **If user selects Execute**: Skill(skill="workflow-execute")
|
||||
- **If user selects Review**: Route to /workflow:status
|
||||
- **Auto mode (--yes)**: Auto-select "Verify TDD Compliance", then auto-continue to execute if APPROVED
|
||||
- Update TaskCreate/TaskUpdate after each phase
|
||||
- After each phase, automatically continue to next phase based on TaskList status
|
||||
|
||||
### Verify Mode
|
||||
- Detect/validate session (from --session flag or auto-detect)
|
||||
- Initialize TaskCreate with verification tasks
|
||||
- Execute Phase 7 through all sub-phases (session validation → chain validation → coverage analysis → report generation)
|
||||
- Present quality gate result and next step options
|
||||
|
||||
## Related Skills
|
||||
|
||||
**Prerequisite Skills**:
|
||||
- None - TDD planning is self-contained (can optionally run brainstorm commands before)
|
||||
|
||||
**Called by Plan Mode** (6 phases):
|
||||
- `/workflow:session:start` - Phase 1: Create or discover TDD workflow session
|
||||
- `/workflow:tools:context-gather` - Phase 2: Gather project context and analyze codebase
|
||||
- `/workflow:tools:test-context-gather` - Phase 3: Analyze existing test patterns and coverage
|
||||
- `/workflow:tools:conflict-resolution` - Phase 4: Detect and resolve conflicts (conditional)
|
||||
- `/compact` - Phase 4: Memory optimization (if context approaching limits)
|
||||
- `/workflow:tools:task-generate-tdd` - Phase 5: Generate TDD tasks with Red-Green-Refactor cycles
|
||||
|
||||
**Called by Verify Mode**:
|
||||
- `/workflow:tools:tdd-coverage-analysis` - Phase 7: Test coverage and cycle analysis
|
||||
|
||||
**Follow-up Skills**:
|
||||
- `/workflow:tdd-verify` - Verify TDD compliance (can also invoke via verify mode)
|
||||
- `/workflow:plan-verify` - Verify plan quality and dependencies
|
||||
- `/workflow:status` - Review TDD task breakdown
|
||||
- `Skill(skill="workflow-execute")` - Begin TDD implementation
|
||||
57
.claude/skills/workflow-tdd/phases/01-session-discovery.md
Normal file
57
.claude/skills/workflow-tdd/phases/01-session-discovery.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# Phase 1: Session Discovery
|
||||
|
||||
Create or discover TDD workflow session and extract session ID.
|
||||
|
||||
## Objective
|
||||
|
||||
- Create a new TDD workflow session via `/workflow:session:start`
|
||||
- Extract session ID for subsequent phases
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 1.1: Execute Session Start
|
||||
|
||||
```javascript
|
||||
Skill(skill="workflow:session:start", args="--type tdd --auto \"TDD: [structured-description]\"")
|
||||
```
|
||||
|
||||
**TDD Structured Format**:
|
||||
```
|
||||
TDD: [Feature Name]
|
||||
GOAL: [Objective]
|
||||
SCOPE: [Included/excluded]
|
||||
CONTEXT: [Background]
|
||||
TEST_FOCUS: [Test scenarios]
|
||||
```
|
||||
|
||||
**Example**:
|
||||
```
|
||||
TDD: JWT Authentication
|
||||
GOAL: Implement JWT-based authentication
|
||||
SCOPE: Email/password login, token generation, token refresh endpoints
|
||||
CONTEXT: Existing user database schema, REST API
|
||||
TEST_FOCUS: Login flow, token validation, refresh rotation, error cases
|
||||
```
|
||||
|
||||
### Step 1.2: Parse Output
|
||||
|
||||
- Extract: `SESSION_ID: WFS-[id]` (store as `sessionId`)
|
||||
|
||||
**Validation**:
|
||||
- Session ID successfully extracted
|
||||
- Session directory `.workflow/active/[sessionId]/` exists
|
||||
|
||||
**Note**: Session directory contains `workflow-session.json` (metadata). Do NOT look for `manifest.json` here - it only exists in `.workflow/archives/` for archived sessions.
|
||||
|
||||
**TodoWrite**: Mark phase 1 completed, phase 2 in_progress
|
||||
|
||||
**After Phase 1**: Return to user showing Phase 1 results, then auto-continue to Phase 2
|
||||
|
||||
## Output
|
||||
|
||||
- **Variable**: `sessionId` (WFS-xxx)
|
||||
- **TodoWrite**: Mark Phase 1 completed, Phase 2 in_progress
|
||||
|
||||
## Next Phase
|
||||
|
||||
Return to orchestrator, then auto-continue to [Phase 2: Context Gathering](02-context-gathering.md).
|
||||
53
.claude/skills/workflow-tdd/phases/02-context-gathering.md
Normal file
53
.claude/skills/workflow-tdd/phases/02-context-gathering.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Phase 2: Context Gathering
|
||||
|
||||
Gather project context and analyze codebase for TDD planning.
|
||||
|
||||
## Objective
|
||||
|
||||
- Gather project context via context-search agents
|
||||
- Generate context-package.json with codebase analysis
|
||||
- Extract conflictRisk to determine Phase 4 execution
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 2.1: Execute Context Gathering
|
||||
|
||||
```javascript
|
||||
Skill(skill="workflow:tools:context-gather", args="--session [sessionId] \"TDD: [structured-description]\"")
|
||||
```
|
||||
|
||||
**Use Same Structured Description**: Pass the same structured format from Phase 1.
|
||||
|
||||
**Input**: `sessionId` from Phase 1
|
||||
|
||||
### Step 2.2: Parse Output
|
||||
|
||||
- Extract: context-package.json path (store as `contextPath`)
|
||||
- Typical pattern: `.workflow/active/[sessionId]/.process/context-package.json`
|
||||
|
||||
**Validation**:
|
||||
- Context package path extracted
|
||||
- File exists and is valid JSON
|
||||
|
||||
### Step 2.3: Extract conflictRisk
|
||||
|
||||
```javascript
|
||||
const contextPackage = Read(contextPath)
|
||||
const conflictRisk = contextPackage.conflict_risk // "none" | "low" | "medium" | "high"
|
||||
```
|
||||
|
||||
**Note**: conflictRisk determines whether Phase 4 (Conflict Resolution) will execute.
|
||||
|
||||
**TodoWrite**: Mark phase 2 completed, phase 3 in_progress
|
||||
|
||||
**After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3
|
||||
|
||||
## Output
|
||||
|
||||
- **Variable**: `contextPath` (path to context-package.json)
|
||||
- **Variable**: `conflictRisk` ("none" | "low" | "medium" | "high")
|
||||
- **TodoWrite**: Mark Phase 2 completed, Phase 3 in_progress
|
||||
|
||||
## Next Phase
|
||||
|
||||
Return to orchestrator, then auto-continue to [Phase 3: Test Coverage Analysis](03-test-coverage-analysis.md).
|
||||
@@ -0,0 +1,78 @@
|
||||
# Phase 3: Test Coverage Analysis
|
||||
|
||||
Analyze existing test coverage, detect test framework, and identify coverage gaps.
|
||||
|
||||
## Objective
|
||||
|
||||
- Analyze existing codebase for test patterns and conventions
|
||||
- Detect current test coverage and framework
|
||||
- Identify related components and integration points
|
||||
- Generate test-context-package.json
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 3.1: Execute Test Context Gathering
|
||||
|
||||
```javascript
|
||||
Skill(skill="workflow:tools:test-context-gather", args="--session [sessionId]")
|
||||
```
|
||||
|
||||
**Purpose**: Analyze existing codebase for:
|
||||
- Existing test patterns and conventions
|
||||
- Current test coverage
|
||||
- Related components and integration points
|
||||
- Test framework detection
|
||||
|
||||
### Step 3.2: Parse Output
|
||||
|
||||
- Extract: testContextPath (`.workflow/active/[sessionId]/.process/test-context-package.json`)
|
||||
|
||||
**Validation**:
|
||||
- test-context-package.json exists and is valid JSON
|
||||
- Contains framework detection results
|
||||
|
||||
### TodoWrite Update (Phase 3 Skill executed - tasks attached)
|
||||
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "in_progress", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": " → Detect test framework and conventions", "status": "in_progress", "activeForm": "Detecting test framework"},
|
||||
{"content": " → Analyze existing test coverage", "status": "pending", "activeForm": "Analyzing test coverage"},
|
||||
{"content": " → Identify coverage gaps", "status": "pending", "activeForm": "Identifying coverage gaps"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: Skill execute **attaches** test-context-gather's 3 tasks. Orchestrator **executes** these tasks.
|
||||
|
||||
**Next Action**: Tasks attached → **Execute Phase 3.1-3.3** sequentially
|
||||
|
||||
### TodoWrite Update (Phase 3 completed - tasks collapsed)
|
||||
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "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)
|
||||
|
||||
## Output
|
||||
|
||||
- **Variable**: `testContextPath` (path to test-context-package.json)
|
||||
- **TodoWrite**: Mark Phase 3 completed
|
||||
|
||||
## Next Phase
|
||||
|
||||
Based on `conflictRisk` from Phase 2:
|
||||
- If conflictRisk ≥ medium → [Phase 4: Conflict Resolution](04-conflict-resolution.md)
|
||||
- If conflictRisk < medium → Skip to [Phase 5: TDD Task Generation](05-tdd-task-generation.md)
|
||||
95
.claude/skills/workflow-tdd/phases/04-conflict-resolution.md
Normal file
95
.claude/skills/workflow-tdd/phases/04-conflict-resolution.md
Normal file
@@ -0,0 +1,95 @@
|
||||
# Phase 4: Conflict Resolution (Conditional)
|
||||
|
||||
Detect and resolve conflicts when conflict risk is medium or high.
|
||||
|
||||
## Objective
|
||||
|
||||
- Execute conflict detection and resolution only when conflictRisk ≥ medium
|
||||
- Generate conflict-resolution.json with resolution strategies
|
||||
- Skip directly to Phase 5 if conflictRisk is none/low
|
||||
|
||||
## Trigger Condition
|
||||
|
||||
**Only execute when**: `context-package.json` indicates `conflict_risk` is "medium" or "high"
|
||||
|
||||
**Skip Behavior**: If conflict_risk is "none" or "low", skip directly to Phase 5. Display: "No significant conflicts detected, proceeding to TDD task generation"
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 4.1: Execute Conflict Resolution
|
||||
|
||||
```javascript
|
||||
Skill(skill="workflow:tools:conflict-resolution", args="--session [sessionId] --context [contextPath]")
|
||||
```
|
||||
|
||||
**Input**:
|
||||
- sessionId from Phase 1
|
||||
- contextPath from Phase 2
|
||||
- conflict_risk from context-package.json
|
||||
|
||||
### Step 4.2: Parse Output
|
||||
|
||||
- Extract: Execution status (success/skipped/failed)
|
||||
- Verify: conflict-resolution.json file path (if executed)
|
||||
|
||||
**Validation**:
|
||||
- File `.workflow/active/[sessionId]/.process/conflict-resolution.json` exists (if executed)
|
||||
|
||||
### TodoWrite Update (Phase 4 Skill executed - tasks attached, if conflict_risk ≥ medium)
|
||||
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": "Phase 4: Conflict Resolution", "status": "in_progress", "activeForm": "Executing conflict resolution"},
|
||||
{"content": " → Detect conflicts with CLI analysis", "status": "in_progress", "activeForm": "Detecting conflicts"},
|
||||
{"content": " → Log and analyze detected conflicts", "status": "pending", "activeForm": "Analyzing conflicts"},
|
||||
{"content": " → Apply resolution strategies", "status": "pending", "activeForm": "Applying resolution strategies"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: Skill execute **attaches** conflict-resolution's 3 tasks. Orchestrator **executes** these tasks.
|
||||
|
||||
**Next Action**: Tasks attached → **Execute Phase 4.1-4.3** sequentially
|
||||
|
||||
### TodoWrite Update (Phase 4 completed - tasks collapsed)
|
||||
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": "Phase 4: Conflict Resolution", "status": "completed", "activeForm": "Executing conflict resolution"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "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 and selected strategies, then auto-continue to Phase 5
|
||||
|
||||
### Memory State Check
|
||||
|
||||
After Phase 4, evaluate current context window usage and memory state:
|
||||
- If memory usage is high (>110K tokens or approaching context limits):
|
||||
|
||||
```javascript
|
||||
Skill(skill="compact")
|
||||
```
|
||||
|
||||
- This optimizes memory before proceeding to Phase 5
|
||||
- Memory compaction is particularly important after analysis phase which may generate extensive documentation
|
||||
- Ensures optimal performance and prevents context overflow
|
||||
|
||||
## Output
|
||||
|
||||
- **File**: `.workflow/active/[sessionId]/.process/conflict-resolution.json` (if executed)
|
||||
- **TodoWrite**: Mark Phase 4 completed, Phase 5 in_progress
|
||||
|
||||
## Next Phase
|
||||
|
||||
Return to orchestrator, then auto-continue to [Phase 5: TDD Task Generation](05-tdd-task-generation.md).
|
||||
105
.claude/skills/workflow-tdd/phases/05-tdd-task-generation.md
Normal file
105
.claude/skills/workflow-tdd/phases/05-tdd-task-generation.md
Normal file
@@ -0,0 +1,105 @@
|
||||
# Phase 5: TDD Task Generation
|
||||
|
||||
Generate TDD tasks with Red-Green-Refactor cycles via action-planning-agent.
|
||||
|
||||
## Objective
|
||||
|
||||
- Generate IMPL_PLAN.md, task JSONs, and TODO_LIST.md with TDD structure
|
||||
- Each task contains internal Red-Green-Refactor cycle
|
||||
- Include Phase 0 user configuration (execution method, CLI tool preference)
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 5.1: Execute TDD Task Generation
|
||||
|
||||
```javascript
|
||||
Skill(skill="workflow:tools:task-generate-tdd", args="--session [sessionId]")
|
||||
```
|
||||
|
||||
**Note**: Phase 0 now includes:
|
||||
- Supplementary materials collection (file paths or inline content)
|
||||
- Execution method preference (Agent/Hybrid/CLI)
|
||||
- CLI tool preference (Codex/Gemini/Qwen/Auto)
|
||||
- These preferences are passed to agent for task generation
|
||||
|
||||
**CLI Tool Selection**: CLI tool usage is determined semantically from user's task description. Include "use Codex/Gemini/Qwen" in your request for CLI execution.
|
||||
|
||||
### Step 5.2: Parse Output
|
||||
|
||||
Extract: feature count, task count, CLI execution IDs assigned
|
||||
|
||||
### Step 5.3: Validate Outputs
|
||||
|
||||
- `plan.json` exists (structured plan overview with `_metadata.plan_type: "tdd"`)
|
||||
- `IMPL_PLAN.md` exists (unified plan with TDD Implementation Tasks section)
|
||||
- `IMPL-*.json` files exist (one per feature, or container + subtasks for complex features)
|
||||
- `TODO_LIST.md` exists with internal TDD phase indicators
|
||||
- Each IMPL task includes:
|
||||
- `meta.tdd_workflow: true`
|
||||
- `cli_execution.id: {session_id}-{task_id}`
|
||||
- `cli_execution: { "strategy": "new|resume|fork|merge_fork", ... }`
|
||||
- `implementation` with exactly 3 steps (red/green/refactor)
|
||||
- Green phase includes test-fix-cycle configuration
|
||||
- `focus_paths`: absolute or clear relative paths (enhanced with exploration critical_files)
|
||||
- `pre_analysis`: includes exploration integration_points analysis
|
||||
- `IMPL_PLAN.md` contains `workflow_type: "tdd"` in frontmatter
|
||||
- User configuration applied:
|
||||
- If executionMethod == "cli" or "hybrid": command field added to steps
|
||||
- CLI tool preference reflected in execution guidance
|
||||
- Task count ≤18 (compliance with hard limit)
|
||||
|
||||
### Red Flag Detection (Non-Blocking Warnings)
|
||||
|
||||
- Task count >18: `⚠️ Task count exceeds hard limit - request re-scope`
|
||||
- Missing cli_execution.id: `⚠️ Task lacks CLI execution ID for resume support`
|
||||
- Missing test-fix-cycle: `⚠️ Green phase lacks auto-revert configuration`
|
||||
- Generic task names: `⚠️ Vague task names suggest unclear TDD cycles`
|
||||
- Missing focus_paths: `⚠️ Task lacks clear file scope for implementation`
|
||||
|
||||
**Action**: Log warnings to `.workflow/active/[sessionId]/.process/tdd-warnings.log` (non-blocking)
|
||||
|
||||
### TodoWrite Update (Phase 5 Skill executed - tasks attached)
|
||||
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "in_progress", "activeForm": "Executing TDD task generation"},
|
||||
{"content": " → Discovery - analyze TDD requirements", "status": "in_progress", "activeForm": "Analyzing TDD requirements"},
|
||||
{"content": " → Planning - design Red-Green-Refactor cycles", "status": "pending", "activeForm": "Designing TDD cycles"},
|
||||
{"content": " → Output - generate IMPL tasks with internal TDD phases", "status": "pending", "activeForm": "Generating TDD tasks"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: Skill execute **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 Update (Phase 5 completed - tasks collapsed)
|
||||
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "completed", "activeForm": "Executing TDD task generation"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "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.
|
||||
|
||||
## Output
|
||||
|
||||
- **File**: `plan.json` (structured plan overview)
|
||||
- **File**: `IMPL_PLAN.md` (unified plan with TDD Implementation Tasks section)
|
||||
- **File**: `IMPL-*.json` (task JSONs with internal TDD cycles)
|
||||
- **File**: `TODO_LIST.md` (task list with TDD phase indicators)
|
||||
- **File**: `.process/tdd-warnings.log` (non-blocking warnings)
|
||||
- **TodoWrite**: Mark Phase 5 completed, Phase 6 in_progress
|
||||
|
||||
## Next Phase
|
||||
|
||||
Return to orchestrator, then auto-continue to [Phase 6: TDD Structure Validation](06-tdd-structure-validation.md).
|
||||
@@ -0,0 +1,179 @@
|
||||
# Phase 6: TDD Structure Validation & Plan Confirmation
|
||||
|
||||
Internal validation of TDD task structure and user decision gate for next steps.
|
||||
|
||||
## Objective
|
||||
|
||||
- Validate Red-Green-Refactor structure in all generated tasks
|
||||
- Verify TDD compliance checkpoints
|
||||
- Gather evidence before claiming completion
|
||||
- Present Plan Confirmation Gate to user
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 6.1: Internal Validation
|
||||
|
||||
Validate each generated task contains complete TDD workflow:
|
||||
|
||||
1. **Task structure validation**:
|
||||
- `meta.tdd_workflow: true` in all IMPL tasks
|
||||
- `cli_execution.id` present (format: {session_id}-{task_id})
|
||||
- `cli_execution` strategy assigned (new/resume/fork/merge_fork)
|
||||
- `implementation` has exactly 3 steps
|
||||
- Each step has correct `tdd_phase`: "red", "green", "refactor"
|
||||
- `focus_paths` are absolute or clear relative paths
|
||||
- `pre_analysis` includes exploration integration analysis
|
||||
|
||||
2. **Dependency validation**:
|
||||
- Sequential features: IMPL-N depends_on ["IMPL-(N-1)"] if needed
|
||||
- Complex features: IMPL-N.M depends_on ["IMPL-N.(M-1)"] for subtasks
|
||||
- CLI execution strategies correctly assigned based on dependency graph
|
||||
|
||||
3. **Agent assignment**: All IMPL tasks use @code-developer
|
||||
|
||||
4. **Test-fix cycle**: Green phase step includes test-fix-cycle logic with max_iterations
|
||||
|
||||
5. **Task count**: Total tasks ≤18 (simple + subtasks hard limit)
|
||||
|
||||
6. **User configuration**:
|
||||
- Execution method choice reflected in task structure
|
||||
- CLI tool preference documented in implementation guidance (if CLI selected)
|
||||
|
||||
### Step 6.2: Red Flag Checklist
|
||||
|
||||
From TDD best practices:
|
||||
- [ ] No tasks skip Red phase (`tdd_phase: "red"` exists in step 1)
|
||||
- [ ] Test files referenced in Red phase (explicit paths, not placeholders)
|
||||
- [ ] Green phase has test-fix-cycle with `max_iterations` configured
|
||||
- [ ] Refactor phase has clear completion criteria
|
||||
|
||||
**Non-Compliance Warning Format**:
|
||||
```
|
||||
⚠️ TDD Red Flag: [issue description]
|
||||
Task: [IMPL-N]
|
||||
Recommendation: [action to fix]
|
||||
```
|
||||
|
||||
### Step 6.3: Evidence Gathering
|
||||
|
||||
Before claiming completion, verify artifacts exist:
|
||||
|
||||
```bash
|
||||
# Verify session artifacts exist
|
||||
ls -la .workflow/active/[sessionId]/{IMPL_PLAN.md,TODO_LIST.md}
|
||||
ls -la .workflow/active/[sessionId]/.task/IMPL-*.json
|
||||
|
||||
# Count generated artifacts
|
||||
echo "IMPL tasks: $(ls .workflow/active/[sessionId]/.task/IMPL-*.json 2>/dev/null | wc -l)"
|
||||
|
||||
# Sample task structure verification (first task)
|
||||
jq '{id, tdd: .meta.tdd_workflow, cli_id: .cli_execution.id, phases: [.implementation[].tdd_phase]}' \
|
||||
"$(ls .workflow/active/[sessionId]/.task/IMPL-*.json | head -1)"
|
||||
```
|
||||
|
||||
**Evidence Required Before Summary**:
|
||||
|
||||
| Evidence Type | Verification Method | Pass Criteria |
|
||||
|---------------|---------------------|---------------|
|
||||
| File existence | `ls -la` artifacts | All files present |
|
||||
| Task count | Count IMPL-*.json | Count matches claims (≤18) |
|
||||
| TDD structure | jq sample extraction | Shows red/green/refactor + cli_execution.id |
|
||||
| CLI execution IDs | jq extraction | All tasks have cli_execution.id assigned |
|
||||
| Warning log | Check tdd-warnings.log | Logged (may be empty) |
|
||||
|
||||
### Step 6.4: Plan Confirmation Gate
|
||||
|
||||
Present user with action choices:
|
||||
|
||||
```javascript
|
||||
console.log(`
|
||||
TDD Planning complete for session: ${sessionId}
|
||||
|
||||
Features analyzed: [N]
|
||||
Total tasks: [M] (1 task per simple feature + subtasks for complex features)
|
||||
|
||||
Task breakdown:
|
||||
- Simple features: [K] tasks (IMPL-1 to IMPL-K)
|
||||
- Complex features: [L] features with [P] subtasks
|
||||
- Total task count: [M] (within 18-task hard limit)
|
||||
|
||||
Structure:
|
||||
- IMPL-1: {Feature 1 Name} (Internal: Red → Green → Refactor)
|
||||
- IMPL-2: {Feature 2 Name} (Internal: Red → Green → Refactor)
|
||||
- IMPL-3: {Complex Feature} (Container)
|
||||
- IMPL-3.1: {Sub-feature A} (Internal: Red → Green → Refactor)
|
||||
- IMPL-3.2: {Sub-feature B} (Internal: Red → Green → Refactor)
|
||||
[...]
|
||||
|
||||
Plans generated:
|
||||
- Unified Implementation Plan: .workflow/active/[sessionId]/IMPL_PLAN.md
|
||||
(includes TDD Implementation Tasks section with workflow_type: "tdd")
|
||||
- Task List: .workflow/active/[sessionId]/TODO_LIST.md
|
||||
(with internal TDD phase indicators and CLI execution strategies)
|
||||
- Task JSONs: .workflow/active/[sessionId]/.task/IMPL-*.json
|
||||
(with cli_execution.id and execution strategies for resume support)
|
||||
|
||||
TDD Configuration:
|
||||
- Each task contains complete Red-Green-Refactor cycle
|
||||
- Green phase includes test-fix cycle (max 3 iterations)
|
||||
- Auto-revert on max iterations reached
|
||||
- CLI execution strategies: new/resume/fork/merge_fork based on dependency graph
|
||||
|
||||
User Configuration Applied:
|
||||
- Execution Method: [agent|hybrid|cli]
|
||||
- CLI Tool Preference: [codex|gemini|qwen|auto]
|
||||
- Supplementary Materials: [included|none]
|
||||
- Task generation follows cli-tools-usage.md guidelines
|
||||
|
||||
⚠️ ACTION REQUIRED: Before execution, ensure you understand WHY each Red phase test is expected to fail.
|
||||
This is crucial for valid TDD - if you don't know why the test fails, you can't verify it tests the right thing.
|
||||
`);
|
||||
|
||||
// Ask user for next action
|
||||
const userChoice = AskUserQuestion({
|
||||
questions: [{
|
||||
question: "TDD Planning complete. What would you like to do next?",
|
||||
header: "Next Action",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{
|
||||
label: "Verify TDD Compliance (Recommended)",
|
||||
description: "Run full TDD compliance verification to check task chain structure, coverage, and Red-Green-Refactor cycle quality."
|
||||
},
|
||||
{
|
||||
label: "Start Execution",
|
||||
description: "Begin implementing TDD tasks immediately with Red-Green-Refactor cycles."
|
||||
},
|
||||
{
|
||||
label: "Review Status Only",
|
||||
description: "View TDD task breakdown and session status without taking further action."
|
||||
}
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
// Execute based on user choice
|
||||
if (userChoice === "Verify TDD Compliance (Recommended)") {
|
||||
// Route to Phase 7 (tdd-verify) within this skill
|
||||
// Orchestrator reads phases/07-tdd-verify.md and executes
|
||||
} else if (userChoice === "Start Execution") {
|
||||
Skill(skill="workflow-execute", args="--session " + sessionId);
|
||||
} else if (userChoice === "Review Status Only") {
|
||||
Skill(skill="workflow:status", args="--session " + sessionId);
|
||||
}
|
||||
```
|
||||
|
||||
**Auto Mode (--yes)**: Auto-select "Verify TDD Compliance", then auto-continue to execute if quality gate is APPROVED.
|
||||
|
||||
## Output
|
||||
|
||||
- **Validation**: TDD structure verified
|
||||
- **User Decision**: Route to Phase 7 / Execute / Review
|
||||
- **TodoWrite**: Mark Phase 6 completed
|
||||
|
||||
## Next Phase (Conditional)
|
||||
|
||||
Based on user's plan confirmation choice:
|
||||
- If "Verify" → [Phase 7: TDD Verification](07-tdd-verify.md)
|
||||
- If "Execute" → Skill(skill="workflow-execute")
|
||||
- If "Review" → External: /workflow:status
|
||||
@@ -1,82 +1,28 @@
|
||||
---
|
||||
name: tdd-verify
|
||||
description: Verify TDD workflow compliance against Red-Green-Refactor cycles. Generates quality report with coverage analysis and quality gate recommendation. Orchestrates sub-commands for comprehensive validation.
|
||||
argument-hint: "[optional: --session WFS-session-id]"
|
||||
allowed-tools: Skill(*), TodoWrite(*), Read(*), Write(*), Bash(*), Glob(*)
|
||||
---
|
||||
# Phase 7: TDD Verification
|
||||
|
||||
# TDD Verification Command (/workflow:tdd-verify)
|
||||
Full TDD compliance verification with quality gate reporting. Generates comprehensive TDD_COMPLIANCE_REPORT.md.
|
||||
|
||||
## Goal
|
||||
## Objective
|
||||
|
||||
Verify TDD workflow execution quality by validating Red-Green-Refactor cycle compliance, test coverage completeness, and task chain structure integrity. This command orchestrates multiple analysis phases and generates a comprehensive compliance report with quality gate recommendation.
|
||||
|
||||
**Output**: A structured Markdown report saved to `.workflow/active/WFS-{session}/TDD_COMPLIANCE_REPORT.md` containing:
|
||||
- Executive summary with compliance score and quality gate recommendation
|
||||
- Task chain validation (TEST → IMPL → REFACTOR structure)
|
||||
- Test coverage metrics (line, branch, function)
|
||||
- Red-Green-Refactor cycle verification
|
||||
- Best practices adherence assessment
|
||||
- Actionable improvement recommendations
|
||||
- Verify TDD task chain structure (TEST → IMPL → REFACTOR or internal Red-Green-Refactor)
|
||||
- Analyze test coverage metrics
|
||||
- Validate TDD cycle execution quality
|
||||
- Generate compliance report with quality gate recommendation
|
||||
|
||||
## Operating Constraints
|
||||
|
||||
**ORCHESTRATOR MODE**:
|
||||
- This command coordinates multiple sub-commands (`/workflow:tools:tdd-coverage-analysis`, `ccw cli`)
|
||||
- This phase coordinates sub-steps and `/workflow:tools:tdd-coverage-analysis`
|
||||
- MAY write output files: TDD_COMPLIANCE_REPORT.md (primary report), .process/*.json (intermediate artifacts)
|
||||
- MUST NOT modify source task files or implementation code
|
||||
- MUST NOT create or delete tasks in the workflow
|
||||
|
||||
**Quality Gate Authority**: The compliance report provides a binding recommendation (BLOCK_MERGE / REQUIRE_FIXES / PROCEED_WITH_CAVEATS / APPROVED) based on objective compliance criteria.
|
||||
|
||||
## Coordinator Role
|
||||
## 4-Step Execution
|
||||
|
||||
**This command is a pure orchestrator**: Execute 4 phases to verify TDD workflow compliance, test coverage, and Red-Green-Refactor cycle execution.
|
||||
### Step 7.1: Session Discovery & Validation
|
||||
|
||||
## Core Responsibilities
|
||||
- Verify TDD task chain structure (TEST → IMPL → REFACTOR)
|
||||
- Analyze test coverage metrics
|
||||
- Validate TDD cycle execution quality
|
||||
- Generate compliance report with quality gate recommendation
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Input Parsing:
|
||||
└─ Decision (session argument):
|
||||
├─ --session provided → Use provided session
|
||||
└─ No session → Auto-detect active session
|
||||
|
||||
Phase 1: Session Discovery & Validation
|
||||
├─ Detect or validate session directory
|
||||
├─ Check required artifacts exist (.task/*.json, .summaries/*)
|
||||
└─ ERROR if invalid or incomplete
|
||||
|
||||
Phase 2: Task Chain Structure Validation
|
||||
├─ Load all task JSONs from .task/
|
||||
├─ Validate TDD structure: TEST-N.M → IMPL-N.M → REFACTOR-N.M
|
||||
├─ Verify dependencies (depends_on)
|
||||
├─ Validate meta fields (tdd_phase, agent)
|
||||
└─ Extract chain validation data
|
||||
|
||||
Phase 3: Coverage & Cycle Analysis
|
||||
├─ Call: /workflow:tools:tdd-coverage-analysis
|
||||
├─ Parse: test-results.json, coverage-report.json, tdd-cycle-report.md
|
||||
└─ Extract coverage metrics and TDD cycle verification
|
||||
|
||||
Phase 4: Compliance Report Generation
|
||||
├─ Aggregate findings from Phases 1-3
|
||||
├─ Calculate compliance score (0-100)
|
||||
├─ Determine quality gate recommendation
|
||||
├─ Generate TDD_COMPLIANCE_REPORT.md
|
||||
└─ Display summary to user
|
||||
```
|
||||
|
||||
## 4-Phase Execution
|
||||
|
||||
### Phase 1: Session Discovery & Validation
|
||||
|
||||
**Step 1.1: Detect Session**
|
||||
```bash
|
||||
IF --session parameter provided:
|
||||
session_id = provided session
|
||||
@@ -99,7 +45,7 @@ summaries_dir = session_dir/.summaries
|
||||
process_dir = session_dir/.process
|
||||
```
|
||||
|
||||
**Step 1.2: Validate Required Artifacts**
|
||||
**Validate Required Artifacts**:
|
||||
```bash
|
||||
# Check task files exist
|
||||
task_files = Glob(task_dir/*.json)
|
||||
@@ -117,13 +63,11 @@ IF NOT summaries_exist:
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Task Chain Structure Validation
|
||||
### Step 7.2: Task Chain Structure Validation
|
||||
|
||||
**Step 2.1: Load and Parse Task JSONs**
|
||||
**Load and Parse Task JSONs**:
|
||||
```bash
|
||||
# Single-pass JSON extraction using jq
|
||||
validation_data = bash("""
|
||||
# Load all tasks and extract structured data
|
||||
cd '{session_dir}/.task'
|
||||
|
||||
# Extract all task IDs
|
||||
@@ -140,16 +84,15 @@ meta_tdd=$(jq -r '.id + ":" + (.meta.tdd_phase // "missing")' *.json 2>/dev/null
|
||||
meta_agent=$(jq -r '.id + ":" + (.meta.agent // "missing")' *.json 2>/dev/null)
|
||||
|
||||
# Output as JSON
|
||||
jq -n --arg ids "$task_ids" \\
|
||||
--arg impl "$impl_deps" \\
|
||||
--arg refactor "$refactor_deps" \\
|
||||
--arg tdd "$meta_tdd" \\
|
||||
--arg agent "$meta_agent" \\
|
||||
jq -n --arg ids "$task_ids" \
|
||||
--arg impl "$impl_deps" \
|
||||
--arg refactor "$refactor_deps" \
|
||||
--arg tdd "$meta_tdd" \
|
||||
--arg agent "$meta_agent" \
|
||||
'{ids: $ids, impl_deps: $impl, refactor_deps: $refactor, tdd: $tdd, agent: $agent}'
|
||||
""")
|
||||
```
|
||||
|
||||
**Step 2.2: Validate TDD Chain Structure**
|
||||
**Validate TDD Chain Structure**:
|
||||
```
|
||||
Parse validation_data JSON and validate:
|
||||
|
||||
@@ -175,14 +118,14 @@ Calculate:
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Coverage & Cycle Analysis
|
||||
### Step 7.3: Coverage & Cycle Analysis
|
||||
|
||||
**Step 3.1: Call Coverage Analysis Sub-command**
|
||||
```bash
|
||||
**Call Coverage Analysis Sub-command**:
|
||||
```javascript
|
||||
Skill(skill="workflow:tools:tdd-coverage-analysis", args="--session {session_id}")
|
||||
```
|
||||
|
||||
**Step 3.2: Parse Output Files**
|
||||
**Parse Output Files**:
|
||||
```bash
|
||||
# Check required outputs exist
|
||||
IF NOT EXISTS(process_dir/test-results.json):
|
||||
@@ -204,7 +147,7 @@ ELSE:
|
||||
cycle_data = Read(process_dir/tdd-cycle-report.md)
|
||||
```
|
||||
|
||||
**Step 3.3: Extract Coverage Metrics**
|
||||
**Extract Coverage Metrics**:
|
||||
```
|
||||
If coverage_data exists:
|
||||
- line_coverage_percent
|
||||
@@ -224,9 +167,9 @@ If cycle_data exists:
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Compliance Report Generation
|
||||
### Step 7.4: Compliance Report Generation
|
||||
|
||||
**Step 4.1: Calculate Compliance Score**
|
||||
**Calculate Compliance Score**:
|
||||
```
|
||||
Base Score: 100 points
|
||||
|
||||
@@ -254,7 +197,7 @@ Coverage Quality:
|
||||
Final Score: Max(0, Base Score - Total Deductions)
|
||||
```
|
||||
|
||||
**Step 4.2: Determine Quality Gate**
|
||||
**Determine Quality Gate**:
|
||||
```
|
||||
IF score >= 90 AND no_critical_violations:
|
||||
recommendation = "APPROVED"
|
||||
@@ -266,57 +209,7 @@ ELSE:
|
||||
recommendation = "BLOCK_MERGE"
|
||||
```
|
||||
|
||||
**Step 4.3: Generate Report**
|
||||
```bash
|
||||
report_content = Generate markdown report (see structure below)
|
||||
report_path = "{session_dir}/TDD_COMPLIANCE_REPORT.md"
|
||||
Write(report_path, report_content)
|
||||
```
|
||||
|
||||
**Step 4.4: Display Summary to User**
|
||||
```bash
|
||||
echo "=== TDD Verification Complete ==="
|
||||
echo "Session: {session_id}"
|
||||
echo "Report: {report_path}"
|
||||
echo ""
|
||||
echo "Quality Gate: {recommendation}"
|
||||
echo "Compliance Score: {score}/100"
|
||||
echo ""
|
||||
echo "Chain Validation: {chain_completeness_score}%"
|
||||
echo "Line Coverage: {line_coverage}%"
|
||||
echo "Branch Coverage: {branch_coverage}%"
|
||||
echo ""
|
||||
echo "Next: Review full report for detailed findings"
|
||||
```
|
||||
|
||||
## TodoWrite Pattern (Optional)
|
||||
|
||||
**Note**: As an orchestrator command, TodoWrite tracking is optional and primarily useful for long-running verification processes. For most cases, the 4-phase execution is fast enough that progress tracking adds noise without value.
|
||||
|
||||
```javascript
|
||||
// Only use TodoWrite for complex multi-session verification
|
||||
// Skip for single-session verification
|
||||
```
|
||||
|
||||
## Validation Logic
|
||||
|
||||
### Chain Validation Algorithm
|
||||
```
|
||||
1. Load all task JSONs from .workflow/active/{sessionId}/.task/
|
||||
2. Extract task IDs and group by feature number
|
||||
3. For each feature:
|
||||
- Check TEST-N.M exists
|
||||
- Check IMPL-N.M exists
|
||||
- Check REFACTOR-N.M exists (optional but recommended)
|
||||
- Verify IMPL-N.M depends_on TEST-N.M
|
||||
- Verify REFACTOR-N.M depends_on IMPL-N.M
|
||||
- Verify meta.tdd_phase values
|
||||
- Verify meta.agent assignments
|
||||
4. Calculate chain completeness score
|
||||
5. Report incomplete or invalid chains
|
||||
```
|
||||
|
||||
### Quality Gate Criteria
|
||||
**Quality Gate Criteria**:
|
||||
|
||||
| Recommendation | Score Range | Critical Violations | Action |
|
||||
|----------------|-------------|---------------------|--------|
|
||||
@@ -331,62 +224,30 @@ echo "Next: Review full report for detailed findings"
|
||||
- Tests didn't pass after IMPL (Green phase violation)
|
||||
- Tests broke during REFACTOR (Refactor phase violation)
|
||||
|
||||
## Output Files
|
||||
```
|
||||
.workflow/active/WFS-{session-id}/
|
||||
├── TDD_COMPLIANCE_REPORT.md # Comprehensive compliance report ⭐
|
||||
└── .process/
|
||||
├── test-results.json # From tdd-coverage-analysis
|
||||
├── coverage-report.json # From tdd-coverage-analysis
|
||||
└── tdd-cycle-report.md # From tdd-coverage-analysis
|
||||
**Generate Report**:
|
||||
```javascript
|
||||
const report_content = generateComplianceReport(/* see template below */)
|
||||
const report_path = `${session_dir}/TDD_COMPLIANCE_REPORT.md`
|
||||
Write(report_path, report_content)
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
**Display Summary to User**:
|
||||
```
|
||||
=== TDD Verification Complete ===
|
||||
Session: {session_id}
|
||||
Report: {report_path}
|
||||
|
||||
### Session Discovery Errors
|
||||
| Error | Cause | Resolution |
|
||||
|-------|-------|------------|
|
||||
| No active session | No WFS-* directories | Provide --session explicitly |
|
||||
| Multiple active sessions | Multiple WFS-* directories | Provide --session explicitly |
|
||||
| Session not found | Invalid session-id | Check available sessions |
|
||||
Quality Gate: {recommendation}
|
||||
Compliance Score: {score}/100
|
||||
|
||||
### Validation Errors
|
||||
| Error | Cause | Resolution |
|
||||
|-------|-------|------------|
|
||||
| Task files missing | Incomplete planning | Run /workflow:tdd-plan first |
|
||||
| Invalid JSON | Corrupted task files | Regenerate tasks |
|
||||
| Missing summaries | Tasks not executed | Execute tasks before verify |
|
||||
Chain Validation: {chain_completeness_score}%
|
||||
Line Coverage: {line_coverage}%
|
||||
Branch Coverage: {branch_coverage}%
|
||||
|
||||
### Analysis Errors
|
||||
| Error | Cause | Resolution |
|
||||
|-------|-------|------------|
|
||||
| Coverage tool missing | No test framework | Configure testing first |
|
||||
| Tests fail to run | Code errors | Fix errors before verify |
|
||||
| Sub-command fails | tdd-coverage-analysis error | Check sub-command logs |
|
||||
|
||||
## Integration & Usage
|
||||
|
||||
### Command Chain
|
||||
- **Called After**: `/workflow:execute` (when TDD tasks completed)
|
||||
- **Calls**: `/workflow:tools:tdd-coverage-analysis`
|
||||
- **Related**: `/workflow:tdd-plan`, `/workflow:status`
|
||||
|
||||
### Basic Usage
|
||||
```bash
|
||||
# Auto-detect active session
|
||||
/workflow:tdd-verify
|
||||
|
||||
# Specify session
|
||||
/workflow:tdd-verify --session WFS-auth
|
||||
Next: Review full report for detailed findings
|
||||
```
|
||||
|
||||
### When to Use
|
||||
- After completing all TDD tasks in a workflow
|
||||
- Before merging TDD workflow branch
|
||||
- For TDD process quality assessment
|
||||
- To identify missing TDD steps
|
||||
|
||||
## TDD Compliance Report Structure
|
||||
## TDD Compliance Report Template
|
||||
|
||||
```markdown
|
||||
# TDD Compliance Report - {Session ID}
|
||||
@@ -436,20 +297,6 @@ echo "Next: Review full report for detailed findings"
|
||||
| Green | IMPL-1.1 | ✅ Pass | Minimal implementation made test pass |
|
||||
| Refactor | REFACTOR-1.1 | ✅ Pass | Code improved, tests remained green |
|
||||
|
||||
### Feature 2: {Feature Name}
|
||||
**Status**: ⚠️ Incomplete
|
||||
**Chain**: TEST-2.1 → IMPL-2.1 (Missing REFACTOR-2.1)
|
||||
|
||||
| Phase | Task | Status | Details |
|
||||
|-------|------|--------|---------|
|
||||
| Red | TEST-2.1 | ✅ Pass | Test created and failed |
|
||||
| Green | IMPL-2.1 | ⚠️ Warning | Implementation seems over-engineered |
|
||||
| Refactor | REFACTOR-2.1 | ❌ Missing | Task not completed |
|
||||
|
||||
**Issues**:
|
||||
- REFACTOR-2.1 task not completed (-10 points)
|
||||
- IMPL-2.1 implementation exceeded minimal scope (-10 points)
|
||||
|
||||
### Chain Validation Summary
|
||||
|
||||
| Metric | Value |
|
||||
@@ -479,8 +326,7 @@ echo "Next: Review full report for detailed findings"
|
||||
|
||||
| File | Lines | Issue | Priority |
|
||||
|------|-------|-------|----------|
|
||||
| src/auth/service.ts | 45-52 | Uncovered error handling | HIGH |
|
||||
| src/utils/parser.ts | 78-85 | Uncovered edge case | MEDIUM |
|
||||
| {file} | {lines} | {issue} | {priority} |
|
||||
|
||||
---
|
||||
|
||||
@@ -491,39 +337,25 @@ echo "Next: Review full report for detailed findings"
|
||||
- ✅ Compliant features: {list}
|
||||
- ❌ Non-compliant features: {list}
|
||||
|
||||
**Violations**:
|
||||
- Feature 3: No evidence of initial test failure (-10 points)
|
||||
|
||||
### Green Phase (Make Test Pass)
|
||||
- {N}/{total} implementations made tests pass ({percent}%)
|
||||
- ✅ Compliant features: {list}
|
||||
- ❌ Non-compliant features: {list}
|
||||
|
||||
**Violations**:
|
||||
- Feature 2: Implementation over-engineered (-10 points)
|
||||
|
||||
### Refactor Phase (Improve Quality)
|
||||
- {N}/{total} features completed refactoring ({percent}%)
|
||||
- ✅ Compliant features: {list}
|
||||
- ❌ Non-compliant features: {list}
|
||||
|
||||
**Violations**:
|
||||
- Feature 2, 4: Refactoring step skipped (-20 points total)
|
||||
|
||||
---
|
||||
|
||||
## Best Practices Assessment
|
||||
|
||||
### Strengths
|
||||
- Clear test descriptions
|
||||
- Good test coverage
|
||||
- Consistent naming conventions
|
||||
- Well-structured code
|
||||
- {strengths}
|
||||
|
||||
### Areas for Improvement
|
||||
- Some implementations over-engineered in Green phase
|
||||
- Missing refactoring steps
|
||||
- Test failure messages could be more descriptive
|
||||
- {improvements}
|
||||
|
||||
---
|
||||
|
||||
@@ -533,33 +365,26 @@ echo "Next: Review full report for detailed findings"
|
||||
{List of critical issues with impact and remediation}
|
||||
|
||||
### High Priority Issues ({count})
|
||||
{List of high priority issues with impact and remediation}
|
||||
{List of high priority issues}
|
||||
|
||||
### Medium Priority Issues ({count})
|
||||
{List of medium priority issues with impact and remediation}
|
||||
{List of medium priority issues}
|
||||
|
||||
### Low Priority Issues ({count})
|
||||
{List of low priority issues with impact and remediation}
|
||||
{List of low priority issues}
|
||||
|
||||
---
|
||||
|
||||
## Recommendations
|
||||
|
||||
### Required Fixes (Before Merge)
|
||||
1. Complete missing REFACTOR tasks (Features 2, 4)
|
||||
2. Verify initial test failures for Feature 3
|
||||
3. Fix tests that broke during refactoring
|
||||
1. {required fixes}
|
||||
|
||||
### Recommended Improvements
|
||||
1. Simplify over-engineered implementations
|
||||
2. Add edge case tests for Features 1, 3
|
||||
3. Improve test failure message clarity
|
||||
4. Increase branch coverage to >85%
|
||||
1. {recommended improvements}
|
||||
|
||||
### Optional Enhancements
|
||||
1. Add more descriptive test names
|
||||
2. Consider parameterized tests for similar scenarios
|
||||
3. Document TDD process learnings
|
||||
1. {optional enhancements}
|
||||
|
||||
---
|
||||
|
||||
@@ -583,3 +408,54 @@ echo "Next: Review full report for detailed findings"
|
||||
**Report End**
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Session Discovery Errors
|
||||
|
||||
| Error | Cause | Resolution |
|
||||
|-------|-------|------------|
|
||||
| No active session | No WFS-* directories | Provide --session explicitly |
|
||||
| Multiple active sessions | Multiple WFS-* directories | Provide --session explicitly |
|
||||
| Session not found | Invalid session-id | Check available sessions |
|
||||
|
||||
### Validation Errors
|
||||
|
||||
| Error | Cause | Resolution |
|
||||
|-------|-------|------------|
|
||||
| Task files missing | Incomplete planning | Run /workflow:tdd-plan first |
|
||||
| Invalid JSON | Corrupted task files | Regenerate tasks |
|
||||
| Missing summaries | Tasks not executed | Execute tasks before verify |
|
||||
|
||||
### Analysis Errors
|
||||
|
||||
| Error | Cause | Resolution |
|
||||
|-------|-------|------------|
|
||||
| Coverage tool missing | No test framework | Configure testing first |
|
||||
| Tests fail to run | Code errors | Fix errors before verify |
|
||||
| Sub-command fails | tdd-coverage-analysis error | Check sub-command logs |
|
||||
|
||||
## Output
|
||||
|
||||
- **File**: `TDD_COMPLIANCE_REPORT.md` (comprehensive compliance report)
|
||||
- **Files**: `.process/test-results.json`, `.process/coverage-report.json`, `.process/tdd-cycle-report.md`
|
||||
|
||||
## Output Files Structure
|
||||
|
||||
```
|
||||
.workflow/active/WFS-{session-id}/
|
||||
├── TDD_COMPLIANCE_REPORT.md # Comprehensive compliance report ⭐
|
||||
└── .process/
|
||||
├── test-results.json # From tdd-coverage-analysis
|
||||
├── coverage-report.json # From tdd-coverage-analysis
|
||||
└── tdd-cycle-report.md # From tdd-coverage-analysis
|
||||
```
|
||||
|
||||
## Next Steps Decision Table
|
||||
|
||||
| Situation | Recommended Command | Purpose |
|
||||
|-----------|---------------------|---------|
|
||||
| APPROVED | `/workflow:execute` | Start TDD implementation |
|
||||
| PROCEED_WITH_CAVEATS | `/workflow:execute` | Start with noted caveats |
|
||||
| REQUIRE_FIXES | Review report, refine tasks | Address issues before proceed |
|
||||
| BLOCK_MERGE | `/workflow:replan` | Significant restructuring needed |
|
||||
| After implementation | Re-run `/workflow:tdd-verify` | Verify post-execution compliance |
|
||||
@@ -6,7 +6,7 @@ allowed-tools: Skill, Task, AskUserQuestion, TaskCreate, TaskUpdate, TaskList, R
|
||||
|
||||
# Workflow Test Fix
|
||||
|
||||
Unified test-fix orchestrator that combines **test planning generation** (Phase 1) with **iterative test-cycle execution** (Phase 2) into a single end-to-end pipeline. Creates test sessions with progressive L0-L3 test layers, generates test tasks, then executes them with adaptive fix cycles until pass rate >= 95% or max iterations reached.
|
||||
Unified test-fix orchestrator that combines **test planning generation** (Phase 1-4) with **iterative test-cycle execution** (Phase 5) into a single end-to-end pipeline. Creates test sessions with progressive L0-L3 test layers, generates test tasks, then executes them with adaptive fix cycles until pass rate >= 95% or max iterations reached.
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
@@ -14,27 +14,29 @@ Unified test-fix orchestrator that combines **test planning generation** (Phase
|
||||
┌───────────────────────────────────────────────────────────────────────────┐
|
||||
│ Workflow Test Fix Orchestrator (SKILL.md) │
|
||||
│ → Pure coordinator: Route entry point, track progress, pass context │
|
||||
│ → Two phases: Generation (Phase 1) + Execution (Phase 2) │
|
||||
│ → Five phases: Session → Context → Analysis → TaskGen → Execution │
|
||||
└──────────────────────────────────┬────────────────────────────────────────┘
|
||||
│
|
||||
┌───────────────────────────┼────────────────────────────┐
|
||||
↓ ↓
|
||||
┌──────────────────────┐ ┌──────────────────────┐
|
||||
│ Phase 1: Test Gen │ │ Phase 2: Test Cycle │
|
||||
│ (test-fix-gen) │─── testSessionId ───────→│ (test-cycle-execute)│
|
||||
│ │ │ │
|
||||
│ 1. Session Create │ │ 1. Discovery │
|
||||
│ 2. Context Gather │ │ 2. Initial Execute │
|
||||
│ 3. Test Analysis │ │ 3. Fix Loop │
|
||||
│ 4. Task Generation │ │ 4. Completion │
|
||||
│ 5. Summary │ │ │
|
||||
└──────────────────────┘ └──────────────────────┘
|
||||
sessionId pass_rate >= 95%
|
||||
contextPath or max iterations
|
||||
IMPL_PLAN.md
|
||||
IMPL-*.json
|
||||
┌────────────┬────────────┬──────┴──────┬────────────┬────────────┐
|
||||
↓ ↓ ↓ ↓ ↓
|
||||
┌──────────┐┌──────────┐┌──────────┐┌──────────┐ ┌──────────────┐
|
||||
│ Phase 1 ││ Phase 2 ││ Phase 3 ││ Phase 4 │ │ Phase 5 │
|
||||
│ Session ││ Context ││ Analysis ││ Task Gen │ │ Test Cycle │
|
||||
│ Start ││ Gather ││ Enhanced ││ Generate │ │ Execute │
|
||||
│ ││ ││ ││ │ │ │
|
||||
│ Input ││ Coverage ││ Gemini ││ IMPL_PLAN│ │ 1. Discovery│
|
||||
│ Detect + ││ or Code ││ L0-L3 ││ IMPL-* │ │ 2. Execute │
|
||||
│ Session ││ Scan ││ AI Issue ││ TODO_LIST│ │ 3. Fix Loop │
|
||||
│ Create ││ ││ ││ │ │ 4. Complete │
|
||||
└────┬─────┘└────┬─────┘└────┬─────┘└────┬─────┘ └──────────────┘
|
||||
│ │ │ │ ↑
|
||||
│testSessionId │ │ │
|
||||
└──→────────┘contextPath│ │ │
|
||||
└──→───────┘AnalysisRes│ │
|
||||
└──→──────┘ testSessionId │
|
||||
└──→──(Summary)──→┘
|
||||
|
||||
Task Pipeline (generated in Phase 1, executed in Phase 2):
|
||||
Task Pipeline (generated in Phase 4, executed in Phase 5):
|
||||
┌──────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
|
||||
│ IMPL-001 │──→│ IMPL-001.3 │──→│ IMPL-001.5 │──→│ IMPL-002 │
|
||||
│ Test Gen │ │ Code Validate │ │ Quality Gate │ │ Test & Fix │
|
||||
@@ -47,7 +49,7 @@ Task Pipeline (generated in Phase 1, executed in Phase 2):
|
||||
|
||||
1. **Unified Pipeline**: Generation and execution are one continuous workflow - no manual handoff
|
||||
2. **Pure Orchestrator**: SKILL.md coordinates only - delegates all execution detail to phase files
|
||||
3. **Auto-Continue**: Phase 1 completes → Phase 2 starts automatically
|
||||
3. **Auto-Continue**: Phase 1→2→3→4→(Summary)→5 automatically
|
||||
4. **Task Attachment/Collapse**: Sub-tasks attached during phase execution, collapsed after completion
|
||||
5. **Progressive Phase Loading**: Phase docs read **only** when that phase executes, not upfront
|
||||
6. **Adaptive Strategy**: Fix loop auto-selects strategy (conservative/aggressive/surgical) based on iteration context
|
||||
@@ -75,21 +77,35 @@ When `--yes` or `-y`: Auto-select first active session, skip confirmations, auto
|
||||
|
||||
```
|
||||
Entry Point Detection:
|
||||
├─ /workflow:test-fix-gen → Full Pipeline (Phase 1 → Phase 2)
|
||||
└─ /workflow:test-cycle-execute → Execution Only (Phase 2)
|
||||
├─ /workflow:test-fix-gen → Full Pipeline (Phase 1→2→3→4→Summary→5)
|
||||
└─ /workflow:test-cycle-execute → Execution Only (Phase 5)
|
||||
|
||||
Phase 1: Test Generation (test-fix-gen)
|
||||
└─ Ref: phases/01-test-fix-gen.md
|
||||
├─ Step 1.1: Detect input mode (session | prompt)
|
||||
├─ Step 1.2: Create test session → testSessionId
|
||||
├─ Step 1.3: Gather test context → contextPath
|
||||
├─ Step 1.4: Test analysis (Gemini) → TEST_ANALYSIS_RESULTS.md
|
||||
├─ Step 1.5: Generate test tasks → IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
|
||||
Phase 1: Session Start (session-start)
|
||||
└─ Ref: phases/01-session-start.md
|
||||
├─ Step 1.0: Detect input mode (session | prompt)
|
||||
├─ Step 1.1: Create test session → testSessionId
|
||||
└─ Output: testSessionId, MODE
|
||||
|
||||
Phase 2: Test Context Gather (test-context-gather)
|
||||
└─ Ref: phases/02-test-context-gather.md
|
||||
├─ Step 1.2: Gather test context → contextPath
|
||||
└─ Output: contextPath
|
||||
|
||||
Phase 3: Test Concept Enhanced (test-concept-enhanced)
|
||||
└─ Ref: phases/03-test-concept-enhanced.md
|
||||
├─ Step 1.3: Test analysis (Gemini) → TEST_ANALYSIS_RESULTS.md
|
||||
└─ Output: TEST_ANALYSIS_RESULTS.md
|
||||
|
||||
Phase 4: Test Task Generate (test-task-generate)
|
||||
└─ Ref: phases/04-test-task-generate.md
|
||||
├─ Step 1.4: Generate test tasks → IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
|
||||
└─ Output: testSessionId, 4+ task JSONs
|
||||
→ Auto-continue to Phase 2
|
||||
|
||||
Phase 2: Test Cycle Execution (test-cycle-execute)
|
||||
└─ Ref: phases/02-test-cycle-execute.md
|
||||
Summary Output (inline after Phase 4):
|
||||
└─ Display summary, auto-continue to Phase 5
|
||||
|
||||
Phase 5: Test Cycle Execution (test-cycle-execute)
|
||||
└─ Ref: phases/05-test-cycle-execute.md
|
||||
├─ Step 2.1: Discovery (load session, tasks, iteration state)
|
||||
├─ Step 2.2: Execute initial tasks (IMPL-001 → 001.3 → 001.5 → 002)
|
||||
├─ Step 2.3: Fix loop (if pass_rate < 95%)
|
||||
@@ -105,20 +121,23 @@ Phase 2: Test Cycle Execution (test-cycle-execute)
|
||||
|
||||
| Phase | Document | Purpose |
|
||||
|-------|----------|---------|
|
||||
| 1 | [phases/01-test-fix-gen.md](phases/01-test-fix-gen.md) | Create test session, gather context, analyze, generate tasks |
|
||||
| 2 | [phases/02-test-cycle-execute.md](phases/02-test-cycle-execute.md) | Execute tasks, iterative fix cycles, completion |
|
||||
| 1 | [phases/01-session-start.md](phases/01-session-start.md) | Detect input mode, create test session |
|
||||
| 2 | [phases/02-test-context-gather.md](phases/02-test-context-gather.md) | Gather test context (coverage/codebase) |
|
||||
| 3 | [phases/03-test-concept-enhanced.md](phases/03-test-concept-enhanced.md) | Gemini analysis, L0-L3 test requirements |
|
||||
| 4 | [phases/04-test-task-generate.md](phases/04-test-task-generate.md) | Generate task JSONs and IMPL_PLAN.md |
|
||||
| 5 | [phases/05-test-cycle-execute.md](phases/05-test-cycle-execute.md) | Execute tasks, iterative fix cycles, completion |
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Start Immediately**: First action is TaskCreate initialization, second action is Phase 1 (or Phase 2 for execute-only entry)
|
||||
1. **Start Immediately**: First action is TaskCreate initialization, second action is Phase 1 (or Phase 5 for execute-only entry)
|
||||
2. **No Preliminary Analysis**: Do not read files or gather context before starting the phase
|
||||
3. **Parse Every Output**: Extract required data from each step output for next step
|
||||
4. **Auto-Continue**: Phase 1 → Phase 2 automatically (for full pipeline entry)
|
||||
4. **Auto-Continue**: Phase 1→2→3→4→(Summary)→5 automatically (for full pipeline entry)
|
||||
5. **Track Progress**: Update TaskCreate/TaskUpdate dynamically with task attachment/collapse pattern
|
||||
6. **Task Attachment Model**: Sub-tasks **attached** during phase, **collapsed** after completion
|
||||
7. **DO NOT STOP**: Continuous workflow until quality gate met or max iterations reached
|
||||
8. **Progressive Loading**: Read phase doc ONLY when that phase is about to execute
|
||||
9. **Entry Point Routing**: `/workflow:test-fix-gen` → Phase 1 + Phase 2; `/workflow:test-cycle-execute` → Phase 2 only
|
||||
9. **Entry Point Routing**: `/workflow:test-fix-gen` → Phase 1-5; `/workflow:test-cycle-execute` → Phase 5 only
|
||||
|
||||
## Input Processing
|
||||
|
||||
@@ -130,7 +149,7 @@ User input → Detect type:
|
||||
└─ Otherwise → MODE=prompt, description=input
|
||||
```
|
||||
|
||||
### test-cycle-execute Entry (Phase 2 Only)
|
||||
### test-cycle-execute Entry (Phase 5 Only)
|
||||
```
|
||||
Arguments → Parse flags:
|
||||
├─ --resume-session="WFS-xxx" → sessionId=WFS-xxx
|
||||
@@ -145,20 +164,60 @@ User Input (session ID | description | file path)
|
||||
↓
|
||||
[Detect Mode: session | prompt]
|
||||
↓
|
||||
Phase 1: Test Generation ─────────────────────────────────────────
|
||||
↓ 1.1: session:start → testSessionId
|
||||
↓ 1.2: test-context-gather/context-gather → contextPath
|
||||
↓ 1.3: test-concept-enhanced → TEST_ANALYSIS_RESULTS.md
|
||||
↓ 1.4: test-task-generate → IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
|
||||
↓ 1.5: Summary with next step
|
||||
Phase 1: Session Start ─────────────────────────────────────────
|
||||
↓ 1.0+1.1: session:start → testSessionId, MODE
|
||||
↓
|
||||
Phase 2: Test Cycle Execution ────────────────────────────────────
|
||||
Phase 2: Test Context Gather ────────────────────────────────────
|
||||
↓ 1.2: test-context-gather/context-gather → contextPath
|
||||
↓
|
||||
Phase 3: Test Concept Enhanced ──────────────────────────────────
|
||||
↓ 1.3: test-concept-enhanced → TEST_ANALYSIS_RESULTS.md
|
||||
↓
|
||||
Phase 4: Test Task Generate ─────────────────────────────────────
|
||||
↓ 1.4: test-task-generate → IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
|
||||
↓
|
||||
Summary Output (inline) ─────────────────────────────────────────
|
||||
↓ Display summary with next step
|
||||
↓
|
||||
Phase 5: Test Cycle Execution ───────────────────────────────────
|
||||
↓ 2.1: Load session + tasks + iteration state
|
||||
↓ 2.2: Execute IMPL-001 → 001.3 → 001.5 → 002
|
||||
↓ 2.3: Fix loop (analyze → fix → retest) until pass_rate >= 95%
|
||||
↓ 2.4: Completion → summary → session archive
|
||||
```
|
||||
|
||||
## Summary Output (after Phase 4)
|
||||
|
||||
After Phase 4 completes, display the following summary before auto-continuing to Phase 5:
|
||||
|
||||
```
|
||||
Test-fix workflow created successfully!
|
||||
|
||||
Input: [original input]
|
||||
Mode: [Session|Prompt]
|
||||
Test Session: [testSessionId]
|
||||
|
||||
Tasks Created:
|
||||
- IMPL-001: Test Understanding & Generation (@code-developer)
|
||||
- IMPL-001.3: Code Validation Gate - AI Error Detection (@test-fix-agent)
|
||||
- IMPL-001.5: Test Quality Gate - Static Analysis & Coverage (@test-fix-agent)
|
||||
- IMPL-002: Test Execution & Fix Cycle (@test-fix-agent)
|
||||
|
||||
Quality Thresholds:
|
||||
- Code Validation: Zero CRITICAL issues, zero compilation errors
|
||||
- Minimum Coverage: 80% line, 70% branch
|
||||
- Static Analysis: Zero critical anti-patterns
|
||||
- Max Fix Iterations: 5
|
||||
|
||||
Review artifacts:
|
||||
- Test plan: .workflow/[testSessionId]/IMPL_PLAN.md
|
||||
- Task list: .workflow/[testSessionId]/TODO_LIST.md
|
||||
- Analysis: .workflow/[testSessionId]/.process/TEST_ANALYSIS_RESULTS.md
|
||||
```
|
||||
|
||||
**CRITICAL - Next Step**: Auto-continue to Phase 5: Test Cycle Execution.
|
||||
Pass `testSessionId` to Phase 5 for test execution pipeline. Do NOT wait for user confirmation — the unified pipeline continues automatically.
|
||||
|
||||
## Test Strategy Overview
|
||||
|
||||
Progressive Test Layers (L0-L3):
|
||||
@@ -177,7 +236,7 @@ Progressive Test Layers (L0-L3):
|
||||
- Pass Rate Gate: >= 95% (criticality-aware) or 100%
|
||||
- Max Fix Iterations: 10 (default, adjustable)
|
||||
|
||||
## Strategy Engine (Phase 2)
|
||||
## Strategy Engine (Phase 5)
|
||||
|
||||
| Strategy | Trigger | Behavior |
|
||||
|----------|---------|----------|
|
||||
@@ -185,16 +244,16 @@ Progressive Test Layers (L0-L3):
|
||||
| **Aggressive** | Pass rate >80% + similar failures | Batch fix related issues |
|
||||
| **Surgical** | Regression detected (pass rate drops >10%) | Minimal changes, rollback focus |
|
||||
|
||||
Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed in Phase 2.
|
||||
Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed in Phase 5.
|
||||
|
||||
## Agent Roles
|
||||
|
||||
| Agent | Used In | Responsibility |
|
||||
|-------|---------|---------------|
|
||||
| **Orchestrator** | Both phases | Route entry, track progress, pass context |
|
||||
| **@code-developer** | Phase 2 (IMPL-001) | Test generation (L1-L3) |
|
||||
| **@test-fix-agent** | Phase 2 | Test execution, code fixes, criticality assignment |
|
||||
| **@cli-planning-agent** | Phase 2 (fix loop) | CLI analysis, root cause extraction, fix task generation |
|
||||
| **Orchestrator** | All phases | Route entry, track progress, pass context |
|
||||
| **@code-developer** | Phase 5 (IMPL-001) | Test generation (L1-L3) |
|
||||
| **@test-fix-agent** | Phase 5 | Test execution, code fixes, criticality assignment |
|
||||
| **@cli-planning-agent** | Phase 5 (fix loop) | CLI analysis, root cause extraction, fix task generation |
|
||||
|
||||
## TodoWrite Pattern
|
||||
|
||||
@@ -206,25 +265,27 @@ Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed
|
||||
> - Sub-task attachment → `TaskCreate` + `TaskUpdate({ addBlockedBy })`
|
||||
> - Sub-task collapse → `TaskUpdate({ status: "completed" })` + `TaskUpdate({ status: "deleted" })` for collapsed sub-items
|
||||
|
||||
### Full Pipeline (Phase 1 + Phase 2)
|
||||
### Full Pipeline (Phase 1-5)
|
||||
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Test Generation", "status": "in_progress"},
|
||||
{"content": " → Create test session", "status": "in_progress"},
|
||||
{"content": " → Gather test context", "status": "pending"},
|
||||
{"content": " → Test analysis (Gemini)", "status": "pending"},
|
||||
{"content": " → Generate test tasks", "status": "pending"},
|
||||
{"content": "Phase 2: Test Cycle Execution", "status": "pending"}
|
||||
{"content": "Phase 1: Session Start", "status": "in_progress"},
|
||||
{"content": "Phase 2: Test Context Gather", "status": "pending"},
|
||||
{"content": "Phase 3: Test Analysis (Gemini)", "status": "pending"},
|
||||
{"content": "Phase 4: Test Task Generate", "status": "pending"},
|
||||
{"content": "Phase 5: Test Cycle Execution", "status": "pending"}
|
||||
]
|
||||
```
|
||||
|
||||
### Phase 1 Collapsed → Phase 2 Active
|
||||
### Phase 1-4 Collapsed → Phase 5 Active
|
||||
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Test Generation", "status": "completed"},
|
||||
{"content": "Phase 2: Test Cycle Execution", "status": "in_progress"},
|
||||
{"content": "Phase 1: Session Start", "status": "completed"},
|
||||
{"content": "Phase 2: Test Context Gather", "status": "completed"},
|
||||
{"content": "Phase 3: Test Analysis (Gemini)", "status": "completed"},
|
||||
{"content": "Phase 4: Test Task Generate", "status": "completed"},
|
||||
{"content": "Phase 5: Test Cycle Execution", "status": "in_progress"},
|
||||
{"content": " → Execute IMPL-001 [code-developer]", "status": "in_progress"},
|
||||
{"content": " → Execute IMPL-001.3 [test-fix-agent]", "status": "pending"},
|
||||
{"content": " → Execute IMPL-001.5 [test-fix-agent]", "status": "pending"},
|
||||
@@ -237,8 +298,8 @@ Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed
|
||||
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Test Generation", "status": "completed"},
|
||||
{"content": "Phase 2: Test Cycle Execution", "status": "in_progress"},
|
||||
{"content": "Phase 1-4: Test Generation", "status": "completed"},
|
||||
{"content": "Phase 5: Test Cycle Execution", "status": "in_progress"},
|
||||
{"content": " → Initial tasks", "status": "completed"},
|
||||
{"content": " → Iteration 1: Initial test (pass: 70%, conservative)", "status": "completed"},
|
||||
{"content": " → Iteration 2: Fix validation (pass: 82%, conservative)", "status": "completed"},
|
||||
@@ -258,7 +319,7 @@ Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed
|
||||
│ ├── IMPL-001.3-validation.json # Code validation gate
|
||||
│ ├── IMPL-001.5-review.json # Test quality gate
|
||||
│ ├── IMPL-002.json # Test execution & fix cycle
|
||||
│ └── IMPL-fix-{N}.json # Generated fix tasks (Phase 2 fix loop)
|
||||
│ └── IMPL-fix-{N}.json # Generated fix tasks (Phase 5 fix loop)
|
||||
├── .process/
|
||||
│ ├── [test-]context-package.json # Context and coverage analysis
|
||||
│ ├── TEST_ANALYSIS_RESULTS.md # Test requirements (L0-L3)
|
||||
@@ -274,17 +335,17 @@ Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Phase 1 (Generation)
|
||||
### Phase 1-4 (Generation)
|
||||
|
||||
| Step | Error Condition | Action |
|
||||
|------|----------------|--------|
|
||||
| Session create | Source session not found (session mode) | Return error with session ID |
|
||||
| Session create | No completed IMPL tasks (session mode) | Return error, source incomplete |
|
||||
| Context gather | Context gathering failed | Return error, check source artifacts |
|
||||
| Analysis | Gemini analysis failed | Return error, check context package |
|
||||
| Task gen | Task generation failed | Retry once, then return error |
|
||||
| Phase | Error Condition | Action |
|
||||
|-------|----------------|--------|
|
||||
| 1: Session Start | Source session not found (session mode) | Return error with session ID |
|
||||
| 1: Session Start | No completed IMPL tasks (session mode) | Return error, source incomplete |
|
||||
| 2: Context Gather | Context gathering failed | Return error, check source artifacts |
|
||||
| 3: Analysis | Gemini analysis failed | Return error, check context package |
|
||||
| 4: Task Gen | Task generation failed | Retry once, then return error |
|
||||
|
||||
### Phase 2 (Execution)
|
||||
### Phase 5 (Execution)
|
||||
|
||||
| Scenario | Action |
|
||||
|----------|--------|
|
||||
@@ -295,7 +356,7 @@ Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed
|
||||
| Regression detected | Rollback last fix, switch to surgical strategy |
|
||||
| Stuck tests detected | Continue with alternative strategy, document |
|
||||
|
||||
## Commit Strategy (Phase 2)
|
||||
## Commit Strategy (Phase 5)
|
||||
|
||||
Automatic commits at key checkpoints:
|
||||
1. **After successful iteration** (pass rate increased): `test-cycle: iteration N - strategy (pass: old% → new%)`
|
||||
@@ -315,16 +376,28 @@ After completion, ask user if they want to expand into issues (test/enhance/refa
|
||||
|
||||
## Coordinator Checklist
|
||||
|
||||
### Phase 1 (test-fix-gen)
|
||||
### Phase 1 (session-start)
|
||||
- [ ] Detect input type (session ID / description / file path)
|
||||
- [ ] Initialize TaskCreate before any execution
|
||||
- [ ] Read Phase 1 doc, execute all 5 internal steps
|
||||
- [ ] Read Phase 1 doc, execute Steps 1.0 + 1.1
|
||||
- [ ] Parse testSessionId from step output, store in memory
|
||||
- [ ] Verify all Phase 1 outputs (4 task JSONs, IMPL_PLAN.md, TODO_LIST.md)
|
||||
- [ ] Collapse Phase 1 tasks, auto-continue to Phase 2
|
||||
|
||||
### Phase 2 (test-cycle-execute)
|
||||
- [ ] Read Phase 2 doc
|
||||
### Phase 2 (test-context-gather)
|
||||
- [ ] Read Phase 2 doc, execute Step 1.2
|
||||
- [ ] Parse contextPath from step output, store in memory
|
||||
|
||||
### Phase 3 (test-concept-enhanced)
|
||||
- [ ] Read Phase 3 doc, execute Step 1.3
|
||||
- [ ] Verify TEST_ANALYSIS_RESULTS.md created
|
||||
|
||||
### Phase 4 (test-task-generate)
|
||||
- [ ] Read Phase 4 doc, execute Step 1.4
|
||||
- [ ] Verify all Phase 1-4 outputs (4 task JSONs, IMPL_PLAN.md, TODO_LIST.md)
|
||||
- [ ] Display Summary output (inline)
|
||||
- [ ] Collapse Phase 1-4 tasks, auto-continue to Phase 5
|
||||
|
||||
### Phase 5 (test-cycle-execute)
|
||||
- [ ] Read Phase 5 doc
|
||||
- [ ] Load session, tasks, iteration state
|
||||
- [ ] Execute initial tasks sequentially
|
||||
- [ ] Calculate pass rate from test-results.json
|
||||
@@ -340,14 +413,6 @@ After completion, ask user if they want to expand into issues (test/enhance/refa
|
||||
- `/workflow:plan` or `/workflow:execute` - Complete implementation (Session Mode source)
|
||||
- None for Prompt Mode
|
||||
|
||||
**Called During Execution**:
|
||||
- `/workflow:session:start` - Phase 1: Create test session
|
||||
- `/workflow:tools:test-context-gather` - Phase 1 (Session Mode)
|
||||
- `/workflow:tools:context-gather` - Phase 1 (Prompt Mode)
|
||||
- `/workflow:tools:test-concept-enhanced` - Phase 1: Gemini analysis
|
||||
- `/workflow:tools:test-task-generate` - Phase 1: Task generation
|
||||
- `/workflow:session:complete` - Phase 2: Archive session
|
||||
|
||||
**Follow-up Skills**:
|
||||
- `/workflow:status` - Review workflow state
|
||||
- `/workflow:review` - Post-implementation review
|
||||
|
||||
60
.claude/skills/workflow-test-fix/phases/01-session-start.md
Normal file
60
.claude/skills/workflow-test-fix/phases/01-session-start.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# Phase 1: Session Start (session-start)
|
||||
|
||||
Detect input mode and create test workflow session.
|
||||
|
||||
## Objective
|
||||
|
||||
- Detect input mode (session ID vs description)
|
||||
- Create test workflow session with appropriate metadata
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 1.0: Detect Input Mode
|
||||
|
||||
```
|
||||
// Automatic mode detection based on input pattern
|
||||
if (input.startsWith("WFS-")) {
|
||||
MODE = "session"
|
||||
// Load source session to preserve original task description
|
||||
Read(".workflow/active/[sourceSessionId]/workflow-session.json")
|
||||
} else {
|
||||
MODE = "prompt"
|
||||
}
|
||||
```
|
||||
|
||||
### Step 1.1: Create Test Session
|
||||
|
||||
```
|
||||
// Session Mode - preserve original task description
|
||||
Skill(skill="workflow:session:start", args="--type test --new \"Test validation for [sourceSessionId]: [originalTaskDescription]\"")
|
||||
|
||||
// Prompt Mode - use user's description directly
|
||||
Skill(skill="workflow:session:start", args="--type test --new \"Test generation for: [description]\"")
|
||||
```
|
||||
|
||||
**Parse Output**:
|
||||
- Extract: `SESSION_ID: WFS-test-[slug]` (store as `testSessionId`)
|
||||
|
||||
**Validation**:
|
||||
- Session Mode: Source session `.workflow/active/[sourceSessionId]/` exists with completed IMPL tasks
|
||||
- Both Modes: New test session directory created with metadata
|
||||
|
||||
**TodoWrite**: Mark step 1.1 completed, step 1.2 in_progress
|
||||
|
||||
### Session Metadata
|
||||
|
||||
**File**: `workflow-session.json`
|
||||
|
||||
| Mode | Fields |
|
||||
|------|--------|
|
||||
| **Session** | `type: "test"`, `source_session_id: "[sourceId]"` |
|
||||
| **Prompt** | `type: "test"` (no source_session_id) |
|
||||
|
||||
## Output
|
||||
|
||||
- **Variable**: `testSessionId` (WFS-test-xxx)
|
||||
- **Variable**: `MODE` (session | prompt)
|
||||
|
||||
## Next Phase
|
||||
|
||||
Continue to [Phase 2: Test Context Gather](02-test-context-gather.md).
|
||||
@@ -1,309 +0,0 @@
|
||||
# Phase 1: Test Fix Generation (test-fix-gen)
|
||||
|
||||
Create test-fix workflow session with progressive test layers (L0-L3), AI code validation, and test task generation. This phase runs 5 internal steps sequentially, calling existing sub-commands via Skill().
|
||||
|
||||
## Objective
|
||||
|
||||
- Detect input mode (session ID vs description)
|
||||
- Create test workflow session
|
||||
- Gather test context (coverage analysis or codebase scan)
|
||||
- Analyze test requirements with Gemini (L0-L3 layers)
|
||||
- Generate test task JSONs via action-planning-agent
|
||||
|
||||
## Test Strategy Overview
|
||||
|
||||
This workflow generates tests using **Progressive Test Layers (L0-L3)**:
|
||||
|
||||
| Layer | Name | Focus |
|
||||
|-------|------|-------|
|
||||
| **L0** | Static Analysis | Compilation, imports, types, AI code issues |
|
||||
| **L1** | Unit Tests | Function/class behavior (happy/negative/edge cases) |
|
||||
| **L2** | Integration Tests | Component interactions, API contracts, failure modes |
|
||||
| **L3** | E2E Tests | User journeys, critical paths (optional) |
|
||||
|
||||
**Key Features**:
|
||||
- **AI Code Issue Detection** - Validates against common AI-generated code problems (hallucinated imports, placeholder code, mock leakage, etc.)
|
||||
- **Project Type Detection** - Applies appropriate test templates (React, Node API, CLI, Library, etc.)
|
||||
- **Quality Gates** - IMPL-001.3 (code validation) and IMPL-001.5 (test quality) ensure high standards
|
||||
|
||||
**Detailed specifications**: See `/workflow:tools:test-task-generate` for complete L0-L3 requirements and quality thresholds.
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 1.0: Detect Input Mode
|
||||
|
||||
```
|
||||
// Automatic mode detection based on input pattern
|
||||
if (input.startsWith("WFS-")) {
|
||||
MODE = "session"
|
||||
// Load source session to preserve original task description
|
||||
Read(".workflow/active/[sourceSessionId]/workflow-session.json")
|
||||
} else {
|
||||
MODE = "prompt"
|
||||
}
|
||||
```
|
||||
|
||||
### Step 1.1: Create Test Session
|
||||
|
||||
```
|
||||
// Session Mode - preserve original task description
|
||||
Skill(skill="workflow:session:start", args="--type test --new \"Test validation for [sourceSessionId]: [originalTaskDescription]\"")
|
||||
|
||||
// Prompt Mode - use user's description directly
|
||||
Skill(skill="workflow:session:start", args="--type test --new \"Test generation for: [description]\"")
|
||||
```
|
||||
|
||||
**Parse Output**:
|
||||
- Extract: `SESSION_ID: WFS-test-[slug]` (store as `testSessionId`)
|
||||
|
||||
**Validation**:
|
||||
- Session Mode: Source session `.workflow/active/[sourceSessionId]/` exists with completed IMPL tasks
|
||||
- Both Modes: New test session directory created with metadata
|
||||
|
||||
**TodoWrite**: Mark step 1.1 completed, step 1.2 in_progress
|
||||
|
||||
### Step 1.2: Gather Test Context
|
||||
|
||||
```
|
||||
// Session Mode - gather from source session
|
||||
Skill(skill="workflow:tools:test-context-gather", args="--session [testSessionId]")
|
||||
|
||||
// Prompt Mode - gather from codebase
|
||||
Skill(skill="workflow:tools:context-gather", args="--session [testSessionId] \"[task_description]\"")
|
||||
```
|
||||
|
||||
**Input**: `testSessionId` from Step 1.1
|
||||
|
||||
**Parse Output**:
|
||||
- Extract: context package path (store as `contextPath`)
|
||||
- Pattern: `.workflow/active/[testSessionId]/.process/[test-]context-package.json`
|
||||
|
||||
**Validation**:
|
||||
- Context package file exists and is valid JSON
|
||||
- Contains coverage analysis (session mode) or codebase analysis (prompt mode)
|
||||
- Test framework detected
|
||||
|
||||
**TodoWrite Update (tasks attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Test Generation", "status": "in_progress"},
|
||||
{"content": " → Create test session", "status": "completed"},
|
||||
{"content": " → Gather test context", "status": "in_progress"},
|
||||
{"content": " → Load source/codebase context", "status": "in_progress"},
|
||||
{"content": " → Analyze test coverage", "status": "pending"},
|
||||
{"content": " → Generate context package", "status": "pending"},
|
||||
{"content": " → Test analysis (Gemini)", "status": "pending"},
|
||||
{"content": " → Generate test tasks", "status": "pending"},
|
||||
{"content": "Phase 2: Test Cycle Execution", "status": "pending"}
|
||||
]
|
||||
```
|
||||
|
||||
**TodoWrite Update (tasks collapsed)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Test Generation", "status": "in_progress"},
|
||||
{"content": " → Create test session", "status": "completed"},
|
||||
{"content": " → Gather test context", "status": "completed"},
|
||||
{"content": " → Test analysis (Gemini)", "status": "pending"},
|
||||
{"content": " → Generate test tasks", "status": "pending"},
|
||||
{"content": "Phase 2: Test Cycle Execution", "status": "pending"}
|
||||
]
|
||||
```
|
||||
|
||||
### Step 1.3: Test Generation Analysis
|
||||
|
||||
```
|
||||
Skill(skill="workflow:tools:test-concept-enhanced", args="--session [testSessionId] --context [contextPath]")
|
||||
```
|
||||
|
||||
**Input**:
|
||||
- `testSessionId` from Step 1.1
|
||||
- `contextPath` from Step 1.2
|
||||
|
||||
**Expected Behavior**:
|
||||
- Use Gemini to analyze coverage gaps
|
||||
- Detect project type and apply appropriate test templates
|
||||
- Generate **multi-layered test requirements** (L0-L3)
|
||||
- Scan for AI code issues
|
||||
- Generate `TEST_ANALYSIS_RESULTS.md`
|
||||
|
||||
**Output**: `.workflow/[testSessionId]/.process/TEST_ANALYSIS_RESULTS.md`
|
||||
|
||||
**Validation** - TEST_ANALYSIS_RESULTS.md must include:
|
||||
- Project Type Detection (with confidence)
|
||||
- Coverage Assessment (current vs target)
|
||||
- Test Framework & Conventions
|
||||
- Multi-Layered Test Plan (L0-L3)
|
||||
- AI Issue Scan Results
|
||||
- Test Requirements by File (with layer annotations)
|
||||
- Quality Assurance Criteria
|
||||
- Success Criteria
|
||||
|
||||
**Note**: Detailed specifications for project types, L0-L3 layers, and AI issue detection are defined in `/workflow:tools:test-concept-enhanced`.
|
||||
|
||||
### Step 1.4: Generate Test Tasks
|
||||
|
||||
```
|
||||
Skill(skill="workflow:tools:test-task-generate", args="--session [testSessionId]")
|
||||
```
|
||||
|
||||
**Input**: `testSessionId` from Step 1.1
|
||||
|
||||
**Note**: test-task-generate invokes action-planning-agent to generate test-specific IMPL_PLAN.md and task JSONs based on TEST_ANALYSIS_RESULTS.md.
|
||||
|
||||
**Expected Output** (minimum 4 tasks):
|
||||
|
||||
| Task | Type | Agent | Purpose |
|
||||
|------|------|-------|---------|
|
||||
| IMPL-001 | test-gen | @code-developer | Test understanding & generation (L1-L3) |
|
||||
| IMPL-001.3 | code-validation | @test-fix-agent | Code validation gate (L0 + AI issues) |
|
||||
| IMPL-001.5 | test-quality-review | @test-fix-agent | Test quality gate |
|
||||
| IMPL-002 | test-fix | @test-fix-agent | Test execution & fix cycle |
|
||||
|
||||
**Validation**:
|
||||
- `.workflow/active/[testSessionId]/.task/IMPL-001.json` exists
|
||||
- `.workflow/active/[testSessionId]/.task/IMPL-001.3-validation.json` exists
|
||||
- `.workflow/active/[testSessionId]/.task/IMPL-001.5-review.json` exists
|
||||
- `.workflow/active/[testSessionId]/.task/IMPL-002.json` exists
|
||||
- `.workflow/active/[testSessionId]/IMPL_PLAN.md` exists
|
||||
- `.workflow/active/[testSessionId]/TODO_LIST.md` exists
|
||||
|
||||
### Step 1.5: Return Summary
|
||||
|
||||
**Return to Orchestrator**:
|
||||
```
|
||||
Test-fix workflow created successfully!
|
||||
|
||||
Input: [original input]
|
||||
Mode: [Session|Prompt]
|
||||
Test Session: [testSessionId]
|
||||
|
||||
Tasks Created:
|
||||
- IMPL-001: Test Understanding & Generation (@code-developer)
|
||||
- IMPL-001.3: Code Validation Gate - AI Error Detection (@test-fix-agent)
|
||||
- IMPL-001.5: Test Quality Gate - Static Analysis & Coverage (@test-fix-agent)
|
||||
- IMPL-002: Test Execution & Fix Cycle (@test-fix-agent)
|
||||
|
||||
Quality Thresholds:
|
||||
- Code Validation: Zero CRITICAL issues, zero compilation errors
|
||||
- Minimum Coverage: 80% line, 70% branch
|
||||
- Static Analysis: Zero critical anti-patterns
|
||||
- Max Fix Iterations: 5
|
||||
|
||||
Review artifacts:
|
||||
- Test plan: .workflow/[testSessionId]/IMPL_PLAN.md
|
||||
- Task list: .workflow/[testSessionId]/TODO_LIST.md
|
||||
- Analysis: .workflow/[testSessionId]/.process/TEST_ANALYSIS_RESULTS.md
|
||||
```
|
||||
|
||||
**CRITICAL - Next Step**: Auto-continue to Phase 2: Test Cycle Execution.
|
||||
Pass `testSessionId` to Phase 2 for test execution pipeline. Do NOT wait for user confirmation — the unified pipeline continues automatically.
|
||||
|
||||
## Execution Flow Diagram
|
||||
|
||||
```
|
||||
User triggers: /workflow:test-fix-gen "Test user authentication"
|
||||
↓
|
||||
[Input Detection] → MODE: prompt
|
||||
↓
|
||||
[TodoWrite Init] Phase 1 sub-steps + Phase 2
|
||||
↓
|
||||
Step 1.1: Create Test Session
|
||||
→ /workflow:session:start --type test
|
||||
→ testSessionId extracted (WFS-test-user-auth)
|
||||
↓
|
||||
Step 1.2: Gather Test Context (Skill executed)
|
||||
→ ATTACH 3 sub-tasks: ← ATTACHED
|
||||
- → Load codebase context
|
||||
- → Analyze test coverage
|
||||
- → Generate context package
|
||||
→ Execute sub-tasks sequentially
|
||||
→ COLLAPSE tasks ← COLLAPSED
|
||||
→ contextPath extracted
|
||||
↓
|
||||
Step 1.3: Test Generation Analysis (Skill executed)
|
||||
→ ATTACH 3 sub-tasks: ← ATTACHED
|
||||
- → Analyze coverage gaps with Gemini
|
||||
- → Detect AI code issues (L0.5)
|
||||
- → Generate L0-L3 test requirements
|
||||
→ Execute sub-tasks sequentially
|
||||
→ COLLAPSE tasks ← COLLAPSED
|
||||
→ TEST_ANALYSIS_RESULTS.md created
|
||||
↓
|
||||
Step 1.4: Generate Test Tasks (Skill executed)
|
||||
→ Single agent task (test-task-generate → action-planning-agent)
|
||||
→ Agent autonomously generates:
|
||||
- IMPL-001.json (test generation)
|
||||
- IMPL-001.3-validation.json (code validation)
|
||||
- IMPL-001.5-review.json (test quality)
|
||||
- IMPL-002.json (test execution)
|
||||
- IMPL_PLAN.md
|
||||
- TODO_LIST.md
|
||||
↓
|
||||
Step 1.5: Return Summary
|
||||
→ Display summary
|
||||
→ Phase 1 complete
|
||||
```
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
### Directory Structure
|
||||
|
||||
```
|
||||
.workflow/active/WFS-test-[session]/
|
||||
├── workflow-session.json # Session metadata
|
||||
├── IMPL_PLAN.md # Test generation and execution strategy
|
||||
├── TODO_LIST.md # Task checklist
|
||||
├── .task/
|
||||
│ ├── IMPL-001.json # Test understanding & generation
|
||||
│ ├── IMPL-001.3-validation.json # Code validation gate
|
||||
│ ├── IMPL-001.5-review.json # Test quality gate
|
||||
│ ├── IMPL-002.json # Test execution & fix cycle
|
||||
│ └── IMPL-*.json # Additional tasks (if applicable)
|
||||
└── .process/
|
||||
├── [test-]context-package.json # Context and coverage analysis
|
||||
└── TEST_ANALYSIS_RESULTS.md # Test requirements and strategy (L0-L3)
|
||||
```
|
||||
|
||||
### Session Metadata
|
||||
|
||||
**File**: `workflow-session.json`
|
||||
|
||||
| Mode | Fields |
|
||||
|------|--------|
|
||||
| **Session** | `type: "test"`, `source_session_id: "[sourceId]"` |
|
||||
| **Prompt** | `type: "test"` (no source_session_id) |
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Step | Error Condition | Action |
|
||||
|------|----------------|--------|
|
||||
| 1.1 | Source session not found (session mode) | Return error with session ID |
|
||||
| 1.1 | No completed IMPL tasks (session mode) | Return error, source incomplete |
|
||||
| 1.2 | Context gathering failed | Return error, check source artifacts |
|
||||
| 1.3 | Gemini analysis failed | Return error, check context package |
|
||||
| 1.4 | Task generation failed | Retry once, then return error |
|
||||
|
||||
## Usage Examples
|
||||
|
||||
```bash
|
||||
# Session Mode - test validation for completed implementation
|
||||
/workflow:test-fix-gen WFS-user-auth-v2
|
||||
|
||||
# Prompt Mode - text description
|
||||
/workflow:test-fix-gen "Test the user authentication API endpoints in src/auth/api.ts"
|
||||
|
||||
# Prompt Mode - file reference
|
||||
/workflow:test-fix-gen ./docs/api-requirements.md
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
- **Variable**: `testSessionId` (WFS-test-xxx)
|
||||
- **Variable**: `contextPath` (context-package.json path)
|
||||
- **Files**: IMPL_PLAN.md, IMPL-*.json (4+), TODO_LIST.md, TEST_ANALYSIS_RESULTS.md
|
||||
- **TodoWrite**: Mark Phase 1 completed, Phase 2 in_progress
|
||||
|
||||
## Next Phase
|
||||
|
||||
Return to orchestrator, then auto-continue to [Phase 2: Test Cycle Execution](02-test-cycle-execute.md).
|
||||
@@ -0,0 +1,66 @@
|
||||
# Phase 2: Test Context Gather (test-context-gather)
|
||||
|
||||
Gather test context via coverage analysis or codebase scan.
|
||||
|
||||
## Objective
|
||||
|
||||
- Gather test context (coverage analysis or codebase scan)
|
||||
- Generate context package for downstream analysis
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 1.2: Gather Test Context
|
||||
|
||||
```
|
||||
// Session Mode - gather from source session
|
||||
Skill(skill="workflow:tools:test-context-gather", args="--session [testSessionId]")
|
||||
|
||||
// Prompt Mode - gather from codebase
|
||||
Skill(skill="workflow:tools:context-gather", args="--session [testSessionId] \"[task_description]\"")
|
||||
```
|
||||
|
||||
**Input**: `testSessionId` from Phase 1
|
||||
|
||||
**Parse Output**:
|
||||
- Extract: context package path (store as `contextPath`)
|
||||
- Pattern: `.workflow/active/[testSessionId]/.process/[test-]context-package.json`
|
||||
|
||||
**Validation**:
|
||||
- Context package file exists and is valid JSON
|
||||
- Contains coverage analysis (session mode) or codebase analysis (prompt mode)
|
||||
- Test framework detected
|
||||
|
||||
**TodoWrite Update (tasks attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Test Generation", "status": "in_progress"},
|
||||
{"content": " → Create test session", "status": "completed"},
|
||||
{"content": " → Gather test context", "status": "in_progress"},
|
||||
{"content": " → Load source/codebase context", "status": "in_progress"},
|
||||
{"content": " → Analyze test coverage", "status": "pending"},
|
||||
{"content": " → Generate context package", "status": "pending"},
|
||||
{"content": " → Test analysis (Gemini)", "status": "pending"},
|
||||
{"content": " → Generate test tasks", "status": "pending"},
|
||||
{"content": "Phase 2: Test Cycle Execution", "status": "pending"}
|
||||
]
|
||||
```
|
||||
|
||||
**TodoWrite Update (tasks collapsed)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Test Generation", "status": "in_progress"},
|
||||
{"content": " → Create test session", "status": "completed"},
|
||||
{"content": " → Gather test context", "status": "completed"},
|
||||
{"content": " → Test analysis (Gemini)", "status": "pending"},
|
||||
{"content": " → Generate test tasks", "status": "pending"},
|
||||
{"content": "Phase 2: Test Cycle Execution", "status": "pending"}
|
||||
]
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
- **Variable**: `contextPath` (context-package.json path)
|
||||
|
||||
## Next Phase
|
||||
|
||||
Continue to [Phase 3: Test Concept Enhanced](03-test-concept-enhanced.md).
|
||||
@@ -0,0 +1,51 @@
|
||||
# Phase 3: Test Concept Enhanced (test-concept-enhanced)
|
||||
|
||||
Analyze test requirements with Gemini using progressive L0-L3 test layers.
|
||||
|
||||
## Objective
|
||||
|
||||
- Use Gemini to analyze coverage gaps
|
||||
- Detect project type and apply appropriate test templates
|
||||
- Generate multi-layered test requirements (L0-L3)
|
||||
- Scan for AI code issues
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 1.3: Test Generation Analysis
|
||||
|
||||
```
|
||||
Skill(skill="workflow:tools:test-concept-enhanced", args="--session [testSessionId] --context [contextPath]")
|
||||
```
|
||||
|
||||
**Input**:
|
||||
- `testSessionId` from Phase 1
|
||||
- `contextPath` from Phase 2
|
||||
|
||||
**Expected Behavior**:
|
||||
- Use Gemini to analyze coverage gaps
|
||||
- Detect project type and apply appropriate test templates
|
||||
- Generate **multi-layered test requirements** (L0-L3)
|
||||
- Scan for AI code issues
|
||||
- Generate `TEST_ANALYSIS_RESULTS.md`
|
||||
|
||||
**Output**: `.workflow/[testSessionId]/.process/TEST_ANALYSIS_RESULTS.md`
|
||||
|
||||
**Validation** - TEST_ANALYSIS_RESULTS.md must include:
|
||||
- Project Type Detection (with confidence)
|
||||
- Coverage Assessment (current vs target)
|
||||
- Test Framework & Conventions
|
||||
- Multi-Layered Test Plan (L0-L3)
|
||||
- AI Issue Scan Results
|
||||
- Test Requirements by File (with layer annotations)
|
||||
- Quality Assurance Criteria
|
||||
- Success Criteria
|
||||
|
||||
**Note**: Detailed specifications for project types, L0-L3 layers, and AI issue detection are defined in `/workflow:tools:test-concept-enhanced`.
|
||||
|
||||
## Output
|
||||
|
||||
- **File**: `.workflow/[testSessionId]/.process/TEST_ANALYSIS_RESULTS.md`
|
||||
|
||||
## Next Phase
|
||||
|
||||
Continue to [Phase 4: Test Task Generate](04-test-task-generate.md).
|
||||
@@ -0,0 +1,46 @@
|
||||
# Phase 4: Test Task Generate (test-task-generate)
|
||||
|
||||
Generate test task JSONs via action-planning-agent.
|
||||
|
||||
## Objective
|
||||
|
||||
- Generate test-specific IMPL_PLAN.md and task JSONs based on TEST_ANALYSIS_RESULTS.md
|
||||
- Create minimum 4 tasks covering test generation, code validation, quality review, and test execution
|
||||
|
||||
## Execution
|
||||
|
||||
### Step 1.4: Generate Test Tasks
|
||||
|
||||
```
|
||||
Skill(skill="workflow:tools:test-task-generate", args="--session [testSessionId]")
|
||||
```
|
||||
|
||||
**Input**: `testSessionId` from Phase 1
|
||||
|
||||
**Note**: test-task-generate invokes action-planning-agent to generate test-specific IMPL_PLAN.md and task JSONs based on TEST_ANALYSIS_RESULTS.md.
|
||||
|
||||
**Expected Output** (minimum 4 tasks):
|
||||
|
||||
| Task | Type | Agent | Purpose |
|
||||
|------|------|-------|---------|
|
||||
| IMPL-001 | test-gen | @code-developer | Test understanding & generation (L1-L3) |
|
||||
| IMPL-001.3 | code-validation | @test-fix-agent | Code validation gate (L0 + AI issues) |
|
||||
| IMPL-001.5 | test-quality-review | @test-fix-agent | Test quality gate |
|
||||
| IMPL-002 | test-fix | @test-fix-agent | Test execution & fix cycle |
|
||||
|
||||
**Validation**:
|
||||
- `.workflow/active/[testSessionId]/.task/IMPL-001.json` exists
|
||||
- `.workflow/active/[testSessionId]/.task/IMPL-001.3-validation.json` exists
|
||||
- `.workflow/active/[testSessionId]/.task/IMPL-001.5-review.json` exists
|
||||
- `.workflow/active/[testSessionId]/.task/IMPL-002.json` exists
|
||||
- `.workflow/active/[testSessionId]/IMPL_PLAN.md` exists
|
||||
- `.workflow/active/[testSessionId]/TODO_LIST.md` exists
|
||||
|
||||
## Output
|
||||
|
||||
- **Files**: IMPL_PLAN.md, IMPL-*.json (4+), TODO_LIST.md
|
||||
- **TodoWrite**: Mark Phase 1-4 completed, Phase 5 in_progress
|
||||
|
||||
## Next Phase
|
||||
|
||||
Return to orchestrator for summary output, then auto-continue to [Phase 5: Test Cycle Execute](05-test-cycle-execute.md).
|
||||
@@ -53,7 +53,7 @@ Load session, tasks, and iteration state.
|
||||
└─ Load session, tasks, iteration state
|
||||
```
|
||||
|
||||
**For full-pipeline entry (from Phase 1)**: Use `testSessionId` passed from Phase 1.
|
||||
**For full-pipeline entry (from Phase 1-4)**: Use `testSessionId` passed from Phase 4.
|
||||
|
||||
**For direct entry (/workflow:test-cycle-execute)**:
|
||||
- `--resume-session="WFS-xxx"` → Use specified session
|
||||
@@ -526,7 +526,7 @@ The orchestrator automatically creates git commits at key checkpoints to enable
|
||||
- **Variable**: `finalPassRate` (percentage)
|
||||
- **File**: `test-results.json` (final results)
|
||||
- **File**: `iteration-state.json` (full iteration history)
|
||||
- **TodoWrite**: Mark Phase 2 completed
|
||||
- **TodoWrite**: Mark Phase 5 completed
|
||||
|
||||
## Next Phase
|
||||
|
||||
@@ -31,6 +31,7 @@ interface FlowchartNodeData extends Record<string, unknown> {
|
||||
type: 'pre-analysis' | 'implementation' | 'section';
|
||||
dependsOn?: string[];
|
||||
status?: 'pending' | 'in_progress' | 'completed' | 'blocked' | 'skipped';
|
||||
showStepStatus?: boolean;
|
||||
}
|
||||
|
||||
// Status icon component
|
||||
|
||||
@@ -11,7 +11,7 @@ import { Badge } from '../ui/Badge';
|
||||
import { Button } from '../ui/Button';
|
||||
import { Tabs, TabsList, TabsTrigger, TabsContent } from '../ui/Tabs';
|
||||
import type { NormalizedTask, LiteTask } from '@/lib/api';
|
||||
import { buildFlowControl } from '@/lib/api';
|
||||
import { buildFlowControl, normalizeTask } from '@/lib/api';
|
||||
import type { TaskData } from '@/types/store';
|
||||
|
||||
// ========== Types ==========
|
||||
@@ -86,8 +86,11 @@ export function TaskDrawer({ task, isOpen, onClose }: TaskDrawerProps) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Use NormalizedTask fields (works for both old nested and new flat formats)
|
||||
const nt = task as NormalizedTask;
|
||||
// Normalize task to unified flat format (handles old nested, new flat, and raw LiteTask/TaskData)
|
||||
const nt = React.useMemo(
|
||||
() => normalizeTask(task as unknown as Record<string, unknown>),
|
||||
[task],
|
||||
);
|
||||
const taskId = nt.task_id || 'N/A';
|
||||
const taskTitle = nt.title || 'Untitled Task';
|
||||
const taskDescription = nt.description;
|
||||
@@ -103,6 +106,13 @@ export function TaskDrawer({ task, isOpen, onClose }: TaskDrawerProps) {
|
||||
const taskFiles = nt.files || flowControl?.target_files || [];
|
||||
const taskScope = nt.scope;
|
||||
|
||||
// Detect if task supports status tracking (new format has explicit status/status_history)
|
||||
const rawData = nt._raw as Record<string, unknown> | undefined;
|
||||
const sourceRaw = (rawData?._raw as Record<string, unknown>) || rawData;
|
||||
const hasStatusTracking = sourceRaw
|
||||
? (sourceRaw.status !== undefined || sourceRaw.status_history !== undefined)
|
||||
: false;
|
||||
|
||||
const statusConfig = taskStatusConfig[taskStatus] || taskStatusConfig.pending;
|
||||
const StatusIcon = statusConfig.icon;
|
||||
|
||||
@@ -135,10 +145,12 @@ export function TaskDrawer({ task, isOpen, onClose }: TaskDrawerProps) {
|
||||
<div className="flex-1 min-w-0 mr-4">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<span className="inline-flex items-center px-2 py-0.5 rounded text-xs font-mono font-semibold bg-primary/10 text-primary border border-primary/20">{taskId}</span>
|
||||
{hasStatusTracking && (
|
||||
<Badge variant={statusConfig.variant} className="gap-1">
|
||||
<StatusIcon className="h-3 w-3" />
|
||||
{formatMessage({ id: statusConfig.label })}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
<h2 id="drawer-title" className="text-lg font-semibold text-foreground">
|
||||
{taskTitle}
|
||||
@@ -352,9 +364,9 @@ export function TaskDrawer({ task, isOpen, onClose }: TaskDrawerProps) {
|
||||
|
||||
{/* Empty State */}
|
||||
{!taskDescription &&
|
||||
!(task as LiteTask).meta?.scope &&
|
||||
!((task as LiteTask).context?.acceptance?.length) &&
|
||||
!((task as LiteTask).context?.focus_paths?.length) &&
|
||||
!taskScope &&
|
||||
!acceptanceCriteria.length &&
|
||||
!focusPaths.length &&
|
||||
!(flowControl?.pre_analysis?.length) &&
|
||||
!(flowControl?.implementation_approach?.length) && (
|
||||
<div className="text-center py-12">
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// ========================================
|
||||
// BottomInspector Component
|
||||
// ========================================
|
||||
// Collapsible bottom panel showing the full association chain
|
||||
// (Issue -> Queue -> Session) for the currently selected entity.
|
||||
// Consumes issueQueueIntegrationStore for association chain data
|
||||
// and useAssociationHighlight context for the highlighted chain.
|
||||
// Association chain visualization (Issue -> Queue -> Session).
|
||||
// Exports InspectorContent (pure content) for embedding in BottomPanel,
|
||||
// and BottomInspector (legacy standalone collapsible wrapper).
|
||||
|
||||
import { useState, useCallback, useMemo } from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
@@ -90,7 +89,86 @@ function formatTimestamp(ts: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
// ========== Main Component ==========
|
||||
// ========== InspectorContent (Pure content, no collapsible wrapper) ==========
|
||||
|
||||
export function InspectorContent() {
|
||||
const { formatMessage } = useIntl();
|
||||
const associationChain = useIssueQueueIntegrationStore(selectAssociationChain);
|
||||
const { chain: highlightedChain } = useAssociationHighlight();
|
||||
|
||||
const activeChain = highlightedChain ?? associationChain;
|
||||
|
||||
const chainDetails = useMemo(() => {
|
||||
if (!activeChain) return null;
|
||||
|
||||
const executions = Object.values(useQueueExecutionStore.getState().executions);
|
||||
const sessions = useCliSessionStore.getState().sessions;
|
||||
|
||||
let queueStatus: string | undefined;
|
||||
let executionTimestamp: string | undefined;
|
||||
if (activeChain.queueItemId) {
|
||||
const exec = executions.find((e) => e.queueItemId === activeChain.queueItemId);
|
||||
if (exec) {
|
||||
queueStatus = exec.status;
|
||||
executionTimestamp = exec.startedAt;
|
||||
}
|
||||
}
|
||||
|
||||
let sessionStatus: string | undefined;
|
||||
let sessionTimestamp: string | undefined;
|
||||
if (activeChain.sessionId) {
|
||||
const session = sessions[activeChain.sessionId];
|
||||
if (session) {
|
||||
sessionStatus = 'active';
|
||||
sessionTimestamp = session.createdAt;
|
||||
}
|
||||
}
|
||||
|
||||
return { queueStatus, executionTimestamp, sessionStatus, sessionTimestamp };
|
||||
}, [activeChain]);
|
||||
|
||||
const hasChain = activeChain !== null;
|
||||
|
||||
return (
|
||||
<div className="h-full overflow-y-auto px-4 py-3">
|
||||
{hasChain ? (
|
||||
<div className="space-y-2">
|
||||
<p className="text-xs font-medium text-muted-foreground">
|
||||
{formatMessage({ id: 'terminalDashboard.inspector.associationChain' })}
|
||||
</p>
|
||||
<div className="flex items-center gap-1 flex-wrap">
|
||||
<ChainNode
|
||||
icon={AlertCircle}
|
||||
label="Issue"
|
||||
entityId={activeChain.issueId}
|
||||
/>
|
||||
<ChainNode
|
||||
icon={ListChecks}
|
||||
label="Queue"
|
||||
entityId={activeChain.queueItemId}
|
||||
status={chainDetails?.queueStatus}
|
||||
timestamp={chainDetails?.executionTimestamp}
|
||||
/>
|
||||
<ChainNode
|
||||
icon={Terminal}
|
||||
label="Session"
|
||||
entityId={activeChain.sessionId}
|
||||
status={chainDetails?.sessionStatus}
|
||||
timestamp={chainDetails?.sessionTimestamp}
|
||||
isLast
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{formatMessage({ id: 'terminalDashboard.inspector.noSelection' })}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ========== Legacy Standalone Component ==========
|
||||
|
||||
export function BottomInspector() {
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
136
ccw/frontend/src/components/terminal-dashboard/BottomPanel.tsx
Normal file
136
ccw/frontend/src/components/terminal-dashboard/BottomPanel.tsx
Normal file
@@ -0,0 +1,136 @@
|
||||
// ========================================
|
||||
// BottomPanel Component
|
||||
// ========================================
|
||||
// Full-width collapsible bottom panel with Queue + Inspector tabs.
|
||||
// Replaces the separate BottomInspector + middle-column QueuePanel layout.
|
||||
// Queue tab shows inline count badge; Inspector tab shows chain indicator.
|
||||
|
||||
import { useState, useCallback, useMemo } from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { ListChecks, Info, ChevronDown, ChevronUp } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Badge } from '@/components/ui/Badge';
|
||||
import { QueuePanel } from './QueuePanel';
|
||||
import { InspectorContent } from './BottomInspector';
|
||||
import { useIssueQueue } from '@/hooks/useIssues';
|
||||
import {
|
||||
useIssueQueueIntegrationStore,
|
||||
selectAssociationChain,
|
||||
} from '@/stores/issueQueueIntegrationStore';
|
||||
|
||||
// ========== Types ==========
|
||||
|
||||
type TabId = 'queue' | 'inspector';
|
||||
|
||||
// ========== Component ==========
|
||||
|
||||
export function BottomPanel() {
|
||||
const { formatMessage } = useIntl();
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [activeTab, setActiveTab] = useState<TabId>('queue');
|
||||
|
||||
const queueQuery = useIssueQueue();
|
||||
const associationChain = useIssueQueueIntegrationStore(selectAssociationChain);
|
||||
|
||||
// Count queue items for badge
|
||||
const queueCount = useMemo(() => {
|
||||
if (!queueQuery.data) return 0;
|
||||
const grouped = queueQuery.data.grouped_items ?? {};
|
||||
let count = 0;
|
||||
for (const items of Object.values(grouped)) {
|
||||
count += items.length;
|
||||
}
|
||||
return count;
|
||||
}, [queueQuery.data]);
|
||||
|
||||
const hasChain = associationChain !== null;
|
||||
|
||||
const toggle = useCallback(() => {
|
||||
setIsOpen((prev) => !prev);
|
||||
}, []);
|
||||
|
||||
const handleTabClick = useCallback((tab: TabId) => {
|
||||
setActiveTab(tab);
|
||||
setIsOpen(true);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'border-t border-border bg-muted/30 shrink-0 transition-all duration-200',
|
||||
)}
|
||||
>
|
||||
{/* Tab bar (always visible, ~36px) */}
|
||||
<div className="flex items-center gap-0 shrink-0">
|
||||
{/* Queue tab */}
|
||||
<button
|
||||
onClick={() => handleTabClick('queue')}
|
||||
className={cn(
|
||||
'flex items-center gap-1.5 px-3 py-1.5 text-xs transition-colors border-b-2',
|
||||
activeTab === 'queue' && isOpen
|
||||
? 'border-b-primary text-foreground font-medium'
|
||||
: 'border-b-transparent text-muted-foreground hover:text-foreground',
|
||||
)}
|
||||
>
|
||||
<ListChecks className="w-3.5 h-3.5" />
|
||||
{formatMessage({ id: 'terminalDashboard.bottomPanel.queueTab' })}
|
||||
{queueCount > 0 && (
|
||||
<Badge variant="info" className="text-[10px] px-1.5 py-0 ml-0.5">
|
||||
{queueCount}
|
||||
</Badge>
|
||||
)}
|
||||
</button>
|
||||
|
||||
{/* Inspector tab */}
|
||||
<button
|
||||
onClick={() => handleTabClick('inspector')}
|
||||
className={cn(
|
||||
'flex items-center gap-1.5 px-3 py-1.5 text-xs transition-colors border-b-2',
|
||||
activeTab === 'inspector' && isOpen
|
||||
? 'border-b-primary text-foreground font-medium'
|
||||
: 'border-b-transparent text-muted-foreground hover:text-foreground',
|
||||
)}
|
||||
>
|
||||
<Info className="w-3.5 h-3.5" />
|
||||
{formatMessage({ id: 'terminalDashboard.bottomPanel.inspectorTab' })}
|
||||
{hasChain && (
|
||||
<span className="ml-1 w-2 h-2 rounded-full bg-primary shrink-0" />
|
||||
)}
|
||||
</button>
|
||||
|
||||
{/* Collapse/expand toggle at right */}
|
||||
<button
|
||||
onClick={toggle}
|
||||
className="ml-auto px-3 py-1.5 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={formatMessage({
|
||||
id: isOpen
|
||||
? 'terminalDashboard.bottomPanel.collapse'
|
||||
: 'terminalDashboard.bottomPanel.expand',
|
||||
})}
|
||||
>
|
||||
{isOpen ? (
|
||||
<ChevronDown className="w-3.5 h-3.5" />
|
||||
) : (
|
||||
<ChevronUp className="w-3.5 h-3.5" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Collapsible content area */}
|
||||
<div
|
||||
className={cn(
|
||||
'overflow-hidden transition-all duration-200',
|
||||
isOpen ? 'max-h-[280px] opacity-100' : 'max-h-0 opacity-0',
|
||||
)}
|
||||
>
|
||||
<div className="h-[280px] border-t border-border/50">
|
||||
{activeTab === 'queue' ? (
|
||||
<QueuePanel embedded />
|
||||
) : (
|
||||
<InspectorContent />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -131,12 +131,23 @@ function QueueItemRow({
|
||||
|
||||
// ========== Empty State ==========
|
||||
|
||||
function QueueEmptyState() {
|
||||
function QueueEmptyState({ compact = false }: { compact?: boolean }) {
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
if (compact) {
|
||||
return (
|
||||
<div className="flex items-center gap-2 text-muted-foreground px-3 py-2">
|
||||
<ListChecks className="h-4 w-4 opacity-30 shrink-0" />
|
||||
<span className="text-xs">{formatMessage({ id: 'terminalDashboard.queuePanel.noItems' })}</span>
|
||||
<span className="text-[10px] opacity-70">{formatMessage({ id: 'terminalDashboard.queuePanel.noItemsDesc' })}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex items-center justify-center text-muted-foreground p-4">
|
||||
<div className="text-center">
|
||||
<ListChecks className="h-10 w-10 mx-auto mb-3 opacity-40" />
|
||||
<ListChecks className="h-6 w-6 mx-auto mb-1.5 opacity-30" />
|
||||
<p className="text-sm">{formatMessage({ id: 'terminalDashboard.queuePanel.noItems' })}</p>
|
||||
<p className="text-xs mt-1 opacity-70">
|
||||
{formatMessage({ id: 'terminalDashboard.queuePanel.noItemsDesc' })}
|
||||
@@ -163,7 +174,7 @@ function QueueErrorState({ error }: { error: Error }) {
|
||||
|
||||
// ========== Main Component ==========
|
||||
|
||||
export function QueuePanel() {
|
||||
export function QueuePanel({ embedded = false }: { embedded?: boolean }) {
|
||||
const { formatMessage } = useIntl();
|
||||
const queueQuery = useIssueQueue();
|
||||
const associationChain = useIssueQueueIntegrationStore(selectAssociationChain);
|
||||
@@ -200,12 +211,14 @@ export function QueuePanel() {
|
||||
if (queueQuery.isLoading) {
|
||||
return (
|
||||
<div className="flex flex-col h-full">
|
||||
{!embedded && (
|
||||
<div className="px-3 py-2 border-b border-border shrink-0">
|
||||
<h3 className="text-sm font-semibold flex items-center gap-2">
|
||||
<ListChecks className="w-4 h-4" />
|
||||
{formatMessage({ id: 'terminalDashboard.queuePanel.title' })}
|
||||
</h3>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex-1 flex items-center justify-center">
|
||||
<Loader2 className="w-5 h-5 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
@@ -217,12 +230,14 @@ export function QueuePanel() {
|
||||
if (queueQuery.error) {
|
||||
return (
|
||||
<div className="flex flex-col h-full">
|
||||
{!embedded && (
|
||||
<div className="px-3 py-2 border-b border-border shrink-0">
|
||||
<h3 className="text-sm font-semibold flex items-center gap-2">
|
||||
<ListChecks className="w-4 h-4" />
|
||||
{formatMessage({ id: 'terminalDashboard.queuePanel.title' })}
|
||||
</h3>
|
||||
</div>
|
||||
)}
|
||||
<QueueErrorState error={queueQuery.error} />
|
||||
</div>
|
||||
);
|
||||
@@ -230,7 +245,8 @@ export function QueuePanel() {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-full">
|
||||
{/* Header with flow indicator */}
|
||||
{/* Header with flow indicator (hidden when embedded) */}
|
||||
{!embedded && (
|
||||
<div className="px-3 py-2 border-b border-border shrink-0 flex items-center justify-between">
|
||||
<h3 className="text-sm font-semibold flex items-center gap-2">
|
||||
<ArrowDownToLine className="w-4 h-4 text-muted-foreground" />
|
||||
@@ -243,10 +259,11 @@ export function QueuePanel() {
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Queue Item List */}
|
||||
{allItems.length === 0 ? (
|
||||
<QueueEmptyState />
|
||||
<QueueEmptyState compact={embedded} />
|
||||
) : (
|
||||
<div className="flex-1 min-h-0 overflow-y-auto p-1.5 space-y-0.5">
|
||||
{allItems.map((item) => (
|
||||
|
||||
@@ -2062,6 +2062,7 @@ export function normalizeTask(raw: Record<string, unknown>): NormalizedTask {
|
||||
const rawFlowControl = raw.flow_control as FlowControl | undefined;
|
||||
const rawMeta = raw.meta as LiteTask['meta'] | undefined;
|
||||
const rawConvergence = raw.convergence as NormalizedTask['convergence'] | undefined;
|
||||
const rawModPoints = raw.modification_points as Array<{ file?: string; target?: string; change?: string }> | undefined;
|
||||
|
||||
// Description: new flat field first, then join old context.requirements, then old details/scope
|
||||
const rawRequirements = rawContext?.requirements;
|
||||
@@ -2075,6 +2076,25 @@ export function normalizeTask(raw: Record<string, unknown>): NormalizedTask {
|
||||
: undefined)
|
||||
|| (raw.scope as string | undefined);
|
||||
|
||||
// Normalize files: new flat files > flow_control.target_files > modification_points
|
||||
const normalizedFiles = normalizeFilesField(raw.files)
|
||||
|| rawFlowControl?.target_files
|
||||
|| (rawModPoints?.length
|
||||
? rawModPoints.filter(m => m.file).map(m => ({ path: m.file!, name: m.target, change: m.change }))
|
||||
: undefined);
|
||||
|
||||
// Normalize focus_paths: top-level > context > files paths
|
||||
const focusPaths = (raw.focus_paths as string[])
|
||||
|| rawContext?.focus_paths
|
||||
|| (normalizedFiles?.length ? normalizedFiles.map(f => f.path).filter(Boolean) : undefined)
|
||||
|| [];
|
||||
|
||||
// Normalize acceptance: convergence > context.acceptance > top-level acceptance
|
||||
const rawAcceptance = raw.acceptance as string[] | undefined;
|
||||
const convergence = rawConvergence
|
||||
|| (rawContext?.acceptance?.length ? { criteria: rawContext.acceptance } : undefined)
|
||||
|| (rawAcceptance?.length ? { criteria: rawAcceptance } : undefined);
|
||||
|
||||
return {
|
||||
// Identity
|
||||
task_id: (raw.task_id as string) || (raw.id as string) || 'N/A',
|
||||
@@ -2089,15 +2109,13 @@ export function normalizeTask(raw: Record<string, unknown>): NormalizedTask {
|
||||
|
||||
// Promoted from context (new first, old fallback)
|
||||
depends_on: (raw.depends_on as string[]) || rawContext?.depends_on || [],
|
||||
focus_paths: (raw.focus_paths as string[]) || rawContext?.focus_paths || [],
|
||||
convergence: rawConvergence || (rawContext?.acceptance?.length
|
||||
? { criteria: rawContext.acceptance }
|
||||
: undefined),
|
||||
focus_paths: focusPaths,
|
||||
convergence,
|
||||
|
||||
// Promoted from flow_control (new first, old fallback)
|
||||
pre_analysis: (raw.pre_analysis as PreAnalysisStep[]) || rawFlowControl?.pre_analysis,
|
||||
implementation: (raw.implementation as (ImplementationStep | string)[]) || rawFlowControl?.implementation_approach,
|
||||
files: normalizeFilesField(raw.files) || rawFlowControl?.target_files,
|
||||
files: normalizedFiles,
|
||||
|
||||
// Promoted from meta (new first, old fallback)
|
||||
type: (raw.type as string) || rawMeta?.type,
|
||||
|
||||
@@ -2,49 +2,73 @@
|
||||
// Terminal Dashboard Page
|
||||
// ========================================
|
||||
// Three-column Allotment layout for terminal execution management.
|
||||
// Left: session groups + agent list
|
||||
// Middle: issue + queue workflow panels
|
||||
// Right: terminal workbench
|
||||
// Top: GlobalKpiBar (real component)
|
||||
// Bottom: BottomInspector (collapsible, real component)
|
||||
// Left: session groups + agent list (with active session count badge)
|
||||
// Middle: full-height IssuePanel
|
||||
// Right: terminal workbench (or issue detail preview)
|
||||
// Bottom: collapsible BottomPanel (Queue + Inspector tabs)
|
||||
// Cross-cutting: AssociationHighlightProvider wraps the layout
|
||||
|
||||
import { useMemo } from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { Allotment } from 'allotment';
|
||||
import 'allotment/dist/style.css';
|
||||
import { FolderTree } from 'lucide-react';
|
||||
import { FolderTree, Activity } from 'lucide-react';
|
||||
import { SessionGroupTree } from '@/components/terminal-dashboard/SessionGroupTree';
|
||||
import { AgentList } from '@/components/terminal-dashboard/AgentList';
|
||||
import { IssuePanel } from '@/components/terminal-dashboard/IssuePanel';
|
||||
import { QueuePanel } from '@/components/terminal-dashboard/QueuePanel';
|
||||
import { TerminalWorkbench } from '@/components/terminal-dashboard/TerminalWorkbench';
|
||||
import { GlobalKpiBar } from '@/components/terminal-dashboard/GlobalKpiBar';
|
||||
import { BottomInspector } from '@/components/terminal-dashboard/BottomInspector';
|
||||
import { BottomPanel } from '@/components/terminal-dashboard/BottomPanel';
|
||||
import { AssociationHighlightProvider } from '@/components/terminal-dashboard/AssociationHighlight';
|
||||
import { Badge } from '@/components/ui/Badge';
|
||||
import {
|
||||
useSessionManagerStore,
|
||||
selectGroups,
|
||||
selectTerminalMetas,
|
||||
} from '@/stores/sessionManagerStore';
|
||||
import type { TerminalStatus } from '@/types/terminal-dashboard';
|
||||
|
||||
// ========== Main Page Component ==========
|
||||
|
||||
export function TerminalDashboardPage() {
|
||||
const { formatMessage } = useIntl();
|
||||
const groups = useSessionManagerStore(selectGroups);
|
||||
const terminalMetas = useSessionManagerStore(selectTerminalMetas);
|
||||
|
||||
// Active session count for left column header badge
|
||||
const sessionCount = useMemo(() => {
|
||||
const allSessionIds = groups.flatMap((g) => g.sessionIds);
|
||||
let activeCount = 0;
|
||||
for (const sid of allSessionIds) {
|
||||
const meta = terminalMetas[sid];
|
||||
const status: TerminalStatus = meta?.status ?? 'idle';
|
||||
if (status === 'active') {
|
||||
activeCount++;
|
||||
}
|
||||
}
|
||||
return activeCount > 0 ? activeCount : allSessionIds.length;
|
||||
}, [groups, terminalMetas]);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-[calc(100vh-56px)] overflow-hidden">
|
||||
{/* GlobalKpiBar at top (flex-shrink-0) */}
|
||||
<GlobalKpiBar />
|
||||
|
||||
{/* AssociationHighlightProvider wraps the three-column layout + bottom inspector */}
|
||||
{/* AssociationHighlightProvider wraps the three-column layout + bottom panel */}
|
||||
<AssociationHighlightProvider>
|
||||
{/* Three-column Allotment layout (flex-1) */}
|
||||
<div className="flex-1 min-h-0">
|
||||
<Allotment proportionalLayout={true}>
|
||||
{/* Left column: Sessions */}
|
||||
<Allotment.Pane preferredSize={250} minSize={180} maxSize={400}>
|
||||
{/* Left column: Sessions + Agents */}
|
||||
<Allotment.Pane preferredSize={220} minSize={180} maxSize={320}>
|
||||
<div className="h-full border-r border-border bg-background flex flex-col">
|
||||
<div className="px-3 py-2 border-b border-border shrink-0">
|
||||
<div className="px-3 py-2 border-b border-border shrink-0 flex items-center justify-between">
|
||||
<h2 className="text-sm font-semibold flex items-center gap-2">
|
||||
<FolderTree className="w-4 h-4" />
|
||||
{formatMessage({ id: 'terminalDashboard.columns.sessions' })}
|
||||
</h2>
|
||||
{sessionCount > 0 && (
|
||||
<Badge variant="secondary" className="text-[10px] px-1.5 py-0 flex items-center gap-1">
|
||||
<Activity className="w-3 h-3" />
|
||||
{sessionCount}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
{/* SessionGroupTree takes remaining space */}
|
||||
<div className="flex-1 min-h-0 overflow-y-auto">
|
||||
@@ -57,25 +81,12 @@ export function TerminalDashboardPage() {
|
||||
</div>
|
||||
</Allotment.Pane>
|
||||
|
||||
{/* Middle column: Workflow (IssuePanel + QueuePanel vertical split) */}
|
||||
<Allotment.Pane minSize={300}>
|
||||
{/* Middle column: Full-height IssuePanel */}
|
||||
<Allotment.Pane minSize={280}>
|
||||
<div className="h-full border-r border-border bg-background overflow-hidden">
|
||||
<Allotment vertical proportionalLayout={true}>
|
||||
{/* Top: IssuePanel */}
|
||||
<Allotment.Pane minSize={120}>
|
||||
<div className="h-full overflow-hidden">
|
||||
<IssuePanel />
|
||||
</div>
|
||||
</Allotment.Pane>
|
||||
{/* Bottom: QueuePanel */}
|
||||
<Allotment.Pane minSize={120}>
|
||||
<div className="h-full overflow-hidden border-t border-border">
|
||||
<QueuePanel />
|
||||
</div>
|
||||
</Allotment.Pane>
|
||||
</Allotment>
|
||||
</div>
|
||||
</Allotment.Pane>
|
||||
|
||||
{/* Right column: Terminal Workbench */}
|
||||
<Allotment.Pane minSize={300}>
|
||||
@@ -86,8 +97,8 @@ export function TerminalDashboardPage() {
|
||||
</Allotment>
|
||||
</div>
|
||||
|
||||
{/* BottomInspector at bottom (flex-shrink-0) */}
|
||||
<BottomInspector />
|
||||
{/* BottomPanel: collapsible Queue + Inspector tabs (full-width) */}
|
||||
<BottomPanel />
|
||||
</AssociationHighlightProvider>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -16,10 +16,9 @@ interface TaskContext {
|
||||
}
|
||||
|
||||
interface TaskFlowControl {
|
||||
implementation_approach: Array<{
|
||||
step: string;
|
||||
action: string;
|
||||
}>;
|
||||
implementation_approach: Array<Record<string, unknown>>;
|
||||
pre_analysis?: Array<Record<string, unknown>>;
|
||||
target_files?: Array<{ path: string; [key: string]: unknown }>;
|
||||
}
|
||||
|
||||
interface NormalizedTask {
|
||||
@@ -29,6 +28,13 @@ interface NormalizedTask {
|
||||
meta: TaskMeta;
|
||||
context: TaskContext;
|
||||
flow_control: TaskFlowControl;
|
||||
// New flat format pass-through fields (consumed by frontend normalizer)
|
||||
description?: string;
|
||||
convergence?: { criteria?: string[]; verification?: string; definition_of_done?: string };
|
||||
focus_paths?: string[];
|
||||
pre_analysis?: Array<Record<string, unknown>>;
|
||||
implementation?: unknown[];
|
||||
files?: Array<{ path: string; [key: string]: unknown }>;
|
||||
_raw: unknown;
|
||||
}
|
||||
|
||||
@@ -282,16 +288,59 @@ function normalizeTask(task: unknown): NormalizedTask | null {
|
||||
const context = taskObj.context as Record<string, unknown> | undefined;
|
||||
const flowControl = taskObj.flow_control as Record<string, unknown> | undefined;
|
||||
const implementation = taskObj.implementation as unknown[] | undefined;
|
||||
const preAnalysis = taskObj.pre_analysis as Array<Record<string, unknown>> | undefined;
|
||||
const convergence = taskObj.convergence as NormalizedTask['convergence'] | undefined;
|
||||
const modificationPoints = taskObj.modification_points as Array<{ file?: string }> | undefined;
|
||||
|
||||
// Ensure id is always a string (handle numeric IDs from JSON)
|
||||
const rawId = taskObj.id ?? taskObj.task_id;
|
||||
const stringId = rawId != null ? String(rawId) : 'unknown';
|
||||
|
||||
// Normalize files: support both string[] and {path, action, change}[] formats
|
||||
const rawFiles = taskObj.files as unknown[] | undefined;
|
||||
const normalizedFiles: Array<{ path: string; [key: string]: unknown }> | undefined =
|
||||
Array.isArray(rawFiles) && rawFiles.length > 0
|
||||
? rawFiles.map(f => typeof f === 'string' ? { path: f } : f as { path: string })
|
||||
: undefined;
|
||||
|
||||
// Extract focus_paths: top-level > context > files paths > modification_points
|
||||
const focusPaths: string[] =
|
||||
(taskObj.focus_paths as string[])
|
||||
|| (context?.focus_paths as string[])
|
||||
|| normalizedFiles?.map(f => f.path).filter(Boolean)
|
||||
|| modificationPoints?.map(m => m.file).filter((f): f is string => !!f)
|
||||
|| [];
|
||||
|
||||
// Build implementation_approach: preserve rich objects, handle strings
|
||||
let implApproach: Array<Record<string, unknown>> = [];
|
||||
if (flowControl?.implementation_approach) {
|
||||
implApproach = flowControl.implementation_approach as Array<Record<string, unknown>>;
|
||||
} else if (implementation) {
|
||||
implApproach = implementation.map((step, i) => {
|
||||
if (typeof step === 'object' && step !== null) {
|
||||
return step as Record<string, unknown>;
|
||||
}
|
||||
return { step: i + 1, title: `Step ${i + 1}`, action: String(step) };
|
||||
});
|
||||
}
|
||||
|
||||
// Build pre_analysis: top-level > flow_control
|
||||
const preAnalysisSteps = preAnalysis
|
||||
|| (flowControl?.pre_analysis as Array<Record<string, unknown>>)
|
||||
|| undefined;
|
||||
|
||||
// Build acceptance criteria: convergence.criteria > context.acceptance
|
||||
const acceptance: string[] =
|
||||
convergence?.criteria
|
||||
|| (context?.acceptance as string[])
|
||||
|| (taskObj.acceptance as string[])
|
||||
|| [];
|
||||
|
||||
return {
|
||||
id: stringId,
|
||||
title: (taskObj.title as string) || (taskObj.name as string) || (taskObj.summary as string) || 'Untitled Task',
|
||||
status: (status as string).toLowerCase(),
|
||||
description: taskObj.description as string | undefined,
|
||||
// Preserve original fields for flexible rendering
|
||||
meta: meta ? {
|
||||
type: (meta.type as string) || (taskObj.type as string) || (taskObj.action as string) || 'task',
|
||||
@@ -306,23 +355,29 @@ function normalizeTask(task: unknown): NormalizedTask | null {
|
||||
},
|
||||
context: context ? {
|
||||
requirements: (context.requirements as string[]) || [],
|
||||
focus_paths: (context.focus_paths as string[]) || [],
|
||||
acceptance: (context.acceptance as string[]) || [],
|
||||
focus_paths: focusPaths,
|
||||
acceptance,
|
||||
depends_on: (context.depends_on as string[]) || []
|
||||
} : {
|
||||
requirements: (taskObj.requirements as string[]) || (taskObj.description ? [taskObj.description as string] : []),
|
||||
focus_paths: (taskObj.focus_paths as string[]) || modificationPoints?.map(m => m.file).filter((f): f is string => !!f) || [],
|
||||
acceptance: (taskObj.acceptance as string[]) || [],
|
||||
requirements: (taskObj.requirements as string[])
|
||||
|| (taskObj.details as string[])
|
||||
|| (taskObj.description ? [taskObj.description as string] : taskObj.scope ? [taskObj.scope as string] : []),
|
||||
focus_paths: focusPaths,
|
||||
acceptance,
|
||||
depends_on: (taskObj.depends_on as string[]) || []
|
||||
},
|
||||
flow_control: flowControl ? {
|
||||
implementation_approach: (flowControl.implementation_approach as Array<{ step: string; action: string }>) || []
|
||||
} : {
|
||||
implementation_approach: implementation?.map((step, i) => ({
|
||||
step: `Step ${i + 1}`,
|
||||
action: step as string
|
||||
})) || []
|
||||
flow_control: {
|
||||
implementation_approach: implApproach,
|
||||
pre_analysis: preAnalysisSteps,
|
||||
target_files: normalizedFiles
|
||||
|| (flowControl?.target_files as Array<{ path: string }>) || undefined,
|
||||
},
|
||||
// New flat format pass-through: let frontend normalizer consume these directly
|
||||
convergence,
|
||||
focus_paths: focusPaths,
|
||||
pre_analysis: preAnalysisSteps,
|
||||
implementation: implementation,
|
||||
files: normalizedFiles,
|
||||
// Keep all original fields for raw JSON view
|
||||
_raw: task
|
||||
};
|
||||
|
||||
@@ -16,11 +16,9 @@ interface TaskContext {
|
||||
}
|
||||
|
||||
interface TaskFlowControl {
|
||||
implementation_approach: Array<{
|
||||
step: string;
|
||||
action: string;
|
||||
}>;
|
||||
target_files?: Array<{ path: string }>;
|
||||
implementation_approach: Array<Record<string, unknown>>;
|
||||
pre_analysis?: Array<Record<string, unknown>>;
|
||||
target_files?: Array<{ path: string; [key: string]: unknown }>;
|
||||
}
|
||||
|
||||
interface NormalizedTask {
|
||||
@@ -30,6 +28,13 @@ interface NormalizedTask {
|
||||
meta: TaskMeta;
|
||||
context: TaskContext;
|
||||
flow_control: TaskFlowControl;
|
||||
// New flat format pass-through fields (consumed by frontend normalizer)
|
||||
description?: string;
|
||||
convergence?: { criteria?: string[]; verification?: string; definition_of_done?: string };
|
||||
focus_paths?: string[];
|
||||
pre_analysis?: Array<Record<string, unknown>>;
|
||||
implementation?: unknown[];
|
||||
files?: Array<{ path: string; [key: string]: unknown }>;
|
||||
_raw: unknown;
|
||||
}
|
||||
|
||||
@@ -750,16 +755,59 @@ function normalizeTask(task: unknown): NormalizedTask | null {
|
||||
const context = taskObj.context as Record<string, unknown> | undefined;
|
||||
const flowControl = taskObj.flow_control as Record<string, unknown> | undefined;
|
||||
const implementation = taskObj.implementation as unknown[] | undefined;
|
||||
const preAnalysis = taskObj.pre_analysis as Array<Record<string, unknown>> | undefined;
|
||||
const convergence = taskObj.convergence as NormalizedTask['convergence'] | undefined;
|
||||
const modificationPoints = taskObj.modification_points as Array<{ file?: string }> | undefined;
|
||||
|
||||
// Ensure id is always a string (handle numeric IDs from JSON)
|
||||
const rawId = taskObj.id ?? taskObj.task_id;
|
||||
const stringId = rawId != null ? String(rawId) : 'unknown';
|
||||
|
||||
// Normalize files: support both string[] and {path, action, change}[] formats
|
||||
const rawFiles = taskObj.files as unknown[] | undefined;
|
||||
const normalizedFiles: Array<{ path: string; [key: string]: unknown }> | undefined =
|
||||
Array.isArray(rawFiles) && rawFiles.length > 0
|
||||
? rawFiles.map(f => typeof f === 'string' ? { path: f } : f as { path: string })
|
||||
: undefined;
|
||||
|
||||
// Extract focus_paths: top-level > context > files paths > modification_points
|
||||
const focusPaths: string[] =
|
||||
(taskObj.focus_paths as string[])
|
||||
|| (context?.focus_paths as string[])
|
||||
|| normalizedFiles?.map(f => f.path).filter(Boolean)
|
||||
|| modificationPoints?.map(m => m.file).filter((f): f is string => !!f)
|
||||
|| [];
|
||||
|
||||
// Build implementation_approach: preserve rich objects, handle strings
|
||||
let implApproach: Array<Record<string, unknown>> = [];
|
||||
if (flowControl?.implementation_approach) {
|
||||
implApproach = flowControl.implementation_approach as Array<Record<string, unknown>>;
|
||||
} else if (implementation) {
|
||||
implApproach = implementation.map((step, i) => {
|
||||
if (typeof step === 'object' && step !== null) {
|
||||
return step as Record<string, unknown>;
|
||||
}
|
||||
return { step: i + 1, title: `Step ${i + 1}`, action: String(step) };
|
||||
});
|
||||
}
|
||||
|
||||
// Build pre_analysis: top-level > flow_control
|
||||
const preAnalysisSteps = preAnalysis
|
||||
|| (flowControl?.pre_analysis as Array<Record<string, unknown>>)
|
||||
|| undefined;
|
||||
|
||||
// Build acceptance criteria: convergence.criteria > context.acceptance
|
||||
const acceptance: string[] =
|
||||
convergence?.criteria
|
||||
|| (context?.acceptance as string[])
|
||||
|| (taskObj.acceptance as string[])
|
||||
|| [];
|
||||
|
||||
return {
|
||||
id: stringId,
|
||||
title: (taskObj.title as string) || (taskObj.name as string) || (taskObj.summary as string) || 'Untitled Task',
|
||||
status: (status as string).toLowerCase(),
|
||||
description: taskObj.description as string | undefined,
|
||||
// Preserve original fields for flexible rendering
|
||||
meta: meta ? {
|
||||
type: (meta.type as string) || (taskObj.type as string) || (taskObj.action as string) || 'task',
|
||||
@@ -774,33 +822,29 @@ function normalizeTask(task: unknown): NormalizedTask | null {
|
||||
},
|
||||
context: context ? {
|
||||
requirements: (context.requirements as string[]) || [],
|
||||
focus_paths: (context.focus_paths as string[]) || [],
|
||||
acceptance: (context.acceptance as string[]) || [],
|
||||
focus_paths: focusPaths,
|
||||
acceptance,
|
||||
depends_on: (context.depends_on as string[]) || []
|
||||
} : {
|
||||
requirements: (taskObj.requirements as string[])
|
||||
|| (taskObj.details as string[])
|
||||
|| (taskObj.description ? [taskObj.description as string] : taskObj.scope ? [taskObj.scope as string] : []),
|
||||
focus_paths: (taskObj.focus_paths as string[])
|
||||
|| (Array.isArray(taskObj.files) && taskObj.files.length > 0 && typeof taskObj.files[0] === 'string'
|
||||
? taskObj.files as string[] : undefined)
|
||||
|| modificationPoints?.map(m => m.file).filter((f): f is string => !!f)
|
||||
|| [],
|
||||
acceptance: (taskObj.acceptance as string[]) || [],
|
||||
focus_paths: focusPaths,
|
||||
acceptance,
|
||||
depends_on: (taskObj.depends_on as string[]) || []
|
||||
},
|
||||
flow_control: flowControl ? {
|
||||
implementation_approach: (flowControl.implementation_approach as Array<{ step: string; action: string }>) || [],
|
||||
target_files: (flowControl.target_files as Array<{ path: string }>) || undefined
|
||||
} : {
|
||||
implementation_approach: implementation?.map((step, i) => ({
|
||||
step: `Step ${i + 1}`,
|
||||
action: step as string
|
||||
})) || [],
|
||||
target_files: Array.isArray(taskObj.files) && taskObj.files.length > 0 && typeof taskObj.files[0] === 'string'
|
||||
? (taskObj.files as string[]).map(f => ({ path: f }))
|
||||
: undefined
|
||||
flow_control: {
|
||||
implementation_approach: implApproach,
|
||||
pre_analysis: preAnalysisSteps,
|
||||
target_files: normalizedFiles
|
||||
|| (flowControl?.target_files as Array<{ path: string }>) || undefined,
|
||||
},
|
||||
// New flat format pass-through: let frontend normalizer consume these directly
|
||||
convergence,
|
||||
focus_paths: focusPaths,
|
||||
pre_analysis: preAnalysisSteps,
|
||||
implementation: implementation,
|
||||
files: normalizedFiles,
|
||||
// Keep all original fields for raw JSON view
|
||||
_raw: task
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user