> ## Documentation Index
> Fetch the complete documentation index at: https://eispatch.framewire.io/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode (experimental)

> Experimental EISPATCH v1.1.0 support for OpenCode: install the plugin, intercept prompts with chat.message, and dispatch to the session or the clipboard.

> [!WARNING]
>
> **Experimental.** OpenCode support in v1.1.0 is verified through real CLI discovery, the portable installer, and an `@opencode-ai/plugin` adapter harness. Native end-to-end verification inside a live OpenCode session is pending. Expect rough edges and report issues on [GitHub](https://github.com/FrameScope/eispatch/issues).

OpenCode integrates with EISPATCH through a plugin (`adapters/opencode/plugin.mjs`). The plugin intercepts trigger prompts, starts a Local Composer, and tries to deliver the approved prompt back into the same OpenCode session.

## Tested version

The README lists `opencode v2.3.0` for the adapter-harness verification.

## Installation

```bash theme={null}
node scripts/install-opencode.mjs
```

The installer writes:

* `~/.config/opencode/plugins/eispatch.mjs`
* `~/.config/opencode/skills/eispatch/SKILL.md`

> [!WARNING]
>
> Keep the cloned repository in place after installing. The installed plugin references absolute paths inside it.

## Plugin hooks

| Hook | Behavior |
| - | - |
| `chat.message` | Checks the user message. If it contains `<!-- DISPATCH_COMPILED_PROMPT`, it passes through. If it matches a trigger prefix (or `EISPATCH_AUTO_INTERCEPT=1` is set), the plugin closes any previous composer server, starts a new Local Composer, and replaces the message parts with a notice containing the composer URL. |
| `experimental.chat.system.transform` | While a composer is active, adds a system note telling the model that the EISPATCH composer is open at the given URL and that it should wait for explicit user approval. This is guidance to the model, not an enforcement mechanism. |

Because the original message parts are replaced with the notice, the model does not receive your unreviewed prompt in that turn.

## Dispatch

After you click **Approve** and **Dispatch** in the composer, the plugin tries these paths in order:

| Order | Method | Result `mode` |
| - | - | - |
| 1 | `client.session.prompt()` on the current session | `opencode-session-prompt` |
| 2 | HTTP `POST <server>/session/<id>/message`, using the plugin's server URL or `OPENCODE_SERVER_URL` | `opencode-http-session` |
| 3 | Neither available | `clipboard-fallback`: paste the approved prompt into OpenCode |

Approval tokens, SHA-256 prompt hashes, and 401/403/409 responses apply because OpenCode uses the [Local Composer](https://eispatch.framewire.io/reference/local-composer-api.md).

## Server lifetime

The OpenCode plugin starts the Local Composer without an idle timeout. The server is closed when the plugin intercepts the next trigger prompt.

## Environment variables

| Variable | Effect |
| - | - |
| `EISPATCH_AUTO_INTERCEPT=1` | Intercept every OpenCode message, even without a trigger prefix. |
| `OPENCODE_SERVER_URL` | Base URL used for HTTP session dispatch when the plugin has no server URL. |

`EISPATCH_NO_SPAWN` is not implemented by the OpenCode plugin.

## Check and uninstall

```bash theme={null}
node scripts/install-opencode.mjs --check
node scripts/install-opencode.mjs --uninstall
```

Uninstall removes only EISPATCH-owned entries.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.