@mohak34/opencode-notifier 0.1.10 → 0.1.12

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # opencode-notifier
2
2
 
3
- OpenCode plugin that plays sounds and sends system notifications when permission is needed, generation completes, or errors occur. Works on macOS, Linux, and Windows.
3
+ OpenCode plugin that plays sounds and sends system notifications when permission is needed, generation completes, errors occur, or the question tool is invoked. Works on macOS, Linux, and Windows.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,7 @@ To pin a specific version:
18
18
 
19
19
  ```json
20
20
  {
21
- "plugin": ["@mohak34/opencode-notifier@0.1.8"]
21
+ "plugin": ["@mohak34/opencode-notifier@0.1.10"]
22
22
  }
23
23
  ```
24
24
 
@@ -46,13 +46,13 @@ Remove-Item -Recurse -Force "$env:USERPROFILE\.cache\opencode\node_modules\@moha
46
46
 
47
47
  Then restart OpenCode - it will download the latest version automatically.
48
48
 
49
- ### If you use a pinned version (e.g., `@0.1.7`)
49
+ ### If you use a pinned version (e.g., `@0.1.10`)
50
50
 
51
51
  1. Update the version in your `opencode.json`:
52
52
 
53
53
  ```json
54
54
  {
55
- "plugin": ["@mohak34/opencode-notifier@0.1.8"]
55
+ "plugin": ["@mohak34/opencode-notifier@0.1.10"]
56
56
  }
57
57
  ```
58
58
 
@@ -94,17 +94,20 @@ To customize the plugin, create `~/.config/opencode/opencode-notifier.json`:
94
94
  "events": {
95
95
  "permission": { "sound": true, "notification": true },
96
96
  "complete": { "sound": true, "notification": true },
97
- "error": { "sound": true, "notification": true }
97
+ "error": { "sound": true, "notification": true },
98
+ "question": { "sound": true, "notification": true }
98
99
  },
99
100
  "messages": {
100
101
  "permission": "OpenCode needs permission",
101
102
  "complete": "OpenCode has finished",
102
- "error": "OpenCode encountered an error"
103
+ "error": "OpenCode encountered an error",
104
+ "question": "OpenCode has a question"
103
105
  },
104
106
  "sounds": {
105
107
  "permission": "/path/to/custom/sound.wav",
106
108
  "complete": "/path/to/custom/sound.wav",
107
- "error": "/path/to/custom/sound.wav"
109
+ "error": "/path/to/custom/sound.wav",
110
+ "question": "/path/to/custom/sound.wav"
108
111
  }
109
112
  }
110
113
  ```
@@ -126,7 +129,8 @@ Control sound and notification separately for each event:
126
129
  "events": {
127
130
  "permission": { "sound": true, "notification": true },
128
131
  "complete": { "sound": false, "notification": true },
129
- "error": { "sound": true, "notification": false }
132
+ "error": { "sound": true, "notification": false },
133
+ "question": { "sound": true, "notification": true }
130
134
  }
131
135
  }
132
136
  ```
@@ -138,7 +142,8 @@ Or use a boolean to toggle both:
138
142
  "events": {
139
143
  "permission": true,
140
144
  "complete": false,
141
- "error": true
145
+ "error": true,
146
+ "question": true
142
147
  }
143
148
  }
144
149
  ```
@@ -152,7 +157,8 @@ Customize notification text:
152
157
  "messages": {
153
158
  "permission": "Action required",
154
159
  "complete": "Done!",
155
- "error": "Something went wrong"
160
+ "error": "Something went wrong",
161
+ "question": "Input needed"
156
162
  }
157
163
  }
158
164
  ```
@@ -166,7 +172,8 @@ Use your own sound files:
166
172
  "sounds": {
167
173
  "permission": "/home/user/sounds/alert.wav",
168
174
  "complete": "/home/user/sounds/done.wav",
169
- "error": "/home/user/sounds/error.wav"
175
+ "error": "/home/user/sounds/error.wav",
176
+ "question": "/home/user/sounds/question.wav"
170
177
  }
171
178
  }
172
179
  ```
@@ -177,7 +184,7 @@ If a custom sound file path is provided but the file doesn't exist, the plugin w
177
184
 
178
185
  ### macOS: Notifications not showing (only sound works)
179
186
 
180
- **Update to v0.1.8 or later** - this version includes a fix for macOS notification events.
187
+ **Update to v0.1.10 or later** - this version includes a fix for macOS notification events.
181
188
 
182
189
  If notifications still don't work after updating:
183
190
 
package/dist/index.js CHANGED
@@ -3731,27 +3731,30 @@ import { readFileSync, existsSync } from "fs";
3731
3731
  import { join } from "path";
3732
3732
  import { homedir } from "os";
3733
3733
  var DEFAULT_EVENT_CONFIG = {
3734
- sound: false,
3734
+ sound: true,
3735
3735
  notification: true
3736
3736
  };
3737
3737
  var DEFAULT_CONFIG = {
3738
- sound: false,
3738
+ sound: true,
3739
3739
  notification: true,
3740
3740
  timeout: 5,
3741
3741
  events: {
3742
3742
  permission: { ...DEFAULT_EVENT_CONFIG },
3743
3743
  complete: { ...DEFAULT_EVENT_CONFIG },
3744
- error: { ...DEFAULT_EVENT_CONFIG }
3744
+ error: { ...DEFAULT_EVENT_CONFIG },
3745
+ question: { ...DEFAULT_EVENT_CONFIG }
3745
3746
  },
3746
3747
  messages: {
3747
3748
  permission: "OpenCode needs permission",
3748
3749
  complete: "OpenCode has finished",
3749
- error: "OpenCode encountered an error"
3750
+ error: "OpenCode encountered an error",
3751
+ question: "OpenCode has a question"
3750
3752
  },
3751
3753
  sounds: {
3752
3754
  permission: null,
3753
3755
  complete: null,
3754
- error: null
3756
+ error: null,
3757
+ question: null
3755
3758
  }
3756
3759
  };
3757
3760
  function getConfigPath() {
@@ -3793,17 +3796,20 @@ function loadConfig() {
3793
3796
  events: {
3794
3797
  permission: parseEventConfig(userConfig.events?.permission ?? userConfig.permission, defaultWithGlobal),
3795
3798
  complete: parseEventConfig(userConfig.events?.complete ?? userConfig.complete, defaultWithGlobal),
3796
- error: parseEventConfig(userConfig.events?.error ?? userConfig.error, defaultWithGlobal)
3799
+ error: parseEventConfig(userConfig.events?.error ?? userConfig.error, defaultWithGlobal),
3800
+ question: parseEventConfig(userConfig.events?.question, defaultWithGlobal)
3797
3801
  },
3798
3802
  messages: {
3799
3803
  permission: userConfig.messages?.permission ?? DEFAULT_CONFIG.messages.permission,
3800
3804
  complete: userConfig.messages?.complete ?? DEFAULT_CONFIG.messages.complete,
3801
- error: userConfig.messages?.error ?? DEFAULT_CONFIG.messages.error
3805
+ error: userConfig.messages?.error ?? DEFAULT_CONFIG.messages.error,
3806
+ question: userConfig.messages?.question ?? DEFAULT_CONFIG.messages.question
3802
3807
  },
3803
3808
  sounds: {
3804
3809
  permission: userConfig.sounds?.permission ?? DEFAULT_CONFIG.sounds.permission,
3805
3810
  complete: userConfig.sounds?.complete ?? DEFAULT_CONFIG.sounds.complete,
3806
- error: userConfig.sounds?.error ?? DEFAULT_CONFIG.sounds.error
3811
+ error: userConfig.sounds?.error ?? DEFAULT_CONFIG.sounds.error,
3812
+ question: userConfig.sounds?.question ?? DEFAULT_CONFIG.sounds.question
3807
3813
  }
3808
3814
  };
3809
3815
  } catch {
@@ -3879,7 +3885,17 @@ var __dirname2 = dirname(fileURLToPath(import.meta.url));
3879
3885
  var DEBOUNCE_MS2 = 1000;
3880
3886
  var lastSoundTime = {};
3881
3887
  function getBundledSoundPath(event) {
3882
- return join2(__dirname2, "..", "sounds", `${event}.wav`);
3888
+ const soundFilename = `${event}.wav`;
3889
+ const possiblePaths = [
3890
+ join2(__dirname2, "..", "sounds", soundFilename),
3891
+ join2(__dirname2, "sounds", soundFilename)
3892
+ ];
3893
+ for (const path of possiblePaths) {
3894
+ if (existsSync2(path)) {
3895
+ return path;
3896
+ }
3897
+ }
3898
+ return join2(__dirname2, "..", "sounds", soundFilename);
3883
3899
  }
3884
3900
  function getSoundFilePath(event, customPath) {
3885
3901
  if (customPath && existsSync2(customPath)) {
@@ -3973,7 +3989,7 @@ async function handleEvent(config, eventType) {
3973
3989
  }
3974
3990
  await Promise.allSettled(promises);
3975
3991
  }
3976
- var NotifierPlugin = async () => {
3992
+ var NotifierPlugin = async ({ project, client, $, directory, worktree }) => {
3977
3993
  const config = loadConfig();
3978
3994
  return {
3979
3995
  event: async ({ event }) => {
@@ -3992,6 +4008,11 @@ var NotifierPlugin = async () => {
3992
4008
  },
3993
4009
  "permission.ask": async () => {
3994
4010
  await handleEvent(config, "permission");
4011
+ },
4012
+ "tool.execute.before": async (input, output) => {
4013
+ if (input.tool === "question") {
4014
+ await handleEvent(config, "question");
4015
+ }
3995
4016
  }
3996
4017
  };
3997
4018
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mohak34/opencode-notifier",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
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",
Binary file