Core plugin implementation for oh-my-opencode-slim, providing:
index.ts)default.server (v1) + default.setup (v2 adapter via src/v2/)tui.ts)tui-state.ts)/preset manager (tui-preset.ts)plugin-entry.ts)health-check.ts)This directory serves as the primary entry point for the plugin's runtime behavior, configuration system, and user-facing UI components.
index.ts acts as a facade that composes multiple subsystems (agents, tools, MCPs, hooks, multiplexer)ForegroundFallbackManagerMultiplexerSessionManager maintains single instance for task session managementOpenCode Core → Plugin Initialization (index.ts)
→ Agent Registration (createAgents/getAgentConfigs)
→ Tool Registration (createCancelTaskTool, etc.)
→ MCP Registration (createBuiltinMcps)
→ Hook Registration (auto-update, phase reminders, cache monitor, etc.)
→ Event Subscription (session lifecycle, message updates, tool execution)
→ Runtime State Tracking (tui-state.ts)
→ TUI Rendering (tui.ts → sidebar_content slot)
→ TUI /preset Management (tui-preset.ts → preset-switch.ts)
| File | Role | Dependencies |
|---|---|---|
index.ts |
Main plugin entry, orchestrates all subsystems; exports dual server/setup default |
Config system, agent factories, tool creators, multiplexer, hooks, v2 adapter |
tui.ts |
TUI sidebar plugin for agent model display | tui-state.ts, config constants, tmux-pane-registry |
tui-state.ts |
Persistent state management for TUI | Node.js fs/promises, os module |
tui-preset.ts |
Three-level /preset manager (preset list → agents → agent edit) using api.ui dialogs |
preset-switch.ts, config loader/constants |
plugin-entry.ts |
Installer-managed plugin entry marker and PluginEntry type |
none |
health-check.ts |
Init health-check thresholds and disabled-tool-aware minimum tool count | none (kept internal, not re-exported) |
loadPluginConfig() reads and validates plugin configuration; RuntimeConfig singleton seeded and host config capturedcreateAgents() instantiates agent definitions (incl. dynamic councillors) with prompts and permissionsgetAgentConfigs() merges defaults with user overrides and runtime presetsrecordTuiAgentModels() captures resolved models/variants for TUI displayHEALTH_CHECK thresholds, adjusted for disabled baseline tools via minimumExpectedToolCounttui exporttui-state.tsTMUX_PANE
registration for parent-aware child-pane routing~/.local/share/opencode/storage/oh-my-opencode-slim/tui-state.json)readTuiSnapshot(): Reads and parses state file (returns empty snapshot on error)readTuiSnapshotAsync(): Async variant for TUI renderingrecordTuiAgentModels(): Updates both agent models and variants atomicallyrecordTuiAgentModel(): Updates single agent's model/variantrecordTuiAgentActivity(): Tracks active agents by session so concurrent
runs of the same agent remain visible until all runs finishclearTuiAgentActivities(): Removes stale activity during startup and
shutdownKey event flows:
Session Lifecycle:
session.created → register child sessionsession.status → multiplexer session management, Companion updates, and
TUI activity statesession.deleted → cleanup session agent map, Companion state, and TUI
activity stateMessage Updates:
message.updated → record agent/model usage in TUI stateTool Execution:
tool.execute.before → apply patch and task session hookstool.execute.after → post-tool hooks (retry guidance, JSON error recovery, file-tool nudges)Chat Integration:
chat.message → track session → agent mapping and mark TUI activityexperimental.chat.system.transform → inject orchestrator prompt for serve modeexperimental.chat.messages.transform → phase reminders, skill filtering, image attachment processingCommand Execution:
command.execute.before → interview, deepwork, reflect, and loop command hooks (preset switching moved to the TUI)Cache Telemetry:
message.updated (completed assistant requests) → cache monitor observes tokens.cache.read/write and logs prompt-cache bust/plateau warningstui.ts slot registration consumed by OpenCode's TUI renderersrc/config/): Configuration loading, validation, the RuntimeConfig runtime-state singleton, and runtime presetssrc/agents/): Agent personalities and permission setssrc/tools/): Tool implementations (task lifecycle controls, webfetch, AST operations, ACP)src/hooks/): Lifecycle hooks for auto-update, phase reminders, cache monitor, orchestrator wake, etc.src/multiplexer/): Tmux/Zellij session management for child sessionssrc/agents/council.ts, src/agents/council-agents.ts): Multi-LLM council orchestrationsrc/companion/): Companion version managementsrc/utils/): Logger, environment checks, background job board/supervisor, session statussrc/v2/): Wraps the v1 factory for the v2 host via default.setupsrc/index.ts imports and composes all subsystemssrc/tui-state.ts is updated during plugin init and message eventssrc/tui.ts reads state and renders sidebarloadPluginConfig() with support for:
~/.config/opencode/oh-my-opencode-slim.json/preset manager (persisted to the config file, applied on next reload)OH_MY_OPENCODE_SLIM_DISABLE