workflow-test-fix

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Workflow 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

核心设计原则

  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→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
  7. Quality Gate: Pass rate >= 95% (criticality-aware) terminates the fix loop
  8. Phase File Hygiene: Phase files reference
    workflowPreferences.*
    for preferences, no CLI flag parsing
  1. 统一流水线:生成与执行为连续工作流,无需手动交接
  2. 纯编排器:SKILL.md仅负责协调,将所有执行细节委托给阶段文件
  3. 自动延续:阶段1→2→3→4→(摘要)→5自动执行
  4. 任务附加/折叠:子任务在阶段执行时附加,完成后折叠
  5. 渐进式阶段加载:仅在该阶段执行时才读取阶段文档,而非提前加载
  6. 自适应策略:修复循环根据迭代上下文自动选择策略(保守/激进/精准)
  7. 质量门禁:通过率≥95%(感知关键程度)时终止修复循环
  8. 阶段文件规范:阶段文件引用
    workflowPreferences.*
    获取配置,不解析CLI标志

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
workflowPreferences.autoYes
within phases.
在分发到阶段执行前,通过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.autoYes
引用。

Execution 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, summary
Phase Reference Documents (read on-demand when phase executes):
PhaseDocumentPurpose
1phases/01-session-start.mdDetect input mode, create test session
2phases/02-test-context-gather.mdGather test context (coverage/codebase)
3phases/03-test-concept-enhanced.mdGemini analysis, L0-L3 test requirements
4phases/04-test-task-generate.mdGenerate task JSONs and IMPL_PLAN.md
5phases/05-test-cycle-execute.mdExecute 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、摘要
阶段参考文档(仅在该阶段即将执行时读取):
阶段文档用途
1phases/01-session-start.md检测输入模式,创建测试会话
2phases/02-test-context-gather.md收集测试上下文(覆盖率/代码库)
3phases/03-test-concept-enhanced.mdGemini分析,L0-L3测试需求
4phases/04-test-task-generate.md生成任务JSON和IMPL_PLAN.md
5phases/05-test-cycle-execute.md执行任务、迭代修复循环、完成流程

Core Rules

核心规则

  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→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-5;
    /workflow:test-cycle-execute
    → Phase 5 only
  1. 立即启动:第一个操作是TaskCreate初始化,第二个操作是阶段1(仅执行入口则为阶段5)
  2. 无预分析:启动阶段前不读取文件或收集上下文
  3. 解析所有输出:从每个步骤输出中提取下一步所需数据
  4. 自动延续:完整流水线入口下,阶段1→2→3→4→(摘要)→5自动执行
  5. 跟踪进度:通过任务附加/折叠模式动态更新TaskCreate/TaskUpdate
  6. 任务附加模型:子任务在阶段执行时附加,完成后折叠
  7. 持续执行:工作流持续运行,直到满足质量门禁或达到最大迭代次数
  8. 渐进式加载:仅在该阶段即将执行时才读取阶段文档
  9. 入口点路由
    /workflow:test-fix-gen
    → 阶段1-5;
    /workflow:test-cycle-execute
    → 仅阶段5

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.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.
阶段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:测试周期执行。将
testSessionId
传递给阶段5以执行测试流水线。无需等待用户确认——统一流水线将自动继续。

Test Strategy Overview

测试策略概述

Progressive Test Layers (L0-L3):
LayerNameFocus
L0Static AnalysisCompilation, imports, types, AI code issues
L1Unit TestsFunction/class behavior (happy/negative/edge cases)
L2Integration TestsComponent interactions, API contracts, failure modes
L3E2E TestsUser 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)

StrategyTriggerBehavior
ConservativeIteration 1-2 (default)Single targeted fix, full validation
AggressivePass rate >80% + similar failuresBatch fix related issues
SurgicalRegression 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角色

AgentUsed InResponsibility
OrchestratorAll phasesRoute entry, track progress, pass context
@code-developerPhase 5 (IMPL-001)Test generation (L1-L3)
@test-fix-agentPhase 5Test execution, code fixes, criticality assignment
@cli-planning-agentPhase 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 use
TodoWrite
syntax to describe the conceptual tracking pattern. At runtime, these are implemented via
TaskCreate/TaskUpdate/TaskList
tools from the allowed-tools list. Map
TodoWrite
examples as follows:
  • Initial list creation →
    TaskCreate
    for each item
  • Status changes →
    TaskUpdate({ taskId, status })
  • Sub-task attachment →
    TaskCreate
    +
    TaskUpdate({ addBlockedBy })
  • Sub-task collapse →
    TaskUpdate({ status: "completed" })
    +
    TaskUpdate({ status: "deleted" })
    for collapsed sub-items
核心概念:通过附加/折叠实现动态任务跟踪,确保实时可见性。
实现说明:阶段文件使用
TodoWrite
语法描述概念性跟踪模式。在运行时,这些模式通过允许工具列表中的
TaskCreate/TaskUpdate/TaskList
工具实现。
TodoWrite
示例映射如下:
  • 初始列表创建 → 为每个项调用
    TaskCreate
  • 状态变更 →
    TaskUpdate({ taskId, status })
  • 子任务附加 →
    TaskCreate
    +
    TaskUpdate({ addBlockedBy })
  • 子任务折叠 →
    TaskUpdate({ status: "completed" })
    + 对折叠子项调用`TaskUpdate({ status: "deleted" })

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(生成环节)

PhaseError ConditionAction
1: Session StartSource session not found (session mode)Return error with session ID
1: Session StartNo completed IMPL tasks (session mode)Return error, source incomplete
2: Context GatherContext gathering failedReturn error, check source artifacts
3: AnalysisGemini analysis failedReturn error, check context package
4: Task GenTask generation failedRetry once, then return error
阶段错误条件操作
1: 会话启动源会话未找到(session模式)返回包含会话ID的错误
1: 会话启动无已完成的IMPL任务(session模式)返回错误,源会话不完整
2: 上下文收集上下文收集失败返回错误,检查源产物
3: 分析环节Gemini分析失败返回错误,检查上下文包
4: 任务生成任务生成失败重试一次,然后返回错误

Phase 5 (Execution)

阶段5(执行环节)

ScenarioAction
Test execution errorLog, retry with error context
CLI analysis failureFallback: Gemini → Qwen → Codex → manual
Agent execution errorSave state, retry with simplified context
Max iterations reachedGenerate failure report, mark blocked
Regression detectedRollback last fix, switch to surgical strategy
Stuck tests detectedContinue with alternative strategy, document
场景操作
测试执行错误记录日志,携带错误上下文重试
CLI分析失败降级方案:Gemini → Qwen → Codex → 手动处理
Agent执行错误保存状态,携带简化上下文重试
达到最大迭代次数生成失败报告,标记为阻塞
检测到回归回滚最后一次修复,切换为精准策略
检测到阻塞测试采用替代策略继续,记录文档

Commit Strategy (Phase 5)

提交策略(阶段5)

Automatic commits at key checkpoints:
  1. After successful iteration (pass rate increased):
    test-cycle: iteration N - strategy (pass: old% → new%)
  2. Before rollback (regression detected):
    test-cycle: rollback iteration N - regression detected
在关键检查点自动提交:
  1. 迭代成功后(通过率提升):
    test-cycle: iteration N - strategy (pass: old% → new%)
  2. 回滚前(检测到回归):
    test-cycle: rollback iteration N - regression detected

Completion Conditions

完成条件

ConditionPass RateAction
Full Success100%Auto-complete session
Partial Success>= 95%, all failures low criticalityAuto-approve with review note
Failure< 95% after max iterationsFailure 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:
  • /workflow:plan
    or
    /workflow:execute
    - Complete implementation (Session Mode source)
  • None for Prompt Mode
Follow-up Skills:
  • Display session status inline - Review workflow state
  • /workflow:review-session-cycle
    - Post-implementation review
  • /issue:new
    - Create follow-up issues
前置技能:
  • /workflow:plan
    /workflow:execute
    - 完整实现(Session Mode源)
  • Prompt Mode无前置技能
后续技能:
  • 内嵌显示会话状态 - 查看工作流状态
  • /workflow:review-session-cycle
    - 实现后评审
  • /issue:new
    - 创建后续问题