src/index.tsdelivers the oh-my-opencode-slim plugin by merging configuration, instantiating orchestrator/subagent definitions, wiring background managers, tmux helpers, built-in tools, MCPs, and lifecycle hooks so OpenCode sees a single cohesive module.config/,agents/,tools/,background/,hooks/, andutils/contain the reusable building blocks (loader/schema/constants, agent factories/permission helpers, tool factories, background polling/session managers, hook implementations, and tmux/variant/log helpers) that power that entry point.cli/exposes the install/update script (argument parsing + interactive prompts) that edits OpenCode config, installs recommended/custom skills, and updates provider credentials to bootstrap this plugin on a host machine.
- Agent creation follows explicit factories (
agents/index.ts, per-agent creators underagents/) with override/permission helpers (config/utils.ts,cli/skills.ts) so defaults live inconfig/constants.ts, prompts can be swapped viaconfig/loader.ts, and variant labels propagate throughutils/agent-variant.ts. - Background tooling composes
BackgroundTaskManager,TmuxSessionManager, andcreateBackgroundTools(which usestoolwith Zod schemas) to provide async/sync task launches plus cancel/output helpers; polling/prompt flow lives intools/background.tswhile TMUX lifecycle usesutils/tmux.tsto spawn/close panes and reapply layouts. - Hooks are isolated (
hooks/auto-update-checker,phase-reminder,post-read-nudge) and exported viahooks/index.ts, so the plugin simply registers them via theevent,experimental.chat.messages.transform, andtool.execute.afterhooks defined inindex.ts. - Supplemental tools (
tools/grep,tools/lsp,tools/quota) bundle ripgrep, LSP helpers, and Antigravity quota calls behind the OpenCodetoolinterface and are mounted inindex.tsalongside background/task tools.
- Startup:
index.tscallsloadPluginConfig(user + project JSON + presets) to build aPluginConfig, passes it togetAgentConfigs(which usescreateAgents, agent factories,loadAgentPrompt, andgetAgentMcpList) and toBackgroundTaskManager/TmuxSessionManager/createBackgroundToolsso the in-memory state matches user overrides. - Plugin registration:
index.tsregisters agents, the tool map (background/task,grep,ast_grep_*,lsp_*,antigravity_quota), MCP definitions (createBuiltinMcps), and hooks (createAutoUpdateCheckerHook,createPhaseReminderHook,createPostReadNudgeHook); configuration hook merges those values back into the OpenCode config (default agent, permission rules parsed fromconfig/agent-mcps, and MCP access policies). - Runtime:
BackgroundTaskManager.launchspins up sessions and prompts agents via the OpenCode client,pollTask/pollSessionwatch for idle status before resolving results, whileTmuxSessionManagerobservessession.createdevents to spawn panes viautils/tmuxand close them when sessions idle or time out; tool hooks prevent recursion by togglingbackground_task/taskpermission when sending prompts. - CLI flow:
cli/install.tsparses flags, optionally asks interactive prompts, checks OpenCode installation, adds plugin entries viacli/config-manager.ts, disables default agents, writes the lite config (cli/config-io.ts), and installs skills (cli/skills.ts,cli/custom-skills.ts).
- Connects directly to the OpenCode plugin API (
@opencode-ai/plugin): registers agents/tools/mcps, responds tosession.createdandtool.execute.afterevents, injectsexperimental.chat.messages.transform, and makes RPC calls viactx.client/ctx.client.sessionthroughouttools/backgroundandbackground/*. - Integrates with the host environment:
utils/tmux.tschecks for tmux and server availability,startTmuxCheckpre-seeds the binary path, andTmuxSessionManager/BackgroundTaskManagercoordinate via shared configuration andtools/backgroundto keep CLI panes synchronized. - Hooks and helpers tie into external behavior:
hooks/auto-update-checkerreadspackage.jsonmetadata, runs safebun install, and posts toasts;hooks/phase-reminder/post-read-nudgeenforce workflow reminders;utils/logger.tscentralizes structured logging used across modules. - CLI utilities modify OpenCode CLI/user config files (
cli/config-manager.ts) and install additional skills/ providers, ensuring the plugin lands with the expected agents, provider auth helpers, and custom skill definitions.