Loading...
Loading...
Compare original and translation side by side
┌────────────────────────────────────────────────────────────────────────────┐
│ Workflow Test-Fix Cycle Orchestrator (SKILL.md) │
│ → Full pipeline: Test generation + Iterative execution │
│ → Phase dispatch: Read phase docs, execute, pass context │
└───────────────┬────────────────────────────────────────────────────────────┘
│
┌────────────┴────────────────────────┐
↓ ↓
┌─────────────────────────┐ ┌─────────────────────────────┐
│ Phase 1: Test-Fix Gen │ │ Phase 2: Test-Cycle Execute │
│ phases/01-test-fix-gen │ │ phases/02-test-cycle-execute │
│ 5 sub-phases: │ │ 3 stages: │
│ ① Create Session │ │ ① Discovery │
│ ② Gather Context │ │ ② Main Loop (iterate) │
│ ③ Test Analysis (Gemini)│ │ ③ Completion │
│ ④ Generate Tasks │ │ │
│ ⑤ Summary │ │ Agents (via spawn_agent): │
│ │ │ @cli-planning-agent │
│ Agents (via spawn_agent)│ │ @test-fix-agent │
│ @test-context-search │ │ │
│ @context-search │ │ Strategy: conservative → │
│ @cli-execution │ │ aggressive → surgical │
│ @action-planning │ │ │
└────────┬────────────────┘ └────────────┬──────────────────┘
↓ ↓
IMPL-001..002.json Pass Rate >= 95%
TEST_ANALYSIS_RESULTS.md Auto-complete session
Task Pipeline:
┌──────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
│ 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 10 iter │
│@code-developer│ │ @test-fix-agent │ │ @test-fix-agent │ │@test-fix-agent│
└──────────────┘ └─────────────────┘ └─────────────────┘ └──────────────┘
│
Fix Loop: │
┌──────────────────┘
↓
┌──────────┐
│ @cli-plan│───→ IMPL-fix-N.json
│ agent │
├──────────┤
│@test-fix │───→ Apply & re-test
│ agent │
└──────────┘┌────────────────────────────────────────────────────────────────────────────┐
│ Workflow Test-Fix Cycle Orchestrator (SKILL.md) │
│ → 完整流水线:测试生成 + 迭代执行 │
│ → 阶段调度:读取阶段文档、执行、传递上下文 │
└───────────────┬────────────────────────────────────────────────────────────┘
│
┌────────────┴────────────────────────┐
↓ ↓
┌─────────────────────────┐ ┌─────────────────────────────┐
│ 阶段1:测试-修复生成 │ │ 阶段2:测试周期执行 │
│ phases/01-test-fix-gen │ │ phases/02-test-cycle-execute │
│ 5个子阶段: │ │ 3个阶段: │
│ ① 创建会话 │ │ ① 发现阶段 │
│ ② 收集上下文 │ │ ② 主循环(迭代) │
│ ③ 测试分析(Gemini)│ │ ③ 完成阶段 │
│ ④ 生成任务 │ │ │
│ ⑤ 总结 │ │ Agents(通过spawn_agent调用): │
│ │ │ @cli-planning-agent │
│ Agents(通过spawn_agent调用)│ │ @test-fix-agent │
│ @test-context-search │ │ │
│ @context-search │ │ 策略:保守 → │
│ @cli-execution │ │ 激进 → 精准修复 │
│ @action-planning │ │ │
└────────┬────────────────┘ └────────────┬──────────────────┘
↓ ↓
IMPL-001..002.json 通过率 ≥ 95%
TEST_ANALYSIS_RESULTS.md 自动完成会话
任务流水线:
┌──────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
│ IMPL-001 │───→│ IMPL-001.3 │───→│ IMPL-001.5 │───→│ IMPL-002 │
│ 测试生成 │ │ 代码验证 │ │ 质量门禁 │ │ 测试与修复 │
│ L1-L3 │ │ L0 + AI代码问题 │ │ 覆盖率80%+ │ │ 最多10次迭代 │
│@code-developer│ │ @test-fix-agent │ │ @test-fix-agent │ │@test-fix-agent│
└──────────────┘ └─────────────────┘ └─────────────────┘ └──────────────┘
│
修复循环: │
┌──────────────────┘
↓
┌──────────┐
│ @cli-plan│───→ IMPL-fix-N.json
│ agent │
├──────────┤
│@test-fix │───→ 应用修复并重新测试
│ agent │
└──────────┘const agentId = spawn_agent({
message: `const agentId = spawn_agent({
message: `ccw spec load --category "planning execution"ccw spec load --category "planning execution"undefinedundefinedconst result = wait({
ids: [agentId],
timeout_ms: 600000 // 10 minutes
})
if (result.timed_out) {
// Handle timeout - can continue waiting or send_input to prompt completion
}const result = wait({
ids: [agentId],
timeout_ms: 600000 // 10分钟
})
if (result.timed_out) {
// 处理超时 - 可继续等待或发送输入提示完成
}send_input({
id: agentId,
message: `send_input({
id: agentId,
message: `undefinedundefinedclose_agent({ id: agentId })close_agent({ id: agentId })workflow-test-fix-cycle <input> [options]workflow-test-fix-cycle <input> [options]
**Quality Gate**: Test pass rate >= 95% (criticality-aware) or 100%
**Max Iterations**: 10 (default, adjustable)
**CLI Tools**: Gemini → Qwen → Codex (fallback chain)
**质量门禁**:测试通过率≥95%(考虑优先级)或100%
**最大迭代次数**:10次(默认,可调整)
**CLI工具**:Gemini → Qwen → Codex( fallback链)| 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) |
| 层级 | 名称 | 关注点 |
|---|---|---|
| L0 | 静态分析 | 编译、导入、类型、AI代码问题 |
| L1 | 单元测试 | 函数/类行为(正常/异常/边界场景) |
| L2 | 集成测试 | 组件交互、API契约、故障模式 |
| L3 | 端到端测试 | 用户流程、关键路径(可选) |
Input → Detect Mode (session | prompt | resume)
│
├─ resume mode → Skip to Phase 2
│
└─ session/prompt mode → Phase 1
│
Phase 1: Test-Fix Generation (phases/01-test-fix-gen.md)
├─ Sub-phase 1.1: Create Test Session → testSessionId
├─ Sub-phase 1.2: Gather Test Context (spawn_agent) → contextPath
├─ Sub-phase 1.3: Test Generation Analysis (spawn_agent → Gemini) → TEST_ANALYSIS_RESULTS.md
├─ Sub-phase 1.4: Generate Test Tasks (spawn_agent) → IMPL-*.json, IMPL_PLAN.md, TODO_LIST.md
└─ Sub-phase 1.5: Phase 1 Summary
│
Phase 2: Test-Cycle Execution (phases/02-test-cycle-execute.md)
├─ Discovery: Load session, tasks, iteration state
├─ Main Loop (for each task):
│ ├─ Execute → Test → Calculate pass_rate
│ ├─ 100% → SUCCESS: Next task
│ ├─ 95-99% + low criticality → PARTIAL SUCCESS: Approve
│ └─ <95% → Fix Loop:
│ ├─ Select strategy: conservative/aggressive/surgical
│ ├─ spawn_agent(@cli-planning-agent) → IMPL-fix-N.json
│ ├─ spawn_agent(@test-fix-agent) → Apply fix & re-test
│ └─ Re-test → Back to decision
└─ Completion: Final validation → Summary → Sync session state → Auto-complete session输入 → 检测模式(会话 | 提示 | 恢复)
│
├─ 恢复模式 → 跳过阶段1
│
└─ 会话/提示模式 → 阶段1
│
阶段1:测试-修复生成(phases/01-test-fix-gen.md)
├─ 子阶段1.1:创建测试会话 → testSessionId
├─ 子阶段1.2:收集测试上下文(spawn_agent) → contextPath
├─ 子阶段1.3:测试生成分析(spawn_agent → Gemini) → TEST_ANALYSIS_RESULTS.md
├─ 子阶段1.4:生成测试任务(spawn_agent) → IMPL-*.json, IMPL_PLAN.md, TODO_LIST.md
└─ 子阶段1.5:阶段1总结
│
阶段2:测试周期执行(phases/02-test-cycle-execute.md)
├─ 发现阶段:加载会话、任务、迭代状态
├─ 主循环(针对每个任务):
│ ├─ 执行 → 测试 → 计算pass_rate
│ ├─ 100% → 成功:进入下一个任务
│ ├─ 95-99% + 低优先级 → 部分成功:批准通过
│ └─ <95% → 修复循环:
│ ├─ 选择策略:保守/激进/精准修复
│ ├─ spawn_agent(@cli-planning-agent) → IMPL-fix-N.json
│ ├─ spawn_agent(@test-fix-agent) → 应用修复并重新测试
│ └─ 重新测试 → 返回决策点
└─ 完成阶段:最终验证 → 总结 → 同步会话状态 → 自动完成会话phases/01-*.mdphases/02-*.mdphases/01-*.mdphases/02-*.mdphases/01-test-fix-gen.mdtestSessionIdcontextPathTEST_ANALYSIS_RESULTS.mdIMPL-001.jsonIMPL-001.3.jsonIMPL-001.5.jsonIMPL-002.jsonIMPL_PLAN.mdTODO_LIST.mdtest-context-search-agentcontext-search-agentcli-execution-agentaction-planning-agentphases/01-test-fix-gen.mdtestSessionIdcontextPathTEST_ANALYSIS_RESULTS.mdIMPL-001.jsonIMPL-001.3.jsonIMPL-001.5.jsonIMPL-002.jsonIMPL_PLAN.mdTODO_LIST.mdtest-context-search-agentcontext-search-agentcli-execution-agentaction-planning-agentphases/02-test-cycle-execute.mdcli-planning-agenttest-fix-agentphases/02-test-cycle-execute.mdcli-planning-agenttest-fix-agent{projectRoot}/.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-fix-{N}.json # Generated fix tasks (Phase 2)
├── .process/
│ ├── [test-]context-package.json # Context and coverage analysis
│ ├── TEST_ANALYSIS_RESULTS.md # Test requirements and strategy (L0-L3)
│ ├── 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/{projectRoot}/.workflow/active/WFS-test-[session]/
├── workflow-session.json # 会话元数据
├── IMPL_PLAN.md # 测试生成与执行策略
├── TODO_LIST.md # 任务清单
├── .task/
│ ├── IMPL-001.json # 测试理解与生成
│ ├── IMPL-001.3-validation.json # 代码验证门禁
│ ├── IMPL-001.5-review.json # 测试质量门禁
│ ├── IMPL-002.json # 测试执行与修复循环
│ └── IMPL-fix-{N}.json # 生成的修复任务(阶段2)
├── .process/
│ ├── [test-]context-package.json # 上下文与覆盖率分析
│ ├── TEST_ANALYSIS_RESULTS.md # 测试需求与策略(L0-L3)
│ ├── iteration-state.json # 当前迭代 + 策略 + 阻塞测试用例
│ ├── test-results.json # 最新结果(通过率、优先级)
│ ├── test-output.log # 完整测试输出
│ ├── fix-history.json # 所有修复尝试
│ ├── iteration-{N}-analysis.md # CLI分析报告
│ └── iteration-{N}-cli-output.txt
└── .summaries/iteration-summaries/[
{ content: "Phase 1: Test-Fix Generation", status: "in_progress" },
{ content: " 1.1 Create Test Session", status: "completed" },
{ content: " 1.2 Gather Test Context", status: "in_progress" },
{ content: " 1.3 Test Generation Analysis", status: "pending" },
{ content: " 1.4 Generate Test Tasks", status: "pending" },
{ content: " 1.5 Phase Summary", status: "pending" },
{ content: "Phase 2: Test-Cycle Execution", status: "pending" }
][
{ content: "Phase 1: Test-Fix Generation", status: "completed" },
{ content: "Phase 2: Test-Cycle Execution", status: "in_progress" },
{ content: " Execute IMPL-001: Generate tests [code-developer]", status: "completed" },
{ content: " Execute IMPL-002: Test & Fix Cycle [ITERATION]", status: "in_progress" },
{ content: " → Iteration 1: Initial test (pass: 70%, conservative)", status: "completed" },
{ content: " → Iteration 2: Fix validation (pass: 82%, conservative)", status: "completed" },
{ content: " → Iteration 3: Batch fix auth (pass: 89%, aggressive)", status: "in_progress" }
][
{ content: "Phase 1: Test-Fix Generation", status: "in_progress" },
{ content: " 1.1 Create Test Session", status: "completed" },
{ content: " 1.2 Gather Test Context", status: "in_progress" },
{ content: " 1.3 Test Generation Analysis", status: "pending" },
{ content: " 1.4 Generate Test Tasks", status: "pending" },
{ content: " 1.5 Phase Summary", status: "pending" },
{ content: "Phase 2: Test-Cycle Execution", status: "pending" }
][
{ content: "Phase 1: Test-Fix Generation", status: "completed" },
{ content: "Phase 2: Test-Cycle Execution", status: "in_progress" },
{ content: " Execute IMPL-001: Generate tests [code-developer]", status: "completed" },
{ content: " Execute IMPL-002: Test & Fix Cycle [ITERATION]", status: "in_progress" },
{ content: " → Iteration 1: Initial test (pass: 70%, conservative)", status: "completed" },
{ content: " → Iteration 2: Fix validation (pass: 82%, conservative)", status: "completed" },
{ content: " → Iteration 3: Batch fix auth (pass: 89%, aggressive)", status: "in_progress" }
]| Phase | Scenario | 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.2 | Agent timeout | Retry with extended timeout, close_agent, then return error |
| 1.3 | Gemini analysis failed | Return error, check context package |
| 1.4 | Task generation failed | Retry once, then return error |
| 2 | Test execution error | Log, retry with error context |
| 2 | CLI analysis failure | Fallback: Gemini → Qwen → Codex → manual |
| 2 | Agent execution error | Save state, close_agent, retry with simplified context |
| 2 | Max iterations reached | Generate failure report, mark blocked |
| 2 | Regression detected | Rollback last fix, switch to surgical strategy |
| 2 | Stuck tests detected | Continue with alternative strategy, document in failure report |
try {
const agentId = spawn_agent({ message: "..." });
const result = wait({ ids: [agentId], timeout_ms: 600000 });
// ... process result ...
close_agent({ id: agentId });
} catch (error) {
if (agentId) close_agent({ id: agentId });
throw error;
}| 阶段 | 场景 | 操作 |
|---|---|---|
| 1.1 | 源会话不存在(会话模式) | 返回包含会话ID的错误 |
| 1.1 | 无已完成的IMPL任务(会话模式) | 返回错误,源实现不完整 |
| 1.2 | 上下文收集失败 | 返回错误,检查源产物 |
| 1.2 | Agent超时 | 延长超时时间重试,调用close_agent,然后返回错误 |
| 1.3 | Gemini分析失败 | 返回错误,检查上下文包 |
| 1.4 | 任务生成失败 | 重试一次,然后返回错误 |
| 2 | 测试执行错误 | 记录日志,携带错误上下文重试 |
| 2 | CLI分析失败 | Fallback:Gemini → Qwen → Codex → 人工处理 |
| 2 | Agent执行错误 | 保存状态,调用close_agent,携带简化上下文重试 |
| 2 | 达到最大迭代次数 | 生成失败报告,标记为阻塞 |
| 2 | 检测到回归 | 回滚上一次修复,切换到精准修复策略 |
| 2 | 检测到阻塞测试用例 | 切换到替代策略继续执行,在失败报告中记录 |
try {
const agentId = spawn_agent({ message: "..." });
const result = wait({ ids: [agentId], timeout_ms: 600000 });
// ... 处理结果 ...
close_agent({ id: agentId });
} catch (error) {
if (agentId) close_agent({ id: agentId });
throw error;
}phases/01-test-fix-gen.mdphases/02-test-cycle-execute.md--resume-sessionphases/01-test-fix-gen.mdphases/02-test-cycle-execute.md--resume-sessionworkflow-planworkflow-executetest-context-search-agentcontext-search-agentcli-execution-agentaction-planning-agentcli-planning-agenttest-fix-agent$session-sync -y "Test-fix cycle complete: {pass_rate}% pass rate"workflow-planworkflow-executetest-context-search-agentcontext-search-agentcli-execution-agentaction-planning-agentcli-planning-agenttest-fix-agent$session-sync -y "Test-fix cycle complete: {pass_rate}% pass rate"