opencode-sfx is an OpenCode plugin that plays short audio clips for key OpenCode events.
Instead of mapping each event to one file, the plugin maps each event to a folder and picks a random clip from that folder when the event fires.
Primary implementation lives in src/index.ts.
Supported events/folders:
sessionStartsessionCreatedpromptSubmitnotificationpermissionstop
Runtime scans each event folder non-recursively and only considers .ogg, .wav, and .mp3 files.
On plugin startup:
- Ensure
soundRootexists. - Ensure each event folder exists under the resolved config.
- If
soundRootdid not exist before startup (first bootstrap), copy the entire bundledassets/tree intosoundRoot.
Bootstrap copy behavior:
- Recursive directory copy.
- Never delete files.
- Never overwrite existing files.
- Create missing destination directories as needed.
Bundled defaults are sourced from the repo assets/ directory.
To change default out-of-box sounds, update files under assets/ (especially event folders).
- Config file:
~/.config/opencode/opencode-sfx.json - Key fields:
enabledplayerCommandplayerArgseventssoundRooteventFolders
- Keep file operations safe: do not remove user files during bootstrap.
- Preserve non-recursive event folder scanning behavior.
- Validate changes with:
npm run typechecknpm run build