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:
catlog22
2026-02-14 21:35:55 +08:00
parent 0d805efe87
commit d535ab4749
27 changed files with 2004 additions and 2363 deletions

View File

@@ -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

View 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).

View File

@@ -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).

View File

@@ -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).

View File

@@ -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).

View File

@@ -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).

View File

@@ -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