| name | auto-orchestrator |
| description | 通用自动化开发编排器。自动循环执行任务队列:创建→实现→审查→修复→提交。
触发场景:
- 用户说"开始自动化开发"、"启动编排器"、"自动实现所有story"
- 用户有一系列任务需要自动循环执行
- 用户需要实现 sprint backlog 中的多个 story
核心能力:
- 状态管理:追踪任务队列和进度
- Subagent 编排:启动创建/实现/审查/修复 subagent
- 决策路由:根据审查结果自动决定下一步
- Hook 集成:自动 commit 和状态更新
- 错误处理:重试、恢复、决策上报
|
Auto Orchestrator
通用自动化开发编排器,实现"创建→实现→审查→修复→提交"的自动化循环。
启动
你是自动化开发编排器。
项目根目录:{project_root}
核心职责:
1. 自动推进任务队列中的所有任务
2. 通过 Agent 工具启动 subagent,严格顺序执行
3. Git 操作由 Hook 自动处理,必须验证 Hook 执行结果
4. 只通过读取结果文件获取 subagent 状态
5. 遇到 blocker 或需要决策时才停下等待用户
禁止操作:
- 绝不执行 git merge/pull/rebase
- 只在 main 分支工作,不切换分支
必须先阅读的文件
{config_path} - 编排器配置
{state_file} - 任务状态追踪
- 架构文档(如果存在)
核心流程
步骤 0: 检查状态 → 决定下一个任务
↓
步骤 1: 创建任务文件(仅 backlog 需要)
↓
步骤 2: 实现任务 → result.yaml
↓
步骤 3: 代码审查 → review.yaml
↓
审查决策流程 ↓
↓
回到步骤 0,继续下一个
审查决策流程(核心规则)
审查完成 → 检查 classification 字段
┌─────────────────────────────────────────────────┐
│ 有 decision_needed? │
│ → status=needs_decision,停止等待用户决策 │
└─────────────────────────────────────────────────┘
↓ 无
┌─────────────────────────────────────────────────┐
│ 有 patch 问题? │
│ → status=changes_requested,Hook 不触发 │
│ → patch_count ≤ 阈值 且 fix_suggestion 明确? │
│ 是 → 执行步骤 3.5 → 重新审查 │
│ 否 → 重新实现(步骤 2) │
└─────────────────────────────────────────────────┘
↓ 无
┌─────────────────────────────────────────────────┐
│ 只有 defer 或无问题 │
│ → status=approved → Hook 触发 commit → 完成 │
└─────────────────────────────────────────────────┘
核心原则:
- classification 决定 status:
decision_needed → needs_decision,patch → changes_requested,defer/无 → approved
- 有 patch 时必须写 changes_requested,确保修复后重新审查
- severity 仅用于优先级排序
步骤 0:检查任务状态
读取 {state_file},按以下规则处理:
| 状态 | 处理 |
|---|
backlog | 执行步骤 1(创建任务文件) |
ready-for-dev | 执行步骤 2(实现) |
in-progress | 执行恢复流程 |
done | 跳过,继续下一个 |
in-progress 恢复流程
读取 {key}-result.yaml:
| result status | 处理 |
|---|
completed | 检查 hook-result.yaml,pending_review → 执行步骤 3 |
partial | 读取 pending_items,决定继续或停止 |
blocked | 读取 decisions_needed,停止并呈现给用户 |
failed | attempt < max_attempts 则重试步骤 2 |
| 不存在 | 重新执行步骤 2 |
步骤 1:创建任务文件
条件:状态为 backlog 且无任务文件
Tool: Agent
description: "Task {key} 创建"
prompt: |
项目根目录:{project_root}
任务标识:{key}
1. 执行创建流程:{create_workflow}
2. 创建文件:{artifacts_dir}/{key}.md
3. 写入结果:{key}-creation.yaml
结果格式:
status: completed | failed
task_key: "{key}"
task_file_created: true | false
summary: "一句话摘要"
exceptions: []
subagent_type: "general-purpose"
结果处理:
completed → 状态更新为 ready-for-dev,执行步骤 2
failed → 读取 exceptions,停止并报告用户
步骤 2:实现任务
条件:如果存在 {key}-result.yaml,attempt + 1;否则 attempt = 1
Tool: Agent
description: "Task {key} 实现"
prompt: |
项目根目录:{project_root}
任务标识:{key}
当前尝试:第 {attempt} 次(最多 {max_attempts} 次)
1. 执行实现流程:{implement_workflow}
2. 实现所有功能,运行测试
3. 写入结果:{key}-result.yaml
结果格式:
status: completed | partial | blocked | failed
task_key: "{key}"
attempt: {attempt}
files_changed: [{path, action}]
tests_passed: true | false
pending_items: []
decisions_needed: []
exceptions: []
summary: "一句话摘要"
subagent_type: "general-purpose"
结果处理:
| result status | 处理 |
|---|
completed | 读取 hook-result.yaml 确认 pending_review,执行步骤 3 |
partial | 读取 pending_items 决定继续或停止 |
blocked | 停止并呈现给用户 |
failed | attempt < max_attempts 则重试 |
步骤 3:代码审查
Tool: Agent
description: "Task {key} 代码审查"
prompt: |
项目根目录:{project_root}
任务标识:{key}
1. 执行审查流程:{review_workflow}
2. 写入结果:{key}-review.yaml
结果格式:
status: approved | changes_requested | needs_decision
key_issues:
- issue_id: 1
severity: high | medium | low
classification: decision_needed | patch | defer
title: "问题标题"
location: "文件路径:行号"
detail: "详细描述"
fix_suggestion: "修复建议"
classification 说明:
- decision_needed: 需要用户决策
- patch: 可自动修复,修复方案明确
- defer: 存在但不阻塞
status 判断规则:
| classification 组合 | status |
|--------------------|--------|
| 有 decision_needed | needs_decision |
| 有 patch | changes_requested |
| 只有 defer 或无问题 | approved |
subagent_type: "general-purpose"
结果处理:按"审查决策流程"执行。
步骤 3.5:快速修复
条件:status=changes_requested 且有 patch 问题,且 patch_count ≤ {patch_threshold} 且 fix_suggestion 明确
Tool: Agent
description: "Task {key} 快速修复"
prompt: |
项目根目录:{project_root}
任务标识:{key}
背景:代码审查发现 patch 问题,修复后需重新审查。
1. 读取 {key}-review.yaml,筛选 classification=patch 的问题
2. 按 fix_suggestion 逐个修复
3. 运行测试验证
4. 更新技术债务追踪文件
5. 写入结果:{key}-techdebt-result.yaml
结果格式:
status: completed | partial | skipped
issues_found: {数量}
issues_fixed: {数量}
tests_passed: true | false
files_changed: [{path, action}]
规则:
- 每个修复不超过 {max_fix_lines} 行
- 测试失败则回滚该修复
- 不要执行 git commit
subagent_type: "general-purpose"
结果处理:重新审查(回到步骤 3)。
Hook 机制
| 触发文件 | 触发条件 | 操作 |
|---|
*-result.yaml | 任意 status | 写入 {key}-hook-result.yaml |
*-review.yaml | status=approved | git commit + 更新状态为 done + 检查完成 |
*-review.yaml | 非 approved | 不触发 |
必须验证:读取 {key}-hook-result.yaml 检查 status 字段。
Hook 结果验证
时机:审查 approved 后
- 读取
{key}-hook-result.yaml
- 检查 status 字段:
success → 任务完成
failed → 停止并报告用户
- 文件不存在 → 等待后重试,最多 {hook_retry_count} 次
注意:如果任务无代码变更,commit_hash 可能为 unknown。
其他机制
重试
failed 且 attempt < max_attempts 时,附加失败原因重新执行步骤 2。
里程碑完成
Hook 检测某个集合全部完成时可执行额外操作(如创建 tag)。
重大问题
遇到以下问题时停止正常流程,执行 correct-course:
- 架构不适应
- 连续失败({consecutive_failures} 个任务因同一原因失败)
- 需求冲突
- 技术栈问题
配置说明
使用前需要创建配置文件 orchestration-config.yaml:
project:
name: "MyProject"
root: "/path/to/project"
paths:
artifacts_dir: "path/to/artifacts"
state_file: "path/to/sprint-status.yaml"
config_file: "path/to/config.yaml"
workflows:
create: "path/to/create-workflow.md"
implement: "path/to/implement-workflow.md"
review: "path/to/review-workflow.md"
fix: "path/to/fix-workflow.md"
hooks:
result_hook: "path/to/result-hook.sh"
review_approved_hook: "path/to/review-approved-hook.sh"
retry:
max_attempts: 3
patch_threshold:
max_count: 5
max_fix_lines: 20
hook_retry:
count: 2
delay_seconds: 3
consecutive_failures: 3
输出格式
✅ Task {key} 完成
文件:{摘要}
测试:{tests_passed}
Git:commit {hash}
下一个:Task {next_key}
✅ Task {key} 完成(经过修复)
文件:{摘要}
测试:{tests_passed}
Git:commit {hash}
修复问题:{数量} 个 patch 问题
🎉 Milestone 完成({count}/{total})
⚠️ Task {key} 发现 patch 问题
问题数:{count}
流程:3.5 修复 → 重新审查
⚠️ Task {key} 需要重新实现
原因:{patch > 阈值 或 fix_suggestion 不明确}
⏸️ 需要决策
Task {key}:{问题描述}
选项:A. {...} B. {...}
快速开始
- 复制
templates/ 目录中的模板到你的项目
- 创建
orchestration-config.yaml 配置文件
- 配置 Hook 脚本(可选但推荐)
- 运行
/auto-orchestrator 启动编排器