Skip to main content
OpenCode is an open-source coding agent that runs in your terminal, IDE, or desktop. Its plugin API lets you register tools that take precedence over the built-ins by name, so a Mirage plugin can swap OpenCode’s read, write, edit, ls, bash, glob, and grep to operate on a Workspace instead of the local disk. Once installed, anything OpenCode reads or writes flows through Mirage and reaches every mounted resource (S3, GCS, Postgres, Linear, Slack, …) as files.

Install

@struktoai/mirage-agents/opencode is a tool factory plus a thin plugin shim. Pair it with @struktoai/mirage-node for any Node or Bun project.
OpenCode runs bun install on startup against .opencode/package.json, so this works whether you use bun, pnpm, or npm in the host project.

Usage

Drop a plugin file into .opencode/plugins/ (project-local) or ~/.config/opencode/plugins/ (global). OpenCode auto-discovers it and merges the returned tool dict over its built-ins.
.opencode/plugins/mirage.ts
Add the dependencies to .opencode/package.json so OpenCode resolves them on startup:
.opencode/package.json
Then run opencode in that directory. The agent’s read /hello.txt, bash 'find /', grep foo /, etc. now all flow through the Mirage workspace.

Exports

Tool reference

Each tool’s execute returns a plain string (matching the OpenCode plugin contract). bash, glob, and grep go through ws.execute(), so they pick up every Mirage shell builtin (resource-aware head, tail, find, grep, etc.) across mounts.

Examples