opencode-probleemwijken 1.0.1 → 1.1.0

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 +37 -1
  2. package/dist/index.js +32 -14
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -50,11 +50,13 @@ Elke keer als OpenCode klaar is met een taak (`session.idle`) of een error krijg
50
50
 
51
51
  ## Configuratie (optioneel)
52
52
 
53
- Maak `~/.config/opencode/probleemwijken.json` om events aan/uit te zetten:
53
+ Maak `~/.config/opencode/probleemwijken.json`:
54
54
 
55
55
  ```json
56
56
  {
57
57
  "enabled": true,
58
+ "includeBundledSounds": true,
59
+ "customSoundsDir": "~/my-sounds",
58
60
  "events": {
59
61
  "complete": true,
60
62
  "subagent_complete": false,
@@ -64,6 +66,40 @@ Maak `~/.config/opencode/probleemwijken.json` om events aan/uit te zetten:
64
66
  }
65
67
  ```
66
68
 
69
+ ### Opties
70
+
71
+ | Optie | Type | Default | Beschrijving |
72
+ |-------|------|---------|--------------|
73
+ | `enabled` | boolean | `true` | Plugin aan/uit |
74
+ | `includeBundledSounds` | boolean | `true` | Probleemwijken geluiden gebruiken |
75
+ | `customSoundsDir` | string | `null` | Pad naar folder met eigen geluiden |
76
+ | `events.complete` | boolean | `true` | Geluid bij voltooide sessie |
77
+ | `events.subagent_complete` | boolean | `false` | Geluid bij voltooide subagent |
78
+ | `events.error` | boolean | `true` | Geluid bij error |
79
+ | `events.permission` | boolean | `false` | Geluid bij permission request |
80
+
81
+ ### Eigen geluiden toevoegen
82
+
83
+ 1. Maak een folder met je eigen MP3/WAV/OGG bestanden
84
+ 2. Configureer het pad in `probleemwijken.json`:
85
+
86
+ ```json
87
+ {
88
+ "customSoundsDir": "/home/user/my-sounds"
89
+ }
90
+ ```
91
+
92
+ De plugin kiest dan random uit zowel de Probleemwijken geluiden als je eigen geluiden.
93
+
94
+ ### Alleen eigen geluiden gebruiken
95
+
96
+ ```json
97
+ {
98
+ "includeBundledSounds": false,
99
+ "customSoundsDir": "/home/user/my-sounds"
100
+ }
101
+ ```
102
+
67
103
  ## Credits
68
104
 
69
105
  - Geluiden van [derkolk.nl/probleemwijken](https://www.derkolk.nl/probleemwijken/)
package/dist/index.js CHANGED
@@ -4,7 +4,8 @@ import { join } from "path";
4
4
  import { homedir } from "os";
5
5
  var DEFAULT_CONFIG = {
6
6
  enabled: true,
7
- soundsDir: null,
7
+ customSoundsDir: null,
8
+ includeBundledSounds: true,
8
9
  events: {
9
10
  complete: true,
10
11
  subagent_complete: false,
@@ -13,8 +14,18 @@ var DEFAULT_CONFIG = {
13
14
  }
14
15
  };
15
16
  function loadConfig() {
16
- const configPath = join(homedir(), ".config", "opencode", "random-soundboard.json");
17
- if (!existsSync(configPath)) {
17
+ const configPaths = [
18
+ join(homedir(), ".config", "opencode", "probleemwijken.json"),
19
+ join(homedir(), ".config", "opencode", "random-soundboard.json")
20
+ ];
21
+ let configPath = null;
22
+ for (const path of configPaths) {
23
+ if (existsSync(path)) {
24
+ configPath = path;
25
+ break;
26
+ }
27
+ }
28
+ if (!configPath) {
18
29
  return DEFAULT_CONFIG;
19
30
  }
20
31
  try {
@@ -22,7 +33,8 @@ function loadConfig() {
22
33
  const userConfig = JSON.parse(content);
23
34
  return {
24
35
  enabled: userConfig.enabled ?? DEFAULT_CONFIG.enabled,
25
- soundsDir: userConfig.soundsDir ?? DEFAULT_CONFIG.soundsDir,
36
+ customSoundsDir: userConfig.customSoundsDir ?? DEFAULT_CONFIG.customSoundsDir,
37
+ includeBundledSounds: userConfig.includeBundledSounds ?? DEFAULT_CONFIG.includeBundledSounds,
26
38
  events: {
27
39
  complete: userConfig.events?.complete ?? DEFAULT_CONFIG.events.complete,
28
40
  subagent_complete: userConfig.events?.subagent_complete ?? DEFAULT_CONFIG.events.subagent_complete,
@@ -58,15 +70,9 @@ function getBundledSoundsDir() {
58
70
  return path;
59
71
  }
60
72
  }
61
- return join2(__dirname2, "..", "sounds");
62
- }
63
- function getSoundsDirectory(config) {
64
- if (config.soundsDir && existsSync2(config.soundsDir)) {
65
- return config.soundsDir;
66
- }
67
- return getBundledSoundsDir();
73
+ return null;
68
74
  }
69
- function getSoundFiles(directory) {
75
+ function getSoundFilesFromDir(directory) {
70
76
  if (!existsSync2(directory)) {
71
77
  return [];
72
78
  }
@@ -80,6 +86,19 @@ function getSoundFiles(directory) {
80
86
  return [];
81
87
  }
82
88
  }
89
+ function getAllSoundFiles(config) {
90
+ const allSounds = [];
91
+ if (config.includeBundledSounds) {
92
+ const bundledDir = getBundledSoundsDir();
93
+ if (bundledDir) {
94
+ allSounds.push(...getSoundFilesFromDir(bundledDir));
95
+ }
96
+ }
97
+ if (config.customSoundsDir && existsSync2(config.customSoundsDir)) {
98
+ allSounds.push(...getSoundFilesFromDir(config.customSoundsDir));
99
+ }
100
+ return allSounds;
101
+ }
83
102
  function getRandomSound(sounds) {
84
103
  if (sounds.length === 0)
85
104
  return null;
@@ -147,8 +166,7 @@ async function playOnWindows(soundPath) {
147
166
  }
148
167
  }
149
168
  async function playRandomSound(config) {
150
- const soundsDir = getSoundsDirectory(config);
151
- const sounds = getSoundFiles(soundsDir);
169
+ const sounds = getAllSoundFiles(config);
152
170
  if (sounds.length === 0) {
153
171
  return;
154
172
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-probleemwijken",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "OpenCode plugin that plays a random Probleemwijken/Derkolk soundboard sound when a session completes",
5
5
  "author": "Daan-Friday",
6
6
  "license": "MIT",