Skip to content

Agent Architecture

OpenCode

OpenCode is the canonical TypeScript-plugin host for agent-connector: it is documented as a terminal, desktop, and IDE-capable open-source agent, but this adapter row focuses on the CLI/plugin file surfaces under OpenCode's JSON config and `.opencode` directories.

Source reviewed #9Checked 2026-07-06
Run type
CLI
Adapter
ts-plugin
Source
OSS · anomalyco/opencode
Stars
★ 205k

Archive Context

This page is one host entry inside the full architecture archive and keeps multi-surface products visible instead of collapsing them into a single run type.

42 host archive
Host page
opencode
Run cohort
CLI: 30
Archive route
/agents

Host Surface Perspectives

The host is the primary architecture boundary. Each runnable surface below separates what the host owns from what agent-connector can safely install for OpenCode.

1 surface entry

CLI

cli
Host entry
A terminal command owns the process, current working directory, stdin/stdout, shell environment, and project file discovery.
Host owns
The CLI host owns agent loop timing, approval prompts, tool execution, session files, and how hook or MCP subprocesses are launched.
Connector role
agent-connector can only write the host's documented CLI config, prompt, memory, hook, MCP, or package files and point them at the home binary. Current wired connector surfaces: MCP server, Hooks, Commands, Skills, Subagents, Memory.
Implementation consequence
A CLI surface is byte-addressable and smoke-testable from a temporary HOME, but terminal UI behavior still belongs to the host process. No visible host-native gap is currently tracked for this surface.

Verified Architecture

Source-checked on 2026-07-06. These notes are intentionally separate from the generated surface matrix below.

Sequence #9

Source pass

Current source review findings are kept as the first architecture section so readers can separate external evidence from the generated local coverage model.

  • OpenCode is treated as the canonical ts-plugin architecture for this project: a generated plugin bridge is the hook boundary instead of a spawned JSON-stdio command.
  • The source target is open and active, so fork-lineage hosts such as Kilo CLI and MiMoCode can be compared against OpenCode before claiming divergence.
  • Because the plugin bridge is a runtime integration, marketplace delivery is tracked separately from the hook paradigm.

Runtime boundary

OpenCode loads a generated TypeScript plugin bridge rather than spawning a JSON-stdio hook command. The host owns the TUI, server, model provider, tool permissions, and session loop; the bridge maps host plugin events back to the stable agent-connector home binary.

  • The public docs describe OpenCode as available through a terminal interface, desktop app, or IDE extension.
  • agent-connector keeps this adapter row scoped to the CLI/plugin file target so multi-surface product identity does not collapse the host-specific install path.

MCP registration

OpenCode config explicitly includes MCP servers in the schema. The adapter must render OpenCode's JSON/JSONC config shape and respect config precedence rather than reuse another host's MCP dialect.

  • OpenCode config sources include remote, global, custom, project, `.opencode` directories, inline, managed files, and macOS managed preferences.
  • Later config sources override earlier conflicts while preserving non-conflicting settings, so direct writes need to be scoped carefully.

Hook bridge

Plugins are OpenCode's hook boundary. Local JavaScript or TypeScript files under `.opencode/plugins/` or global config plugins can subscribe to events; npm plugins are configured separately and cached by the host.

  • Plugin modules export functions that receive project, client, shell, directory, and worktree context.
  • The plugin docs show event hooks such as tool execution interception, which maps naturally to a TypeScript bridge.
  • Plugin load order separates global config, project config, global plugins, and project plugins.

Content surfaces

OpenCode's `.opencode` and global config directories include plural subdirectories for agents, commands, plugins, skills, tools, themes, and modes. These are durable host-native content surfaces rather than ad hoc generated files.

  • Agent configuration supports role-specific prompt files, model choices, temperatures, and step limits.
  • OpenCode creates or reads AGENTS.md-style project memory during initialization.
  • Commands and skills should be documented as content surfaces separate from the plugin hook layer.

Marketplace and host-only affordances

OpenCode can load npm plugin packages and local plugin files, so marketplace delivery and direct generated-plugin writes are both relevant. The adapter should distinguish drivable package install from direct bridge generation.

  • npm plugins are installed automatically at startup and cached under the host cache directory.
  • The host also exposes sharing, web, IDE, GitHub, GitLab, permissions, LSP, and ACP support as product affordances outside the core connector surfaces.

Host-specific shape

OpenCode is the canonical ts-plugin host: the generated plugin bridge is the hook boundary and the same adapter owns MCP, commands, skills, subagents, and memory artifacts.

  • Form factor: CLI.
  • Native surfaces: MCP server, Hooks, Commands, Skills, Subagents, Memory.
  • Wired surfaces: MCP server, Hooks, Commands, Skills, Subagents, Memory.
  • Visible gaps: none.

Hooks

Hooks enter through a generated plugin module that the host loads in its own runtime.

MCP

The adapter writes this host's native MCP registration dialect, including its root key, scope, transport fields, and environment syntax.

Memory

Managed memory text is written into the rules or memory file this host actually reads, with ownership markers for reversible uninstall.

Marketplace and affordances

A marketplace or plugin-driver path is wired, so install/update/uninstall can be driven rather than only emitted as files.

  • Runtime handlers: none.
  • User-visible affordances: Users see managed commands + skills + subagents + memory surfaces after install; runtime-only surfaces stay behind the host boundary..

Known Limits

  • This adapter page is about the CLI/plugin integration target even though OpenCode also presents desktop and IDE surfaces.
  • Plugin event-level claims should track the current OpenCode plugin docs and adapter bridge tests.
  • Config precedence makes unmanaged overwrites risky; adapter expansion should remain non-clobbering.

Architecture Diagram

Host-specific flow for the CLI surface.

ts-plugin
Host-owned architecture flowHost surfaceCLIRuntimets-pluginNative artifactsMCP + hooks + content + memoryConnector boundaryplugin bridgeUser surfacecmds + skills + agents + memoryagent-connector writes only documented host artifacts; the host owns the agent loop.
  1. 1
    Entry point: CLI

    Terminal agent process reads user/project config and invokes the connector home binary for runtime callbacks.

  2. 2
    Connector package

    defineConnector package declares server, hooks, content, memory, and actions.

  3. 3
    Adapter module: opencode

    ts-plugin renderer at src/adapters/opencode/index.ts.

  4. 4
    Native host artifacts

    Adapter writes MCP config + plugin module + content files + memory/rules + marketplace bundle through this host's native file, package, or marketplace surface.

  5. 5
    Runtime boundary

    host loads generated TypeScript plugin bridge

  6. 6
    User-visible surface

    Users see managed commands + skills + subagents + memory surfaces after install; runtime-only surfaces stay behind the host boundary.

  7. 7
    Coverage ceiling

    6/6 native surfaces wired. No visible host-native gap in the current coverage matrix.

Component Diagram

Static parts of the OpenCode integration and which side owns each one.

Components and ownershipOpenCode hosthostagent-connector packageconnectoropencode adapterts-pluginNative artifactsartifactsRuntime bridgeruntimeUser-visible surfaceuser
  • OpenCode host

    CLI surface owns the model loop, UI shell, config discovery, and native lifecycle for this integration.

  • agent-connector package

    Normalizes connector declarations into MCP, hook, memory, content, and action payloads before delegating to a host adapter.

  • opencode adapter

    Implements the ts-plugin translation layer in src/adapters/opencode/index.ts.

  • Native artifacts

    Adapter writes MCP config + plugin module + content files + memory/rules + marketplace bundle through this host's native file, package, or marketplace surface.

  • Runtime bridge

    host loads generated TypeScript plugin bridge

  • User-visible surface

    Users see managed commands + skills + subagents + memory surfaces after install; runtime-only surfaces stay behind the host boundary.

Runtime Sequence Flow

Message order from install to runtime for the CLI surface.

User / projectagent-connectoropencode adapterOpenCodeAgent runtimeCoverage matrix1. Choose host adapter2. Resolve connector declaration3. Render host-native shape4. Host loads artifacts5. Run through host boundary6. Expose remaining ceiling
  1. 1 · User / project
    Choose host adapter

    Install or update starts against OpenCode; the selected surface is CLI.

  2. 2 · agent-connector
    Resolve connector declaration

    The package reads connector metadata and routes it to the opencode adapter instead of exposing a generic host contract.

  3. 3 · opencode adapter
    Render host-native shape

    Adapter writes MCP config + plugin module + content files + memory/rules + marketplace bundle through this host's native file, package, or marketplace surface.

  4. 4 · OpenCode
    Host loads artifacts

    host loads generated TypeScript plugin bridge

  5. 5 · Agent runtime
    Run through host boundary

    Users see managed commands + skills + subagents + memory surfaces after install; runtime-only surfaces stay behind the host boundary.

  6. 6 · Coverage matrix
    Expose remaining ceiling

    6/6 native surfaces wired. No visible host-native gap in the current coverage matrix.

Architecture Archive

The same five study axes are rendered for every host: runtime shape, hooks, MCP, memory, and host-only affordances.

Host-specific shape

OpenCode is the canonical ts-plugin host: the generated plugin bridge is the hook boundary and the same adapter owns MCP, commands, skills, subagents, and memory artifacts.

  • Form factor: CLI.
  • Native surfaces: MCP server, Hooks, Commands, Skills, Subagents, Memory.
  • Wired surfaces: MCP server, Hooks, Commands, Skills, Subagents, Memory.
  • Visible gaps: none.

Hooks

Hooks enter through a generated plugin module that the host loads in its own runtime.

MCP

The adapter writes this host's native MCP registration dialect, including its root key, scope, transport fields, and environment syntax.

Memory

Managed memory text is written into the rules or memory file this host actually reads, with ownership markers for reversible uninstall.

Marketplace and affordances

A marketplace or plugin-driver path is wired, so install/update/uninstall can be driven rather than only emitted as files.

  • Runtime handlers: none.
  • User-visible affordances: Users see managed commands + skills + subagents + memory surfaces after install; runtime-only surfaces stay behind the host boundary..

Special Feature Inventory

Host-specific capabilities separated from the generic surface matrix: lifecycle hooks, MCP registration, memory/rules, marketplace delivery, and UI or content affordances owned by the host.

Lifecycle hooks

Wired

Hooks enter through a generated plugin module that the host loads in its own runtime.

MCP registration

Wired

The adapter writes this host's native MCP registration dialect, including its root key, scope, transport fields, and environment syntax.

Memory and rules

Wired

Managed memory text is written into the rules or memory file this host actually reads, with ownership markers for reversible uninstall.

Marketplace delivery

Driver wired

A marketplace or plugin-driver path is wired, so install/update/uninstall can be driven rather than only emitted as files.

Host-only affordances

3/3 wired

Wired host affordances: Commands, Skills, Subagents. Host-native gaps: none. Not confirmed: Statusline handler, Action affordances.

Source Review Notes

Latest source pass for host-specific architecture details. This is separate from generated adapter coverage and local drift guards.

Checked 2026-07-06Open review source
anomalyco/opencode repository
  • OpenCode is treated as the canonical ts-plugin architecture for this project: a generated plugin bridge is the hook boundary instead of a spawned JSON-stdio command.
  • The source target is open and active, so fork-lineage hosts such as Kilo CLI and MiMoCode can be compared against OpenCode before claiming divergence.
  • Because the plugin bridge is a runtime integration, marketplace delivery is tracked separately from the hook paradigm.

Evidence Map

Each host page ties public source evidence to the local adapter and drift guards that keep the rendered archive aligned with code.

Public source: anomalyco/opencode

Primary public repository or product source used for current host status and source links.

external
Open source

Local adapter implementation

Defines the install/uninstall behavior, native config rendering, capability flags, and any runtime parse/format bridge for this host.

local
src/adapters/opencode/index.ts

Platform metadata and host-native matrix

Records the form factor, public source target, ranking source, native host surfaces, and current agent-connector coverage cells.

local
site/src/platform-data.ts

Architecture drift guard

Asserts that every registered host has a page, diagram, host-specific brief, source link, form-factor band, and adapter-aligned surface data.

local
tests/docs/platform-drift.test.ts

Marketplace driver registry

Shows this host has a drivable package/plugin install path beyond direct native-file writes.

local
src/core/marketplace-drivers/registry.ts

Runtime Shape

The host loads a generated TypeScript plugin module that bridges in-process host events to the connector runtime.

MCP registration
Wired through this adapter
Hook bridge
Wired

Connector Surfaces

Static content

MCP server, Hooks, Commands, Skills, Subagents, Memory

Runtime handlers

No runtime handler surfaces wired

Surface Matrix

Wired means agent-connector installs it now. Host native marks support we know about but have not wired yet.

SurfaceStatus
MCP server
Static content
agent-connector installs this surface today.
Wired
Hooks
Static content
agent-connector installs this surface today.
Wired
Commands
Static content
agent-connector installs this surface today.
Wired
Skills
Static content
agent-connector installs this surface today.
Wired
Subagents
Static content
agent-connector installs this surface today.
Wired
Memory
Static content
agent-connector installs this surface today.
Wired
Statusline handler
Runtime handler
No confirmed host-native surface.
N/A
Action affordances
Runtime handler
No confirmed host-native surface.
N/A