opencode-plugin-boops 2.5.2 → 2.6.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 (3) hide show
  1. package/cli/browse +2 -26
  2. package/index.ts +20 -20
  3. package/package.json +1 -1
package/cli/browse CHANGED
@@ -5,6 +5,7 @@ import { fileURLToPath } from "url";
5
5
  import { homedir } from "os";
6
6
  import { spawn, exec } from "child_process";
7
7
  import https from "https";
8
+ import { parse } from "smol-toml";
8
9
 
9
10
  // Get the directory where this script is located
10
11
  const __filename = fileURLToPath(import.meta.url);
@@ -96,32 +97,7 @@ function loadCurrentConfig() {
96
97
 
97
98
  try {
98
99
  const content = readFileSync(configPath, "utf-8");
99
- const config = {};
100
-
101
- // Simple TOML parser for our use case
102
- const lines = content.split("\n");
103
- let currentSection = null;
104
-
105
- for (const line of lines) {
106
- const trimmed = line.trim();
107
- if (!trimmed || trimmed.startsWith("#")) continue;
108
-
109
- // Section header
110
- if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
111
- currentSection = trimmed.slice(1, -1);
112
- if (!config[currentSection]) config[currentSection] = {};
113
- continue;
114
- }
115
-
116
- // Key = value (handle quoted keys like "session.error")
117
- const match = trimmed.match(/^"?([^"=]+)"?\s*=\s*"?([^"]+)"?$/);
118
- if (match && currentSection) {
119
- const [, key, value] = match;
120
- config[currentSection][key.trim()] = value.trim().replace(/"/g, "");
121
- }
122
- }
123
-
124
- return config;
100
+ return parse(content);
125
101
  } catch (e) {
126
102
  return {};
127
103
  }
package/index.ts CHANGED
@@ -171,35 +171,35 @@ export const BoopsPlugin: Plugin = async ({ client }) => {
171
171
  }
172
172
  }
173
173
 
174
- // Get cache path for an event (no extension, stores by event name)
175
- const getCachePath = (eventName: string): string => {
176
- // Sanitize event name for filesystem (replace dots with dashes)
177
- const safeName = eventName.replace(/\./g, "-")
178
- return join(cacheDir, safeName)
174
+ // Get cache path for a sound (uses URL hash to ensure uniqueness)
175
+ const getCachePath = (url: string): string => {
176
+ // Use a hash of the URL to ensure unique cache keys
177
+ // This works for all URLs (notificationsounds.com, custom URLs, etc.)
178
+ const hash = Bun.hash(url).toString(16)
179
+
180
+ // Try to preserve the file extension for better debugging
181
+ let ext = '.ogg'
182
+ try {
183
+ const urlObj = new URL(url)
184
+ const pathname = urlObj.pathname
185
+ const extMatch = pathname.match(/\.(\w+)$/)
186
+ if (extMatch) ext = `.${extMatch[1]}`
187
+ } catch {
188
+ // Use default extension if URL parsing fails
189
+ }
190
+
191
+ return join(cacheDir, `${hash}${ext}`)
179
192
  }
180
193
 
181
- // Download and cache a sound file from URL for a specific event
194
+ // Download and cache a sound file from URL
182
195
  const downloadSound = async (url: string, eventName: string): Promise<string> => {
183
- const cachedPath = getCachePath(eventName)
196
+ const cachedPath = getCachePath(url)
184
197
 
185
198
  // Return cached file if it exists
186
199
  if (existsSync(cachedPath)) {
187
200
  return cachedPath
188
201
  }
189
202
 
190
- // Delete any old cached file for this event (in case URL changed)
191
- try {
192
- const files = await readdir(cacheDir)
193
- const safeName = eventName.replace(/\./g, "-")
194
- for (const file of files) {
195
- if (file.startsWith(safeName)) {
196
- await unlink(join(cacheDir, file))
197
- }
198
- }
199
- } catch {
200
- // Ignore errors
201
- }
202
-
203
203
  // Download the file
204
204
  await log(`Downloading sound for ${eventName}: ${url}`)
205
205
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-plugin-boops",
3
- "version": "2.5.2",
3
+ "version": "2.6.1",
4
4
  "description": "Sound notifications for OpenCode - plays pleasant sounds when tasks complete or input is needed",
5
5
  "main": "index.ts",
6
6
  "type": "module",