opencode-plugin-boops 2.0.2 → 2.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.
package/README.md CHANGED
@@ -13,19 +13,27 @@ Sound notifications for OpenCode - plays pleasant "boop" sounds when tasks compl
13
13
 
14
14
  ## Installation
15
15
 
16
- Add to your OpenCode config file:
16
+ ### Quick Install (Recommended)
17
17
 
18
- **Global installation** (recommended):
19
18
  ```bash
20
- # Edit ~/.config/opencode/opencode.json
19
+ npx opencode-plugin-boops install
21
20
  ```
22
21
 
23
- **Per-project installation**:
24
- ```bash
25
- # Edit opencode.json in your project root
22
+ This automatically adds the plugin to your OpenCode config. Then restart OpenCode.
23
+
24
+ ### Manual Installation
25
+
26
+ Add the plugin to your OpenCode config file:
27
+
28
+ **Global** (`~/.config/opencode/opencode.json`):
29
+ ```json
30
+ {
31
+ "$schema": "https://opencode.ai/config.json",
32
+ "plugin": ["opencode-plugin-boops"]
33
+ }
26
34
  ```
27
35
 
28
- Add the plugin to the config:
36
+ **Per-project** (`opencode.json` in project root):
29
37
  ```json
30
38
  {
31
39
  "$schema": "https://opencode.ai/config.json",
@@ -35,21 +43,21 @@ Add the plugin to the config:
35
43
 
36
44
  Then restart OpenCode. The plugin will be automatically downloaded and installed from npm.
37
45
 
38
- ### Quick setup
39
-
40
- If you don't have an OpenCode config yet:
46
+ ## CLI Commands
41
47
 
42
48
  ```bash
43
- # Create global config
44
- mkdir -p ~/.config/opencode
45
- echo '{"$schema":"https://opencode.ai/config.json","plugin":["opencode-plugin-boops"]}' > ~/.config/opencode/opencode.json
46
- ```
49
+ # Install plugin (adds to OpenCode config)
50
+ npx opencode-plugin-boops install
47
51
 
48
- Or for a specific project:
52
+ # Uninstall plugin (removes from config)
53
+ npx opencode-plugin-boops uninstall # Interactive - asks about data cleanup
54
+ npx opencode-plugin-boops uninstall --full # Remove plugin + data
49
55
 
50
- ```bash
51
- # In your project directory
52
- echo '{"$schema":"https://opencode.ai/config.json","plugin":["opencode-plugin-boops"]}' > opencode.json
56
+ # Browse 448 sounds with semantic tags
57
+ npx opencode-plugin-boops browse
58
+
59
+ # Show help
60
+ npx opencode-plugin-boops
53
61
  ```
54
62
 
55
63
  ## How it works
@@ -230,11 +238,11 @@ The test command automatically reloads your config file, so you can edit `boops.
230
238
  The plugin includes a beautiful TUI for browsing and assigning sounds:
231
239
 
232
240
  ```bash
233
- # If plugin is installed
234
- ~/.config/opencode/plugins/boops/browse
235
-
236
- # Or try it with npx (browse-only, saving disabled)
241
+ # Browse and test sounds
237
242
  npx opencode-plugin-boops browse
243
+
244
+ # Or after installation:
245
+ ~/.config/opencode/plugins/boops/browse
238
246
  ```
239
247
 
240
248
  Features:
package/cli/install ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * OpenCode Boops Plugin - Installer
4
+ * Automatically adds the plugin to your OpenCode config
5
+ */
6
+
7
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
8
+ import { join } from "path";
9
+ import { homedir } from "os";
10
+
11
+ const CONFIG_DIR = join(homedir(), ".config", "opencode");
12
+ const CONFIG_PATH = join(CONFIG_DIR, "opencode.json");
13
+ const PLUGIN_NAME = "opencode-plugin-boops";
14
+
15
+ console.log("šŸ”Š OpenCode Boops Plugin Installer\n");
16
+
17
+ // Ensure config directory exists
18
+ mkdirSync(CONFIG_DIR, { recursive: true });
19
+
20
+ // Read or create config
21
+ let config;
22
+ if (existsSync(CONFIG_PATH)) {
23
+ console.log("šŸ“ Found existing OpenCode config");
24
+ try {
25
+ const content = readFileSync(CONFIG_PATH, "utf-8");
26
+ config = JSON.parse(content);
27
+ } catch (error) {
28
+ console.error("āŒ Failed to parse opencode.json:", error.message);
29
+ console.log("Please fix your config manually at:", CONFIG_PATH);
30
+ process.exit(1);
31
+ }
32
+ } else {
33
+ console.log("šŸ“ Creating new OpenCode config");
34
+ config = {
35
+ "$schema": "https://opencode.ai/config.json",
36
+ };
37
+ }
38
+
39
+ // Add plugin if not already present
40
+ if (!config.plugin) {
41
+ config.plugin = [];
42
+ } else if (typeof config.plugin === "string") {
43
+ config.plugin = [config.plugin];
44
+ }
45
+
46
+ if (config.plugin.includes(PLUGIN_NAME)) {
47
+ console.log("āœ“ Plugin already installed in config");
48
+ } else {
49
+ config.plugin.push(PLUGIN_NAME);
50
+ writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2) + "\n");
51
+ console.log("āœ“ Added plugin to OpenCode config");
52
+ }
53
+
54
+ console.log("\nšŸ“ Config location:", CONFIG_PATH);
55
+ console.log("\nšŸŽµ Next steps:");
56
+ console.log(" 1. Restart OpenCode (the plugin will auto-install)");
57
+ console.log(" 2. Browse sounds: npx opencode-plugin-boops browse");
58
+ console.log(" 3. Customize config: $EDITOR ~/.config/opencode/plugins/boops/boops.toml");
59
+ console.log("\n✨ Done!");
package/cli/main ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * OpenCode Boops Plugin - CLI Entry Point
4
+ */
5
+
6
+ import { spawn } from "child_process";
7
+ import { fileURLToPath } from "url";
8
+ import { dirname, join } from "path";
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = dirname(__filename);
12
+
13
+ const command = process.argv[2] || "browse";
14
+ const args = process.argv.slice(3);
15
+
16
+ const commands = {
17
+ install: join(__dirname, "install"),
18
+ uninstall: join(__dirname, "uninstall"),
19
+ browse: join(__dirname, "browse"),
20
+ };
21
+
22
+ if (!commands[command]) {
23
+ console.log("OpenCode Boops Plugin\n");
24
+ console.log("Usage:");
25
+ console.log(" npx opencode-plugin-boops install - Add plugin to OpenCode config");
26
+ console.log(" npx opencode-plugin-boops uninstall - Remove plugin from config");
27
+ console.log(" npx opencode-plugin-boops browse - Browse and test sounds (default)");
28
+ console.log(" npx opencode-plugin-boops - Same as browse");
29
+ process.exit(1);
30
+ }
31
+
32
+ const child = spawn(commands[command], args, {
33
+ stdio: "inherit",
34
+ });
35
+
36
+ child.on("exit", (code) => {
37
+ process.exit(code || 0);
38
+ });
package/cli/uninstall ADDED
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * OpenCode Boops Plugin - Uninstaller
4
+ * Removes the plugin from OpenCode config and optionally cleans up data
5
+ */
6
+
7
+ import { existsSync, readFileSync, writeFileSync, rmSync } from "fs";
8
+ import { join } from "path";
9
+ import { homedir } from "os";
10
+ import { createInterface } from "readline";
11
+
12
+ const CONFIG_DIR = join(homedir(), ".config", "opencode");
13
+ const CONFIG_PATH = join(CONFIG_DIR, "opencode.json");
14
+ const PLUGIN_NAME = "opencode-plugin-boops";
15
+ const PLUGIN_DIR = join(CONFIG_DIR, "plugins", "boops");
16
+ const CACHE_DIR = join(homedir(), ".cache", "opencode", "boops");
17
+
18
+ console.log("šŸ”Š OpenCode Boops Plugin Uninstaller\n");
19
+
20
+ // Remove from config
21
+ if (existsSync(CONFIG_PATH)) {
22
+ try {
23
+ const content = readFileSync(CONFIG_PATH, "utf-8");
24
+ const config = JSON.parse(content);
25
+
26
+ if (config.plugin) {
27
+ if (typeof config.plugin === "string") {
28
+ if (config.plugin === PLUGIN_NAME) {
29
+ delete config.plugin;
30
+ console.log("āœ“ Removed plugin from config");
31
+ } else {
32
+ console.log("ℹ Plugin not found in config");
33
+ }
34
+ } else if (Array.isArray(config.plugin)) {
35
+ const index = config.plugin.indexOf(PLUGIN_NAME);
36
+ if (index > -1) {
37
+ config.plugin.splice(index, 1);
38
+ if (config.plugin.length === 0) {
39
+ delete config.plugin;
40
+ }
41
+ console.log("āœ“ Removed plugin from config");
42
+ } else {
43
+ console.log("ℹ Plugin not found in config");
44
+ }
45
+ }
46
+
47
+ writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2) + "\n");
48
+ } else {
49
+ console.log("ℹ No plugins in config");
50
+ }
51
+ } catch (error) {
52
+ console.error("āŒ Failed to update config:", error.message);
53
+ process.exit(1);
54
+ }
55
+ } else {
56
+ console.log("ℹ No OpenCode config found");
57
+ }
58
+
59
+ // Ask about cleaning up data
60
+ const rl = createInterface({
61
+ input: process.stdin,
62
+ output: process.stdout,
63
+ });
64
+
65
+ const shouldCleanup = process.argv.includes("--full") || process.argv.includes("-f");
66
+
67
+ if (shouldCleanup) {
68
+ cleanup();
69
+ } else {
70
+ console.log("\nšŸ“¦ Plugin data locations:");
71
+ if (existsSync(PLUGIN_DIR)) {
72
+ console.log(" • Config & data:", PLUGIN_DIR);
73
+ }
74
+ if (existsSync(CACHE_DIR)) {
75
+ console.log(" • Cached sounds:", CACHE_DIR);
76
+ }
77
+
78
+ console.log("\nšŸ—‘ļø Clean up plugin data?");
79
+ console.log(" This will remove your custom config and cached sounds.");
80
+
81
+ rl.question("\n Remove data? [y/N] ", (answer) => {
82
+ if (answer.toLowerCase() === "y" || answer.toLowerCase() === "yes") {
83
+ cleanup();
84
+ } else {
85
+ console.log("\nāœ“ Kept plugin data (you can remove manually later)");
86
+ console.log(" rm -rf", PLUGIN_DIR);
87
+ console.log(" rm -rf", CACHE_DIR);
88
+ }
89
+ rl.close();
90
+ });
91
+ }
92
+
93
+ function cleanup() {
94
+ let removed = false;
95
+
96
+ if (existsSync(PLUGIN_DIR)) {
97
+ rmSync(PLUGIN_DIR, { recursive: true, force: true });
98
+ console.log("āœ“ Removed plugin directory");
99
+ removed = true;
100
+ }
101
+
102
+ if (existsSync(CACHE_DIR)) {
103
+ rmSync(CACHE_DIR, { recursive: true, force: true });
104
+ console.log("āœ“ Removed cached sounds");
105
+ removed = true;
106
+ }
107
+
108
+ if (!removed) {
109
+ console.log("ℹ No plugin data found");
110
+ }
111
+
112
+ console.log("\n✨ Uninstall complete!");
113
+ console.log("\nšŸ’” Restart OpenCode to complete the removal");
114
+
115
+ if (!shouldCleanup) {
116
+ rl.close();
117
+ }
118
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-plugin-boops",
3
- "version": "2.0.2",
3
+ "version": "2.1.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",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "homepage": "https://github.com/towc/opencode-plugin-boops#readme",
25
25
  "bin": {
26
- "opencode-plugin-boops": "cli/browse"
26
+ "opencode-plugin-boops": "cli/main"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@opencode-ai/plugin": "^1.0.0"
@@ -39,6 +39,9 @@
39
39
  "index.ts",
40
40
  "sounds.json",
41
41
  "boops.default.toml",
42
+ "cli/main",
43
+ "cli/install",
44
+ "cli/uninstall",
42
45
  "cli/browse",
43
46
  "README.md",
44
47
  "LICENSE"