opencode

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 10 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.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 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. opencode keeps state in three 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)

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

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