@mohak34/opencode-notifier 0.1.0 → 0.1.2

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,4 +1,4 @@
1
- # @mohak34/opencode-notifier
1
+ # opencode-notifier
2
2
 
3
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.
4
4
 
package/dist/index.js CHANGED
@@ -3731,11 +3731,11 @@ 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: true,
3734
+ sound: false,
3735
3735
  notification: true
3736
3736
  };
3737
3737
  var DEFAULT_CONFIG = {
3738
- sound: true,
3738
+ sound: false,
3739
3739
  notification: true,
3740
3740
  timeout: 5,
3741
3741
  events: {
@@ -3791,9 +3791,9 @@ function loadConfig() {
3791
3791
  notification: globalNotification,
3792
3792
  timeout: typeof userConfig.timeout === "number" && userConfig.timeout > 0 ? userConfig.timeout : DEFAULT_CONFIG.timeout,
3793
3793
  events: {
3794
- permission: parseEventConfig(userConfig.events?.permission, defaultWithGlobal),
3795
- complete: parseEventConfig(userConfig.events?.complete, defaultWithGlobal),
3796
- error: parseEventConfig(userConfig.events?.error, defaultWithGlobal)
3794
+ permission: parseEventConfig(userConfig.events?.permission ?? userConfig.permission, defaultWithGlobal),
3795
+ complete: parseEventConfig(userConfig.events?.complete ?? userConfig.complete, defaultWithGlobal),
3796
+ error: parseEventConfig(userConfig.events?.error ?? userConfig.error, defaultWithGlobal)
3797
3797
  },
3798
3798
  messages: {
3799
3799
  permission: userConfig.messages?.permission ?? DEFAULT_CONFIG.messages.permission,
@@ -3826,7 +3826,11 @@ function getSoundPath(config, event) {
3826
3826
  // src/notify.ts
3827
3827
  var import_node_notifier = __toESM(require_node_notifier(), 1);
3828
3828
  var NOTIFICATION_TITLE = "OpenCode";
3829
+ function debug(msg) {
3830
+ console.error(`[opencode-notifier] ${msg}`);
3831
+ }
3829
3832
  async function sendNotification(message, timeout) {
3833
+ debug(`Sending notification: "${message}" (timeout: ${timeout}s)`);
3830
3834
  return new Promise((resolve) => {
3831
3835
  import_node_notifier.default.notify({
3832
3836
  title: NOTIFICATION_TITLE,
@@ -3834,7 +3838,12 @@ async function sendNotification(message, timeout) {
3834
3838
  sound: false,
3835
3839
  timeout,
3836
3840
  icon: undefined
3837
- }, () => {
3841
+ }, (err, response, metadata) => {
3842
+ if (err) {
3843
+ debug(`Notification error: ${err}`);
3844
+ } else {
3845
+ debug(`Notification sent. Response: ${response}, Metadata: ${JSON.stringify(metadata)}`);
3846
+ }
3838
3847
  resolve();
3839
3848
  });
3840
3849
  });
@@ -3925,22 +3934,32 @@ async function playSound(event, customPath) {
3925
3934
  }
3926
3935
 
3927
3936
  // src/index.ts
3937
+ function debug2(msg) {
3938
+ console.error(`[opencode-notifier] ${msg}`);
3939
+ }
3928
3940
  async function handleEvent(config, eventType) {
3941
+ debug2(`Handling event: ${eventType}`);
3942
+ debug2(`Config for ${eventType}: sound=${isEventSoundEnabled(config, eventType)}, notification=${isEventNotificationEnabled(config, eventType)}`);
3929
3943
  const promises = [];
3930
3944
  if (isEventNotificationEnabled(config, eventType)) {
3931
3945
  const message = getMessage(config, eventType);
3946
+ debug2(`Queueing notification: "${message}"`);
3932
3947
  promises.push(sendNotification(message, config.timeout));
3933
3948
  }
3934
3949
  if (isEventSoundEnabled(config, eventType)) {
3935
3950
  const customSoundPath = getSoundPath(config, eventType);
3951
+ debug2(`Queueing sound: ${customSoundPath || "default"}`);
3936
3952
  promises.push(playSound(eventType, customSoundPath));
3937
3953
  }
3938
3954
  await Promise.allSettled(promises);
3955
+ debug2(`Event ${eventType} handled`);
3939
3956
  }
3940
3957
  var NotifierPlugin = async () => {
3941
3958
  const config = loadConfig();
3959
+ debug2(`Plugin loaded. Config: ${JSON.stringify(config)}`);
3942
3960
  return {
3943
3961
  event: async ({ event }) => {
3962
+ debug2(`Received event: ${event.type}`);
3944
3963
  if (event.type === "permission.updated") {
3945
3964
  await handleEvent(config, "permission");
3946
3965
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mohak34/opencode-notifier",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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",