@mohak34/opencode-notifier 0.1.18 → 0.1.19

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 (3) hide show
  1. package/README.md +20 -0
  2. package/dist/index.js +17 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -84,6 +84,24 @@ The plugin works out of the box on all platforms. For best results:
84
84
 
85
85
  **Note**: To disable icons, set `showIcon: false` in your configuration.
86
86
 
87
+ ### macOS: Choosing Your Notification System
88
+
89
+ On macOS, you can choose between two notification backends:
90
+
91
+ - **`osascript`** (default): Most reliable method that always works. Uses AppleScript to display notifications. **Limitation**: Cannot display custom icons (shows Script Editor icon instead).
92
+
93
+ - **`node-notifier`**: Supports custom icons but some users experience reliability issues where notifications don't appear.
94
+
95
+ To use `node-notifier` with custom icons:
96
+
97
+ ```json
98
+ {
99
+ "notificationSystem": "node-notifier"
100
+ }
101
+ ```
102
+
103
+ If you experience missing notifications with `node-notifier`, switch back to `osascript` (or remove the option to use the default).
104
+
87
105
  ## Configuration
88
106
 
89
107
  To customize the plugin, create `~/.config/opencode/opencode-notifier.json`:
@@ -95,6 +113,7 @@ To customize the plugin, create `~/.config/opencode/opencode-notifier.json`:
95
113
  "timeout": 5,
96
114
  "showProjectName": true,
97
115
  "showIcon": true,
116
+ "notificationSystem": "osascript",
98
117
  "command": {
99
118
  "enabled": false,
100
119
  "path": "/path/to/command",
@@ -134,6 +153,7 @@ To customize the plugin, create `~/.config/opencode/opencode-notifier.json`:
134
153
  | `timeout` | number | `5` | Notification duration in seconds (Linux only) |
135
154
  | `showProjectName` | boolean | `true` | Show project folder name in notification title |
136
155
  | `showIcon` | boolean | `true` | Show OpenCode icon in notifications |
156
+ | `notificationSystem` | string | `"osascript"` | macOS only: `"osascript"` (reliable, no icons) or `"node-notifier"` (icons, may have issues) |
137
157
  | `command` | object | — | Command execution settings (enabled/path/args/minDuration) |
138
158
 
139
159
  ### Events
package/dist/index.js CHANGED
@@ -3744,6 +3744,7 @@ var DEFAULT_CONFIG = {
3744
3744
  timeout: 5,
3745
3745
  showProjectName: true,
3746
3746
  showIcon: true,
3747
+ notificationSystem: "osascript",
3747
3748
  command: {
3748
3749
  enabled: false,
3749
3750
  path: "",
@@ -3812,6 +3813,7 @@ function loadConfig() {
3812
3813
  timeout: typeof userConfig.timeout === "number" && userConfig.timeout > 0 ? userConfig.timeout : DEFAULT_CONFIG.timeout,
3813
3814
  showProjectName: userConfig.showProjectName ?? DEFAULT_CONFIG.showProjectName,
3814
3815
  showIcon: userConfig.showIcon ?? DEFAULT_CONFIG.showIcon,
3816
+ notificationSystem: userConfig.notificationSystem === "node-notifier" ? "node-notifier" : "osascript",
3815
3817
  command: {
3816
3818
  enabled: typeof userCommand.enabled === "boolean" ? userCommand.enabled : DEFAULT_CONFIG.command.enabled,
3817
3819
  path: typeof userCommand.path === "string" ? userCommand.path : DEFAULT_CONFIG.command.path,
@@ -3888,13 +3890,26 @@ if (platform === "Linux" || platform.match(/BSD$/)) {
3888
3890
  platformNotifier = import_node_notifier.default;
3889
3891
  }
3890
3892
  var lastNotificationTime = {};
3891
- async function sendNotification(title, message, timeout, iconPath) {
3893
+ async function sendNotification(title, message, timeout, iconPath, notificationSystem = "osascript") {
3892
3894
  const now = Date.now();
3893
3895
  if (lastNotificationTime[message] && now - lastNotificationTime[message] < DEBOUNCE_MS) {
3894
3896
  return;
3895
3897
  }
3896
3898
  lastNotificationTime[message] = now;
3897
3899
  if (platform === "Darwin") {
3900
+ if (notificationSystem === "node-notifier") {
3901
+ return new Promise((resolve) => {
3902
+ const notificationOptions = {
3903
+ title,
3904
+ message,
3905
+ timeout,
3906
+ icon: iconPath
3907
+ };
3908
+ import_node_notifier.default.notify(notificationOptions, () => {
3909
+ resolve();
3910
+ });
3911
+ });
3912
+ }
3898
3913
  return new Promise((resolve) => {
3899
3914
  const escapedMessage = message.replace(/"/g, "\\\"");
3900
3915
  const escapedTitle = title.replace(/"/g, "\\\"");
@@ -4049,7 +4064,7 @@ async function handleEvent(config, eventType, projectName, elapsedSeconds) {
4049
4064
  if (isEventNotificationEnabled(config, eventType)) {
4050
4065
  const title = getNotificationTitle(config, projectName);
4051
4066
  const iconPath = getIconPath(config);
4052
- promises.push(sendNotification(title, message, config.timeout, iconPath));
4067
+ promises.push(sendNotification(title, message, config.timeout, iconPath, config.notificationSystem));
4053
4068
  }
4054
4069
  if (isEventSoundEnabled(config, eventType)) {
4055
4070
  const customSoundPath = getSoundPath(config, eventType);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mohak34/opencode-notifier",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
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",