Package Exports
- opencode-subagent-statusline
- opencode-subagent-statusline/runtime
- opencode-subagent-statusline/tui
Readme
opencode-subagent-statusline
OpenCode plugin para ver qué subagentes están corriendo, cuáles terminaron y cuánto contexto/tokens consumieron.
Sirve en dos modos:
- TUI plugin: muestra el panel
Subagentsdentro de la UI de OpenCode. - Server/runtime plugin: escribe
state.jsonystatus.txtpara integrarlo como fallback/statusline externa.
Probarlo desde este repo
Requisitos
- Node.js moderno compatible con TypeScript ESM.
pnpm.- OpenCode instalado y funcionando.
- Opcional:
sqlite3si querés que el TUI intente rehidratar tokens de sesiones ya finalizadas desde la base local de OpenCode.
1) Instalar dependencias
pnpm install2) Compilar el plugin (tui + runtime)
pnpm buildEsto genera dist/tui.js (entrada principal npm para tui.json) y dist/index.js (runtime fallback).
3) Activar el TUI plugin
Editá ~/.config/opencode/tui.json y agregá el plugin.
Si lo instalaste desde npm, usá el nombre del paquete:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": [
"opencode-subagent-statusline"
]
}Para probar rápido desde este repo podés apuntar directo al source:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": [
"/home/joaquinvesapa/vesapa/sub-agent-statusline/src/tui.tsx"
]
}Si preferís probar lo compilado:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": [
"/home/joaquinvesapa/vesapa/sub-agent-statusline/dist/tui.js"
]
}Este repo no modifica tu
tui.jsonautomáticamente. Lo editás vos, lo probás, y si no te gusta sacás esa línea. Es así de simple.
4) Activar el plugin server/runtime opcional
Si además querés que se escriban archivos para una statusline externa, agregá el runtime plugin en tu opencode.json:
{
"plugin": [
"opencode-subagent-statusline/runtime"
]
}En desarrollo local, también podés usar la ruta compilada directa: .../dist/index.js.
5) Verificar que funciona
Abrí OpenCode y dispará 2 o 3 subagentes/tareas en paralelo. Deberías ver:
- En el sidebar:
Subagentsconrunning,doneyerror. - En la parte inferior/home: un resumen compacto.
- Si activaste el runtime plugin:
state.jsonystatus.txten el directorio runtime.
Para limpiar la prueba, quitá la entrada del plugin en tui.json/opencode.json y reiniciá OpenCode.
Qué hace
TypeScript OpenCode plugin with two surfaces:
- Server/runtime plugin (
src/index.ts) that persistsstate.json+status.txt(fallback/statusline integration). - TUI plugin (
src/tui.tsx) that renders live subagent progress in OpenCode UI slots.
Behavior
Both plugin surfaces listen to the same event family:
session.createdsession.idlesession.errormessage.updatedmessage.part.updated
Tracked lifecycle:
session.created(withparentID) →runningsession.idle(known child) →donesession.error(known child) →error
Best-effort details:
- title (
title/namecandidates) - timing (
startedAt,updatedAt,endedAt,elapsedMs) - tokens/context (
input,output,total,contextPercent)
TUI behavior
src/tui.tsx exports a TUI plugin module:
id: "subagent-statusline.tui"- registers
sidebar_content(session-scoped) - registers a compact
home_bottomsummary
sidebar_content filters subagents by the active sidebar session:
- only children where
child.parentID === ctx.session_id
Sidebar layout:
- Title:
Subagents - Aggregate:
● {running} running · ✓ {done} done · ✕ {error} error - Per child: status icon + title + elapsed + context when available (tokens and/or
%)
Theme usage:
warning→ runningsuccess→ doneerror→ errortextMuted→ secondary info
Elapsed time updates while OpenCode TUI is open via interval timer, and all timers/event handlers are disposed through plugin lifecycle cleanup.
Server fallback behavior (files)
No manual state.json creation is required. The server plugin writes:
state.json(full machine-readable state)status.txt(compact statusline line)
Example rendered line:
↳ 2 running · 1 done · 0 error · build-index 01:23 ctx 12.4k tok · reviewer 00:41 · test-fixes 00:12 ctx 31.0%Default path (per OpenCode process):
${XDG_RUNTIME_DIR ?? os.tmpdir()}/opencode-subagent-statusline/pid-${process.pid}/state.jsonOptional instance override:
${XDG_RUNTIME_DIR ?? os.tmpdir()}/opencode-subagent-statusline/${OPENCODE_SUBAGENT_STATUSLINE_INSTANCE}/state.jsonstatus.txt is written next to state.json.
Configuration
1) Server/runtime plugin (opencode.json)
Use the server plugin for file output fallback:
{
"plugin": ["opencode-subagent-statusline/runtime"]
}Fallback local:
{
"plugin": ["/home/joaquinvesapa/vesapa/sub-agent-statusline/dist/index.js"]
}2) TUI plugin (~/.config/opencode/tui.json)
OpenCode TUI plugins are configured in tui.json (not opencode.json).
Example:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": [
"opencode-sdd-engram-manage",
"opencode-subagent-statusline"
],
"theme": "rosepine"
}This repository does not modify your global
tui.jsonautomatically.
Environment variables (server plugin)
OPENCODE_SUBAGENT_STATUSLINE_STATE: explicitstate.jsonpathOPENCODE_SUBAGENT_STATUSLINE_INSTANCE: isolated instance directory nameOPENCODE_SUBAGENT_STATUSLINE_PRESERVE_STATE=1: do not reset on startupOPENCODE_SUBAGENT_STATUSLINE_COLOR=0: disable ANSI instatus.txtNO_COLOR: standard ANSI opt-out
Caveats: event shape + context extraction
OpenCode payloads can vary by event and version. This plugin intentionally uses defensive extraction:
- accepts
sessionID/sessionIdand nestedproperties.infovariants - extracts context/tokens by scanning nested payload keys
- updates message-derived details only for known child sessions
- unknown/missing fields are ignored instead of crashing
If token/context fields are unavailable, the UI/text rendering omits context for that child.