Loading...
Loading...
Compare original and translation side by side
┌──────────────────────────────────────────────────────────────────┐
│ Workflow TDD Orchestrator (SKILL.md) │
│ → Route by mode: plan | verify │
│ → Pure coordinator: Execute phases, parse outputs, pass context │
└──────────────────────────────┬───────────────────────────────────┘
│
┌───────────────────────┴───────────────────────┐
↓ ↓
┌─────────────┐ ┌───────────┐
│ Plan Mode │ │ Verify │
│ (default) │ │ Mode │
│ Phase 1-6 │ │ Phase 7 │
└──────┬──────┘ └───────────┘
│
┌─────┼─────┬─────┬─────┬─────┐
↓ ↓ ↓ ↓ ↓ ↓
┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐
│ 1 │ │ 2 │ │ 3 │ │ 4 │ │ 5 │ │ 6 │
│Ses│ │Ctx│ │Tst│ │Con│ │Gen│ │Val│
└───┘ └───┘ └───┘ └───┘ └─┬─┘ └───┘
↓
┌───────────┐
│ Confirm │─── Verify ──→ Phase 7
│ (choice) │─── Execute ─→ Skill("workflow-execute")
└───────────┘─── Review ──→ Display session status inline┌──────────────────────────────────────────────────────────────────┐
│ Workflow TDD Orchestrator (SKILL.md) │
│ → 按模式路由:plan | verify │
│ → 纯协调器:执行阶段、解析输出、传递上下文 │
└──────────────────────────────┬───────────────────────────────────┘
│
┌───────────────────────┴───────────────────────┐
↓ ↓
┌─────────────┐ ┌───────────┐
│ Plan模式 │ │ Verify │
│ (默认) │ │ 模式 │
│ 阶段1-6 │ │ 阶段7 │
└──────┬──────┘ └───────────┘
│
┌─────┼─────┬─────┬─────┬─────┐
↓ ↓ ↓ ↓ ↓ ↓
┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐
│ 1 │ │ 2 │ │ 3 │ │ 4 │ │ 5 │ │ 6 │
│会话│ │上下文│ │测试│ │冲突│ │生成│ │验证│
└───┘ └───┘ └───┘ └───┘ └─┬─┘ └───┘
↓
┌───────────┐
│ 确认 │─── 验证 ──→ 阶段7
│ (选项) │─── 执行 ─→ Skill("workflow-execute")
└───────────┘─── 查看 ──→ 内联显示会话状态// ★ 统一 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.autoYes// ★ 统一 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.autoYesconst args = $ARGUMENTS
const mode = detectMode(args)
function detectMode(args) {
// Skill trigger determines mode
if (skillName === 'workflow-tdd-verify') return 'verify'
return 'plan' // default: workflow-tdd-plan
}const args = $ARGUMENTS
const mode = detectMode(args)
function detectMode(args) {
// 技能触发词决定模式
if (skillName === 'workflow-tdd-verify') return 'verify'
return 'plan' // 默认:workflow-tdd-plan
}⚠️ COMPACT DIRECTIVE: Context compression MUST check TodoWrite phase status. The phase currently markedis the active execution phase — preserve its FULL content. Only compress phases markedin_progressorcompleted.pending
⚠️ 压缩指令:上下文压缩必须检查TodoWrite阶段状态。 当前标记为的阶段是活跃执行阶段 —— 保留其完整内容。 仅压缩标记为in_progress或completed的阶段。pending
Input Parsing:
└─ Convert user input to TDD structured format (GOAL/SCOPE/CONTEXT/TEST_FOCUS)
Phase 1: Session Discovery
└─ Ref: phases/01-session-discovery.md
└─ Output: sessionId (WFS-xxx)
Phase 2: Context Gathering
└─ Ref: phases/02-context-gathering.md
├─ Tasks attached: Analyze structure → Identify integration → Generate package
└─ Output: contextPath + conflictRisk
Phase 3: Test Coverage Analysis
└─ Ref: phases/03-test-coverage-analysis.md
├─ Tasks attached: Detect framework → Analyze coverage → Identify gaps
└─ Output: testContextPath
Phase 4: Conflict Resolution (conditional: conflictRisk ≥ medium)
└─ Decision (conflictRisk check):
├─ conflictRisk ≥ medium → Ref: phases/04-conflict-resolution.md
│ ├─ Tasks attached: Detect conflicts → Log analysis → Apply strategies
│ └─ Output: conflict-resolution.json
└─ conflictRisk < medium → Skip to Phase 5
Phase 5: TDD Task Generation
└─ Ref: phases/05-tdd-task-generation.md
├─ Tasks attached: Discovery → Planning → Output
└─ Output: IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
Phase 6: TDD Structure Validation
└─ Ref: phases/06-tdd-structure-validation.md
└─ Output: Validation report + Plan Confirmation Gate
Plan Confirmation (User Decision Gate):
└─ Decision (user choice):
├─ "Verify TDD Compliance" (Recommended) → Route to Phase 7 (tdd-verify)
├─ "Start Execution" → Skill(skill="workflow-execute")
└─ "Review Status Only" → Display session status inline输入解析:
└─ 将用户输入转换为TDD结构化格式(GOAL/SCOPE/CONTEXT/TEST_FOCUS)
阶段1:会话发现
└─ 参考:phases/01-session-discovery.md
└─ 输出:sessionId (WFS-xxx)
阶段2:上下文收集
└─ 参考:phases/02-context-gathering.md
├─ 附加任务:分析结构 → 识别集成 → 生成包
└─ 输出:contextPath + conflictRisk
阶段3:测试覆盖分析
└─ 参考:phases/03-test-coverage-analysis.md
├─ 附加任务:检测框架 → 分析覆盖率 → 识别缺口
└─ 输出:testContextPath
阶段4:冲突解决(条件:conflictRisk ≥ medium)
└─ 决策(conflictRisk检查):
├─ conflictRisk ≥ medium → 参考:phases/04-conflict-resolution.md
│ ├─ 附加任务:检测冲突 → 记录分析 → 应用策略
│ └─ 输出:conflict-resolution.json
└─ conflictRisk < medium → 跳过至阶段5
阶段5:TDD任务生成
└─ 参考:phases/05-tdd-task-generation.md
├─ 附加任务:发现 → 规划 → 输出
└─ 输出:IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
阶段6:TDD结构验证
└─ 参考:phases/06-tdd-structure-validation.md
└─ 输出:验证报告 + 计划确认门
计划确认(用户决策门):
├─ "验证TDD合规性"(推荐)→ 路由至阶段7(tdd-verify)
├─ "开始执行" → Skill(skill="workflow-execute")
└─ "仅查看状态" → 内联显示会话状态Phase 7: TDD Verification
└─ Ref: phases/07-tdd-verify.md
└─ Output: TDD_COMPLIANCE_REPORT.md with quality gate recommendation| Phase | Document | Purpose | Mode | Compact |
|---|---|---|---|---|
| 1 | phases/01-session-discovery.md | Create or discover TDD workflow session | plan | TodoWrite 驱动 |
| 2 | phases/02-context-gathering.md | Gather project context and analyze codebase | plan | TodoWrite 驱动 |
| 3 | phases/03-test-coverage-analysis.md | Analyze test coverage and framework detection | plan | TodoWrite 驱动 |
| 4 | phases/04-conflict-resolution.md | Detect and resolve conflicts (conditional) | plan | TodoWrite 驱动 |
| 5 | phases/05-tdd-task-generation.md | Generate TDD tasks with Red-Green-Refactor cycles | plan | TodoWrite 驱动 + 🔄 sentinel |
| 6 | phases/06-tdd-structure-validation.md | Validate TDD structure and present confirmation gate | plan | TodoWrite 驱动 + 🔄 sentinel |
| 7 | phases/07-tdd-verify.md | Full TDD compliance verification with quality gate | verify | TodoWrite 驱动 |
in_progresscompletedRead()阶段7:TDD验证
└─ 参考:phases/07-tdd-verify.md
└─ 输出:带有质量门建议的TDD_COMPLIANCE_REPORT.md| 阶段 | 文档 | 目的 | 模式 | 压缩规则 |
|---|---|---|---|---|
| 1 | phases/01-session-discovery.md | 创建或发现TDD工作流会话 | plan | TodoWrite 驱动 |
| 2 | phases/02-context-gathering.md | 收集项目上下文并分析代码库 | plan | TodoWrite 驱动 |
| 3 | phases/03-test-coverage-analysis.md | 分析测试覆盖情况并检测框架 | plan | TodoWrite 驱动 |
| 4 | phases/04-conflict-resolution.md | 检测并解决冲突(条件触发) | plan | TodoWrite 驱动 |
| 5 | phases/05-tdd-task-generation.md | 生成含红-绿-重构周期的TDD任务 | plan | TodoWrite 驱动 + 🔄 sentinel |
| 6 | phases/06-tdd-structure-validation.md | 验证TDD结构并呈现确认门 | plan | TodoWrite 驱动 + 🔄 sentinel |
| 7 | phases/07-tdd-verify.md | 完整TDD合规性验证及质量门 | verify | TodoWrite 驱动 |
in_progresscompletedRead()NO PRODUCTION CODE WITHOUT A FAILING TEST FIRSTimplementationNO PRODUCTION CODE WITHOUT A FAILING TEST FIRSTimplementation| Checkpoint | Validation Phase | Evidence Required |
|---|---|---|
| Test-first structure | Phase 5 | |
| Red phase exists | Phase 6 | Step 1: |
| Green phase with test-fix | Phase 6 | Step 2: |
| Refactor phase exists | Phase 6 | Step 3: |
| 检查点 | 验证阶段 | 所需证据 |
|---|---|---|
| 测试优先结构 | 阶段5 | |
| 红阶段存在 | 阶段6 | 步骤1: |
| 含测试修复的绿阶段 | 阶段6 | 步骤2: |
| 重构阶段存在 | 阶段6 | 步骤3: |
User: "Build authentication system"
Structured:
TDD: Authentication System
GOAL: Build authentication system
SCOPE: Core authentication features
CONTEXT: New implementation
TEST_FOCUS: Authentication scenariosUser: "Add JWT authentication with email/password login and token refresh"
Structured:
TDD: JWT Authentication
GOAL: Implement JWT-based authentication
SCOPE: Email/password login, token generation, token refresh endpoints
CONTEXT: JWT token-based security, refresh token rotation
TEST_FOCUS: Login flow, token validation, refresh rotation, error cases用户: "构建认证系统"
结构化:
TDD: 认证系统
GOAL: 构建认证系统
SCOPE: 核心认证功能
CONTEXT: 全新实现
TEST_FOCUS: 认证场景用户: "添加支持邮箱/密码登录和令牌刷新的JWT认证"
结构化:
TDD: JWT认证
GOAL: 实现基于JWT的认证
SCOPE: 邮箱/密码登录、令牌生成、令牌刷新端点
CONTEXT: JWT令牌安全、刷新令牌轮换
TEST_FOCUS: 登录流程、令牌验证、刷新轮换、错误场景User Input (task description)
↓
[Convert to TDD Structured Format]
↓ Structured Description:
↓ TDD: [Feature Name]
↓ GOAL: [objective]
↓ SCOPE: [boundaries]
↓ CONTEXT: [background]
↓ TEST_FOCUS: [test scenarios]
↓
Phase 1: session:start --auto "TDD: structured-description"
↓ Output: sessionId
↓
Phase 2: context-gather --session sessionId "structured-description"
↓ Input: sessionId + structured description
↓ Output: contextPath (context-package.json) + conflictRisk
↓
Phase 3: test-context-gather --session sessionId
↓ Input: sessionId
↓ Output: testContextPath (test-context-package.json)
↓
Phase 4: conflict-resolution [conditional: conflictRisk ≥ medium]
↓ Input: sessionId + contextPath + conflictRisk
↓ Output: conflict-resolution.json
↓ Skip if conflictRisk is none/low → proceed directly to Phase 5
↓
Phase 5: task-generate-tdd --session sessionId
↓ Input: sessionId + all accumulated context
↓ Output: IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
↓
Phase 6: TDD Structure Validation (internal)
↓ Validate Red-Green-Refactor structure
↓ Present Plan Confirmation Gate
↓
Plan Confirmation (User Decision Gate):
├─ "Verify TDD Compliance" (Recommended) → Route to Phase 7
├─ "Start Execution" → Skill(skill="workflow-execute")
└─ "Review Status Only" → Display session status inline用户输入(任务描述)
↓
[转换为TDD结构化格式]
↓ 结构化描述:
↓ TDD: [功能名称]
↓ GOAL: [目标]
↓ SCOPE: [边界]
↓ CONTEXT: [背景]
↓ TEST_FOCUS: [测试场景]
↓
阶段1: session:start --auto "TDD: structured-description"
↓ 输出: sessionId
↓
阶段2: context-gather --session sessionId "structured-description"
↓ 输入: sessionId + 结构化描述
↓ 输出: contextPath (context-package.json) + conflictRisk
↓
阶段3: test-context-gather --session sessionId
↓ 输入: sessionId
↓ 输出: testContextPath (test-context-package.json)
↓
阶段4: conflict-resolution [条件: conflictRisk ≥ medium]
↓ 输入: sessionId + contextPath + conflictRisk
↓ 输出: conflict-resolution.json
↓ 若conflictRisk为none/low则跳过 → 直接进入阶段5
↓
阶段5: task-generate-tdd --session sessionId
↓ 输入: sessionId + 所有累积上下文
↓ 输出: IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
↓
阶段6: TDD结构验证(内部)
↓ 验证红-绿-重构结构
↓ 呈现计划确认门
↓
计划确认(用户决策门):
├─ "验证TDD合规性"(推荐)→ 路由至阶段7
├─ "开始执行" → Skill(skill="workflow-execute")
└─ "仅查看状态" → 内联显示会话状态Input: --session sessionId (or auto-detect)
↓
Phase 7: Session discovery → Chain validation → Coverage analysis → Report
↓ Output: TDD_COMPLIANCE_REPORT.md with quality gate输入: --session sessionId(或自动检测)
↓
阶段7: 会话发现 → 链验证 → 覆盖分析 → 报告
↓ 输出: 带有质量门的TDD_COMPLIANCE_REPORT.mdImplementation Note: Phase files usesyntax to describe the conceptual tracking pattern. At runtime, these are implemented viaTodoWritetools. Map as follows:TaskCreate/TaskUpdate/TaskList
- 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
- 初始列表创建 → 为每个项目执行
TaskCreate- 状态变更 →
TaskUpdate({ taskId, status })- 子任务附加 →
+TaskCreateTaskUpdate({ addBlockedBy })- 子任务折叠 →
+ 对折叠子项执行`TaskUpdate({ status: "deleted" })TaskUpdate({ status: "completed" })
in_progresspendingin_progresspending[
{"content": "Phase 1: Session Discovery", "status": "in_progress", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "pending", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "pending", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
][
{"content": "Phase 1: Session Discovery", "status": "in_progress", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "pending", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "pending", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
][
{"content": "Phase 1: Session Discovery", "status": "completed"},
{"content": "Phase 2: Context Gathering", "status": "completed"},
{"content": "Phase 3: Test Coverage Analysis", "status": "in_progress"},
{"content": " → Detect test framework and conventions", "status": "in_progress"},
{"content": " → Analyze existing test coverage", "status": "pending"},
{"content": " → Identify coverage gaps", "status": "pending"},
{"content": "Phase 5: TDD Task Generation", "status": "pending"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending"}
][
{"content": "Phase 1: Session Discovery", "status": "completed"},
{"content": "Phase 2: Context Gathering", "status": "completed"},
{"content": "Phase 3: Test Coverage Analysis", "status": "in_progress"},
{"content": " → Detect test framework and conventions", "status": "in_progress"},
{"content": " → Analyze existing test coverage", "status": "pending"},
{"content": " → Identify coverage gaps", "status": "pending"},
{"content": "Phase 5: TDD Task Generation", "status": "pending"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending"}
][
{"content": "Phase 1: Session Discovery", "status": "completed"},
{"content": "Phase 2: Context Gathering", "status": "completed"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed"},
{"content": "Phase 5: TDD Task Generation", "status": "pending"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending"}
][
{"content": "Phase 1: Session Discovery", "status": "completed"},
{"content": "Phase 2: Context Gathering", "status": "completed"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed"},
{"content": "Phase 5: TDD Task Generation", "status": "pending"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending"}
][
{"content": "Phase 1: Session Discovery", "status": "completed"},
{"content": "Phase 2: Context Gathering", "status": "completed"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed"},
{"content": "Phase 5: TDD Task Generation", "status": "in_progress"},
{"content": " → Discovery - analyze TDD requirements", "status": "in_progress"},
{"content": " → Planning - design Red-Green-Refactor cycles", "status": "pending"},
{"content": " → Output - generate IMPL tasks with internal TDD phases", "status": "pending"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending"}
][
{"content": "Phase 1: Session Discovery", "status": "completed"},
{"content": "Phase 2: Context Gathering", "status": "completed"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed"},
{"content": "Phase 5: TDD Task Generation", "status": "in_progress"},
{"content": " → Discovery - analyze TDD requirements", "status": "in_progress"},
{"content": " → Planning - design Red-Green-Refactor cycles", "status": "pending"},
{"content": " → Output - generate IMPL tasks with internal TDD phases", "status": "pending"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending"}
]Skill(skill="memory-capture")Skill(skill="memory-capture")planning-notes.mdplanning-notes.mdin_progressin_progress| Error Type | Detection | Recovery Action |
|---|---|---|
| Parsing failure | Empty/malformed output | Retry once, then report |
| Missing context-package | File read error | Re-run Phase 2 (context-gathering) |
| Invalid task JSON | jq parse error | Report malformed file path |
| Task count exceeds 18 | Count validation ≥19 | Request re-scope, split into multiple sessions |
| Missing cli_execution.id | All tasks lack ID | Regenerate tasks with phase 0 user config |
| Test-context missing | File not found | Re-run Phase 3 (test-coverage-analysis) |
| Phase timeout | No response | Retry phase, check CLI connectivity |
| CLI tool not available | Tool not in cli-tools.json | Fall back to alternative preferred tool |
| 错误类型 | 检测方式 | 恢复操作 |
|---|---|---|
| 解析失败 | 输出为空/格式错误 | 重试一次,然后报告 |
| 缺少context-package | 文件读取错误 | 重新运行阶段2(上下文收集) |
| 无效任务JSON | jq解析错误 | 报告格式错误的文件路径 |
| 任务数超过18 | 计数验证≥19 | 请求重新划定范围,拆分为多个会话 |
| 缺少cli_execution.id | 所有任务均无ID | 使用阶段0用户配置重新生成任务 |
| 缺少test-context | 文件未找到 | 重新运行阶段3(测试覆盖分析) |
| 阶段超时 | 无响应 | 重试阶段,检查CLI连接性 |
| CLI工具不可用 | 工具不在cli-tools.json中 | 回退到替代首选工具 |
| Pattern | Warning Message | Recommended Action |
|---|---|---|
| Task count >10 | High task count detected | Consider splitting into multiple sessions |
| Missing test-fix-cycle | Green phase lacks auto-revert | Add |
| Red phase missing test path | Test file path not specified | Add explicit test file paths |
| Generic task names | Vague names like "Add feature" | Use specific behavior descriptions |
| No refactor criteria | Refactor phase lacks completion criteria | Define clear refactor scope |
| 模式 | 警告消息 | 推荐操作 |
|---|---|---|
| 任务数>10 | 检测到任务数过多 | 考虑拆分为多个会话 |
| 缺少test-fix-cycle | 绿阶段缺少自动回滚 | 向任务配置添加 |
| 红阶段缺少测试路径 | 未指定测试文件路径 | 添加明确的测试文件路径 |
| 通用任务名称 | 模糊名称如"Add feature" | 使用具体的行为描述 |
| 无重构标准 | 重构阶段缺少完成标准 | 定义清晰的重构范围 |
.process/tdd-warnings.logworkflow-execute.process/tdd-warnings.logworkflow-execute/workflow:session:startphases/02-context-gathering.mdphases/03-test-coverage-analysis.mdphases/04-conflict-resolution.mdmemory-capturephases/05-tdd-task-generation.mdphases/07-tdd-verify.mdworkflow-tdd-planworkflow-planSkill(skill="workflow-execute")/workflow:session:startphases/02-context-gathering.mdphases/03-test-coverage-analysis.mdphases/04-conflict-resolution.mdmemory-capturephases/05-tdd-task-generation.mdphases/07-tdd-verify.mdworkflow-tdd-planworkflow-planSkill(skill="workflow-execute")