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.
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
.opencode/package.json so OpenCode resolves them on startup:
.opencode/package.json
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’sexecute 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
examples/typescript/agents/opencode/ram_opencode.ts, an end-to-end runner that spawns OpenCode via@opencode-ai/sdk, loads a RAM-backed plugin that pre-writes/hello.txt, and asksgpt-5.4-minitocatit.