Initial commit: Hermes Agent skills collection

- Trading skills (OKX, dividend, lottery, quantitative)
- Creative skills (ASCII art, diagrams, video)
- Development skills (GitHub, debugging, TDD)
- Research skills (arXiv, blog monitoring)
- Productivity skills (email, documents, notes)
- MCP integration skills
- Custom user skills
This commit is contained in:
Hermes Skills Manager
2026-07-05 02:31:15 -04:00
commit 6770bc9b9d
908 changed files with 239614 additions and 0 deletions
+116
View File
@@ -0,0 +1,116 @@
---
name: cross-platform-push
description: "跨平台消息推送:从当前会话推送消息到Telegram/QQ/微信任一端。用cronjob deliver机制实现。"
version: 1.0.0
tags: [messaging, cross-platform, telegram, qq, weixin, push]
---
# 跨平台消息推送
从当前会话推送任意消息到其他平台(Telegram/QQ/微信)。
## 适用场景
- 当前在 Telegram DM/群,需要推送到 QQ 或微信
- 当前在 QQ,需要推送到 Telegram
- 交易结果、告警、通知等需要多端同步
- **channel_prompts 中推送交易确认到 QQ**(常见场景)
## 平台地址
| 平台 | hermes send 目标 | cronjob deliver 地址 |
|------|-----------------|---------------------|
| Telegram DM | `telegram` | `telegram:656685714` |
| QQ DM | `qqbot` | `qqbot:B1EF50442496D57C1B4F3890501C34C2` |
| 微信 | `weixin` | `weixin:o9cq8023LU5LqpUAGHMaMe5uscds@im.wechat` |
## 使用方法
### 方法 A:hermes send(推荐、最简单、当前会话直接调用)
```bash
# 推送到 QQ 私信
hermes send -t qqbot "消息内容"
# 推送到 Telegram 私信
hermes send -t telegram "消息内容"
```
**在 channel_prompts 中使用:**
```yaml
channel_prompts:
'-1003966251111': '解析信号...然后通过 terminal("hermes send -t qqbot '"'"'信号摘要+操作建议'"'"'") 推送到QQ'
```
**从 execute_code 中使用:**
```python
from hermes_tools import terminal
terminal('hermes send -t qqbot "消息内容"')
```
### 方法 B:cronjob deliver(DM 会话无 terminal 权限时)
```python
# 1. 创建一次性任务
cronjob(action='create',
deliver='qqbot:B1EF50442496D57C1B4F3890501C34C2',
prompt='直接原样输出以下内容:\n\n<消息正文>',
schedule='2099-01-01T00:00:00')
# 返回 job_id
# 2. 立即执行
cronjob(action='run', job_id='xxx')
# 3. 清理
cronjob(action='remove', job_id='xxx')
```
### 推送到多个平台(并行创建)
```python
job_qq = cronjob(deliver='qqbot:...', ...)
job_wx = cronjob(deliver='weixin:...', ...)
cronjob(action='run', job_id=job_qq)
cronjob(action='run', job_id=job_wx)
cronjob(action='remove', job_id=job_qq)
cronjob(action='remove', job_id=job_wx)
```
## 关键规则
1. **方法 A(hermes send)优先** — 比 cronjob 更简单、无残留、消息原文发送
2. **cronjob prompt 开头加"直接原样输出"** — 防止 LLM 二次加工
3. **cronjob 用完即删** — 执行完 run 后立即 remove
4. **hermes send 必须用 -t 参数** — 正确:`hermes send -t qqbot "msg"`,错误:`hermes send qqbot "msg"`
## 在 channel_prompts 中使用(TG 到 QQ 推送桥)
channel_prompts 中让 agent 通过 terminal 调用 hermes send:
```yaml
-1003966251111: '你是交易信号处理器。解析【币种】【方向】【仓位】等字段。然后通过 terminal("hermes send -t qqbot '"'"'信号摘要+建议操作'"'"'") 推送到QQ。不要在群里回复。'
```
### 注意点
- hermes send 用单引号包裹消息即可,无需复杂转义
- 消息保持在 200 字以内
- 明确要求"不要在群里回复"
- 非交易消息直接忽略,不推不回复
## Pitfalls
- **send_message 工具不可用** — send_message 是 Hermes 内部工具,有意不注册为 agent 可调用工具。旧版 channel_prompts 引用 send_message 无效。必须用 hermes send(通过 terminal)或 cronjob deliver 替代。
- cronjob 的 LLM 可能改写消息内容,prompt 要明确说"原样输出"
- 一次性 cronjob 不会自动删除,必须手动 remove
- deliver 格式必须正确,拼错不会报错但消息丢失
- **hermes send 必须用 -t 参数**,不是位置参数
- **config.yaml 编辑安全**:hermes config set 存嵌套 dict 会转成 JSON 字符串(YAML 格式错误)。正确的嵌套 dict 写法:用 Python 的 yaml.dump 或 sed 做行级替换。patch/write_file 被 config.yaml 安全拦截。
## 故障诊断
当推送失败时,参阅 references/qqbot-delivery-diagnostics.md 按序排查。
常见诊断路径:
1. `hermes send -t qqbot "测试"` — 最简单连通性测试
2. `cronjob list` — 看 last_delivery_error
3. `cat ~/.hermes/gateway_state.json` — 检查 qqbot.state
4. `systemctl --user restart hermes-gateway` — 需外部 shell
@@ -0,0 +1,113 @@
# QQ Bot / Hermes Gateway 推送故障诊断
当 QQ Bot 推送失败(cron job 或 send_message 报错)时,按以下顺序排查。
## 1. 从 Cron Job 错误入手
```bash
cronjob(action='list') # 查看 last_delivery_error
```
典型错误模式:
| 错误 | 根因 |
|------|------|
| `Not connected` | QQ Bot 适配器未连接(离线/WebSocket断连) |
| `Temporary failure in name resolution` | DNS 解析失败(本地 DNS 问题) |
| `Name or service not known` | 同上,DNS 不通 |
| `WebSocket closed` | QQ API WebSocket 连接断开 |
## 2. 检查 Gateway 状态
```bash
cat ~/.hermes/gateway_state.json
# 关注 platforms.qqbot.state 字段
# state=connected → 连接正常
# state=disconnected/reconnecting → 出问题了
```
输出示例:
```json
{
"gateway_state": "running",
"platforms": {
"qqbot": {
"state": "connected",
"updated_at": "2026-06-26T11:30:37.726746+00:00"
}
}
}
```
## 3. 检查 Gateway 日志
```bash
strings ~/.hermes/logs/gateway.log | grep -i "qqbot"
# 或筛选更全面
strings ~/.hermes/logs/gateway.log | grep -iE "qqbot|error|disconnect"
```
关键日志标记(按时间序):
| 日志 | 含义 |
|------|------|
| `Not connected` | QQ Bot 刚启但尚未就绪 |
| `Still not connected after 15s` | 连接超时 |
| `Disconnected` | WebSocket 已断开 |
| `Access token refreshed` | Token 刷新成功(正常) |
| `WebSocket connected` | WebSocket 长连建立 ✅ |
| `Connected` + `Identify sent` | 适配器登录完成 ✅ |
| `Ready, session_id=...` | 完全就绪,可收发消息 ✅ |
## 4. 检查进程/容器
```bash
# QQ Bot 是 Hermes gateway 内部适配器,没有独立进程
# 检查 gateway 本身运行状态
systemctl --user status hermes-gateway | head -10
```
## 5. 常见根因与修复
### DNS 故障(最常见)
- 错误: `Temporary failure in name resolution`
- 影响: QQ Bot 和微信同时断连
- 修复: 重启 gateway 让适配器重新解析 DNS
```bash
# 注意:agent 内可能被拦截,需外部 shell 执行
systemctl --user restart hermes-gateway
```
- 验证: 重启后检查 `gateway_state.json` 中 qqbot.state=connected
### Gateway 重启
- 错误: `Not connected` 后紧跟 `Disconnected`
- 修复: 等待 gateway 自动恢复(~30s)
- 验证: qqbot 日志出现 `Ready, session_id=...` 即恢复
### WebSocket 异常断开
- 错误: `WebSocket closed` 无重连
- 修复: 重启 gateway
- 验证: 同上
## 6. 验证推送
修复后立即测试:
```python
cronjob(action='create',
deliver='qqbot:B1EF50442496D57C1B4F3890501C34C2',
prompt='直接原样输出:✅ QQ Bot 推送测试 - ' + __import__('datetime').datetime.now().strftime('%H:%M:%S'),
schedule='2099-01-01T00:00:00')
cronjob(action='remove', job_id='<返回的job_id>')
```
## 7. 系统级网络健康
如果 DNS 反复故障:
```bash
# 检查 DNS 配置
cat /etc/resolv.conf
# 测试 QQ API DNS 解析
nslookup api.sgroup.qq.com
# 或换公共 DNS(8.8.8.8 / 114.114.114.114)
```