Install
Create amirage.yaml in your project:
mirage.yaml
opencode.json:
opencode.json
opencode normally. Mirage searches the project and parent directories for mirage.yaml, workspace.yaml, .mirage/workspace.yaml, and their .yml variants.
To select another config or disable stale-write protection, pass plugin options:
opencode.json
MIRAGE_OPENCODE_CONFIG or MIRAGE_CONFIG to the workspace config path.
Stale writes
Stale-write protection is enabled by default and isolated per OpenCode session.read records a content fingerprint; write and edit verify it immediately before changing the file. If the file changed, OpenCode must reread it before retrying.
bash commands are not tracked because they can read or mutate arbitrary paths. Use the structured read, write, and edit tools when stale-write protection is required.
Custom plugin
Use@struktoai/mirage-agents/opencode directly when the workspace is constructed in code rather than YAML:
.opencode/plugins/mirage.ts:
.opencode/plugins/mirage.ts
.opencode/package.json:
.opencode/package.json
Exports
Tool reference
Tools return text except PDF and image reads, which return OpenCode attachments.bash, glob, and grep run through the Mirage shell across all 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.