@mohak34/opencode-notifier 0.1.8 → 0.1.10
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.
- package/README.md +130 -6
- package/dist/index.js +14 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,18 +12,67 @@ Add the plugin to your `opencode.json` or `opencode.jsonc`:
|
|
|
12
12
|
}
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
Using `@latest` ensures you always get the newest version when the cache is refreshed.
|
|
16
|
+
|
|
17
|
+
To pin a specific version:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"plugin": ["@mohak34/opencode-notifier@0.1.8"]
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
15
25
|
Restart OpenCode. The plugin will be automatically installed and loaded.
|
|
16
26
|
|
|
17
27
|
## Updating
|
|
18
28
|
|
|
19
|
-
OpenCode caches plugins in `~/.cache/opencode`.
|
|
29
|
+
OpenCode caches plugins in `~/.cache/opencode`. Plugins are not auto-updated; you need to clear the cache to get new versions.
|
|
30
|
+
|
|
31
|
+
### If you use `@latest`
|
|
32
|
+
|
|
33
|
+
Clear the cache and restart OpenCode:
|
|
34
|
+
|
|
35
|
+
**Linux/macOS:**
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
rm -rf ~/.cache/opencode/node_modules/@mohak34/opencode-notifier
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Windows (PowerShell):**
|
|
20
42
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
```powershell
|
|
44
|
+
Remove-Item -Recurse -Force "$env:USERPROFILE\.cache\opencode\node_modules\@mohak34\opencode-notifier"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Then restart OpenCode - it will download the latest version automatically.
|
|
48
|
+
|
|
49
|
+
### If you use a pinned version (e.g., `@0.1.7`)
|
|
50
|
+
|
|
51
|
+
1. Update the version in your `opencode.json`:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"plugin": ["@mohak34/opencode-notifier@0.1.8"]
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
2. Clear the cache (see commands above)
|
|
60
|
+
|
|
61
|
+
3. Restart OpenCode
|
|
24
62
|
|
|
25
|
-
|
|
26
|
-
|
|
63
|
+
### Check installed version
|
|
64
|
+
|
|
65
|
+
**Linux/macOS:**
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
cat ~/.cache/opencode/node_modules/@mohak34/opencode-notifier/package.json | grep version
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Windows (PowerShell):**
|
|
72
|
+
|
|
73
|
+
```powershell
|
|
74
|
+
Get-Content "$env:USERPROFILE\.cache\opencode\node_modules\@mohak34\opencode-notifier\package.json" | Select-String "version"
|
|
75
|
+
```
|
|
27
76
|
|
|
28
77
|
## Platform Notes
|
|
29
78
|
|
|
@@ -124,6 +173,81 @@ Use your own sound files:
|
|
|
124
173
|
|
|
125
174
|
If a custom sound file path is provided but the file doesn't exist, the plugin will fall back to the bundled sound.
|
|
126
175
|
|
|
176
|
+
## Troubleshooting
|
|
177
|
+
|
|
178
|
+
### macOS: Notifications not showing (only sound works)
|
|
179
|
+
|
|
180
|
+
**Update to v0.1.8 or later** - this version includes a fix for macOS notification events.
|
|
181
|
+
|
|
182
|
+
If notifications still don't work after updating:
|
|
183
|
+
|
|
184
|
+
1. **Install terminal-notifier via Homebrew:**
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
brew install terminal-notifier
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
2. **Check notification permissions:**
|
|
191
|
+
- Open **System Settings > Notifications**
|
|
192
|
+
- Find your terminal app (e.g., Ghostty, iTerm2, Terminal)
|
|
193
|
+
- Make sure notifications are set to **Banners** or **Alerts**
|
|
194
|
+
- Also enable notifications for **terminal-notifier** if it appears in the list
|
|
195
|
+
|
|
196
|
+
### Linux: Notifications not showing
|
|
197
|
+
|
|
198
|
+
1. **Install notify-send:**
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Debian/Ubuntu
|
|
202
|
+
sudo apt install libnotify-bin
|
|
203
|
+
|
|
204
|
+
# Fedora
|
|
205
|
+
sudo dnf install libnotify
|
|
206
|
+
|
|
207
|
+
# Arch
|
|
208
|
+
sudo pacman -S libnotify
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
2. **Test if it works:**
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
notify-send "Test" "Hello"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Linux: Sounds not playing
|
|
218
|
+
|
|
219
|
+
Install one of these audio players: `paplay`, `aplay`, `mpv`, or `ffplay`.
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Debian/Ubuntu (PulseAudio)
|
|
223
|
+
sudo apt install pulseaudio-utils
|
|
224
|
+
|
|
225
|
+
# Or install mpv
|
|
226
|
+
sudo apt install mpv
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Windows: Notifications not showing
|
|
230
|
+
|
|
231
|
+
1. Open **Settings > System > Notifications**
|
|
232
|
+
2. Make sure notifications are enabled
|
|
233
|
+
3. Check that your terminal app has notification permissions
|
|
234
|
+
|
|
235
|
+
### General: Plugin not loading
|
|
236
|
+
|
|
237
|
+
1. **Check your opencode.json syntax:**
|
|
238
|
+
|
|
239
|
+
```json
|
|
240
|
+
{
|
|
241
|
+
"plugin": ["@mohak34/opencode-notifier@latest"]
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
2. **Clear the cache and restart:**
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
rm -rf ~/.cache/opencode/node_modules/@mohak34/opencode-notifier
|
|
249
|
+
```
|
|
250
|
+
|
|
127
251
|
## License
|
|
128
252
|
|
|
129
253
|
MIT
|
package/dist/index.js
CHANGED
|
@@ -3826,6 +3826,7 @@ function getSoundPath(config, event) {
|
|
|
3826
3826
|
// src/notify.ts
|
|
3827
3827
|
var import_node_notifier = __toESM(require_node_notifier(), 1);
|
|
3828
3828
|
import os from "os";
|
|
3829
|
+
import { exec } from "child_process";
|
|
3829
3830
|
var NOTIFICATION_TITLE = "OpenCode";
|
|
3830
3831
|
var DEBOUNCE_MS = 1000;
|
|
3831
3832
|
var platform = os.type();
|
|
@@ -3833,13 +3834,10 @@ var platformNotifier;
|
|
|
3833
3834
|
if (platform === "Linux" || platform.match(/BSD$/)) {
|
|
3834
3835
|
const { NotifySend } = import_node_notifier.default;
|
|
3835
3836
|
platformNotifier = new NotifySend({ withFallback: false });
|
|
3836
|
-
} else if (platform === "Darwin") {
|
|
3837
|
-
const { NotificationCenter } = import_node_notifier.default;
|
|
3838
|
-
platformNotifier = new NotificationCenter({ withFallback: false });
|
|
3839
3837
|
} else if (platform === "Windows_NT") {
|
|
3840
3838
|
const { WindowsToaster } = import_node_notifier.default;
|
|
3841
3839
|
platformNotifier = new WindowsToaster({ withFallback: false });
|
|
3842
|
-
} else {
|
|
3840
|
+
} else if (platform !== "Darwin") {
|
|
3843
3841
|
platformNotifier = import_node_notifier.default;
|
|
3844
3842
|
}
|
|
3845
3843
|
var lastNotificationTime = {};
|
|
@@ -3849,6 +3847,15 @@ async function sendNotification(message, timeout) {
|
|
|
3849
3847
|
return;
|
|
3850
3848
|
}
|
|
3851
3849
|
lastNotificationTime[message] = now;
|
|
3850
|
+
if (platform === "Darwin") {
|
|
3851
|
+
return new Promise((resolve) => {
|
|
3852
|
+
const escapedMessage = message.replace(/"/g, "\\\"");
|
|
3853
|
+
const escapedTitle = NOTIFICATION_TITLE.replace(/"/g, "\\\"");
|
|
3854
|
+
exec(`osascript -e 'display notification "${escapedMessage}" with title "${escapedTitle}"'`, () => {
|
|
3855
|
+
resolve();
|
|
3856
|
+
});
|
|
3857
|
+
});
|
|
3858
|
+
}
|
|
3852
3859
|
return new Promise((resolve) => {
|
|
3853
3860
|
const notificationOptions = {
|
|
3854
3861
|
title: NOTIFICATION_TITLE,
|
|
@@ -3856,9 +3863,6 @@ async function sendNotification(message, timeout) {
|
|
|
3856
3863
|
timeout,
|
|
3857
3864
|
icon: undefined
|
|
3858
3865
|
};
|
|
3859
|
-
if (platform === "Darwin") {
|
|
3860
|
-
notificationOptions.sound = false;
|
|
3861
|
-
}
|
|
3862
3866
|
platformNotifier.notify(notificationOptions, () => {
|
|
3863
3867
|
resolve();
|
|
3864
3868
|
});
|
|
@@ -3985,6 +3989,9 @@ var NotifierPlugin = async () => {
|
|
|
3985
3989
|
if (event.type === "session.error") {
|
|
3986
3990
|
await handleEvent(config, "error");
|
|
3987
3991
|
}
|
|
3992
|
+
},
|
|
3993
|
+
"permission.ask": async () => {
|
|
3994
|
+
await handleEvent(config, "permission");
|
|
3988
3995
|
}
|
|
3989
3996
|
};
|
|
3990
3997
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mohak34/opencode-notifier",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "OpenCode plugin that sends system notifications and plays sounds when permission is needed, generation completes, or errors occur",
|
|
5
5
|
"author": "mohak34",
|
|
6
6
|
"license": "MIT",
|