Epic AI Swarm Orchestration v3.1
Multi-agent coding orchestration: plan → endorse → spawn → monitor → review → integrate → ship.
Core Workflow
- 1. Plan — Break work into parallel tasks, present plan to user for endorsement
- Endorse —
endorse-task.sh <task-id> (or auto-endorsed via spawn-batch.sh) - Spawn —
spawn-batch.sh (multi) or spawn-agent.sh (single) - Monitor — Auto: tmux sessions,
notify-on-complete.sh watchers, INLINECODE5 - Review — Auto: reviewer agent spawns on completion, max 3 fix rounds
- Integrate — Auto:
integration-watcher.sh merges all branches, resolves conflicts - Ship — Auto-merge to main, cleanup worktrees, notify user
Script Reference
Primary (use these)
| Script | Purpose | When |
|---|
| INLINECODE7 | Spawn N agents + auto-integration | Multi-agent work |
| INLINECODE8 |
Spawn single agent | Single tasks |
|
endorse-task.sh | Endorse a task | Before spawning |
|
check-agents.sh | Check tmux status | Quick status |
|
cleanup.sh | Remove worktrees + branches | Post-merge |
Usage
CODEBLOCK0
spawn-agent.sh
CODEBLOCK1
- -
project-dir: Absolute path to project root - INLINECODE13 : Unique ID (used for branch name + tmux session)
- INLINECODE14 : Task prompt text or path to
.md prompt file - INLINECODE16 :
claude | codex | gemini (default: claude) - INLINECODE21 : Model override (default: per duty table)
- INLINECODE22 :
low | medium | high (default: high)
Supporting Scripts
| Script | Purpose |
|---|
| INLINECODE27 | Poll + auto-merge (called by spawn-batch) |
| INLINECODE28 |
Per-agent watcher (called by spawn-agent) |
|
start-integration.sh | Manual integration start |
|
pulse-check.sh | Detect stuck agents |
|
queue-watcher.sh | Process inbox queue |
|
inbox-add.sh | Add task to inbox |
|
inbox-list.sh | List queued tasks |
|
assess-models.sh | Weekly model rotation |
|
deploy-notify.sh | CI/CD build notifications |
|
esr-log.sh | Log to ESR/work history |
|
daily-standup.sh | Generate standup summary |
|
cleanup.sh | Post-merge cleanup |
Setup
- 1. Copy
scripts/ to your workspace (e.g., ~/workspace/swarm/) - Copy
duty-table.template.json → duty-table.json and customize - Ensure
tmux, git, gh CLI, and at least one coding agent CLI are installed - For notifications: configure OpenClaw with Telegram/Discord
Dependencies
- -
bash 4+ (macOS: install via Homebrew, ships with Linux) - INLINECODE47 (all platforms:
brew install tmux / apt install tmux) - INLINECODE50 +
gh CLI (for PR creation and merging) - INLINECODE52 (JSON processing:
brew install jq / apt install jq) - At least one coding agent:
claude (Claude Code), codex, or INLINECODE57 - Optional:
openclaw (for Telegram/Discord notifications)
macOS Notes
- - macOS ships with bash 3.x; install bash 5+ via INLINECODE59
- Use
brew install gnu-sed and alias sed=gsed if scripts use GNU sed features - INLINECODE62 works identically on macOS and Linux
Configuration
duty-table.json
Maps roles to agents/models:
CODEBLOCK2
Endorsement System
Every task requires endorsement before spawning (safety gate):
- -
spawn-batch.sh auto-endorses all tasks in the batch - Manual: INLINECODE64
- 30-second cooldown between endorsement and spawn
Hard Rules
- 1. Always endorse before spawning — no endorsement = no spawn
- Use spawn-batch.sh for 2+ tasks — it starts the integration watcher
- Never use bare
claude --print in background — bypasses tmux, notifications, everything - Let notify-on-complete.sh handle notifications — don't add
openclaw system event to prompts
Epic AI 蜂群编排 v3.1
多智能体编码编排:规划 → 批准 → 生成 → 监控 → 审查 → 集成 → 交付。
核心工作流
- 1. 规划 — 将工作分解为并行任务,向用户展示计划以获取批准
- 批准 — endorse-task.sh (或通过 spawn-batch.sh 自动批准)
- 生成 — spawn-batch.sh(多智能体)或 spawn-agent.sh(单智能体)
- 监控 — 自动:tmux 会话、notify-on-complete.sh 监视器、pulse-check.sh
- 审查 — 自动:审查智能体在完成后自动生成,最多 3 轮修复
- 集成 — 自动:integration-watcher.sh 合并所有分支,解决冲突
- 交付 — 自动合并到主分支,清理工作树,通知用户
脚本参考
主要脚本(使用这些)
| 脚本 | 用途 | 使用时机 |
|---|
| spawn-batch.sh | 生成 N 个智能体 + 自动集成 | 多智能体工作 |
| spawn-agent.sh |
生成单个智能体 | 单个任务 |
| endorse-task.sh | 批准任务 | 生成之前 |
| check-agents.sh | 检查 tmux 状态 | 快速状态检查 |
| cleanup.sh | 移除工作树 + 分支 | 合并后 |
使用方法
bash
1. 编写提示
cat > /tmp/prompt-task1.md << EOF
... 任务描述 ...
EOF
2. 创建任务 JSON
cat > /tmp/tasks.json << EOF
[
{id: task-1, description: /tmp/prompt-task1.md, agent: claude, model: claude-sonnet-4-6},
{id: task-2, description: /tmp/prompt-task2.md, agent: claude, model: claude-sonnet-4-6}
]
EOF
3. 批准 + 生成
cd path/to/swarm/scripts
bash endorse-task.sh task-1
bash endorse-task.sh task-2
bash spawn-batch.sh /path/to/project batch-id Description /tmp/tasks.json
spawn-agent.sh
spawn-agent.sh <项目目录> <任务ID> <描述或提示文件> [智能体] [模型] [推理级别]
- - project-dir:项目根目录的绝对路径
- task-id:唯一 ID(用于分支名称和 tmux 会话)
- description:任务提示文本或 .md 提示文件的路径
- agent:claude | codex | gemini(默认:claude)
- model:模型覆盖(默认:按职责表)
- reasoning:low | medium | high(默认:high)
辅助脚本
| 脚本 | 用途 |
|---|
| integration-watcher.sh | 轮询 + 自动合并(由 spawn-batch 调用) |
| notify-on-complete.sh |
每个智能体的监视器(由 spawn-agent 调用) |
| start-integration.sh | 手动启动集成 |
| pulse-check.sh | 检测卡住的智能体 |
| queue-watcher.sh | 处理收件箱队列 |
| inbox-add.sh | 添加任务到收件箱 |
| inbox-list.sh | 列出队列中的任务 |
| assess-models.sh | 每周模型轮换 |
| deploy-notify.sh | CI/CD 构建通知 |
| esr-log.sh | 记录到 ESR/工作历史 |
| daily-standup.sh | 生成每日站会摘要 |
| cleanup.sh | 合并后清理 |
设置
- 1. 将 scripts/ 复制到你的工作空间(例如 ~/workspace/swarm/)
- 复制 duty-table.template.json → duty-table.json 并自定义
- 确保安装了 tmux、git、gh CLI 和至少一个编码智能体 CLI
- 通知功能:使用 Telegram/Discord 配置 OpenClaw
依赖项
- - bash 4+(macOS:通过 Homebrew 安装,Linux 自带)
- tmux(所有平台:brew install tmux / apt install tmux)
- git + gh CLI(用于创建和合并 PR)
- jq(JSON 处理:brew install jq / apt install jq)
- 至少一个编码智能体:claude(Claude Code)、codex 或 gemini
- 可选:openclaw(用于 Telegram/Discord 通知)
macOS 注意事项
- - macOS 自带 bash 3.x;通过 brew install bash 安装 bash 5+
- 如果脚本使用 GNU sed 功能,使用 brew install gnu-sed 并设置别名 sed=gsed
- tmux 在 macOS 和 Linux 上运行方式相同
配置
duty-table.json
将角色映射到智能体/模型:
json
{
dutyTable: {
architect: {agent: claude, model: claude-opus-4-6},
builder: {agent: claude, model: claude-sonnet-4-6},
reviewer: {agent: claude, model: claude-sonnet-4-6},
integrator:{agent: claude, model: claude-opus-4-6}
}
}
批准系统
每个任务在生成前都需要批准(安全门):
- - spawn-batch.sh 自动批准批次中的所有任务
- 手动:bash endorse-task.sh
- 批准和生成之间有 30 秒冷却时间
硬性规则
- 1. 始终在生成前批准 — 未批准 = 无法生成
- 2 个及以上任务使用 spawn-batch.sh — 它会启动集成监视器
- 切勿在后台使用裸 claude --print — 会绕过 tmux、通知等所有功能
- 让 notify-on-complete.sh 处理通知 — 不要在提示中添加 openclaw system event