Documentation
¶
Overview ¶
Package opencode implements adapters.HarnessAdapter for the opencode CLI.
Phase 3-c prototype: the goal is to validate that adapters.HarnessAdapter composes for a non-claude harness. Run() forks `opencode run` with signal forwarding and exit normalisation; session persistence, payload_patch.json writes and boid task notify integration are deliberately left out (see docs/plans/agent-aware-boid.md Phase 3-c).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct{}
Adapter implements adapters.HarnessAdapter for the opencode CLI.
func (*Adapter) Bindings ¶
Bindings declares the host bind-mounts opencode.Adapter.Run() needs inside the sandbox. opencode keeps state in four trees:
- ~/.opencode/ — package install + bin/ (rw, node_modules)
- ~/.config/opencode/ — opencode.jsonc config + node_modules (rw)
- ~/.local/share/opencode/ — auth.json, sqlite, repos snapshot (rw)
- ~/.local/state/opencode/ — model.json (selected model), kv.json (UI settings), frecency/prompt history (rw)
The state tree matters for parity with the host: opencode persists the most-recently-selected model in ~/.local/state/opencode/model.json and picks its default from that "recent" list at startup. Without this bind the sandbox opencode can't see it and falls back to a built-in default, so the model and UI settings the user chose on the host silently don't apply inside boid.
The resolved binary parent dir is added on top so a plain `opencode` on PATH (e.g. ~/.local/bin/opencode dropped by a packaged install) lands inside the sandbox under the same path the host sees.
Embedded skills are surfaced at ~/.claude/skills/<name> — opencode auto-detects skills under ~/.claude/ (same convention claude itself uses), so the bootstrap prompt can reference one canonical path across harnesses. See codex/bindings.go for the full rationale.
All entries are Optional so a missing source on the host is silently skipped; the dispatcher converts Optional → shell-level if-guard.
func (*Adapter) Run ¶
Run forks opencode. Interactive vs non-interactive is keyed off rc.TaskID: session jobs (JobKindSession) carry no task and are user-initiated, so they land in interactive TUI mode; hook jobs carry a BOID_TASK_ID and fall through to non-interactive `opencode run`. Mirrors the codex adapter and how the claude adapter discriminates JobKindSession from JobKindHook via rc.TaskID == "".
Other responsibilities mirror the claude / codex adapters: signal forwarding via sigutil, exit code normalisation for daemon-initiated stops, PWD strip on the child env, and cmd.Dir as the source of truth for the workdir.
Session persistence and payload_patch.json writes are deliberately NOT wired here — see docs/plans/multi-harness-production.md for the explicit non-goals (interactive sessions are run-and-done, no resume yet).