OpenCode plugin: console.log spam corrupts TUI display
Bug
The generated OpenCode plugin (memorix installHooks('opencode', ...)) contains console.log calls that write directly to OpenCode's TUI stdout, corrupting the terminal display.
Affected code
The generated .opencode/plugins/memorix.js has three console.log calls:
// Line 11 — on plugin load
console.log('[memorix] plugin loaded, directory:', directory);
// Line 22 — on every hook fire (fires on EVERY tool call + session event)
console.log('[memorix] hook fired:', payload.hook_event_name);
// Line 24 — on hook errors
console.log('[memorix] hook error:', err?.message ?? err);
Why this is a problem
In OpenCode, console.log from plugins goes directly to stdout, bypassing the TUI's log-level system (logLevel config). This means every single tool execution, session event, and idle ping dumps [memorix] hook fired: tool.execute.after etc. into the chat display, making it unreadable.
Additionally, the > /dev/null 2>&1 redirect used in some versions doesn't work in Bun's $ shell template — it throws expected a command or assignment but got: "Redirect", which then triggers the error handler's console.error, creating even more spam.
Screenshots
[memorix] hook fired: session.idle
[memorix] hook fired: tool.execute.after
[memorix] hook error: expected a command or assignment but got: "Redirect"
[memorix] hook error: expected a command or assignment but got: "Redirect"
[memorix] hook error: expected a command or assignment but got: "Redirect"
Suggested fix
- Remove all
console.log/console.errorcalls from the generated plugin - Use
.quiet()instead of> /dev/null 2>&1for Bun's shell (.quiet()is the Bun-native way to suppress output) - Silently ignore hook errors (or route through
client.app.logif available)
Environment
- OpenCode 1.3.0
- memorix (latest via mcpm)
- macOS 15.5
Thanks for reporting this — the underlying problem was real for older generated OpenCode plugin installs. Current main / v1.0.5 already uses the silent plugin template (.quiet().nothrow(), no console.log/console.error, no shell redirect spam), and we also shipped stale-install detection so memorix hooks status can flag outdated OpenCode plugin files and prompt a reinstall. In other words: the noisy template is fixed, and old installs are now detectable. Closing this as resolved in v1.0.5.
Nice! Just updated it