dondon-notify 0.1.0 → 0.1.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/notify.ts +19 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dondon-notify",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Native OS notifications for OpenCode - know when tasks complete",
5
5
  "type": "module",
6
6
  "main": "src/notify.ts",
package/src/notify.ts CHANGED
@@ -218,30 +218,31 @@ interface KittyNotificationOptions {
218
218
 
219
219
  function sendKittyNotification(options: KittyNotificationOptions): void {
220
220
  const { title, message, sound, focusOnClick = true } = options
221
-
221
+
222
222
  try {
223
- // Build Kitty OSC 99 notification metadata
224
- const metadataParts = ["i=1", "d=1"]
225
-
226
- // Add focus action if requested
223
+ // Build Kitty OSC 99 notification
224
+ // Protocol: \x1b]99;<metadata>;<payload>\x1b\\
225
+ // Metadata is colon-separated key=value pairs
226
+ // d=0 means more data coming, d=1 means done
227
+
228
+ const baseParts = ["i=1"]
227
229
  if (focusOnClick) {
228
- metadataParts.push("a=focus")
230
+ baseParts.push("a=focus")
229
231
  }
230
-
231
- // Add sound if configured ( Kitty supports some sound names)
232
232
  if (sound && sound !== "silent") {
233
- metadataParts.push(`s=${sound}`)
233
+ baseParts.push(`s=${sound}`)
234
234
  }
235
-
236
- const metadata = metadataParts.join(":")
237
- const titlePayload = `p=title;${title}`
238
- const bodyPayload = `p=body;${message}`
239
-
240
- // Create the escape sequence
241
- const escapeSequence = `\x1b]99;${metadata};${titlePayload}\x1b\\\x1b]99;${metadata};${bodyPayload}\x1b\\`
242
-
235
+
236
+ // Title message (d=0 = not done, more coming)
237
+ const titleMeta = [...baseParts, "d=0", "p=title"].join(":")
238
+ const titleSeq = `\x1b]99;${titleMeta};${title}\x1b\\`
239
+
240
+ // Body message (d=1 = done)
241
+ const bodyMeta = [...baseParts, "d=1", "p=body"].join(":")
242
+ const bodySeq = `\x1b]99;${bodyMeta};${message}\x1b\\`
243
+
243
244
  // Send to stdout
244
- process.stdout.write(escapeSequence)
245
+ process.stdout.write(titleSeq + bodySeq)
245
246
  } catch (error) {
246
247
  // Fall back to system notification if Kitty notification fails
247
248
  console.warn("Kitty notification failed, falling back to system notification:", error)