opencode

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 8 Imported by: 0

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 application 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 New

func New() *Adapter

New returns a new Adapter.

func (*Adapter) Bindings

func (a *Adapter) Bindings(homeDir string) []adapters.BindMount

Bindings declares the host bind-mounts opencode.Adapter.Run() needs inside the sandbox.

Phase 4 PR3 (docs/plans/home-workspace-volume.md) retires every entry this method used to return: the rw ~/.opencode / ~/.config/opencode / ~/.local/share/opencode / ~/.local/state/opencode state trees, the resolved `opencode` binary's parent dir (PATH), the per-embedded-skill ~/.local/share/boid/skills/<name> -> ~/.claude/skills/<name> binds, and the individual ro binds for each non-embedded host skill under ~/.claude/skills/* (bitbucket, jira, google-*, ms-graph, ...). All of that state now lives directly in the sandbox's $HOME, which Runner.Dispatch (internal/dispatcher/workspace_home.go) bind-mounts from a persistent per-workspace home directory instead of a fresh tmpfs — so ~/.opencode, ~/.config/opencode etc. simply already exist at those paths without any adapter-declared bind. The opencode CLI binary itself is expected to be installed into that same workspace home by the workspace's init.sh (see the plan doc's init.sh 契約 section); a missing binary now fails fast with an explicit message from Run() (run.go) instead of silently falling back to a bind that no longer exists.

Embedded skills DO reach the sandbox's $HOME, but by no mount at all, and the dispatcher owns that too. They are baked into the runner image (build/container/Dockerfile, internal/dispatcher's embeddedSkillsImageDir) and symlinked into each of skillDiscoveryRoots by the workspace-home init container's prelude. Two earlier mechanisms sat here: Phase 4 PR3 copied the content into the workspace home (skills.DeployAll straight into <home>/.claude/skills), which had to go once the home became a named volume the daemon cannot write to; PR3 of docs/plans/workspace-home-volume-persistence.md (論点 e-2) then replaced that with one read-only bind per skill, sourced from a host-visible directory the daemon re-materialized on every dispatch.

Keeping skill delivery dispatcher-side rather than restoring it here is what keeps this method nil: how skills reach a home is a property of how boid stages a sandbox, identical for every harness, not of what the opencode CLI needs. Which directories a harness then SCANS is the harness's own business, and the three do not agree — see skillDiscoveryRoots for the table and why a link is written into more than one place.

Non-embedded host skills (bitbucket, jira, google-* etc.) still have no adapter-side exposure path at all: a workspace that wants opencode to see them is the workspace author's responsibility, via the workspace's init.sh copying them into the workspace home (e.g. `cp -r ~/.claude/skills/<name> "$BOID_WORKSPACE_HOME/.claude/skills/"`) — see the plan doc's dogfood checklist. That arrangement is exactly why PR3's binds were per skill rather than one bind of the whole ~/.claude/skills directory: a directory-wide bind would have hidden every skill copied in this way. The constraint outlived the binds and is now satisfied for free — a symlink at <root>/<name> shadows nothing else in <root>, so a hand-copied skill sitting beside it stays visible without anyone having to arrange for it.

The HarnessAdapter interface still requires this method; returning an empty slice keeps the contract satisfied for any future $HOME-independent bind a harness might need.

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 application 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).

func (*Adapter) Usage

func (a *Adapter) Usage(_ context.Context, _ string) (adapters.Usage, error)

Usage is not implemented in Phase 3-c (see codex/opencode.go for the same rationale).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL