opencode-plugin-boops 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +118 -0
  3. package/index.ts +65 -0
  4. package/package.json +33 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 towc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # opencode-plugin-boops 🔊
2
+
3
+ Sound notifications for OpenCode - plays pleasant "boop" sounds when tasks complete or input is needed.
4
+
5
+ ## Features
6
+
7
+ - 🎵 Pleasant glass chime when AI completes a response
8
+ - 📡 Sonar ping when AI needs your permission or input
9
+ - 🔄 Automatic fallback to alternative sounds if preferred sounds aren't available
10
+ - 🐧 Works on Linux (with `paplay` or `aplay`)
11
+ - 🍎 Works on macOS (requires custom sound configuration)
12
+
13
+ ## Installation
14
+
15
+ ### Using OpenCode config
16
+
17
+ Add to your `opencode.json` or `~/.config/opencode/opencode.json`:
18
+
19
+ ```json
20
+ {
21
+ "$schema": "https://opencode.ai/config.json",
22
+ "plugin": ["opencode-plugin-boops"]
23
+ }
24
+ ```
25
+
26
+ ### Manual installation
27
+
28
+ Place the plugin file in your OpenCode plugins directory:
29
+
30
+ ```bash
31
+ # Global
32
+ mkdir -p ~/.config/opencode/plugins
33
+ cp index.ts ~/.config/opencode/plugins/boops.ts
34
+
35
+ # Per-project
36
+ mkdir -p .opencode/plugins
37
+ cp index.ts .opencode/plugins/boops.ts
38
+ ```
39
+
40
+ ## How it works
41
+
42
+ The plugin listens to OpenCode events:
43
+
44
+ - **`session.idle`** - Fires when the AI finishes responding → plays completion sound (glass.ogg)
45
+ - **`permission.asked`** - Fires when the AI needs permission → plays attention sound (sonar.ogg)
46
+
47
+ ## Customization
48
+
49
+ ### Custom sounds
50
+
51
+ To use your own sounds, modify the sound file paths in `index.ts`:
52
+
53
+ ```typescript
54
+ const inputSound = '/path/to/your/input-sound.ogg'
55
+ const completeSound = '/path/to/your/complete-sound.ogg'
56
+ ```
57
+
58
+ ### macOS
59
+
60
+ On macOS, you can use system sounds:
61
+
62
+ ```typescript
63
+ const inputSound = '/System/Library/Sounds/Ping.aiff'
64
+ const completeSound = '/System/Library/Sounds/Glass.aiff'
65
+ ```
66
+
67
+ And update the `playSound` function to use `afplay`:
68
+
69
+ ```typescript
70
+ await Bun.$`afplay ${primaryFile}`.quiet()
71
+ ```
72
+
73
+ ## Requirements
74
+
75
+ - OpenCode 1.0+
76
+ - Linux: `paplay` (PulseAudio) or `aplay` (ALSA)
77
+ - macOS: `afplay` (built-in)
78
+ - Sound files at specified paths (or system sounds)
79
+
80
+ ## Troubleshooting
81
+
82
+ ### No sound playing
83
+
84
+ 1. Check if sound files exist:
85
+ ```bash
86
+ ls /usr/share/sounds/gnome/default/alerts/glass.ogg
87
+ ls /usr/share/sounds/gnome/default/alerts/sonar.ogg
88
+ ```
89
+
90
+ 2. Test sound manually:
91
+ ```bash
92
+ paplay /usr/share/sounds/gnome/default/alerts/glass.ogg
93
+ ```
94
+
95
+ 3. Check OpenCode logs:
96
+ ```bash
97
+ tail -f ~/.local/share/opencode/log/*.log | grep boops
98
+ ```
99
+
100
+ ### Sounds too loud/quiet
101
+
102
+ Adjust your system volume or use different sound files.
103
+
104
+ ## Contributing
105
+
106
+ Contributions welcome! Feel free to:
107
+ - Add support for Windows
108
+ - Add configurable sound options
109
+ - Improve cross-platform compatibility
110
+ - Add more event triggers
111
+
112
+ ## License
113
+
114
+ MIT
115
+
116
+ ## Author
117
+
118
+ Created by [towc](https://github.com/towc)
package/index.ts ADDED
@@ -0,0 +1,65 @@
1
+ import type { Plugin } from "@opencode-ai/plugin"
2
+
3
+ export const BoopsPlugin: Plugin = async ({ client }) => {
4
+ // Default sounds - users can customize via config
5
+ const inputSound = '/usr/share/sounds/gnome/default/alerts/sonar.ogg'
6
+ const completeSound = '/usr/share/sounds/gnome/default/alerts/glass.ogg'
7
+
8
+ // Fallback sounds for systems without GNOME sounds
9
+ const fallbackInputSound = '/usr/share/sounds/alsa/Front_Left.wav'
10
+ const fallbackCompleteSound = '/usr/share/sounds/alsa/Front_Right.wav'
11
+
12
+ const log = async (message: string, extra?: any) => {
13
+ await client.app.log({
14
+ service: "opencode-plugin-boops",
15
+ level: "info",
16
+ message,
17
+ extra
18
+ })
19
+ }
20
+
21
+ // Try multiple sound players and files
22
+ const playSound = async (primaryFile: string, fallbackFile: string, label: string) => {
23
+ try {
24
+ // Try primary sound with paplay
25
+ await Bun.$`paplay ${primaryFile}`.quiet()
26
+ return
27
+ } catch {
28
+ try {
29
+ // Try fallback sound with paplay
30
+ await Bun.$`paplay ${fallbackFile}`.quiet()
31
+ return
32
+ } catch {
33
+ try {
34
+ // Try primary with aplay
35
+ await Bun.$`aplay ${primaryFile}`.quiet()
36
+ return
37
+ } catch {
38
+ try {
39
+ // Try fallback with aplay
40
+ await Bun.$`aplay ${fallbackFile}`.quiet()
41
+ return
42
+ } catch {
43
+ // Last resort: terminal bell
44
+ await log(`All sound attempts failed for ${label}, using terminal bell`)
45
+ await Bun.$`echo -e "\a"`.quiet()
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
51
+
52
+ await log("Boops plugin initialized - sound notifications enabled")
53
+
54
+ return {
55
+ event: async ({ event }) => {
56
+ if (event.type === "session.idle") {
57
+ await playSound(completeSound, fallbackCompleteSound, "completion")
58
+ }
59
+
60
+ if (event.type === "permission.asked") {
61
+ await playSound(inputSound, fallbackInputSound, "input-needed")
62
+ }
63
+ }
64
+ }
65
+ }
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "opencode-plugin-boops",
3
+ "version": "1.0.0",
4
+ "description": "Sound notifications for OpenCode - plays pleasant sounds when tasks complete or input is needed",
5
+ "main": "index.ts",
6
+ "type": "module",
7
+ "keywords": [
8
+ "opencode",
9
+ "plugin",
10
+ "notifications",
11
+ "sound",
12
+ "audio",
13
+ "alerts"
14
+ ],
15
+ "author": "towc",
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/towc/opencode-plugin-boops.git"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/towc/opencode-plugin-boops/issues"
23
+ },
24
+ "homepage": "https://github.com/towc/opencode-plugin-boops#readme",
25
+ "peerDependencies": {
26
+ "@opencode-ai/plugin": "^1.0.0"
27
+ },
28
+ "files": [
29
+ "index.ts",
30
+ "README.md",
31
+ "LICENSE"
32
+ ]
33
+ }