Loading...
Loading...
Compare original and translation side by side
┌─────────────────────────────────────────────────────────────┐
│ User Input (Task) │
└────────────────────────────┬────────────────────────────────┘
│
v
┌──────────────────────────────┐
│ Main Flow (Inline Orchestration) │
│ Phase 1 → 2 → 3 → 4 │
└──────────────────────────────┘
│
┌────────────────────┼────────────────────┐
│ │ │
v v v
┌────────┐ ┌────────┐ ┌────────┐
│ RA │ │ EP │ │ CD │
│Agent │ │Agent │ │Agent │
└────────┘ └────────┘ └────────┘
│ │ │
└────────────────────┼────────────────────┘
│
v
┌────────┐
│ VAS │
│ Agent │
└────────┘
│
v
┌──────────────────────────────┐
│ Summary Report │
│ & Markdown Docs │
└──────────────────────────────┘┌─────────────────────────────────────────────────────────────┐
│ User Input (Task) │
└────────────────────────────┬────────────────────────────────┘
│
v
┌──────────────────────────────┐
│ Main Flow (Inline Orchestration) │
│ Phase 1 → 2 → 3 → 4 │
└──────────────────────────────┘
│
┌────────────────────┼────────────────────┐
│ │ │
v v v
┌────────┐ ┌────────┐ ┌────────┐
│ RA │ │ EP │ │ CD │
│Agent │ │Agent │ │Agent │
└────────┘ └────────┘ └────────┘
│ │ │
└────────────────────┼────────────────────┘
│
v
┌────────┐
│ VAS │
│ Agent │
└────────┘
│
v
┌──────────────────────────────┐
│ Summary Report │
│ & Markdown Docs │
└──────────────────────────────┘history/discoveries.ndjsonhistory/discoveries.ndjson| Arg | Required | Description |
|---|---|---|
| TASK | One of TASK or --cycle-id | Task description (for new cycle, mutually exclusive with --cycle-id) |
| --cycle-id | One of TASK or --cycle-id | Existing cycle ID to continue (from API or previous session) |
| --extend | No | Extension description (only valid with --cycle-id) |
| --auto | No | Auto-cycle mode (run all phases sequentially without user confirmation) |
| --parallel | No | Number of parallel agents (default: 4, max: 4) |
| 参数 | 是否必填 | 描述 |
|---|---|---|
| TASK | TASK或--cycle-id二选一 | 任务描述(用于新周期,与--cycle-id互斥) |
| --cycle-id | TASK或--cycle-id二选一 | 要继续的现有周期ID(来自API或之前的会话) |
| --extend | 否 | 扩展描述(仅与--cycle-id配合有效) |
| --auto | 否 | 自动周期模式(按顺序运行所有阶段,无需用户确认) |
| --parallel | 否 | 并行Agent数量(默认:4,最大值:4) |
--auto--autoprep-package.json{projectRoot}/.workflow/.cycle/prep-package.json/prompts:prep-cycle{projectRoot}/.workflow/.cycle/prep-package.json/prompts:prep-cycleInput Parsing:
└─ Parse arguments (TASK | --cycle-id + --extend)
└─ Convert to structured context (cycleId, state, progressDir)
Phase 1: Session Initialization
└─ Ref: phases/01-session-init.md
├─ Create new cycle OR resume existing cycle
├─ Initialize state file and directory structure
└─ Output: cycleId, state, progressDir
Phase 2: Agent Execution (Parallel)
└─ Ref: phases/02-agent-execution.md
├─ Tasks attached: Spawn RA → Spawn EP → Spawn CD → Spawn VAS → Wait all
├─ Spawn RA, EP, CD, VAS agents in parallel
├─ Wait for all agents with timeout handling
└─ Output: agentOutputs (4 agent results)
Phase 3: Result Aggregation & Iteration
└─ Ref: phases/03-result-aggregation.md
├─ Parse PHASE_RESULT from each agent
├─ Detect issues (test failures, blockers)
├─ Decision: Issues found AND iteration < max?
│ ├─ Yes → Send feedback via send_input, loop back to Phase 2
│ └─ No → Proceed to Phase 4
└─ Output: parsedResults, iteration status
Phase 4: Completion & Summary
└─ Ref: phases/04-completion-summary.md
├─ Generate unified summary report
├─ Update final state
├─ Sync session state: $session-sync -y "Dev cycle complete: {iterations} iterations"
├─ Close all agents
└─ Output: final cycle report with continuation instructions| Phase | Document | Purpose |
|---|---|---|
| 1 | phases/01-session-init.md | Session creation/resume and state initialization |
| 2 | phases/02-agent-execution.md | Parallel agent spawning and execution |
| 3 | phases/03-result-aggregation.md | Result parsing, feedback generation, iteration handling |
| 4 | phases/04-completion-summary.md | Final summary generation and cleanup |
Input Parsing:
└─ Parse arguments (TASK | --cycle-id + --extend)
└─ Convert to structured context (cycleId, state, progressDir)
Phase 1: Session Initialization
└─ Ref: phases/01-session-init.md
├─ Create new cycle OR resume existing cycle
├─ Initialize state file and directory structure
└─ Output: cycleId, state, progressDir
Phase 2: Agent Execution (Parallel)
└─ Ref: phases/02-agent-execution.md
├─ Tasks attached: Spawn RA → Spawn EP → Spawn CD → Spawn VAS → Wait all
├─ Spawn RA, EP, CD, VAS agents in parallel
├─ Wait for all agents with timeout handling
└─ Output: agentOutputs (4 agent results)
Phase 3: Result Aggregation & Iteration
└─ Ref: phases/03-result-aggregation.md
├─ Parse PHASE_RESULT from each agent
├─ Detect issues (test failures, blockers)
├─ Decision: Issues found AND iteration < max?
│ ├─ Yes → Send feedback via send_input, loop back to Phase 2
│ └─ No → Proceed to Phase 4
└─ Output: parsedResults, iteration status
Phase 4: Completion & Summary
└─ Ref: phases/04-completion-summary.md
├─ Generate unified summary report
├─ Update final state
├─ Sync session state: $session-sync -y "Dev cycle complete: {iterations} iterations"
├─ Close all agents
└─ Output: final cycle report with continuation instructions| 阶段 | 文档 | 用途 |
|---|---|---|
| 1 | phases/01-session-init.md | 会话创建/恢复与状态初始化 |
| 2 | phases/02-agent-execution.md | 并行Agent启动与执行 |
| 3 | phases/03-result-aggregation.md | 结果解析、反馈生成、迭代处理 |
| 4 | phases/04-completion-summary.md | 最终总结生成与清理 |
User Input (TASK | --cycle-id + --extend)
↓
[Parse Arguments]
↓ cycleId, state, progressDir
Phase 1: Session Initialization
↓ cycleId, state, progressDir (initialized/resumed)
Phase 2: Agent Execution
├─ All agents read coordination/discoveries.ndjson on start
├─ Each agent explores → writes new discoveries to board
├─ Later-finishing agents benefit from earlier agents' findings
↓ agentOutputs {ra, ep, cd, vas} + shared discoveries.ndjson
Phase 3: Result Aggregation
↓ parsedResults, hasIssues, iteration count
↓ [Loop back to Phase 2 if issues and iteration < max]
↓ (discoveries.ndjson carries over across iterations)
Phase 4: Completion & Summary
↓ finalState, summaryReport
Return: cycle_id, iterations, final_stateUser Input (TASK | --cycle-id + --extend)
↓
[Parse Arguments]
↓ cycleId, state, progressDir
Phase 1: Session Initialization
↓ cycleId, state, progressDir (initialized/resumed)
Phase 2: Agent Execution
├─ All agents read coordination/discoveries.ndjson on start
├─ Each agent explores → writes new discoveries to board
├─ Later-finishing agents benefit from earlier agents' findings
↓ agentOutputs {ra, ep, cd, vas} + shared discoveries.ndjson
Phase 3: Result Aggregation
↓ parsedResults, hasIssues, iteration count
↓ [Loop back to Phase 2 if issues and iteration < max]
↓ (discoveries.ndjson carries over across iterations)
Phase 4: Completion & Summary
↓ finalState, summaryReport
Return: cycle_id, iterations, final_state{projectRoot}/.workflow/.cycle/
├── {cycleId}.json # Master state file
├── {cycleId}.progress/
├── ra/
│ ├── requirements.md # Current version (complete rewrite)
│ ├── changes.log # NDJSON complete history (append-only)
│ └── history/ # Archived snapshots
├── ep/
│ ├── exploration.md # Codebase exploration report
│ ├── architecture.md # Architecture design
│ ├── plan.json # Structured task list (current version)
│ ├── changes.log # NDJSON complete history
│ └── history/
├── cd/
│ ├── implementation.md # Current version
│ ├── debug-log.ndjson # Debug hypothesis tracking
│ ├── changes.log # NDJSON complete history
│ └── history/
├── vas/
│ ├── summary.md # Current version
│ ├── changes.log # NDJSON complete history
│ └── history/
└── coordination/
├── discoveries.ndjson # Shared discovery board (all agents append)
├── timeline.md # Execution timeline
└── decisions.log # Decision log{projectRoot}/.workflow/.cycle/
├── {cycleId}.json # 主状态文件
├── {cycleId}.progress/
├── ra/
│ ├── requirements.md # 当前版本(完全重写)
│ ├── changes.log # NDJSON格式完整历史(追加写入)
│ └── history/ # 归档快照
├── ep/
│ ├── exploration.md # 代码库探索报告
│ ├── architecture.md # 架构设计
│ ├── plan.json # 结构化任务列表(当前版本)
│ ├── changes.log # NDJSON格式完整历史
│ └── history/
├── cd/
│ ├── implementation.md # 当前版本
│ ├── debug-log.ndjson # 调试假设追踪
│ ├── changes.log # NDJSON格式完整历史
│ └── history/
├── vas/
│ ├── summary.md # 当前版本
│ ├── changes.log # NDJSON格式完整历史
│ └── history/
└── coordination/
├── discoveries.ndjson # 共享发现看板(所有Agent追加内容)
├── timeline.md # 执行时间线
└── decisions.log # 决策日志{projectRoot}/.workflow/.cycle/{cycleId}.json{
"cycle_id": "cycle-v1-20260122T100000-abc123",
"title": "Task title",
"description": "Full task description",
"status": "created | running | paused | completed | failed",
"created_at": "ISO8601", "updated_at": "ISO8601",
"max_iterations": 5, "current_iteration": 0,
"agents": {
"ra": { "status": "idle | running | completed | failed", "output_files": [] },
"ep": { "status": "idle", "output_files": [] },
"cd": { "status": "idle", "output_files": [] },
"vas": { "status": "idle", "output_files": [] }
},
"current_phase": "init | ra | ep | cd | vas | aggregation | complete",
"completed_phases": [],
"requirements": null, "plan": null, "changes": [], "test_results": null,
"coordination": { "feedback_log": [], "blockers": [] }
}.progress/{projectRoot}/.workflow/.cycle/{cycleId}.json{
"cycle_id": "cycle-v1-20260122T100000-abc123",
"title": "Task title",
"description": "Full task description",
"status": "created | running | paused | completed | failed",
"created_at": "ISO8601", "updated_at": "ISO8601",
"max_iterations": 5, "current_iteration": 0,
"agents": {
"ra": { "status": "idle | running | completed | failed", "output_files": [] },
"ep": { "status": "idle", "output_files": [] },
"cd": { "status": "idle", "output_files": [] },
"vas": { "status": "idle", "output_files": [] }
},
"current_phase": "init | ra | ep | cd | vas | aggregation | complete",
"completed_phases": [],
"requirements": null, "plan": null, "changes": [], "test_results": null,
"coordination": { "feedback_log": [], "blockers": [] }
}.progress/[
{"content": "Phase 1: Session Initialization", "status": "completed"},
{"content": "Phase 2: Agent Execution", "status": "in_progress"},
{"content": " → Spawn RA Agent", "status": "completed"},
{"content": " → Spawn EP Agent", "status": "completed"},
{"content": " → Spawn CD Agent", "status": "in_progress"},
{"content": " → Spawn VAS Agent", "status": "pending"},
{"content": "Phase 3: Result Aggregation", "status": "pending"},
{"content": "Phase 4: Completion & Summary", "status": "pending"}
][
{"content": "Phase 1: Session Initialization", "status": "completed"},
{"content": "Phase 2: Agent Execution", "status": "in_progress"},
{"content": " → Spawn RA Agent", "status": "completed"},
{"content": " → Spawn EP Agent", "status": "completed"},
{"content": " → Spawn CD Agent", "status": "in_progress"},
{"content": " → Spawn VAS Agent", "status": "pending"},
{"content": "Phase 3: Result Aggregation", "status": "pending"},
{"content": "Phase 4: Completion & Summary", "status": "pending"}
][
{"content": "Phase 1: Session Initialization", "status": "completed"},
{"content": "Phase 2: Agent Execution (4 agents completed)", "status": "completed"},
{"content": "Phase 3: Result Aggregation", "status": "in_progress"},
{"content": "Phase 4: Completion & Summary", "status": "pending"}
][
{"content": "Phase 1: Session Initialization", "status": "completed"},
{"content": "Phase 2: Agent Execution (4 agents completed)", "status": "completed"},
{"content": "Phase 3: Result Aggregation", "status": "in_progress"},
{"content": "Phase 4: Completion & Summary", "status": "pending"}
][
{"content": "Phase 1: Session Initialization", "status": "completed"},
{"content": "Iteration 1: Agent Execution + Aggregation", "status": "completed"},
{"content": "Iteration 2: Feedback → Re-execution → Aggregation", "status": "in_progress"},
{"content": "Phase 4: Completion & Summary", "status": "pending"}
][
{"content": "Phase 1: Session Initialization", "status": "completed"},
{"content": "Iteration 1: Agent Execution + Aggregation", "status": "completed"},
{"content": "Iteration 2: Feedback → Re-execution → Aggregation", "status": "in_progress"},
{"content": "Phase 4: Completion & Summary", "status": "pending"}
]Archive: copy requirements.md → history/requirements-v1.0.0.md
Rewrite: overwrite requirements.md with v1.1.0 (complete new content)
Append: changes.log ← {"timestamp","version":"1.1.0","action":"update","description":"..."}| Agent Output | Rewrite (per iteration) | Append-only |
|---|---|---|
| RA | requirements.md | changes.log |
| EP | exploration.md, architecture.md, plan.json | changes.log |
| CD | implementation.md, issues.md | changes.log, debug-log.ndjson |
| VAS | summary.md, test-results.json | changes.log |
归档:将requirements.md复制到history/requirements-v1.0.0.md
重写:用v1.1.0版本内容覆盖requirements.md(全新内容)
追加:向changes.log写入{"timestamp","version":"1.1.0","action":"update","description":"..."}| Agent输出 | 每次迭代重写 | 仅追加 |
|---|---|---|
| RA | requirements.md | changes.log |
| EP | exploration.md, architecture.md, plan.json | changes.log |
| CD | implementation.md, issues.md | changes.log, debug-log.ndjson |
| VAS | summary.md, test-results.json | changes.log |
coordination/discoveries.ndjsonecho '...' >> discoveries.ndjsontsagenttypedata{"ts":"2026-01-22T10:00:00+08:00","agent":"ra","type":"tech_stack","data":{"language":"TypeScript","framework":"Express","test":"Jest","build":"tsup"}}| type | Dedup Key | Writers | Readers | Required |
|---|---|---|---|---|
| singleton | RA | EP, CD, VAS | |
| | RA | EP, CD | |
| | RA, EP | CD | |
| singleton | EP | CD, VAS | |
| | EP, CD | CD, VAS | |
| | EP | CD | |
| | EP | CD | |
| singleton | CD | VAS | |
| | CD | VAS | |
| singleton | CD, VAS | VAS, CD | |
| singleton | VAS | CD | |
| singleton | VAS | CD | |
| | any | all | |
echo >>typecoordination/discoveries.ndjsonecho '...' >> discoveries.ndjsontsagenttypedata{"ts":"2026-01-22T10:00:00+08:00","agent":"ra","type":"tech_stack","data":{"language":"TypeScript","framework":"Express","test":"Jest","build":"tsup"}}| 类型 | 去重键 | 写入Agent | 读取Agent | 必填 |
|---|---|---|---|---|
| 单例 | RA | EP, CD, VAS | |
| | RA | EP, CD | |
| | RA, EP | CD | |
| 单例 | EP | CD, VAS | |
| | EP, CD | CD, VAS | |
| | EP | CD | |
| | EP | CD | |
| 单例 | CD | VAS | |
| | CD | VAS | |
| 单例 | CD, VAS | VAS, CD | |
| 单例 | VAS | CD | |
| 单例 | VAS | CD | |
| | 任意 | 所有 | |
echo >>typePHASE_RESULT:
- phase: ra | ep | cd | vas
- status: success | failed | partial
- files_written: [list]
- summary: one-line summary
- issues: []PHASE_RESULT:
- phase: ra | ep | cd | vas
- status: success | failed | partial
- files_written: [列表]
- summary: 单行总结
- issues: []send_inputundefinedsend_inputundefined
**Rules**: Only main flow writes state file. Agents read state, write to own `.progress/{agent}/` directory only.
**规则**:仅主流程可写入状态文件。Agent仅读取状态,且仅写入自身的`.progress/{agent}/`目录。| Error Type | Recovery |
|---|---|
| Agent timeout | send_input requesting convergence, then retry |
| State corrupted | Rebuild from progress markdown files and changes.log |
| Agent failed | Re-spawn agent with previous context |
| Conflicting results | Main flow sends reconciliation request |
| Missing files | RA/EP agents identify and request clarification |
| Max iterations reached | Generate summary with remaining issues documented |
| 错误类型 | 恢复方式 |
|---|---|
| Agent超时 | 发送要求收敛的send_input请求,然后重试 |
| 状态损坏 | 从进度Markdown文件和changes.log重建 |
| Agent执行失败 | 使用之前的上下文重新启动Agent |
| 结果冲突 | 主流程发送协调请求 |
| 文件缺失 | RA/EP Agent识别问题并请求澄清 |
| 达到最大迭代次数 | 生成包含未解决问题的总结报告 |
| Document | Purpose |
|---|---|
| roles/ | Agent role definitions (RA, EP, CD, VAS) |
| 文档 | 用途 |
|---|---|
| roles/ | Agent角色定义(RA、EP、CD、VAS) |
undefinedundefinedundefinedundefined