mcpField
A
agent-notifier

agent-notifier

github.com/crossoverjieAgent 工作流19109 次安装17 周前更新
代码仓库

关于 agent-notifier

agent-notifier 是一个通过各平台 Hooks 触发通知的技能,供使用 AI 编码 Agent 的开发者获知 Agent 等待输入或完成任务。它支持多个 Agent 平台,并可将通知发送到启用的多个渠道。

主要功能

  1. 01通过 Hooks 触发通知
  2. 02支持多种 AI Agent 平台
  3. 03支持声音与 macOS 通知
  4. 04支持 Telegram、邮件和 Webhook
  5. 05并行发送至启用渠道

适用场景

  1. 01Agent 等待用户输入时接收提醒
  2. 02Agent 会话结束后获知任务完成
  3. 03将通知发送到 Slack 或 Discord

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/crossoverjie/skills --skill agent-notifier

安装后在 Claude Code 中输入/agent-notifier确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

notify-config.json
notify.py
opencode-plugin.js
README.md
requirements.txt
setup.py
test_notify.py

详细介绍

Agent Notifier 技能

为 AI 编码 Agent 提供确定性、由钩子驱动的通知。Agent 需要输入或完成任务时,绝不错过。

原因

基于大模型的“完成时播放声音”提示词并不可靠——上下文压缩会丢弃这些提示词,而且模型对“完成”的判断并不一致。此技能使用各平台的钩子系统,确保通知触发。

前提条件

  • Python 3(仅使用标准库,无外部依赖)
  • 至少一个受支持的 AI Agent 平台

支持的平台

平台钩子事件
Claude CodeNotification(idle_prompt、permission_prompt)
GitHub Copilot CLIsessionEnd、postToolUse
Cursorstop、afterFileEdit
Codexagent-turn-complete
Aider--notifications-command
OpenCodesession.idle(插件)

快速开始

# Interactive setup — detects platforms, configures channels, installs hooks
python3 skills/agent-notifier/setup.py
Copilot CLI 用户

Copilot CLI 从项目的 .github/hooks/ 目录加载钩子(不支持全局钩子)。请在每个需要通知的项目中创建钩子文件:

mkdir -p .github/hooks
cat > .github/hooks/agent-notifier.json << 'EOF'
{
  "version": 1,
  "hooks": {
    "sessionEnd": [
      {"type": "command", "bash": "python3 $HOME/.claude/skills/agent-notifier/notify.py"}
    ],
    "postToolUse": [
      {"type": "command", "bash": "python3 $HOME/.claude/skills/agent-notifier/notify.py"}
    ]
  }
}
EOF
OpenCode 用户

OpenCode 使用 JavaScript 插件系统。将插件复制到你的插件目录:

mkdir -p ~/.config/opencode/plugins
cp skills/agent-notifier/opencode-plugin.js ~/.config/opencode/plugins/agent-notifier.js

手动使用

# Test with simulated Claude Code event
echo '{"notification_type":"idle_prompt","message":"Waiting for input"}' | python3 skills/agent-notifier/notify.py

# Test with simulated OpenCode event
echo '{"platform":"opencode","event_type":"session.idle","message":"Session completed"}' | python3 skills/agent-notifier/notify.py

# Test with command-line args (Aider style)
python3 skills/agent-notifier/notify.py "Task completed"

通知渠道

渠道默认状态要求
声音已启用macOS(afplay)或 Linux(paplay/aplay)
macOS 通知已启用仅限 macOS
Telegram已禁用Bot token + Chat ID
电子邮件已禁用SMTP 凭据
Slack已禁用Incoming Webhook URL
Discord已禁用Webhook URL
钉钉已禁用Webhook URL + 可选 Secret

配置

配置文件按以下顺序查找:

  1. ~/.claude/notify-config.json
  2. skills/agent-notifier/notify-config.json(模板)

运行 python3 skills/agent-notifier/setup.py 进行交互式配置,或直接编辑 JSON 文件。

输出

通知会并发发送到所有已启用的渠道。单个渠道的失败会记录到 stderr,不会影响其他渠道。

评论

支持 Markdown