omh-autopilot
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOMH Autopilot — End-to-End Autonomous Pipeline
OMH Autopilot — 端到端自主工作流
When to Use
适用场景
- End-to-end feature implementation from idea to verified, reviewed code
- The user says: "autopilot", "build me", "handle it all", "e2e this"
- 从想法到经过验证、评审的代码的端到端功能实现
- 用户提出:“autopilot”、“帮我构建”、“全权处理”、“完成这个端到端流程”
When NOT to Use
不适用场景
- Single-file changes or trivial tasks (just do them)
- You want to stay in one continuous session (autopilot is multi-session)
- You only need planning (omh-ralplan) or execution (omh-ralph)
- 单文件修改或琐碎任务(直接处理即可)
- 希望保持连续会话(autopilot为多会话模式)
- 仅需要规划(omh-ralplan)或执行(omh-ralph)功能
Prerequisites
前置条件
- The plugin must be installed (
omh)~/.hermes/plugins/omh/
- 必须安装插件(路径:
omh)~/.hermes/plugins/omh/
Architecture: One Phase Step Per Invocation
架构:每次调用执行一个阶段步骤
Each autopilot invocation reads state, does ONE unit of work, exits. The caller re-invokes.
This preserves fresh context at every level — including during the ralph loop.
Invocation 1: Phase 0 — requirements (or skip)
Invocation 2: Phase 1 — planning (or skip)
Invocations 3-N: Phase 2 — ralph iterations (one per call)
Invocation N+1: Phase 3 — QA cycle [FRESH SESSION]
Invocation M: Phase 4 — validation round [FRESH SESSION]
Final: Phase 5 — cleanup → completeSee for how to drive the loop.
references/caller-examples.md每次autopilot调用会读取状态,完成一项工作单元后退出。调用方会重新发起调用。
这种方式在每个层级都能保留最新上下文——包括在ralph循环期间。
Invocation 1: Phase 0 — requirements (or skip)
Invocation 2: Phase 1 — planning (or skip)
Invocations 3-N: Phase 2 — ralph iterations (one per call)
Invocation N+1: Phase 3 — QA cycle [FRESH SESSION]
Invocation M: Phase 4 — validation round [FRESH SESSION]
Final: Phase 5 — cleanup → complete更多调用示例请参考。
references/caller-examples.mdProcedure
流程步骤
Step 0: Resolve Instance and Acquire Lock
步骤0:解析实例并获取锁
Autopilot drives a goal through spec → plan → ralph → QA → validation.
Two autopilot sessions on the same goal would race on ,
, and state simultaneously. Use per-instance state
autopilotralphralph-tasks- advisory lock.
- Resolve in this order:
instance_id- If a confirmed spec exists at , use
.omh/specs/{name}-spec.md.instance_id = "{name}" - Else if a plan exists at , use
.omh/plans/ralplan-{slug}.md.instance_id = "{slug}" - Else derive from the goal: .
instance_id = kebab(goal)[:60]
- If a confirmed spec exists at
- Acquire the autopilot lock:
On
lock = omh_state(action="lock", mode="autopilot", lock_key="{instance_id}", session_id="{HERMES_SESSION_ID or uuid}", holder_note="autopilot driving {goal_or_plan}"), reportacquired=false, offer wait/cancel/different goal. Stale-pid auto-release applies.held_by - Pass to every
instance_idcall in this invocation (autopilot, ralph, ralph-tasks).omh_state - When dispatching to ralph in Phase 2, pass the same
in the delegation context so the ralph subagent acquires
instance_idlock on the same slug.mode="ralph" - Release the autopilot lock at every exit point (paused,
blocked, complete, exception):
omh_state(action="unlock", mode="autopilot", lock_key="{instance_id}", session_id="{HERMES_SESSION_ID or uuid}")
Singleton fallback (legacy). Omittingwritesinstance_idand skips locking. Acceptable only when running one autopilot at a time..omh/state/autopilot-state.json
Autopilot会推动目标从需求规格→规划→ralph执行→QA→验证的全流程。
针对同一目标的两个autopilot会话会在、和状态上产生竞争。需使用每个实例的独立状态+建议性锁。
autopilotralphralph-tasks- 按以下顺序解析:
instance_id- 如果存在已确认的需求规格,使用
.omh/specs/{name}-spec.md。instance_id = "{name}" - 如果存在规划文档,使用
.omh/plans/ralplan-{slug}.md。instance_id = "{slug}" - 否则从目标推导:。
instance_id = kebab(goal)[:60]
- 如果
- 获取autopilot锁:
如果
lock = omh_state(action="lock", mode="autopilot", lock_key="{instance_id}", session_id="{HERMES_SESSION_ID or uuid}", holder_note="autopilot driving {goal_or_plan}"),报告acquired=false信息,提供等待/取消/更换目标的选项。过期进程会自动释放锁。held_by - 在本次调用的所有请求中传入
omh_state(包括autopilot、ralph、ralph-tasks相关调用)。instance_id - 在阶段2调度ralph时,在委托上下文中传入相同的,以便ralph子代理获取同一标识的
instance_id锁。mode="ralph" - 在所有退出点释放autopilot锁(暂停、阻塞、完成、异常):
omh_state(action="unlock", mode="autopilot", lock_key="{instance_id}", session_id="{HERMES_SESSION_ID or uuid}")
单例回退(旧版):如果省略,会写入instance_id并跳过锁机制。仅在同时运行一个autopilot时适用。.omh/state/autopilot-state.json
On Every Invocation: Dispatch
每次调用:调度逻辑
state = omh_state(action="read", mode="autopilot", instance_id="{instance_id}")- Not found: Fresh start → Smart Detection (below)
- Found: Check flag → if true, clear it and exit (phase boundary)
context_checkpoint - Check staleness: → warn, offer fresh start
state.stale = true - Check pause: if matches current completed phase → set phase="paused", exit
pause_after_phase - Dispatch to current phase handler
state = omh_state(action="read", mode="autopilot", instance_id="{instance_id}")- 未找到状态:全新启动→智能检测(见下文)
- 找到状态:检查标记→如果为true,清除标记并退出(阶段边界)
context_checkpoint - 检查状态过期:→发出警告,提供重新启动选项
state.stale = true - 检查暂停设置:如果与当前已完成阶段匹配→设置phase="paused"并退出
pause_after_phase - 调度到当前阶段的处理逻辑
Smart Detection (Fresh Start)
智能检测(全新启动)
When no autopilot state exists, detect artifacts:
- Confirmed spec in → create state at Phase 1
.omh/specs/*-spec.md - Consensus plan in → create state at Phase 2
.omh/plans/ralplan-*.md - Ralph complete (→ phase="complete") → create state at Phase 3
omh_state(action="check", mode="ralph", instance_id="{instance_id}") - Nothing → create state at Phase 0
Check for active ralph: → if active, warn about existing session.
omh_state(action="check", mode="ralph", instance_id="{instance_id}")omh_state(action="write", mode="autopilot", instance_id="{instance_id}", data={
"phase": "requirements", "goal": "...", "ralph_iteration": 0,
"qa_cycle": 0, "max_qa_cycles": 5, "validation_round": 0,
"max_validation_rounds": 3, "validation_verdicts": {},
"skip_qa": false, "skip_validation": false, "pause_after_phase": null
})当不存在autopilot状态时,检测已有产物:
- 中存在已确认的需求规格→创建阶段1的状态
.omh/specs/*-spec.md - 中存在共识规划→创建阶段2的状态
.omh/plans/ralplan-*.md - Ralph执行完成(返回phase="complete")→创建阶段3的状态
omh_state(action="check", mode="ralph", instance_id="{instance_id}") - 无任何产物→创建阶段0的状态
检查是否有活跃的ralph会话:→如果活跃,警告用户存在现有会话。
omh_state(action="check", mode="ralph", instance_id="{instance_id}")omh_state(action="write", mode="autopilot", instance_id="{instance_id}", data={
"phase": "requirements", "goal": "...", "ralph_iteration": 0,
"qa_cycle": 0, "max_qa_cycles": 5, "validation_round": 0,
"max_validation_rounds": 3, "validation_verdicts": {},
"skip_qa": false, "skip_validation": false, "pause_after_phase": null
})Phase 0: Requirements
阶段0:需求确认
Goal: Ensure a confirmed spec exists.
- Check with
.omh/specs/*-spec.md→ found? Setstatus: confirmed, advance to Phase 1, exitspec_file - Not found — assess input:
- Concrete (file paths, function names, specific tech): generate inline spec, advance
- Vague: Load and follow it. This phase is interactive.
omh-deep-interview
- Update state: ,
phase: "planning". Exit.spec_file: "<path>"
For fully autonomous runs: run separately first.
omh-deep-interview目标:确保存在已确认的需求规格。
- 检查中是否有
.omh/specs/*-spec.md的文档→找到?设置status: confirmed,推进到阶段1并退出spec_file - 未找到→评估输入:
- 具体需求(含文件路径、函数名、特定技术):生成内嵌需求规格,推进阶段
- 模糊需求:加载并执行流程。本阶段为交互式。
omh-deep-interview
- 更新状态:,
phase: "planning"。退出。spec_file: "<path>"
完全自主运行建议:先单独运行。
omh-deep-interviewPhase 1: Planning
阶段1:规划制定
Goal: Ensure a consensus plan exists.
- Check → found? Set
.omh/plans/ralplan-*.md, advance to Phase 2, exitplan_file - Not found: Load , follow its procedure with the spec as input
omh-ralplan - Update state: ,
phase: "execution",plan_file,ralph_iteration: 0. Exit.context_checkpoint: true
目标:确保存在共识规划文档。
- 检查→找到?设置
.omh/plans/ralplan-*.md,推进到阶段2并退出plan_file - 未找到:加载,以需求规格为输入执行其流程
omh-ralplan - 更新状态:,
phase: "execution",plan_file,ralph_iteration: 0。退出。context_checkpoint: true
Phase 2: Execution (Ralph Iterations)
阶段2:执行(Ralph迭代)
Each invocation performs exactly ONE ralph iteration:
- Run one ralph iteration via with the omh-ralph skill context:
delegate_taskdelegate_task(goal="[omh-role:executor] Follow the omh-ralph skill procedure: read state, pick the next incomplete task, execute it, verify, update state, exit.", context="<current ralph state + plan file contents>") - After ralph completes its step, check ralph status:
ralph = omh_state(action="check", mode="ralph", instance_id="{instance_id}")- → increment
active=true, exit (caller re-invokes)ralph_iteration - → advance:
phase="complete",phase: "qa", exitcontext_checkpoint: true - → set autopilot
phase="blocked", report, exitphase: "blocked"
每次调用仅执行一次ralph迭代:
- 通过调用一次ralph迭代,传入omh-ralph技能上下文:
delegate_taskdelegate_task(goal="[omh-role:executor] Follow the omh-ralph skill procedure: read state, pick the next incomplete task, execute it, verify, update state, exit.", context="<current ralph state + plan file contents>") - ralph完成步骤后,检查其状态:
ralph = omh_state(action="check", mode="ralph", instance_id="{instance_id}")- →递增
active=true,退出(调用方重新发起调用)ralph_iteration - →推进阶段:
phase="complete",phase: "qa",退出context_checkpoint: true - →设置autopilot的
phase="blocked",报告状态并退出phase: "blocked"
Phase 3: QA Cycling
阶段3:QA循环
Each invocation performs ONE QA cycle. Starts in fresh session (context_checkpoint).
If → advance to Phase 4, exit.
skip_qa: true- Gather evidence using the project's actual build/test/lint commands (check for
Makefile, package.json, Cargo.toml, pyproject.toml, etc. to determine the right commands):
evidence = omh_gather_evidence(commands=["<build>", "<test>", "<lint>"]) - If → advance:
evidence.all_pass,phase: "validation", exitcontext_checkpoint: true - If failures:
- Increment . Check 3-strike on
qa_cycle. If triggered → phase="blocked", exitqa_error_history - If (default 5) → phase="blocked", exit
qa_cycle > max_qa_cycles - Delegate diagnosis to architect subagent (read-only)
- Delegate fix to executor subagent
- Update state, exit (next invocation re-runs QA)
- Increment
每次调用执行一次QA循环。在全新会话中启动(context_checkpoint)。
如果→推进到阶段4并退出。
skip_qa: true- 使用项目实际的构建/测试/代码检查命令收集证据(检查Makefile、package.json、Cargo.toml、pyproject.toml等文件以确定正确命令):
evidence = omh_gather_evidence(commands=["<build>", "<test>", "<lint>"]) - 如果→推进阶段:
evidence.all_pass,phase: "validation",退出context_checkpoint: true - 如果存在失败:
- 递增。检查
qa_cycle是否达到3次错误触发阈值→如果触发,设置phase="blocked"并退出qa_error_history - 如果(默认5次)→设置phase="blocked"并退出
qa_cycle > max_qa_cycles - 将问题诊断委托给架构师子代理(只读权限)
- 将修复任务委托给执行者子代理
- 更新状态,退出(下一次调用会重新运行QA)
- 递增
Phase 4: Multi-Reviewer Validation
阶段4:多评审者验证
Each invocation performs ONE validation round. Starts in fresh session.
If → advance to Phase 5, exit.
skip_validation: true- Gather evidence using the project's actual build/test commands:
evidence = omh_gather_evidence(commands=["<build>", "<test>"]) - Delegate 3 parallel reviews (exactly 3 = Hermes concurrent limit):
delegate_task(tasks=[ {goal: "[omh-role:architect] Architectural review:\n{spec + plan}", context: "{evidence}"}, {goal: "[omh-role:security-reviewer] Security review:\n{changed files list}", context: "{evidence}"}, {goal: "[omh-role:code-reviewer] Code quality review:\n{changed files list}", context: "{evidence}"} ]) - Record verdicts in
validation_verdicts - All APPROVE → advance to Phase 5, exit
- Any REQUEST_CHANGES → delegate fix to executor, increment , exit
validation_round - If (default 3) → phase="blocked", exit
validation_round > max_validation_rounds
每次调用执行一次验证轮次。在全新会话中启动。
如果→推进到阶段5并退出。
skip_validation: true- 使用项目实际的构建/测试命令收集证据:
evidence = omh_gather_evidence(commands=["<build>", "<test>"]) - 委托3个并行评审任务(最多3个=Hermes并发限制):
delegate_task(tasks=[ {goal: "[omh-role:architect] Architectural review:\n{spec + plan}", context: "{evidence}"}, {goal: "[omh-role:security-reviewer] Security review:\n{changed files list}", context: "{evidence}"}, {goal: "[omh-role:code-reviewer] Code quality review:\n{changed files list}", context: "{evidence}"} ]) - 将评审结果记录到
validation_verdicts - 全部通过APPROVE→推进到阶段5并退出
- 存在任何REQUEST_CHANGES→将修复任务委托给执行者,递增并退出
validation_round - 如果(默认3次)→设置phase="blocked"并退出
validation_round > max_validation_rounds
Phase 5: Cleanup
阶段5:清理
- Set (safety — if interrupted, re-invocation retries cleanup)
phase: "complete" - Delete state files:
omh_state(action="clear", mode="autopilot", instance_id="{instance_id}") omh_state(action="clear", mode="ralph", instance_id="{instance_id}") omh_state(action="clear", mode="ralph-tasks", instance_id="{instance_id}") - Preserve: ,
.omh/logs/,.omh/plans/.omh/specs/ - Report completion summary: goal, phases completed, ralph iterations, QA cycles, validation rounds
- 设置(安全机制——如果被中断,重新调用会重试清理步骤)
phase: "complete" - 删除状态文件:
omh_state(action="clear", mode="autopilot", instance_id="{instance_id}") omh_state(action="clear", mode="ralph", instance_id="{instance_id}") omh_state(action="clear", mode="ralph-tasks", instance_id="{instance_id}") - 保留以下目录:、
.omh/logs/、.omh/plans/.omh/specs/ - 报告完成总结:目标、已完成阶段、ralph迭代次数、QA循环次数、验证轮次
State Management
状态管理
All state via tool. Atomic writes and staleness handled automatically.
omh_state所有状态通过工具处理。自动处理原子写入和状态过期逻辑。
omh_stateSentinel Convention
哨兵约定
omh_state(action="check", mode="autopilot", instance_id="{instance_id}")
→ {exists, active, phase, stale}omh_state(action="check", mode="autopilot", instance_id="{instance_id}")
→ {exists, active, phase, stale}Pitfalls
注意事项
- Don't loop ralph in a single session. Each ralph iteration is a separate invocation. Context exhaustion is real.
- Don't reimplement ralph. Load the skill, follow its procedure.
- Phase boundaries = fresh sessions. Respect .
context_checkpoint - Don't skip QA. Ralph verifies per-task. QA catches integration issues.
- Phase 0 is interactive if no spec exists. Pre-create specs for automated runs.
- 3 subagent limit. Phase 4 uses all 3 slots for parallel review.
- 不要在单个会话中循环调用ralph。每次ralph迭代都是独立的调用。上下文耗尽是真实存在的问题。
- 不要重新实现ralph。加载对应的技能并遵循其流程。
- 阶段边界=全新会话。请遵守标记。
context_checkpoint - 不要跳过QA。Ralph仅验证单个任务,QA能捕获集成问题。
- 如果没有需求规格,阶段0是交互式的。自动化运行请预先创建需求规格。
- 子代理限制为3个。阶段4会使用全部3个插槽进行并行评审。