opencode-rexd-target is an OpenCode plugin that makes selected remote machines feel like local development.
It routes tool calls to REXD, the Remote Execution Daemon, over SSH stdio (ssh ... rexd --stdio).
REXD is a lightweight remote execution daemon that exposes process, filesystem, and PTY operations through a JSON-RPC API.
This plugin acts as the OpenCode client layer for REXD targets:
- On active target: tool calls are routed to remote
rexd - Without active target: file/shell tools run locally (normal OpenCode behavior)
- PTY tools are currently remote-only and require an active target
/targetcommand handling:list,use,status,clear- Transparent tool routing to remote REXD when a target is active
- Local fallback when no target is active
- Core remote filesystem and shell support:
bash,read,write,list,glob,grep - Remote file parity with native REXD methods:
edit,apply_patch - PTY support via dedicated remote tools:
pty_spawn,pty_write,pty_read,pty_list,pty_kill
- OpenCode with plugin support
- REXD installed on target hosts and reachable over SSH
- Target registry at
~/.config/rexd/targets.json - REXD version with
fs.editandfs.patchsupport (v0.1.3+). ForloginShellcompatibility mode, use v0.1.4+.
Latest release:
curl -fsSL https://raw.githubusercontent.com/samiralibabic/opencode-rexd-target/main/scripts/install.sh | bashPinned version:
curl -fsSL https://raw.githubusercontent.com/samiralibabic/opencode-rexd-target/main/scripts/install.sh | OPENCODE_REXD_TARGET_VERSION=v0.3.1 bashThe installer places files in your OpenCode config directory:
~/.config/opencode/plugins/rexd-target.js~/.config/opencode/commands/target.md
- Ensure every target host runs REXD
v0.1.4or newer. - Create/update
~/.config/rexd/targets.jsonon your local machine. - Restart OpenCode so the plugin is reloaded.
- Run
/target listand then/target use <alias>.
Example ~/.config/rexd/targets.json:
{
"version": 1,
"targets": {
"prod": {
"transport": "ssh",
"host": "example.com",
"user": "deploy",
"loginShell": false,
"workspaceRoots": ["/srv/app"],
"defaultCwd": "/srv/app"
}
}
}loginShell is optional and defaults to false.
false(default): predictable non-login shell execution for automation.true: compatibility mode for legacy targets that require login-shell startup files.
In OpenCode:
/target list/target use <alias>/target status/target clear
Active target state is persisted per chat session under ~/.config/opencode/rexd-target/sessions/ and refreshed during normal remote use, so active chats are not pruned as stale.
Update in this order:
- Update
rexdon remote target hosts. - Update this plugin locally.
- Restart OpenCode.
- Reconnect in each chat with
/target use <alias>.
Update commands:
# 1) remote hosts
curl -fsSL https://raw.githubusercontent.com/samiralibabic/rexd/main/scripts/install.sh | REXD_VERSION=v0.1.4 bash
# 2) local plugin
curl -fsSL https://raw.githubusercontent.com/samiralibabic/opencode-rexd-target/main/scripts/install.sh | OPENCODE_REXD_TARGET_VERSION=v0.3.1 bashIf you update the plugin before rexd, remote edit/apply_patch calls can fail with method-not-found errors on older servers.
If your repo still has an old .opencode/rexd-state.json from previous versions, it can be removed.
Note: this plugin now preserves OpenCode UI metadata for edit and apply_patch so TUI diff rendering works the same way as native tools.
As of v0.2.5, plugin bash results also mirror output into metadata.output so OpenCode's Bash tool panel reliably shows command body output.
- Bash tool shows header but no body output:
- Update to
v0.2.5or newer. - Restart OpenCode after installing.
- If needed, clear/reselect target with
/target clearthen/target use <alias>.
- Update to
make typecheck
make build- License:
LICENSE - Contributing:
CONTRIBUTING.md - Code of conduct:
CODE_OF_CONDUCT.md - Security policy:
SECURITY.md
