Archon:用 YAML 定义的软件工厂

不是又一个 coding agent,而是给 agent 立规矩的那一层:YAML 写流程、脚本给事实、agent 做判断、人只在闸门出现。

分享
Archon:用 YAML 定义的软件工厂

把 backlog 丢给 coding agent,多数人拿到两种结果:要么是一个自己不敢信的黑盒,要么是一台「垃圾喷子炮」——吐出一堆没人读的 PR。这两个词来自 Warp 团队的拆解,我们此前整理过那套流程。

Archon 走的是另一条路:它不替你写代码,它规定活儿怎么干。 流程写成 YAML(节点图),agent 在节点里做判断,脚本节点给事实,需要你拍板的地方就停下来等你。仓库当前是 v0.17.x(2026-11-28 发布),MIT,自托管。

它 2026 年中被重写过一次:从「AI 指挥中心(知识库 + 任务管理)」改成了现在的 harness builder。所以网上一大半教程已经过期——文末列了哪几篇别照做。

这篇按「装 → 跑通 → 自己写一条 → 接内置工厂」四步走,命令和 YAML 都取自官方文档(archon.diy/docs),可以直接抄。


一、装:三步,两个前提

前提一:装一个 agent,并登录。 Archon 自己不提供模型。 - Claude Code:curl -fsSL https://claude.ai/install.sh | bash(Windows PowerShell:irm https://claude.ai/install.ps1 | iex),然后跑一次 claude 登录。 - Codex:装 Codex CLI,跑 codex login。 - Pi 也可以作为 provider。

前提二:Archon 的 provider 版本必须和 CLI 版本一致。 升级 Archon 之后要重新执行一次 archon provider add,否则运行会直接失败并提示你要跑哪条命令。

# macOS / Linux
curl -fsSL https://archon.diy/install | bash

# Windows(PowerShell)
irm https://archon.diy/install.ps1 | iex

# Homebrew(装完自己加 provider)
brew install coleam00/archon/archon
archon setup

安装器会问你要加哪些 provider;不想交互就显式指定:

curl -fsSL https://archon.diy/install | bash -s -- --providers codex
archon provider add claude codex pi     # 也可以手工加

x64 的预编译包要求 CPU 支持 AVX2;老机器或屏蔽了 AVX2 的虚机请走源码安装(git clone + bun install,需要 Bun 和 gh)。Docker 镜像里已带 Claude Code,不用再配路径。

验收:

archon version
archon doctor        # 列出已装 provider 及其诊断结果

二、跑通:先让内置工作流干一件小事

在任意 git 仓库里:

cd your-project
archon workflow list
archon workflow run archon-investigate "Why does the login test fail?"

archon-investigate 会把问题顺着代码追到能证明答案为止,并且保证不改动你的仓库。运行过程会流式打印到终端,最后给出报告。

跑完之后:

archon workflow runs            # 本项目最近的运行,带 ID
archon workflow get <run-id>    # 单次运行:状态、节点、结论
archon workflow attention       # 停下来等你决策的运行

需要你拍板的运行会以 attention item(待决策项)的形式暂停。答复:

archon workflow respond <run-id> <decision> "理由"
# 或者针对审批型节点
archon workflow approve <run-id> "把 flag 处理留在 cli.ts"
archon workflow reject  <run-id> "范围太大"

想用浏览器看,就 archon serve(默认端口 3090,Docker 里是 3000)。

这里有个概念要先记住:暂停的运行不占进程。 它可以停几分钟,也可以停几天,答案回来再继续。这是「人在环上」而不是「人在环里」的实现方式。

三、写第一条自己的产线

官方给的分工原则是三句话,值得背下来:

YAML 负责编排,脚本负责计算,agent 负责判断。

要建的是 build-change:给一段需求 → agent 写计划 → 你审批 → agent 实现 → 跑测试 → 测试挂了就让一个新 agent 去修。

3.1 目录长这样

.archon/workflows/my-team/build-change/
├── build-change.yaml
├── commands/
│   └── fix-tests.md
└── fixtures/

my-team 是包名,随便起。注意:工作流只能从自己目录下的 commands/ 和 scripts/ 解析文件,所以两个工作流可以各有一个 fix-tests.md 而不打架。

3.2 先写一条命令(给 agent 的说明书)

commands/fix-tests.md:

---
description: Find why the tests fail after a change and fix the cause
---

# Fix failing tests

The change described in $ARTIFACTS_DIR/plan.md was implemented, and the
project's tests now fail. The test output is:

$INPUTS.test_output

Decide whether the failure comes from the change or from a test that the plan
says should change. Fix the cause, not the symptom: do not delete or skip a
test to make it pass. Run the tests again, then commit the fix.

两个变量值得单独说:

  • $ARTIFACTS_DIR:Archon 为每次运行建的产物目录,在你的仓库之外。计划、报告放这里,不污染 git。
  • $INPUTS.test_output:上游节点传进来的值,下面用 with: 绑定。

3.3 再写工作流

build-change.yaml:

name: build-change
description: |
  Plan a change from a brief, wait for you to approve the plan, implement it,
  run the tests, and fix the code if they fail.
  Use when: you have a small, well-described change for this repository.
inputs:
  test_command:
    default: npm test
    description: the command that runs this project's tests

nodes:
  - id: plan
    prompt: |
      Read the brief below and the code it touches. Write an implementation
      plan to $ARTIFACTS_DIR/plan.md: the files you will change, the approach,
      and how you will know it works. Do not change any files yet.

      Brief:
      $ARGUMENTS
    output_format:
      type: object
      properties:
        summary: { type: string }
      required: [summary]
      additionalProperties: false

  - id: approve-plan
    depends_on: [plan]
    wait:
      attention: |
        $plan.output.summary

        Read the full plan with `archon workflow artifacts <run-id> plan.md`.
        Approve to implement it, or reject with what to change.
      form: approval

  - id: stop
    depends_on: [approve-plan]
    when: "$approve-plan.output.decision == 'reject'"
    cancel: The plan was rejected.

  - id: implement
    depends_on: [approve-plan]
    when: "$approve-plan.output.decision == 'approve'"
    prompt: |
      Implement the plan in $ARTIFACTS_DIR/plan.md. Reviewer notes, if any:
      $approve-plan.output.text
      Commit your changes with a clear message.

  - id: test
    depends_on: [implement]
    runtime: bun
    script: |
      const run = Bun.spawnSync(['sh', '-c', process.env.INPUTS_TEST_COMMAND ?? '']);
      const output = (run.stdout.toString() + run.stderr.toString()).slice(-4000);
      console.log(JSON.stringify({ passed: run.exitCode === 0, output }));
    output_format:
      type: object
      properties:
        passed: { type: boolean }
        output: { type: string }
      required: [passed, output]
      additionalProperties: false

  - id: fix
    depends_on: [test]
    when: "$test.output.passed == false"
    command: fix-tests
    context: fresh
    with:
      test_output: $test.output.output

3.4 逐节点解释(这段是全文最该读的)

节点 类型 关键点
plan agent 节点 $ARGUMENTS 是你运行这条工作流时传的那段话;output_format 强制 agent 返回符合 schema 的 JSON,不符合就判节点失败——所以后面的闸门能稳定拿到 $plan.output.summary,不用去解析散文
approve-plan wait: 节点 form: approval 表示答案是 approve / reject,外加可选文字;暂停期间不占进程
stop 分支 拒绝不是取消,而是一个正常答案,所以由 YAML 决定后面怎么走:这里直接 cancel
implement agent 节点 只在批准后运行;$approve-plan.output.text 把你在审批时写的备注带进去
test 脚本节点 测试过没过是事实,所以用脚本跑命令、报退出码,不做解释。output_format 对脚本 stdout 同样生效,不匹配就失败
fix 命令节点 只在失败时运行;context: fresh 开一个全新的 agent 会话——让它读真实的测试输出,而不是实现者「以为自己写了什么」

再加两条规则:

  • 没有依赖关系的节点会并行。 这里每个都依赖前一个,所以是串行。
  • 只在「应该由人决定」的地方放暂停。 代码或 agent 自己能判的,写成节点。

四、零成本验证:三步,一个 token 都不花

这是 Archon 最值得学的设计——先证明「路线对」,再花钱。

4.1 校验

archon validate workflows build-change
#   build-change    ok
# Results: 1 valid, 0 with errors

它会按真实运行的方式加载工作流,能抓出:拼错的键、when: 引用了上游从没声明过的字段、命令文件不存在、以及节点类型不支持的键。比如给 prompt 节点写 timeout::

ERROR [validation_error] DAG node validation failed: Node 'plan': 'timeout' is only supported on bash, loop, loop_group or script nodes, not on prompt nodes.

4.2 用桩跑一遍

archon workflow run build-change --dry-run --stubs-init stubs.yaml

生成的 stubs.yaml 改成一个「测试会失败」的剧本:

plan: { summary: "Add a --version flag that prints the version from package.json." }
implement: "Added the flag and a test."
test: { passed: false, output: "version.test.ts: expected 1.2.0, got undefined" }
fix: "Read the version from package.json at startup."
archon workflow run build-change --dry-run --stubs stubs.yaml "Add a --version flag"
STUBBED   plan (prompt)
PAUSED    approve-plan (wait) -- durable wait
Simulation outcome: paused

它会像真运行一样停在闸门。给 wait 节点也补一个桩,再跑:

approve-plan: { decision: approve, text: "" }
STUBBED   plan (prompt)
STUBBED   approve-plan (wait) -- answered by stub
SKIPPED   stop (cancel) -- when_condition (...decision == 'reject')
STUBBED   implement (prompt)
STUBBED   test (script)
STUBBED   fix (command)
Simulation outcome: completed

dry run 会打印每个 agent 节点最终解析出来的 prompt、以及将要用哪个 provider / 模型。它验证的是接线(路由、闸门、when:、变量替换),不是模型写得好不好。

想让 test 真跑、其他仍然用桩:删掉它的桩,加 --exec-code --input test_command="npm test"。

4.3 把路线固化成 fixture

fixture 就是「带预期结果的桩文件」,放在 fixtures/,archon workflow test 每次重放。一条路线一个:

fixtures/approved.stubs.yaml——测试通过,所以 fix 不该运行:

plan: { summary: "Add a --version flag that prints the version from package.json." }
approve-plan: { decision: approve, text: "" }
implement: "Added the flag and a test."
test: { passed: true, output: "12 pass, 0 fail" }
fixture:
  expect: completed
  reached: [implement, test]

注意这里故意不给 fix 桩——路线一旦走到 fix,fixture 就失败。这就是「证明它被跳过」的写法。

再补两条:red.stubs.yaml(测试失败 → fix 运行,并且 resolved-text-contains 检查失败输出真的传到了修 bug 的 agent 手里)、rejected.stubs.yaml(拒绝 → 取消,implement 不给桩)。

archon workflow test build-change
# ✔ .../approved.stubs.yaml -> build-change   completed
# ✔ .../red.stubs.yaml      -> build-change   completed
# ✔ .../rejected.stubs.yaml -> build-change   cancelled
# 3 passed, 0 failed

workflow test 不创建运行、不调用模型。每次改完工作流都跑它,并且放进 CI。


五、真跑:输入就是契约

这一段是全文第二该读的。Archon 管的是「活怎么干」——隔离、闸门、重试、审计;它管不了「你到底想要什么」。含糊的需求只会换来一个自信的、答非所问的方案。

所以每次运行的输入(issue 正文、Slack 消息、一篇文章)都要写清六件事:

Problem 今天具体哪里不对
Why it is worth solving 不管它要付什么代价
Why now 为什么是现在
Desired outcome 做完之后,可观察到什么变化
Invariants 任何可接受的实现都必须保持什么
Acceptance 你怎么知道做完了

想指定做法就写在最后(可选);不写,运行自己选路子。有约束("复用这个 helper"、"不许加新依赖")必须说出来——它没法尊重你没说的偏好。

archon workflow run build-change --branch feat/version-flag --input test_command="npm test" "$(cat <<'BRIEF'
Problem: the CLI has no way to print its version, so bug reports never say
which release they were filed against.

Outcome: `mycli --version` prints the version from package.json and exits 0.

Invariants: no new dependency; every other flag behaves as before.

Acceptance: a test runs `mycli --version` and checks the output.
BRIEF
)"

运行在自己的 git worktree(分支 feat/version-flag)里干活,改动不进你的工作区。plan 跑完会打印 Workflow paused -- waiting for approval. 然后返回。

archon workflow attention                    # 等你决策的运行和 ID
archon workflow artifacts <run-id> plan.md    # 打 plan
archon workflow approve <run-id> "flag 处理留在 cli.ts"
archon workflow get <run-id> --verbose        # 查每个节点的状态

一个实操细节:如果你同时开着 archon serve 或 archon workflow wake,续跑可能被另一个 host 抢先接管(同一条续跑只在一个 host 执行)。在终端里的 approve 可能立刻返回,但活儿还在别处跑——想确认实现真的落到分支上,就等运行结束再看。


六、接内置工厂:issue → 已合并 PR

内置的 sdlc 包就是一个「五条队列」的软件工厂。它对应的是 O'Reilly 那篇文章里八个阶段的完整产线,只是这里每一步都是 YAML 节点。你写 issue,剩下的按队列走:

队列 干什么
archon-intake 校验作者是否在维护者名单里,给维护者的 issue 分诊并打路线标签
archon-split 分诊判定「一件干不完」时,拆成多个 issue 再送回 intake
archon-build-queue 一轮轮把 issue 做到 PR Ready;维护者回 ready 就交给合并队列
archon-merge-queue 合并 Ready 且 CI 绿的 PR,合不了的退回去
archon-discoveries 记录运行中发现的、超出本任务范围的问题

先装 forge 插件,否则到不了 GitHub:

archon plugin add coleam00/Archon/plugins/forge-github

它用的是你 gh auth login 的凭据(或 GH_TOKEN)。然后照包里 README 的顺序做(这是官方指定的唯一权威步骤,含每一步的验收命令和你需要拍板的决定):

https://github.com/coleam00/Archon/blob/dev/.archon/workflows/sdlc/README.md#set-up-the-pack

要点:维护者名单 maintainers.json 必须包含运行安装的那个账号(否则队列自己开的 issue 会被当成外部提交);包里自带的 archon-* 标签会自动创建;第一轮建议每条队列手工跑一次,看清楚它会写什么,再挂定时/事件触发。

它写东西的地方(都写在你指定的仓库里):

  • 标签:缺就建,按增量加减,别人打的标签不会被抹掉
  • issue:重复或已被合并变更交付的,关掉并留一条带原因的评论
  • 分支:build/<issue>-<slug>-<run>,从不 force-push、从不 rebase
  • PR:先开 draft,描述里只有「评审确认每条验收项都满足、且 issue 上没有仍生效的裁决」时才写 Closes #N
  • CI:红灯如果明显不是本次改动引起的,重跑一次;默认分支本身是红的就绝不重跑

想停:删掉 schedule 和 webhook 绑定只能挡住新运行——已经在跑的链条会继续互相点火(intake 路由 → build → merge → discoveries)。要真停,archon workflow status --all 找出来,用 archon workflow cancel / abandon;只想停单个条目,就在它的 attention item 上回 park。


七、日常运维:四个命令 + 一个原则

archon workflow status            # 本项目在跑和暂停的运行
archon workflow status --all      # 整个安装
archon workflow runs              # 最近所有状态的运行
archon serve                      # Web UI(默认 3090)

一个原则:状态落在你自己的库里。 默认 SQLite,设 DATABASE_URL 可以换 PostgreSQL;运行事件、审批记录、每次运行的花费都在里面,不依赖厂商云端。


八、十个坑(按踩到的概率排序)

  1. 旧教程过期:2025-10 的《The OFFICIAL Archon Guide》讲的是旧版「指挥中心」(知识库 + 任务管理);2026-04 那期 VPS 教程装的是旧架构。现在的 Archon 是 YAML 工厂,版本 v0.17.x。
  2. provider 版本漂移:升级 CLI 后不重新 archon provider add,运行会直接失败。
  3. 以为 Archon 会装 agent:不会。它只连接你已装的 CLI/SDK;Claude Code 要自己装、自己登录。
  4. 老 CPU:x64 预编译包要 AVX2,虚机屏蔽了就用源码装。
  5. when: 引用未声明字段:archon validate workflows 能提前抓到,别跳过。
  6. 给 prompt 节点加 timeout::只有 bash / loop / loop_group / script 支持,校验期就报错。
  7. 把需求写成一句话:六要素缺一项,你会得到一个自信的错答案。build queue 会反问你缺的那一项,别指望它猜。
  8. .env 里的密钥:CLI 会剥掉目标仓库 .env 里的键,凭据要放 ~/.archon/.env 或项目 .archon/.env。
  9. 以为删了定时任务就停了:链条会继续点火,见第六节。
  10. 以为 approve 之后就一定在本机跑:另一个 host 可能接管续跑,用 workflow get --verbose 看状态。

九、它在这个赛道的坐标

同类的开源实现里,OpenHands(94.6k star)是「控制台 + 多 agent 托管」,Robin(LangChain 的 open-swe,11.3k)是「发动机」,Archon 是唯一把流程、闸门、记账当第一性问题的那个(这套「build / review / learn」的分层,另有一篇拆得更细)——这也是 Stripe 建 Minions、Ramp 建 Inspect 时最花时间的部分。

差别就在一句话:工厂的差异不在 agent,在那层自己写的闸门。 Archon 把那层闸门做成了 YAML。


参考

  • 官方文档:https://archon.diy/docs/ (Why Archon / Installation / Quick Start / Build your first workflow / Operate runs / The SDLC factory / Workflow language)
  • 文档的 LLM 版(可直接喂给 agent):https://archon.diy/llms-full.txt
  • 仓库:https://github.com/coleam00/Archon (v0.17.1,2026-11-28)
  • 内置 SDLC 工厂的安装手册:.archon/workflows/sdlc/README.md
  • 作者讲解(重写版唯一官方视频):Cole Medin《The Next Evolution of AI Coding Is Harnesses — Here's How to Build Them》,2026-06