@chousyn/opencode-alertCross-platform notification plugin for OpenCode — desktop alerts, sound alerts, and webhook notifications with project-level configuration
1
55
近 7 天 14
29.3
生态多维模型
2 个月前
2026-06-05
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@chousyn/opencode-alert@0.2.5"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@chousyn/opencode-alert@0.2.5"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D @chousyn/opencode-alertopencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
opencode-alert
Cross-platform notification plugin for OpenCode — desktop alerts, sound alerts, and webhook notifications with project-level configuration.
Features
- Desktop notifications (Windows Toast, macOS Notification Center, Linux notify-send)
- Sound alerts with custom audio file support
- Smart filtering: quiet hours, throttle
- Project-level configuration with deep merge
- Zero context pollution (no tools or prompts injected)
Tech Stack
- Runtime: TypeScript (strict ESM), Node.js ≥18
- Build: tsup
- Test: Vitest
- Lint: Biome
- Desktop notifications: node-notifier (optional peer dependency) with OS shell fallbacks
- Sound: Platform-native commands (afplay / ffplay / PowerShell)
- Config: JSONC with deep merge and JSON Schema validation
Installation
npm (Recommended)
Add to your OpenCode config (~/.config/opencode/opencode.json):
{
"plugin": ["@chousyn/opencode-alert"]
}
Or pin a version:
{
"plugin": ["@chousyn/opencode-alert@0.2.4"]
}
Local Development
{
"plugin": ["file:///path/to/opencode-alert"]
}
Configuration
Create ~/.config/opencode/alert.jsonc (global) or .opencode/alert.jsonc (project):
{
// Global toggle
"enabled": true,
// Desktop notifications
"desktop": {
"enabled": true,
"events": ["idle", "error", "permission"]
},
// Sound notifications
"sound": {
"enabled": true,
"events": {
"idle": "ding.wav",
"error": "alert.wav",
"permission": "ping.wav"
},
"default": "ding.wav",
"customDir": "~/.config/opencode/alert-sounds/"
},
// Smart filtering
"filter": {
"quietHours": {
"enabled": false,
"start": "22:00",
"end": "08:00"
},
"minInterval": 5
}
}
Config Search Order
OPENCODE_ALERT_CONFIGenvironment variable.opencode/alert.jsonc(project)alert.jsonc(project root)~/.config/opencode/alert.jsonc(global)
Project config overrides global config (deep merge).
Minimal Config
{ "enabled": true }
Events
| Event | Trigger | Default Notification |
|---|---|---|
idle |
AI task completed | Session title |
error |
Session error | Error message |
permission |
AI requests permission | Permission details |
question |
AI asks a question | Session title |
Platform Requirements
Desktop Notifications
- Windows: No additional setup (uses SnoreToast via node-notifier)
- macOS: No additional setup (uses Notification Center)
- Linux: Requires
notify-send(install:sudo apt install libnotify-bin)
Sound
- macOS: No additional setup (uses
afplay) - Linux: Requires
ffmpeg(install:sudo apt install ffmpeg) - Windows: No additional setup (uses PowerShell SoundPlayer/MediaPlayer)
Comparison
| Feature | @chousyn/opencode-alert | opencode-notify | opencode-notificator |
|---|---|---|---|
| Windows | Yes | Yes | No |
| Custom sounds | All platforms | macOS only | All platforms |
| Webhook | Planned | No | No |
| Project config | Planned | No | No |
| Quiet hours | Yes | Yes | No |
| Toggle enabled | Yes | No (uninstall) | Yes |
| npm published | Yes | No (OCX) | No (manual) |
Development
npm install
npm run build
npm test
npm run lint
License
MIT