workflow-test-fix
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWorkflow Test Fix
工作流测试修复
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.
将测试计划生成(第1-4阶段)与迭代测试周期执行(第5阶段)整合为单一端到端流水线的统一测试修复编排器。创建包含渐进式L0-L3测试层级的测试会话,生成测试任务,然后通过自适应修复周期执行任务,直到通过率≥95%或达到最大迭代次数。
Architecture Overview
架构概述
┌───────────────────────────────────────────────────────────────────────────┐
│ Workflow Test Fix Orchestrator (SKILL.md) │
│ → Pure coordinator: Route entry point, track progress, pass context │
│ → Five phases: Session → Context → Analysis → TaskGen → Execution │
└──────────────────────────────────┬────────────────────────────────────────┘
│
┌────────────┬────────────┬──────┴──────┬────────────┬────────────┐
↓ ↓ ↓ ↓ ↓
┌──────────┐┌──────────┐┌──────────┐┌──────────┐ ┌──────────────┐
│ 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 4, executed in Phase 5):
┌──────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
│ 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 N iter │
│@code-developer│ │ @test-fix-agent │ │ @test-fix-agent │ │@test-fix-agent│
└──────────────┘ └─────────────────┘ └─────────────────┘ └──────────────┘┌───────────────────────────────────────────────────────────────────────────┐
│ Workflow Test Fix Orchestrator (SKILL.md) │
│ → 纯协调器:路由入口点、跟踪进度、传递上下文 │
│ → 五个阶段:Session → Context → Analysis → TaskGen → Execution │
└──────────────────────────────────┬────────────────────────────────────────┘
│
┌────────────┬────────────┬──────┴──────┬────────────┬────────────┐
↓ ↓ ↓ ↓ ↓
┌──────────┐┌──────────┐┌──────────┐┌──────────┐ ┌──────────────┐
│ 阶段1 ││ 阶段2 ││ 阶段3 ││ 阶段4 │ │ 阶段5 │
│ 会话启动 ││ 上下文收集 ││ 增强分析 ││ 任务生成 │ │ 测试周期执行 │
│ ││ ││ ││ │ │ │
│ 输入检测+││ 覆盖率或代码││ Gemini ││ IMPL_PLAN│ │ 1. 发现环节│
│ 会话创建 ││ 扫描 ││ L0-L3 ││ IMPL-* │ │ 2. 执行环节 │
│ ││ ││ AI问题分析 ││ TODO_LIST│ │ 3. 修复循环 │
│ ││ ││ ││ │ │ 4. 完成环节 │
└────┬─────┘└────┬─────┘└────┬─────┘└────┬─────┘ └──────────────┘
│ │ │ │ ↑
│testSessionId │ │ │
└──→────────┘contextPath│ │ │
└──→───────┘AnalysisRes│ │
└──→──────┘ testSessionId │
└──→──(摘要)──→┘
任务流水线(第4阶段生成,第5阶段执行):
┌──────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
│ IMPL-001 │──→│ IMPL-001.3 │──→│ IMPL-001.5 │──→│ IMPL-002 │
│ 测试生成 │ │ 代码验证 │ │ 质量门禁 │ │ 测试与修复 │
│ L1-L3 │ │ L0 + AI问题检测 │ │ 覆盖率80%+ │ │ 最大N次迭代 │
│@code-developer│ │ @test-fix-agent │ │ @test-fix-agent │ │@test-fix-agent│
└──────────────┘ └─────────────────┘ └─────────────────┘ └──────────────┘Key Design Principles
核心设计原则
- Unified Pipeline: Generation and execution are one continuous workflow - no manual handoff
- Pure Orchestrator: SKILL.md coordinates only - delegates all execution detail to phase files
- Auto-Continue: Phase 1→2→3→4→(Summary)→5 automatically
- Task Attachment/Collapse: Sub-tasks attached during phase execution, collapsed after completion
- Progressive Phase Loading: Phase docs read only when that phase executes, not upfront
- Adaptive Strategy: Fix loop auto-selects strategy (conservative/aggressive/surgical) based on iteration context
- Quality Gate: Pass rate >= 95% (criticality-aware) terminates the fix loop
- Phase File Hygiene: Phase files reference for preferences, no CLI flag parsing
workflowPreferences.*
- 统一流水线:生成与执行为连续工作流,无需手动交接
- 纯编排器:SKILL.md仅负责协调,将所有执行细节委托给阶段文件
- 自动延续:阶段1→2→3→4→(摘要)→5自动执行
- 任务附加/折叠:子任务在阶段执行时附加,完成后折叠
- 渐进式阶段加载:仅在该阶段执行时才读取阶段文档,而非提前加载
- 自适应策略:修复循环根据迭代上下文自动选择策略(保守/激进/精准)
- 质量门禁:通过率≥95%(感知关键程度)时终止修复循环
- 阶段文件规范:阶段文件引用获取配置,不解析CLI标志
workflowPreferences.*
Usage
使用方法
Full pipeline and execute-only modes are triggered by skill name routing (see Mode Detection). Workflow preferences (auto mode) are collected interactively via AskUserQuestion before dispatching to phases.
Full pipeline (workflow:test-fix-gen): Task description or session ID as arguments → interactive preference collection → generate + execute pipeline
Execute only (workflow:test-cycle-execute): Auto-discovers active session → interactive preference collection → execution loop
完整流水线和仅执行模式通过技能名称路由触发(见模式检测)。工作流偏好(自动模式)在分发到阶段前,通过AskUserQuestion交互收集。
完整流水线(workflow:test-fix-gen):以任务描述或会话ID为参数 → 交互式偏好收集 → 生成+执行流水线
仅执行模式(workflow:test-cycle-execute):自动发现活动会话 → 交互式偏好收集 → 执行循环
Interactive Preference Collection
交互式偏好收集
Before dispatching to phase execution, collect workflow preferences via AskUserQuestion:
javascript
// ★ 统一 auto mode 检测:-y/--yes 从 $ARGUMENTS 或 ccw 传播
const autoYes = /\b(-y|--yes)\b/.test($ARGUMENTS)
if (autoYes) {
// 自动模式:跳过所有询问,使用默认值
workflowPreferences = { autoYes: true }
} else {
const prefResponse = AskUserQuestion({
questions: [
{
question: "是否跳过所有确认步骤(自动模式)?",
header: "Auto Mode",
multiSelect: false,
options: [
{ label: "Interactive (Recommended)", description: "交互模式,包含确认步骤" },
{ label: "Auto", description: "跳过所有确认,自动执行" }
]
}
]
})
workflowPreferences = {
autoYes: prefResponse.autoMode === 'Auto'
}
}workflowPreferences is passed to phase execution as context variable, referenced as within phases.
workflowPreferences.autoYes在分发到阶段执行前,通过AskUserQuestion收集工作流偏好:
javascript
// ★ 统一auto mode检测:-y/--yes从$ARGUMENTS或ccw传播
const autoYes = /\b(-y|--yes)\b/.test($ARGUMENTS)
if (autoYes) {
// 自动模式:跳过所有询问,使用默认值
workflowPreferences = { autoYes: true }
} else {
const prefResponse = AskUserQuestion({
questions: [
{
question: "是否跳过所有确认步骤(自动模式)?",
header: "Auto Mode",
multiSelect: false,
options: [
{ label: "Interactive (Recommended)", description: "交互模式,包含确认步骤" },
{ label: "Auto", description: "跳过所有确认,自动执行" }
]
}
]
})
workflowPreferences = {
autoYes: prefResponse.autoMode === 'Auto'
}
}workflowPreferences作为上下文变量传递给阶段执行,在阶段内通过引用。
workflowPreferences.autoYesExecution Flow
执行流程
Entry Point Detection:
├─ /workflow:test-fix-gen → Full Pipeline (Phase 1→2→3→4→Summary→5)
└─ /workflow:test-cycle-execute → Execution Only (Phase 5)
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
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%)
│ ├─ Select strategy: conservative/aggressive/surgical
│ ├─ Generate fix task via @cli-planning-agent
│ ├─ Execute fix via @test-fix-agent
│ └─ Re-test → loop or exit
└─ Step 2.4: Completion (summary, session archive)
└─ Output: final pass_rate, summaryPhase Reference Documents (read on-demand when phase executes):
| Phase | Document | Purpose |
|---|---|---|
| 1 | phases/01-session-start.md | Detect input mode, create test session |
| 2 | phases/02-test-context-gather.md | Gather test context (coverage/codebase) |
| 3 | phases/03-test-concept-enhanced.md | Gemini analysis, L0-L3 test requirements |
| 4 | phases/04-test-task-generate.md | Generate task JSONs and IMPL_PLAN.md |
| 5 | phases/05-test-cycle-execute.md | Execute tasks, iterative fix cycles, completion |
入口点检测:
├─ /workflow:test-fix-gen → 完整流水线(阶段1→2→3→4→摘要→5)
└─ /workflow:test-cycle-execute → 仅执行模式(阶段5)
阶段1:会话启动(session-start)
└─ 参考:phases/01-session-start.md
├─ 步骤1.0:检测输入模式(session | prompt)
├─ 步骤1.1:创建测试会话 → testSessionId
└─ 输出:testSessionId, MODE
阶段2:测试上下文收集(test-context-gather)
└─ 参考:phases/02-test-context-gather.md
├─ 步骤1.2:收集测试上下文 → contextPath
└─ 输出:contextPath
阶段3:测试概念增强(test-concept-enhanced)
└─ 参考:phases/03-test-concept-enhanced.md
├─ 步骤1.3:Gemini测试分析 → TEST_ANALYSIS_RESULTS.md
└─ 输出:TEST_ANALYSIS_RESULTS.md
阶段4:测试任务生成(test-task-generate)
└─ 参考:phases/04-test-task-generate.md
├─ 步骤1.4:生成测试任务 → IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
└─ 输出:testSessionId, 4+任务JSON文件
摘要输出(阶段4后内嵌显示):
└─ 显示摘要,自动延续到阶段5
阶段5:测试周期执行(test-cycle-execute)
└─ 参考:phases/05-test-cycle-execute.md
├─ 步骤2.1:发现环节(加载会话、任务、迭代状态)
├─ 步骤2.2:执行初始任务(IMPL-001 → 001.3 → 001.5 → 002)
├─ 步骤2.3:修复循环(若pass_rate < 95%)
│ ├─ 选择策略:保守/激进/精准
│ ├─ 通过@cli-planning-agent生成修复任务
│ ├─ 通过@test-fix-agent执行修复
│ └─ 重新测试 → 循环或退出
└─ 步骤2.4:完成环节(摘要、会话归档)
└─ 输出:最终pass_rate、摘要阶段参考文档(仅在该阶段即将执行时读取):
| 阶段 | 文档 | 用途 |
|---|---|---|
| 1 | phases/01-session-start.md | 检测输入模式,创建测试会话 |
| 2 | phases/02-test-context-gather.md | 收集测试上下文(覆盖率/代码库) |
| 3 | phases/03-test-concept-enhanced.md | Gemini分析,L0-L3测试需求 |
| 4 | phases/04-test-task-generate.md | 生成任务JSON和IMPL_PLAN.md |
| 5 | phases/05-test-cycle-execute.md | 执行任务、迭代修复循环、完成流程 |
Core Rules
核心规则
- Start Immediately: First action is TaskCreate initialization, second action is Phase 1 (or Phase 5 for execute-only entry)
- No Preliminary Analysis: Do not read files or gather context before starting the phase
- Parse Every Output: Extract required data from each step output for next step
- Auto-Continue: Phase 1→2→3→4→(Summary)→5 automatically (for full pipeline entry)
- Track Progress: Update TaskCreate/TaskUpdate dynamically with task attachment/collapse pattern
- Task Attachment Model: Sub-tasks attached during phase, collapsed after completion
- DO NOT STOP: Continuous workflow until quality gate met or max iterations reached
- Progressive Loading: Read phase doc ONLY when that phase is about to execute
- Entry Point Routing: → Phase 1-5;
/workflow:test-fix-gen→ Phase 5 only/workflow:test-cycle-execute
- 立即启动:第一个操作是TaskCreate初始化,第二个操作是阶段1(仅执行入口则为阶段5)
- 无预分析:启动阶段前不读取文件或收集上下文
- 解析所有输出:从每个步骤输出中提取下一步所需数据
- 自动延续:完整流水线入口下,阶段1→2→3→4→(摘要)→5自动执行
- 跟踪进度:通过任务附加/折叠模式动态更新TaskCreate/TaskUpdate
- 任务附加模型:子任务在阶段执行时附加,完成后折叠
- 持续执行:工作流持续运行,直到满足质量门禁或达到最大迭代次数
- 渐进式加载:仅在该阶段即将执行时才读取阶段文档
- 入口点路由:→ 阶段1-5;
/workflow:test-fix-gen→ 仅阶段5/workflow:test-cycle-execute
Input Processing
输入处理
test-fix-gen Entry (Full Pipeline)
test-fix-gen入口(完整流水线)
User input → Detect type:
├─ Starts with "WFS-" → MODE=session, sourceSessionId=input
├─ Ends with ".md" → MODE=prompt, description=Read(input)
└─ Otherwise → MODE=prompt, description=input用户输入 → 检测类型:
├─ 以"WFS-"开头 → MODE=session, sourceSessionId=输入内容
├─ 以".md"结尾 → MODE=prompt, description=读取(输入文件)
└─ 其他情况 → MODE=prompt, description=输入内容test-cycle-execute Entry (Phase 5 Only)
test-cycle-execute入口(仅阶段5)
Arguments → Parse flags:
├─ --resume-session="WFS-xxx" → sessionId=WFS-xxx
├─ --max-iterations=N → maxIterations=N (default: 10)
└─ (no args) → auto-discover active test session参数 → 解析标志:
├─ --resume-session="WFS-xxx" → sessionId=WFS-xxx
├─ --max-iterations=N → maxIterations=N(默认值:10)
└─ 无参数 → 自动发现活动测试会话Data Flow
数据流
User Input (session ID | description | file path)
↓
[Detect Mode: session | prompt]
↓
Phase 1: Session Start ─────────────────────────────────────────
↓ 1.0+1.1: session:start → testSessionId, MODE
↓
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用户输入(会话ID | 描述 | 文件路径)
↓
[检测模式:session | prompt]
↓
阶段1:会话启动 ─────────────────────────────────────────
↓ 1.0+1.1: session:start → testSessionId, MODE
↓
阶段2:测试上下文收集 ────────────────────────────────────
↓ 1.2: test-context-gather/context-gather → contextPath
↓
阶段3:测试概念增强 ──────────────────────────────────
↓ 1.3: test-concept-enhanced → TEST_ANALYSIS_RESULTS.md
↓
阶段4:测试任务生成 ─────────────────────────────────────
↓ 1.4: test-task-generate → IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
↓
摘要输出(内嵌显示) ─────────────────────────────────────────
↓ 显示包含下一步的摘要
↓
阶段5:测试周期执行 ───────────────────────────────────
↓ 2.1: 加载会话、任务、迭代状态
↓ 2.2: 按顺序执行初始任务
↓ 2.3: 计算test-results.json中的通过率
↓ 2.4: 若pass_rate < 95%:进入修复循环
↓ 2.5: 跟踪迭代次数、阻塞测试、回归情况
↓ 2.6: 若pass_rate ≥95%或达到最大迭代次数:完成流程
↓ 2.7: 生成完成摘要
↓ 2.8: 提供完成后扩展选项Summary Output (after Phase 4)
阶段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.mdCRITICAL - Next Step: Auto-continue to Phase 5: Test Cycle Execution.
Pass to Phase 5 for test execution pipeline. Do NOT wait for user confirmation — the unified pipeline continues automatically.
testSessionId阶段4完成后,在自动延续到阶段5前显示以下摘要:
测试修复工作流创建成功!
输入:[原始输入]
模式:[Session|Prompt]
测试会话:[testSessionId]
已创建任务:
- IMPL-001: 测试理解与生成 (@code-developer)
- IMPL-001.3: 代码验证门禁 - AI错误检测 (@test-fix-agent)
- IMPL-001.5: 测试质量门禁 - 静态分析与覆盖率 (@test-fix-agent)
- IMPL-002: 测试执行与修复循环 (@test-fix-agent)
质量阈值:
- 代码验证:零CRITICAL问题,零编译错误
- 最低覆盖率:80%行覆盖率,70%分支覆盖率
- 静态分析:零关键反模式
- 最大修复迭代次数:5
查看产物:
- 测试计划:.workflow/[testSessionId]/IMPL_PLAN.md
- 任务列表:.workflow/[testSessionId]/TODO_LIST.md
- 分析结果:.workflow/[testSessionId]/.process/TEST_ANALYSIS_RESULTS.md重要 - 下一步:自动延续到阶段5:测试周期执行。将传递给阶段5以执行测试流水线。无需等待用户确认——统一流水线将自动继续。
testSessionIdTest Strategy Overview
测试策略概述
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) |
Quality Thresholds:
- Code Validation (IMPL-001.3): Zero CRITICAL issues, zero compilation errors
- Minimum Coverage: 80% line, 70% branch
- Static Analysis (IMPL-001.5): Zero critical anti-patterns
- Pass Rate Gate: >= 95% (criticality-aware) or 100%
- Max Fix Iterations: 10 (default, adjustable)
渐进式测试层级(L0-L3):
| 层级 | 名称 | 关注点 |
|---|---|---|
| L0 | 静态分析 | 编译、导入、类型、AI代码问题 |
| L1 | 单元测试 | 函数/类行为(正常/异常/边界场景) |
| L2 | 集成测试 | 组件交互、API契约、故障模式 |
| L3 | 端到端测试 | 用户旅程、关键路径(可选) |
质量阈值:
- 代码验证(IMPL-001.3):零CRITICAL问题,零编译错误
- 最低覆盖率:80%行覆盖率,70%分支覆盖率
- 静态分析(IMPL-001.5):零关键反模式
- 通过率门禁:≥95%(感知关键程度)或100%
- 最大修复迭代次数:10(默认值,可调整)
Strategy Engine (Phase 5)
策略引擎(阶段5)
| 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 and CLI fallback chain (Gemini → Qwen → Codex) are detailed in Phase 5.
| 策略 | 触发条件 | 行为 |
|---|---|---|
| 保守策略 | 迭代1-2(默认) | 单一针对性修复,完整验证 |
| 激进策略 | 通过率>80% + 类似失败 | 批量修复相关问题 |
| 精准策略 | 检测到回归(通过率下降>10%) | 最小化变更,聚焦回滚 |
选择逻辑和CLI降级链(Gemini → Qwen → Codex)在阶段5中有详细说明。
Agent Roles
Agent角色
| Agent | Used In | Responsibility |
|---|---|---|
| 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 |
| Agent | 使用阶段 | 职责 |
|---|---|---|
| 编排器 | 所有阶段 | 路由入口、跟踪进度、传递上下文 |
| @code-developer | 阶段5(IMPL-001) | 测试生成(L1-L3) |
| @test-fix-agent | 阶段5 | 测试执行、代码修复、关键程度分配 |
| @cli-planning-agent | 阶段5(修复循环) | CLI分析、根因提取、修复任务生成 |
TodoWrite Pattern
TodoWrite模式
Core Concept: Dynamic task tracking with attachment/collapse for real-time visibility.
Implementation Note: Phase files usesyntax to describe the conceptual tracking pattern. At runtime, these are implemented viaTodoWritetools from the allowed-tools list. MapTaskCreate/TaskUpdate/TaskListexamples as follows:TodoWrite
- Initial list creation →
for each itemTaskCreate- Status changes →
TaskUpdate({ taskId, status })- Sub-task attachment →
+TaskCreateTaskUpdate({ addBlockedBy })- Sub-task collapse →
+TaskUpdate({ status: "completed" })for collapsed sub-itemsTaskUpdate({ status: "deleted" })
核心概念:通过附加/折叠实现动态任务跟踪,确保实时可见性。
实现说明:阶段文件使用语法描述概念性跟踪模式。在运行时,这些模式通过允许工具列表中的TodoWrite工具实现。TaskCreate/TaskUpdate/TaskList示例映射如下:TodoWrite
- 初始列表创建 → 为每个项调用
TaskCreate- 状态变更 →
TaskUpdate({ taskId, status })- 子任务附加 →
+TaskCreateTaskUpdate({ addBlockedBy })- 子任务折叠 →
+ 对折叠子项调用`TaskUpdate({ status: "deleted" })TaskUpdate({ status: "completed" })
Full Pipeline (Phase 1-5)
完整流水线(阶段1-5)
json
[
{"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"}
]json
[
{"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-4 Collapsed → Phase 5 Active
阶段1-4折叠 → 阶段5激活
json
[
{"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"},
{"content": " → Execute IMPL-002 [test-fix-agent]", "status": "pending"},
{"content": " → Fix Loop", "status": "pending"}
]json
[
{"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"},
{"content": " → Execute IMPL-002 [test-fix-agent]", "status": "pending"},
{"content": " → Fix Loop", "status": "pending"}
]Fix Loop Iterations
修复循环迭代
json
[
{"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"},
{"content": " → Iteration 3: Batch fix (pass: 89%, aggressive)", "status": "in_progress"}
]json
[
{"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"},
{"content": " → Iteration 3: Batch fix (pass: 89%, aggressive)", "status": "in_progress"}
]Session File 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-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)
│ ├── 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/.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 # 生成的修复任务(阶段5修复循环)
├── .process/
│ ├── [test-]context-package.json # 上下文与覆盖率分析
│ ├── TEST_ANALYSIS_RESULTS.md # 测试需求(L0-L3)
│ ├── iteration-state.json # 当前迭代+策略+阻塞测试
│ ├── test-results.json # 最新结果(pass_rate、关键程度)
│ ├── test-output.log # 完整测试输出
│ ├── fix-history.json # 所有修复尝试
│ ├── iteration-{N}-analysis.md # CLI分析报告
│ └── iteration-{N}-cli-output.txt
└── .summaries/
└── iteration-summaries/Error Handling
错误处理
Phase 1-4 (Generation)
阶段1-4(生成环节)
| 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 |
| 阶段 | 错误条件 | 操作 |
|---|---|---|
| 1: 会话启动 | 源会话未找到(session模式) | 返回包含会话ID的错误 |
| 1: 会话启动 | 无已完成的IMPL任务(session模式) | 返回错误,源会话不完整 |
| 2: 上下文收集 | 上下文收集失败 | 返回错误,检查源产物 |
| 3: 分析环节 | Gemini分析失败 | 返回错误,检查上下文包 |
| 4: 任务生成 | 任务生成失败 | 重试一次,然后返回错误 |
Phase 5 (Execution)
阶段5(执行环节)
| 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 |
| 场景 | 操作 |
|---|---|
| 测试执行错误 | 记录日志,携带错误上下文重试 |
| CLI分析失败 | 降级方案:Gemini → Qwen → Codex → 手动处理 |
| Agent执行错误 | 保存状态,携带简化上下文重试 |
| 达到最大迭代次数 | 生成失败报告,标记为阻塞 |
| 检测到回归 | 回滚最后一次修复,切换为精准策略 |
| 检测到阻塞测试 | 采用替代策略继续,记录文档 |
Commit Strategy (Phase 5)
提交策略(阶段5)
Automatic commits at key checkpoints:
- After successful iteration (pass rate increased):
test-cycle: iteration N - strategy (pass: old% → new%) - Before rollback (regression detected):
test-cycle: rollback iteration N - regression detected
在关键检查点自动提交:
- 迭代成功后(通过率提升):
test-cycle: iteration N - strategy (pass: old% → new%) - 回滚前(检测到回归):
test-cycle: rollback iteration N - regression detected
Completion Conditions
完成条件
| Condition | Pass Rate | Action |
|---|---|---|
| Full Success | 100% | Auto-complete session |
| Partial Success | >= 95%, all failures low criticality | Auto-approve with review note |
| Failure | < 95% after max iterations | Failure report, mark blocked |
| 条件 | 通过率 | 操作 |
|---|---|---|
| 完全成功 | 100% | 自动完成会话 |
| 部分成功 | ≥95%,所有失败为低关键程度 | 自动批准并添加审核备注 |
| 失败 | 达到最大迭代次数后<95% | 生成失败报告,标记为阻塞 |
Post-Completion Expansion
完成后扩展
After completion, ask user if they want to expand into issues (test/enhance/refactor/doc). Selected items call .
/issue:new "{summary} - {dimension}"完成后,询问用户是否要扩展为问题(测试/增强/重构/文档)。选中项将调用。
/issue:new "{summary} - {dimension}"Coordinator Checklist
协调器检查清单
Phase 1 (session-start)
阶段1(session-start)
- Detect input type (session ID / description / file path)
- Initialize TaskCreate before any execution
- Read Phase 1 doc, execute Steps 1.0 + 1.1
- Parse testSessionId from step output, store in memory
- 检测输入类型(会话ID / 描述 / 文件路径)
- 在任何执行前初始化TaskCreate
- 读取阶段1文档,执行步骤1.0 + 1.1
- 从步骤输出中解析testSessionId,存储到内存
Phase 2 (test-context-gather)
阶段2(test-context-gather)
- Read Phase 2 doc, execute Step 1.2
- Parse contextPath from step output, store in memory
- 读取阶段2文档,执行步骤1.2
- 从步骤输出中解析contextPath,存储到内存
Phase 3 (test-concept-enhanced)
阶段3(test-concept-enhanced)
- Read Phase 3 doc, execute Step 1.3
- Verify TEST_ANALYSIS_RESULTS.md created
- 读取阶段3文档,执行步骤1.3
- 验证TEST_ANALYSIS_RESULTS.md已创建
Phase 4 (test-task-generate)
阶段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
- 读取阶段4文档,执行步骤1.4
- 验证阶段1-4所有输出(4个任务JSON、IMPL_PLAN.md、TODO_LIST.md)
- 显示内嵌摘要输出
- 折叠阶段1-4任务,自动延续到阶段5
Phase 5 (test-cycle-execute)
阶段5(test-cycle-execute)
- Read Phase 5 doc
- Load session, tasks, iteration state
- Execute initial tasks sequentially
- Calculate pass rate from test-results.json
- If pass_rate < 95%: Enter fix loop
- Track iteration count, stuck tests, regression
- If pass_rate >= 95% or max iterations: Complete
- Generate completion summary
- Offer post-completion expansion
- 读取阶段5文档
- 加载会话、任务、迭代状态
- 按顺序执行初始任务
- 从test-results.json计算通过率
- 若pass_rate < 95%:进入修复循环
- 跟踪迭代次数、阻塞测试、回归情况
- 若pass_rate ≥95%或达到最大迭代次数:完成流程
- 生成完成摘要
- 提供完成后扩展选项
Related Skills
相关技能
Prerequisite Skills:
- or
/workflow:plan- Complete implementation (Session Mode source)/workflow:execute - None for Prompt Mode
Follow-up Skills:
- Display session status inline - Review workflow state
- - Post-implementation review
/workflow:review-session-cycle - - Create follow-up issues
/issue:new
前置技能:
- 或
/workflow:plan- 完整实现(Session Mode源)/workflow:execute - Prompt Mode无前置技能
后续技能:
- 内嵌显示会话状态 - 查看工作流状态
- - 实现后评审
/workflow:review-session-cycle - - 创建后续问题
/issue:new