返回命令列表
技能与插件hermes hooks

hermes hooks 命令 — 完整参考与示例

hermes hooks 完整参考:列出、测试、撤销和诊断 ~/.hermes/config.yaml 中声明的 shell 脚本钩子。

2026年7月27日

概述

hermes hooks 检查声明在 ~/.hermes/config.yaml 中的 shell 脚本钩子,使用合成负载测试它们,并管理 ~/.hermes/shell-hooks-allowlist.json 中的首次使用同意列表。

hermes hooks <list|test|revoke|doctor>

支持别名:ls 等同于 listremove/rm 等同于 revoke

子命令

list(或 ls)— 列出已配置的钩子

hermes hooks list
hermes hooks ls

显示每个钩子的匹配器、超时时间和同意状态。

test — 用合成负载触发匹配的钩子

hermes hooks test pre_tool_call
hermes hooks test pre_tool_call --for-tool terminal
hermes hooks test subagent_stop --payload-file ./payload.json
选项 说明
event(位置参数) 钩子事件名,例如 pre_tool_callpre_llm_callsubagent_stop
--for-tool FOR_TOOL 只触发匹配器与该工具名匹配的钩子(用于 pre_tool_call / post_tool_call)。
--payload-file PAYLOAD_FILE 执行前合并到合成负载的 JSON 文件路径。

revoke(或 removerm)— 移除命令的允许列表条目

hermes hooks revoke "~/.hermes/hooks/notify.sh"
hermes hooks rm "~/.hermes/hooks/notify.sh"

移除 config.yaml 中声明的精确命令字符串的允许列表条目。更改在下次重启 Hermes 后生效。

doctor — 检查每个已配置的钩子

hermes hooks doctor

检查每个钩子的:可执行权限、允许列表状态、mtime 漂移、JSON 有效性以及合成运行耗时。

常见场景

编辑配置后审查所有钩子

hermes config edit
hermes hooks list

在批准前测试钩子

hermes hooks test pre_tool_call --for-tool terminal

撤销钩子的同意

hermes hooks revoke "~/.hermes/hooks/backup.sh"

诊断钩子问题

hermes hooks doctor

技巧

  • 钩子定义在 ~/.hermes/config.yaml 中;同意状态单独记录在 ~/.hermes/shell-hooks-allowlist.json 中。
  • 撤销同意不会删除钩子定义 — 只是重置批准状态,并在重启 Hermes 后生效。
  • 使用 hermes hooks test 配合 --payload-file 可以在不运行完整会话的情况下模拟真实负载。
  • hermes hooks doctor 是发现权限、语法或耗时问题的最快方式。
  • 批准前务必审查钩子脚本;它们以 Hermes 进程的相同权限运行。

Explore All Commands

Browse the full command reference with search and category filters.

返回命令列表