Skip to content

Commit d535ab4

Browse files
author
catlog22
committed
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.
1 parent 0d805ef commit d535ab4

27 files changed

Lines changed: 2003 additions & 2362 deletions

.claude/commands/workflow/tdd-plan.md

Lines changed: 0 additions & 631 deletions
This file was deleted.

.claude/commands/workflow/test-cycle-execute.md

Lines changed: 0 additions & 504 deletions
This file was deleted.

.claude/commands/workflow/test-fix-gen.md

Lines changed: 0 additions & 477 deletions
This file was deleted.

.claude/skills/workflow-tdd/SKILL.md

Lines changed: 459 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Phase 1: Session Discovery
2+
3+
Create or discover TDD workflow session and extract session ID.
4+
5+
## Objective
6+
7+
- Create a new TDD workflow session via `/workflow:session:start`
8+
- Extract session ID for subsequent phases
9+
10+
## Execution
11+
12+
### Step 1.1: Execute Session Start
13+
14+
```javascript
15+
Skill(skill="workflow:session:start", args="--type tdd --auto \"TDD: [structured-description]\"")
16+
```
17+
18+
**TDD Structured Format**:
19+
```
20+
TDD: [Feature Name]
21+
GOAL: [Objective]
22+
SCOPE: [Included/excluded]
23+
CONTEXT: [Background]
24+
TEST_FOCUS: [Test scenarios]
25+
```
26+
27+
**Example**:
28+
```
29+
TDD: JWT Authentication
30+
GOAL: Implement JWT-based authentication
31+
SCOPE: Email/password login, token generation, token refresh endpoints
32+
CONTEXT: Existing user database schema, REST API
33+
TEST_FOCUS: Login flow, token validation, refresh rotation, error cases
34+
```
35+
36+
### Step 1.2: Parse Output
37+
38+
- Extract: `SESSION_ID: WFS-[id]` (store as `sessionId`)
39+
40+
**Validation**:
41+
- Session ID successfully extracted
42+
- Session directory `.workflow/active/[sessionId]/` exists
43+
44+
**Note**: Session directory contains `workflow-session.json` (metadata). Do NOT look for `manifest.json` here - it only exists in `.workflow/archives/` for archived sessions.
45+
46+
**TodoWrite**: Mark phase 1 completed, phase 2 in_progress
47+
48+
**After Phase 1**: Return to user showing Phase 1 results, then auto-continue to Phase 2
49+
50+
## Output
51+
52+
- **Variable**: `sessionId` (WFS-xxx)
53+
- **TodoWrite**: Mark Phase 1 completed, Phase 2 in_progress
54+
55+
## Next Phase
56+
57+
Return to orchestrator, then auto-continue to [Phase 2: Context Gathering](02-context-gathering.md).
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Phase 2: Context Gathering
2+
3+
Gather project context and analyze codebase for TDD planning.
4+
5+
## Objective
6+
7+
- Gather project context via context-search agents
8+
- Generate context-package.json with codebase analysis
9+
- Extract conflictRisk to determine Phase 4 execution
10+
11+
## Execution
12+
13+
### Step 2.1: Execute Context Gathering
14+
15+
```javascript
16+
Skill(skill="workflow:tools:context-gather", args="--session [sessionId] \"TDD: [structured-description]\"")
17+
```
18+
19+
**Use Same Structured Description**: Pass the same structured format from Phase 1.
20+
21+
**Input**: `sessionId` from Phase 1
22+
23+
### Step 2.2: Parse Output
24+
25+
- Extract: context-package.json path (store as `contextPath`)
26+
- Typical pattern: `.workflow/active/[sessionId]/.process/context-package.json`
27+
28+
**Validation**:
29+
- Context package path extracted
30+
- File exists and is valid JSON
31+
32+
### Step 2.3: Extract conflictRisk
33+
34+
```javascript
35+
const contextPackage = Read(contextPath)
36+
const conflictRisk = contextPackage.conflict_risk // "none" | "low" | "medium" | "high"
37+
```
38+
39+
**Note**: conflictRisk determines whether Phase 4 (Conflict Resolution) will execute.
40+
41+
**TodoWrite**: Mark phase 2 completed, phase 3 in_progress
42+
43+
**After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3
44+
45+
## Output
46+
47+
- **Variable**: `contextPath` (path to context-package.json)
48+
- **Variable**: `conflictRisk` ("none" | "low" | "medium" | "high")
49+
- **TodoWrite**: Mark Phase 2 completed, Phase 3 in_progress
50+
51+
## Next Phase
52+
53+
Return to orchestrator, then auto-continue to [Phase 3: Test Coverage Analysis](03-test-coverage-analysis.md).
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Phase 3: Test Coverage Analysis
2+
3+
Analyze existing test coverage, detect test framework, and identify coverage gaps.
4+
5+
## Objective
6+
7+
- Analyze existing codebase for test patterns and conventions
8+
- Detect current test coverage and framework
9+
- Identify related components and integration points
10+
- Generate test-context-package.json
11+
12+
## Execution
13+
14+
### Step 3.1: Execute Test Context Gathering
15+
16+
```javascript
17+
Skill(skill="workflow:tools:test-context-gather", args="--session [sessionId]")
18+
```
19+
20+
**Purpose**: Analyze existing codebase for:
21+
- Existing test patterns and conventions
22+
- Current test coverage
23+
- Related components and integration points
24+
- Test framework detection
25+
26+
### Step 3.2: Parse Output
27+
28+
- Extract: testContextPath (`.workflow/active/[sessionId]/.process/test-context-package.json`)
29+
30+
**Validation**:
31+
- test-context-package.json exists and is valid JSON
32+
- Contains framework detection results
33+
34+
### TodoWrite Update (Phase 3 Skill executed - tasks attached)
35+
36+
```json
37+
[
38+
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
39+
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
40+
{"content": "Phase 3: Test Coverage Analysis", "status": "in_progress", "activeForm": "Executing test coverage analysis"},
41+
{"content": " → Detect test framework and conventions", "status": "in_progress", "activeForm": "Detecting test framework"},
42+
{"content": " → Analyze existing test coverage", "status": "pending", "activeForm": "Analyzing test coverage"},
43+
{"content": " → Identify coverage gaps", "status": "pending", "activeForm": "Identifying coverage gaps"},
44+
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
45+
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
46+
]
47+
```
48+
49+
**Note**: Skill execute **attaches** test-context-gather's 3 tasks. Orchestrator **executes** these tasks.
50+
51+
**Next Action**: Tasks attached → **Execute Phase 3.1-3.3** sequentially
52+
53+
### TodoWrite Update (Phase 3 completed - tasks collapsed)
54+
55+
```json
56+
[
57+
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
58+
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
59+
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
60+
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
61+
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
62+
]
63+
```
64+
65+
**Note**: Phase 3 tasks completed and collapsed to summary.
66+
67+
**After Phase 3**: Return to user showing test coverage results, then auto-continue to Phase 4/5 (depending on conflict_risk)
68+
69+
## Output
70+
71+
- **Variable**: `testContextPath` (path to test-context-package.json)
72+
- **TodoWrite**: Mark Phase 3 completed
73+
74+
## Next Phase
75+
76+
Based on `conflictRisk` from Phase 2:
77+
- If conflictRisk ≥ medium → [Phase 4: Conflict Resolution](04-conflict-resolution.md)
78+
- If conflictRisk < medium → Skip to [Phase 5: TDD Task Generation](05-tdd-task-generation.md)
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Phase 4: Conflict Resolution (Conditional)
2+
3+
Detect and resolve conflicts when conflict risk is medium or high.
4+
5+
## Objective
6+
7+
- Execute conflict detection and resolution only when conflictRisk ≥ medium
8+
- Generate conflict-resolution.json with resolution strategies
9+
- Skip directly to Phase 5 if conflictRisk is none/low
10+
11+
## Trigger Condition
12+
13+
**Only execute when**: `context-package.json` indicates `conflict_risk` is "medium" or "high"
14+
15+
**Skip Behavior**: If conflict_risk is "none" or "low", skip directly to Phase 5. Display: "No significant conflicts detected, proceeding to TDD task generation"
16+
17+
## Execution
18+
19+
### Step 4.1: Execute Conflict Resolution
20+
21+
```javascript
22+
Skill(skill="workflow:tools:conflict-resolution", args="--session [sessionId] --context [contextPath]")
23+
```
24+
25+
**Input**:
26+
- sessionId from Phase 1
27+
- contextPath from Phase 2
28+
- conflict_risk from context-package.json
29+
30+
### Step 4.2: Parse Output
31+
32+
- Extract: Execution status (success/skipped/failed)
33+
- Verify: conflict-resolution.json file path (if executed)
34+
35+
**Validation**:
36+
- File `.workflow/active/[sessionId]/.process/conflict-resolution.json` exists (if executed)
37+
38+
### TodoWrite Update (Phase 4 Skill executed - tasks attached, if conflict_risk ≥ medium)
39+
40+
```json
41+
[
42+
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
43+
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
44+
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
45+
{"content": "Phase 4: Conflict Resolution", "status": "in_progress", "activeForm": "Executing conflict resolution"},
46+
{"content": " → Detect conflicts with CLI analysis", "status": "in_progress", "activeForm": "Detecting conflicts"},
47+
{"content": " → Log and analyze detected conflicts", "status": "pending", "activeForm": "Analyzing conflicts"},
48+
{"content": " → Apply resolution strategies", "status": "pending", "activeForm": "Applying resolution strategies"},
49+
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
50+
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
51+
]
52+
```
53+
54+
**Note**: Skill execute **attaches** conflict-resolution's 3 tasks. Orchestrator **executes** these tasks.
55+
56+
**Next Action**: Tasks attached → **Execute Phase 4.1-4.3** sequentially
57+
58+
### TodoWrite Update (Phase 4 completed - tasks collapsed)
59+
60+
```json
61+
[
62+
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
63+
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
64+
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
65+
{"content": "Phase 4: Conflict Resolution", "status": "completed", "activeForm": "Executing conflict resolution"},
66+
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
67+
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
68+
]
69+
```
70+
71+
**Note**: Phase 4 tasks completed and collapsed to summary.
72+
73+
**After Phase 4**: Return to user showing conflict resolution results and selected strategies, then auto-continue to Phase 5
74+
75+
### Memory State Check
76+
77+
After Phase 4, evaluate current context window usage and memory state:
78+
- If memory usage is high (>110K tokens or approaching context limits):
79+
80+
```javascript
81+
Skill(skill="compact")
82+
```
83+
84+
- This optimizes memory before proceeding to Phase 5
85+
- Memory compaction is particularly important after analysis phase which may generate extensive documentation
86+
- Ensures optimal performance and prevents context overflow
87+
88+
## Output
89+
90+
- **File**: `.workflow/active/[sessionId]/.process/conflict-resolution.json` (if executed)
91+
- **TodoWrite**: Mark Phase 4 completed, Phase 5 in_progress
92+
93+
## Next Phase
94+
95+
Return to orchestrator, then auto-continue to [Phase 5: TDD Task Generation](05-tdd-task-generation.md).
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Phase 5: TDD Task Generation
2+
3+
Generate TDD tasks with Red-Green-Refactor cycles via action-planning-agent.
4+
5+
## Objective
6+
7+
- Generate IMPL_PLAN.md, task JSONs, and TODO_LIST.md with TDD structure
8+
- Each task contains internal Red-Green-Refactor cycle
9+
- Include Phase 0 user configuration (execution method, CLI tool preference)
10+
11+
## Execution
12+
13+
### Step 5.1: Execute TDD Task Generation
14+
15+
```javascript
16+
Skill(skill="workflow:tools:task-generate-tdd", args="--session [sessionId]")
17+
```
18+
19+
**Note**: Phase 0 now includes:
20+
- Supplementary materials collection (file paths or inline content)
21+
- Execution method preference (Agent/Hybrid/CLI)
22+
- CLI tool preference (Codex/Gemini/Qwen/Auto)
23+
- These preferences are passed to agent for task generation
24+
25+
**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.
26+
27+
### Step 5.2: Parse Output
28+
29+
Extract: feature count, task count, CLI execution IDs assigned
30+
31+
### Step 5.3: Validate Outputs
32+
33+
- `plan.json` exists (structured plan overview with `_metadata.plan_type: "tdd"`)
34+
- `IMPL_PLAN.md` exists (unified plan with TDD Implementation Tasks section)
35+
- `IMPL-*.json` files exist (one per feature, or container + subtasks for complex features)
36+
- `TODO_LIST.md` exists with internal TDD phase indicators
37+
- Each IMPL task includes:
38+
- `meta.tdd_workflow: true`
39+
- `cli_execution.id: {session_id}-{task_id}`
40+
- `cli_execution: { "strategy": "new|resume|fork|merge_fork", ... }`
41+
- `implementation` with exactly 3 steps (red/green/refactor)
42+
- Green phase includes test-fix-cycle configuration
43+
- `focus_paths`: absolute or clear relative paths (enhanced with exploration critical_files)
44+
- `pre_analysis`: includes exploration integration_points analysis
45+
- `IMPL_PLAN.md` contains `workflow_type: "tdd"` in frontmatter
46+
- User configuration applied:
47+
- If executionMethod == "cli" or "hybrid": command field added to steps
48+
- CLI tool preference reflected in execution guidance
49+
- Task count ≤18 (compliance with hard limit)
50+
51+
### Red Flag Detection (Non-Blocking Warnings)
52+
53+
- Task count >18: `⚠️ Task count exceeds hard limit - request re-scope`
54+
- Missing cli_execution.id: `⚠️ Task lacks CLI execution ID for resume support`
55+
- Missing test-fix-cycle: `⚠️ Green phase lacks auto-revert configuration`
56+
- Generic task names: `⚠️ Vague task names suggest unclear TDD cycles`
57+
- Missing focus_paths: `⚠️ Task lacks clear file scope for implementation`
58+
59+
**Action**: Log warnings to `.workflow/active/[sessionId]/.process/tdd-warnings.log` (non-blocking)
60+
61+
### TodoWrite Update (Phase 5 Skill executed - tasks attached)
62+
63+
```json
64+
[
65+
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
66+
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
67+
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
68+
{"content": "Phase 5: TDD Task Generation", "status": "in_progress", "activeForm": "Executing TDD task generation"},
69+
{"content": " → Discovery - analyze TDD requirements", "status": "in_progress", "activeForm": "Analyzing TDD requirements"},
70+
{"content": " → Planning - design Red-Green-Refactor cycles", "status": "pending", "activeForm": "Designing TDD cycles"},
71+
{"content": " → Output - generate IMPL tasks with internal TDD phases", "status": "pending", "activeForm": "Generating TDD tasks"},
72+
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
73+
]
74+
```
75+
76+
**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.
77+
78+
**Next Action**: Tasks attached → **Execute Phase 5.1-5.3** sequentially
79+
80+
### TodoWrite Update (Phase 5 completed - tasks collapsed)
81+
82+
```json
83+
[
84+
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
85+
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
86+
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
87+
{"content": "Phase 5: TDD Task Generation", "status": "completed", "activeForm": "Executing TDD task generation"},
88+
{"content": "Phase 6: TDD Structure Validation", "status": "in_progress", "activeForm": "Validating TDD structure"}
89+
]
90+
```
91+
92+
**Note**: Phase 5 tasks completed and collapsed to summary. Each generated IMPL task contains complete Red-Green-Refactor cycle internally.
93+
94+
## Output
95+
96+
- **File**: `plan.json` (structured plan overview)
97+
- **File**: `IMPL_PLAN.md` (unified plan with TDD Implementation Tasks section)
98+
- **File**: `IMPL-*.json` (task JSONs with internal TDD cycles)
99+
- **File**: `TODO_LIST.md` (task list with TDD phase indicators)
100+
- **File**: `.process/tdd-warnings.log` (non-blocking warnings)
101+
- **TodoWrite**: Mark Phase 5 completed, Phase 6 in_progress
102+
103+
## Next Phase
104+
105+
Return to orchestrator, then auto-continue to [Phase 6: TDD Structure Validation](06-tdd-structure-validation.md).

0 commit comments

Comments
 (0)