opencode-probleemwijken 1.0.0 → 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 +69 -28
  2. package/dist/index.js +39 -15
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -4,45 +4,30 @@ OpenCode plugin dat een willekeurig geluid afspeelt van de legendarische [Proble
4
4
 
5
5
  ## Installatie
6
6
 
7
- ### Optie 1: Lokale plugin (aanbevolen)
7
+ Voeg de plugin toe aan je `opencode.json`:
8
8
 
9
- 1. Kopieer `plugin.ts` naar je OpenCode plugins directory:
10
-
11
- ```bash
12
- cp plugin.ts ~/.config/opencode/plugins/probleemwijken.ts
9
+ ```json
10
+ {
11
+ "plugin": ["opencode-probleemwijken@latest"]
12
+ }
13
13
  ```
14
14
 
15
- 2. Kopieer de sounds naar je config directory:
15
+ Herstart OpenCode en je bent klaar!
16
16
 
17
- ```bash
18
- mkdir -p ~/.config/opencode/sounds/random-soundboard
19
- cp sounds/*.mp3 ~/.config/opencode/sounds/random-soundboard/
20
- ```
21
-
22
- 3. Zorg dat je `@opencode-ai/plugin` hebt in `~/.config/opencode/package.json`:
17
+ ### Specifieke versie
23
18
 
24
19
  ```json
25
20
  {
26
- "dependencies": {
27
- "@opencode-ai/plugin": "^1.0.0"
28
- }
21
+ "plugin": ["opencode-probleemwijken@1.0.0"]
29
22
  }
30
23
  ```
31
24
 
32
- 4. Herstart OpenCode
33
-
34
- ### Optie 2: Eigen geluiden toevoegen
35
-
36
- Je kunt ook je eigen MP3/WAV/OGG/M4A bestanden toevoegen aan de `~/.config/opencode/sounds/random-soundboard/` directory.
37
-
38
25
  ## Wat doet het?
39
26
 
40
- Elke keer als OpenCode klaar is met een taak (session.idle) of een error krijgt (session.error), speelt de plugin een willekeurig geluid af uit de collectie.
27
+ Elke keer als OpenCode klaar is met een taak (`session.idle`) of een error krijgt (`session.error`), speelt de plugin een willekeurig geluid af uit de collectie van 36 klassieke Derkolk soundboard fragmenten.
41
28
 
42
29
  ## Geluiden
43
30
 
44
- De plugin bevat 36 klassieke Derkolk soundboard fragmenten:
45
-
46
31
  - "VLIEG!"
47
32
  - "Half elf"
48
33
  - "Boertje!?"
@@ -51,13 +36,69 @@ De plugin bevat 36 klassieke Derkolk soundboard fragmenten:
51
36
  - "Koffie"
52
37
  - "Pitbull"
53
38
  - "Tetete"
54
- - ... en nog veel meer!
39
+ - "Kakwijk"
40
+ - "Doei Henk"
41
+ - ... en nog 26 meer!
55
42
 
56
43
  ## Platform ondersteuning
57
44
 
58
- - **macOS**: Gebruikt `afplay` (ingebouwd)
59
- - **Linux**: Gebruikt `mpv` of `ffplay`
60
- - **Windows**: Gebruikt Windows Media Player via PowerShell
45
+ | Platform | Audio player |
46
+ |----------|--------------|
47
+ | macOS | `afplay` (ingebouwd) |
48
+ | Linux | `mpv` of `ffplay` |
49
+ | Windows | Windows Media Player via PowerShell |
50
+
51
+ ## Configuratie (optioneel)
52
+
53
+ Maak `~/.config/opencode/probleemwijken.json`:
54
+
55
+ ```json
56
+ {
57
+ "enabled": true,
58
+ "includeBundledSounds": true,
59
+ "customSoundsDir": "~/my-sounds",
60
+ "events": {
61
+ "complete": true,
62
+ "subagent_complete": false,
63
+ "error": true,
64
+ "permission": false
65
+ }
66
+ }
67
+ ```
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
+ ```
61
102
 
62
103
  ## Credits
63
104
 
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;
@@ -105,12 +124,18 @@ async function runCommand(command, args) {
105
124
  });
106
125
  }
107
126
  async function playOnLinux(soundPath) {
108
- const players = [
127
+ const ext = extname(soundPath).toLowerCase();
128
+ const isWav = ext === ".wav";
129
+ const universalPlayers = [
109
130
  { command: "mpv", args: ["--no-video", "--no-terminal", soundPath] },
110
131
  { command: "ffplay", args: ["-nodisp", "-autoexit", "-loglevel", "quiet", soundPath] },
132
+ { command: "cvlc", args: ["--play-and-exit", "--no-video", "-q", soundPath] }
133
+ ];
134
+ const wavOnlyPlayers = [
111
135
  { command: "paplay", args: [soundPath] },
112
136
  { command: "aplay", args: [soundPath] }
113
137
  ];
138
+ const players = isWav ? [...universalPlayers, ...wavOnlyPlayers] : universalPlayers;
114
139
  for (const player of players) {
115
140
  try {
116
141
  await runCommand(player.command, player.args);
@@ -141,8 +166,7 @@ async function playOnWindows(soundPath) {
141
166
  }
142
167
  }
143
168
  async function playRandomSound(config) {
144
- const soundsDir = getSoundsDirectory(config);
145
- const sounds = getSoundFiles(soundsDir);
169
+ const sounds = getAllSoundFiles(config);
146
170
  if (sounds.length === 0) {
147
171
  return;
148
172
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-probleemwijken",
3
- "version": "1.0.0",
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",