Symptoms
- Brain plugin status never transitions to 'ready' during initialization — stays at 'init' or 'busy' indefinitely
- Bus publish failure errors written to
console.warn instead of OpenCode app.log
Root Cause
Issue A (status stuck): In _serverPlugin (src/four-opencode-brain.ts lines 213-216), updateStatus('ready') is only called when !autoIngest. Since BRAIN_AUTO_INGEST defaults to true, the status stays at 'init' until the fire-and-forget runAutoIngest() completes (which could be minutes later, or never if the bus is broken).
Issue B (console.warn): In src/status.ts, two places use console.warn for bus errors (line 53 in getBus(), line 113 in write()). These should use _client?.app?.log(...) like the rest of the codebase does (startStatusServer() already uses this pattern correctly).
Fix Plan
1. src/status.ts — Replace console.warn with _client?.app?.log()
Location 1 — getBus() line 53:
BEFORE:
console.warn('[brain] BusClient connect failed:', (err as Error).message);
AFTER:
_client?.app?.log({ body: { service: 'brain', level: 'warn', message: 'BusClient connect failed', extra: { error: String(err) } } }).catch(() => {});
Location 2 — write() line 113:
BEFORE:
console.warn('[brain] Bus publish failed:', (err as Error).message);
AFTER:
_client?.app?.log({ body: { service: 'brain', level: 'warn', message: 'Bus publish failed', extra: { error: String(err) } } }).catch(() => {});
2. src/four-opencode-brain.ts — Always set 'ready' at init completion
Lines 213-216:
BEFORE:
// Init complete — only set idle if NOT auto-ingesting
if (!autoIngest) {
updateStatus('ready'); // init complete, no auto-ingest
}
AFTER:
// Init complete — plugin is ready for tool calls. Auto-ingest (if any) runs in background and
// will transition to 'busy' → 'ready' on its own.
updateStatus('ready');
Verification
- After fix, brain plugin status should transition
init → ready immediately on startup
- If auto-ingest is enabled, status will then go
ready → busy → ready as ingest runs
- Bus errors should appear in OpenCode logs via
app.log, not raw console.warn
Symptoms
console.warninstead of OpenCodeapp.logRoot Cause
Issue A (status stuck): In
_serverPlugin(src/four-opencode-brain.tslines 213-216),updateStatus('ready')is only called when!autoIngest. SinceBRAIN_AUTO_INGESTdefaults totrue, the status stays at'init'until the fire-and-forgetrunAutoIngest()completes (which could be minutes later, or never if the bus is broken).Issue B (console.warn): In
src/status.ts, two places useconsole.warnfor bus errors (line 53 ingetBus(), line 113 inwrite()). These should use_client?.app?.log(...)like the rest of the codebase does (startStatusServer()already uses this pattern correctly).Fix Plan
1.
src/status.ts— Replaceconsole.warnwith_client?.app?.log()Location 1 —
getBus()line 53:BEFORE:
AFTER:
Location 2 —
write()line 113:BEFORE:
AFTER:
2.
src/four-opencode-brain.ts— Always set 'ready' at init completionLines 213-216:
BEFORE:
AFTER:
Verification
init → readyimmediately on startupready → busy → readyas ingest runsapp.log, not rawconsole.warn