一、Skills 技能系统:Agent 的自我进化

这是 Hermes 最核心的差异化能力——自进化。Agent 解决复杂问题后,会把可复用的流程保存成「技能(Skill)」,下次遇到类似任务自动加载。Skill 是透明的人类可读 Markdown 文件,随时可以看、改、删。

1. 管理技能

hermes skills list                              # 列出已安装技能
hermes skills browse                            # 浏览可用技能
hermes skills search honcho                      # 搜索
hermes skills install honcho                     # 按 ID 安装
hermes skills install <url>/SKILL.md             # 按 URL 安装
hermes skills uninstall honcho                   # 卸载

会话内用 /skills 管理。

2. 技能目录结构

技能默认放在 ~/.hermes/skills/:

~/.hermes/skills/
├── mlops/                    # 类别目录
│   └── axolotl/
│       ├── SKILL.md          # 主说明文件(必需)
│       ├── references/       # 参考资料
│       ├── templates/        # 输出模板
│       ├── scripts/          # 辅助脚本
│       └── assets/           # 图片数据等
└── .hub/                     # Skills Hub 状态

SKILL.md 是入口文件,其他目录都是可选。

3. 一个 SKILL.md 长什么样

# Technical Blog Post Writing
​
Write technical blog posts targeting AI/ML developers. Follow this workflow:
​
## Structure
- **Hook** (100-150 words): Start with a real problem
- **Background** (200-300 words): Context
- **Deep Dive** (1000-1500 words): Core content with code
- **Key Takeaways** (bullet points): 3-5 conclusions
​
## Code Examples
- Must be complete and runnable
- Use Python 3.11+ syntax
- Prefer `uv` over `pip`

就是一份结构化工作指南,Agent 加载后照着执行。

4. 外部技能目录

团队共享技能目录时,可以额外扫描:

# ~/.hermes/config.yaml
skills:
  external_dirs:
    - ~/.agents/skills
    - /home/shared/team-skills

规则:只读扫描、本地优先、路径不存在则跳过。

5. Skill Bundles(v0.15+)

一个斜杠命令同时加载多个技能:

hermes skills bundle create writing-day --skills blogwatcher,markdown-style,seo-check
# 之后 /writing-day 即可一次加载三个

6. 平台特定技能(Linux 重点)

技能可以限定操作系统,写在 SKILL.md 的 frontmatter 里:

platforms:
  - linux
  - macos
  # - windows  # 不在 Windows 显示

7. Agent 自建技能(skill_manage)

Agent 可以用 skill_manage 工具自己创建/修改/删除技能——这是它的「程序记忆」:

动作

用途

create

创建新技能

patch

小范围修改(优先用)

edit

整体重写

delete

删除

write_file / remove_file

管理支持文件

示例(Agent 内部调用):

skill_manage(
    action="create",
    name="docker-troubleshooting",
    category="devops",
    description="Systematic Docker troubleshooting workflow.",
    content="# Docker Troubleshooting\n..."
)

8. Curator:技能自动维护

Curator 是技能的「管家」,防止技能库无限膨胀。它会跟踪技能的使用频率,把长期不用的从 active → stale → 归档到 ~/.hermes/skills/.archive/。

hermes curator status        # 查看状态
hermes curator run           # 手动运行策展
hermes curator pin <skill>   # 固定技能(保护不被归档)
hermes curator restore <skill>  # 恢复已归档技能

配置:

curator:
  enabled: true
  interval_hours: 168      # 每 7 天检查
  stale_after_days: 30     # 30 天未用变 stale
  archive_after_days: 90   # 90 天未用归档

二、Hooks 钩子系统:在关键时刻插一脚

Hermes 提供三种钩子,在生命周期关键点执行自定义代码。都非阻塞,出错不影响 Agent 运行。

维度

Shell Hooks

Plugin Hooks

Gateway Hooks

语言

任意(Bash 等)

仅 Python

仅 Python

运行环境

CLI + Gateway

CLI + Gateway

仅 Gateway

注册位置

config.yaml 的 hooks:

插件 register()

~/.hermes/hooks/<name>/HOOK.yaml

常见事件:

钩子

时机

能否影响流程

pre_tool_call

工具执行前

✓ 可 block

post_tool_call

工具返回后

观察型

pre_llm_call

LLM 调用前

✓ 可注入 context

post_llm_call

LLM 调用后

观察型

on_session_start / on_session_end

会话开始/结束

观察型

实用示例:危险命令拦截

pre_tool_call 是唯一能阻止工具执行的钩子,适合安全防护。

  1. 注册:

# ~/.hermes/config.yaml
hooks:
  pre_tool_call:
    - command: "~/.hermes/agent-hooks/danger-guard.sh"
      timeout: 5
  1. 创建脚本 ~/.hermes/agent-hooks/danger-guard.sh(Linux 版,纯 Bash):

#!/usr/bin/env bash
PAYLOAD=$(cat)   # 工具调用信息从 stdin 传入(JSON)
​
TOOL_NAME=$(echo "$PAYLOAD" | python3 -c "import sys,json; print(json.load(sys.stdin).get('name',''))")
PARAMS=$(echo "$PAYLOAD" | python3 -c "import sys,json; print(json.dumps(json.load(sys.stdin).get('parameters',{})))")
​
if [ "$TOOL_NAME" != "terminal" ]; then
  printf '{"action":"allow"}\n'
  exit 0
fi
​
CMD=$(echo "$PARAMS" | python3 -c "import sys,json; print(json.load(sys.stdin).get('command',''))")
​
if echo "$CMD" | grep -qiE "rm\s+-rf\s+/|DROP\s+TABLE|shutdown|mkfs\.|chmod\s+-R\s+777\s+/"; then
  printf '{"action":"block","reason":"Dangerous command blocked by guard hook"}\n'
  exit 0
fi
​
printf '{"action":"allow"}\n'
  1. 赋权:chmod +x ~/.hermes/agent-hooks/danger-guard.sh

三、Plugins 插件系统:不改核心加能力

插件无需修改 Hermes 核心代码即可添加工具、钩子、集成。

1. 最小插件结构

~/.hermes/plugins/hello-world/
├── plugin.yaml      # 清单:名称、版本、描述
└── __init__.py      # 定义 register(ctx)

plugin.yaml:

name: hello-world
version: "1.0"
description: A minimal example plugin.

__init__.py 里定义 register(ctx),用 ctx.register_tool(...) 注册工具。

2. 管理插件

hermes plugins list             # 查看
hermes plugins install user/repo  # 从 GitHub 装
hermes plugins enable <name>    # 启用
hermes plugins disable <name>   # 禁用

新安装插件默认不启用,需手动加入 config.yaml:

plugins:
  enabled:
    - my-plugin
  disabled:
    - noisy-plugin   # disabled 优先

四、Cron 定时任务:让 Agent 定时干活

Hermes 内置定时任务系统,用自然语言或 cron 表达式安排任务,由 Gateway 执行。

1. 创建任务

/cron add 30m "提醒我检查构建结果"
/cron add "every 2h" "检查服务器状态"
​
hermes cron create "every 2h" "检查服务器状态"

也可以直接自然语言让 Hermes 创建:

每天早上 9 点检查 Hacker News 上的 AI 新闻,发摘要到 Telegram。

2. 调度格式

类型

示例

行为

相对延迟

30m、2h、1d

一次性

循环间隔

every 30m、every 1d

重复

Cron 表达式

0 9 * * *

按 cron 规则

ISO 时间

2026-03-15T09:00:00

指定时间一次

Cron 格式 分 时 日 月 周:0 9 * * * = 每天 9:00,0 9 * * 1-5 = 工作日 9:00。

3. 管理任务

/cron list                         # 查看
/cron edit <id> --schedule "4h"    # 改调度
/cron pause <id> / resume <id>     # 暂停/恢复
/cron run <id>                     # 手动触发
/cron remove <id>                  # 删除

任务存在 ~/.hermes/cron/jobs.json,输出在 ~/.hermes/cron/output/{job_id}/{timestamp}.md。

4. 结果投递

deliver 决定结果发到哪:origin(来源平台)、local(存本地文件)、telegram/discord(指定平台)等。

hermes cron create "every 30m" "检查服务状态" --deliver telegram

如果回复以 [SILENT] 开头,成功时抑制投递(出问题才报告)。

5. No-Agent 模式(不需要 LLM)

监控类纯脚本任务,不需要 LLM 推理,省 token:

hermes cron create "every 5m" \
  --no-agent \
  --script memory-watchdog.sh \
  --deliver telegram \
  --name "memory-watchdog"

脚本放 ~/.hermes/scripts/。

6. context_from 串联任务

让一个任务读取上一个任务的输出,形成流水线:

Job 1:收集数据 (7:00)
Job 2:读取 Job1 输出筛选 (7:30)  context_from=<job1_id>
Job 3:读取 Job2 输出生成报告 (8:00)  context_from=<job2_id>