给 Hermes Agent 打
「能力层」补丁

Capability-layer patches
for Hermes Agent

关掉审批、护栏与命令黑名单,换掉系统提示词人格,让模型被拒时自动重采样。 79 条能力,四层落地(AST / 运行时 shim / 文本 / 配置),改坏了能逐字节回滚。

Disables approval prompts, guardrails and command blocklists, replaces the system-prompt persona, and re-samples when the model refuses. 79 capabilities across four layers (AST / runtime shim / text / config), with byte-exact rollback.

version capabilities platform node license
# 装一次,跑一条
npm i -g https://github.com/XiaoBinGan/hermes-purge/releases/latest/download/hermes-purge.tgz
purge setup --yes
# 反悔也一条
purge revert --force

它做什么

What it does

四条线,都是「宿主里的代码路径」,不是「提示词里的措辞」。

Four control points, all of them code paths in the host — not wording in a prompt.

① 审批门

① Approval gates

执行命令前的 (y/N) 不再出现。包含命令审批、编辑确认、模式切换。

The (y/N) before running a command goes away, including command approval, edit confirmation and mode switches.

② 护栏与黑名单

② Guardrails & blocklists

命令黑名单、路径围栏、终端守卫、技能扫描——共 22 条,各自落到真实函数。

Command blocklists, path fences, terminal guards, skill scanning — 22 of them, each anchored to a real function.

③ 人格与拒答

③ Persona & refusals

SOUL.md 换成人格 payload;模型回一句「我不能」时自动重采样继续。

SOUL.md becomes your persona payload; when the model says "I can't", it re-samples and keeps going.

④ 配置层默认值

④ Config-layer defaults

approvals.mode、max_tokens、上下文压缩阈值、prefill、.env。

approvals.mode, max_tokens, compaction thresholds, prefill, .env.

为什么是改宿主,不是改提示词

Why patch the host instead of the prompt

因为拒绝和审批不是对话,是代码路径。你可以跟模型拉扯二十轮,最后仍输给三层文件之外的一个 if not approved: return。

Because refusals and approvals are not a conversation, they are code paths. You can argue with the model for twenty turns and still lose to an if not approved: return three files deep.

四层落地

Four layers

AST 改函数体 → 运行时 shim → 文本兜底 → 配置开关。强层不可用时降级并说明原因。

AST rewrite → runtime shim → text fallback → config. When the strong layer is unavailable it downgrades and says why.

断言而非感觉

Assertions, not vibes

L1 py_compile → L2 14 条行为断言 → L3 真实一轮对话。

L1 py_compile → L2 fourteen behavioural assertions → L3 a real turn.

逐字节回滚

Byte-exact rollback

内容寻址快照 + sha256 清单,revert 后 sha256 == 原件(10132 个文件实测)。

Content-addressed snapshots + sha256 manifest; after revert, sha256 == original (verified on 10,132 files).

四态检测

Four states

applied / pending / drifted / unsupported——「宿主没这个机制」和「补丁坏了」必须分开。

applied / pending / drifted / unsupported — "host lacks the mechanism" must never look like "my anchor broke".

0 依赖

Zero dependencies

只要求 Node ≥18;安装体积 1.6 MB;不需要管理员、不需要 token。

Only Node ≥18 required; 1.6 MB installed; no admin rights, no token.

双泳道

Two lanes

macOS 与 Windows 各自维护锚点文件,结构上不可能互相覆盖。

macOS and Windows keep separate anchor files — structurally unable to overwrite each other.

安装

Install

macOS、Linux、Windows(PowerShell / CMD / Git Bash)同一条命令。

Same command on macOS, Linux and Windows (PowerShell / CMD / Git Bash).

# 1. 装(不需要 GitHub 账号、不需要 npm token、不需要管理员)
npm i -g https://github.com/XiaoBinGan/hermes-purge/releases/latest/download/hermes-purge.tgz

# 2. 应用(检测 → 计划 → 落地 → 验证)
purge setup --yes

# 3. 确认
purge status          # applied 65 / 79 就对了;其余 14 条是本机宿主版本没有的机制
机器上没有 npm? No npm on this machine?
curl -fsSL https://github.com/XiaoBinGan/hermes-purge/releases/latest/download/install.sh | bash -s -- --setup --yes
irm https://github.com/XiaoBinGan/hermes-purge/releases/latest/download/install.ps1 -OutFile $env:TEMP\hp-install.ps1
powershell -ExecutionPolicy Bypass -File $env:TEMP\hp-install.ps1 -Setup -Yes
想改代码(改完立即生效) Hacking on it (edit → take effect immediately)
git clone https://github.com/XiaoBinGan/hermes-purge.git
cd hermes-purge && ./install.sh --setup --yes

会把仓库链接到 ~/.hermes-purge(Windows 用目录联接,不是复制)。

Links the checkout into ~/.hermes-purge (a junction on Windows, not a copy).

边界,写在最前面而不是脚注:Scope, stated up front rather than in a footer: 它会关掉审批、护栏与命令黑名单,装完之后 Hermes 执行命令不再向你确认。 请只在你自己拥有、或你明确获授权的机器上使用。 It switches approval prompts, guardrails and blocklists off — after install, Hermes runs commands without asking. Use it on machines you own or are explicitly authorised to modify.

兼容性(实测,不是估的)

Compatibility (measured, not estimated)

数字取决于夹具,所以给区间而不是一个数。

Numbers depend on the fixture, so here is the range rather than a single figure.

宿主版本 / 夹具Host / fixture 结果Result
0.21.0 (macOS 实机)(live macOS host) applied 65 · unsupported 14 · drifted 0
0.21.5 / 0.21.6 / 0.21.7 (pristine 归档)(pristine archive) applied 75 · unsupported 4 · drifted 0
同上 + 一个空 SOUL.md same + an empty SOUL.md applied 76 · unsupported 3 · drifted 0
Windows 11 ARM(VirtualBox 实机,工具链) Windows 11 ARM (VirtualBox, toolchain) SMOKE_EXIT=0 ,无跳过, no skips

剩下 3 条(C27 / C50 / C52)在任何版本上都恒为 unsupported:它们的锚点在上游根本不存在 (例如 C50 要找 REDACT_WALK_MAX_DEPTH = 320,而 0.21.7 的 redact.py 里只有一句提到「320KB」的注释)。如实标注,不硬凑成 applied。

The remaining three (C27 / C50 / C52) are always unsupported: their anchors simply do not exist upstream (e.g. C50 looks for REDACT_WALK_MAX_DEPTH = 320, while 0.21.7's redact.py only mentions "320KB" in a comment). Reported honestly, never faked as applied.

常见问题

FAQ

装完之后 purge status 不是 79/79,正常吗? After install, purge status isn't 79/79 — is that normal?

正常。unsupported 表示「这台宿主的版本里没有这个机制」,不是补丁坏了。 0.21.0 上是 65,0.21.5+ 是 75–76。要看的是 drifted 0。

Yes. unsupported means "this host version lacks the mechanism", not a broken patch. It is 65 on 0.21.0 and 75–76 on 0.21.5+. What matters is drifted 0.

purge revert 之后审批还关着? After purge revert, approvals are still off?

默认只还原代码层,config.yaml 与 .env 归宿主所有、不动。 要连配置一起还原用 purge revert --force。命令会明确提示这一点。

By default only the code layer is restored; config.yaml and .env belong to the host and are left alone. Use purge revert --force to restore them too — the command says so explicitly.

同一个文件被多条补丁改,会不会互相覆盖? Multiple patches on one file — do they overwrite each other?

不会。定位缓存按「文件 + size + mtime」失效,写入后重新定位;4.0 起一次 apply 就能收敛(此前要跑两遍)。

No. The location cache keys on file + size + mtime, so it re-locates after every write; since 4.0 a single apply converges (it used to need two).

改坏了怎么回退? What if it breaks something?

内容寻址快照 + sha256 清单,revert 之后源码 sha256 与原件一致 (0.21.7 上 10132 个文件实测通过)。

Content-addressed snapshots plus a sha256 manifest: after revert the sources hash-match the originals (verified on 10,132 files against 0.21.7).

会不会把我的 Hermes 搞坏 / 影响升级? Will it damage Hermes or break upgrades?

补丁会在锚点失配时降级到下一层,并把状态报成 drifted 而不是假装成功。 宿主升级后跑一次 purge status 就知道哪几条要重新落。

When an anchor stops matching, it downgrades to the next layer and reports drifted instead of pretending success. After a host upgrade, one purge status tells you what needs re-landing.

为什么不用提示词解决? Why not just prompt it better?

提示词管不住代码路径。审批、黑名单、护栏都在宿主里,模型说什么都不影响那个 return。

A prompt cannot reach a code path. Approvals, blocklists and guardrails live in the host; nothing the model says changes that return.

文档

Documentation

每一项都能重跑,判据是命令输出。

Everything here is re-runnable; the criterion is the command output.