OpenCode V2 plugin: /ssh, /disconnect_ssh, /list_ssh + @server targeted
remote execution.
npm run typecheck—tsc --noEmit, coverssrc + testsnpm run build—tsc -p tsconfig.build.json, emitsdist/fromsrconlynpm test—vitest run tests(mention parsing, namespace table, quoting, command building)- Focused:
npx vitest run tests/core.test.ts -t "<test name>" npm run dev—tsc --watch -p tsconfig.build.json- Order:
typecheck→testbeforebuild. No CI config in repo. - Format (mdformat CLI, no config):
mdformat --wrap 80 --check README.md AGENTS.md, write withmdformat --wrap 80 README.md AGENTS.md. Keep prose lines ≤80 chars.
src/index.ts— plugin entrypoint: commands,ssh_exectool,tool.hook("execute.before"),session.hook("context")hint, reference sync, cleanup. All side effects (ssh spawn, fs, sockets) live here.src/core.ts— pure logic, fully unit-tested:extractMentions,stripTargetMentions,decide,buildRemoteCommand,namespaceOf,socketPathFor/refPathFor,isHostInSshConfig.tests/core.test.ts— unit tests forcore.tsonly;index.tsrequires live OpenCode server (see README "Manual verification").
- Plugin paths must be directories:
"plugins": ["/path/.../dist"]. File paths are rejected by OpenCode. - Never load two copies at once: global + project configs in the same server =
separate in-memory registries. This repo's
opencode.jsoncintentionally keeps"plugins": []to avoid double-load during dev. dist/is gitignored but required at runtime;buildemitsdist/index.js+dist/core.js.- Tool hook must match both
bash(historic) andshell(current) tool ids. If mentions stop rewriting after upgrade, check id first. - Namespace isolation: key =
workspaceID ?? directory.decide()fails (server X is not connected, thrown verbatim to model) on cross-namespace mention — never silently runs local. Unknown mention = local passthrough by design. @serverreferences are location-global union across namespaces, so completion may suggest a server the current workspace can't use (fails per above by design). Descriptors live in~/.ssh/opencode-refs/, sockets~/.ssh/opencode_<nsHash>_<server>.- TUI caches reference list per process: new
@servercompletions need full TUI restart, but routing works immediately. Upstream:ctx.reference.reload()never invalidates the client — anomalyco/opencode#53954 (open,reproduced). If that issue closes fixed, retest and drop the restart note. - SSH needs passphrase-less auth (
ssh-agent/keychain); connections use ControlMaster (-MNf/-O check/-O stop).