opencode

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package opencode reads the project-scoped OpenCode V2 model catalog. It also releases verified disposable checkout locations.

Index

Constants

View Source
const (
	Executable           = "opencode2"
	RuntimeVersionPrefix = Executable + " v0.0.0-beta-"
	MinimumBetaBuild     = 18314
	MinimumVersion       = RuntimeVersionPrefix + "18314"
	StableFloor          = "2.0.0"
	VerifiedStable       = "2.2.6"
)

Variables

This section is empty.

Functions

func ReleaseLocation added in v0.17.0

func ReleaseLocation(ctx context.Context, runner execx.Runner, primary, target string) error

ReleaseLocation retains the single-checkout handoff for review replacement.

func SessionDirectory added in v0.17.0

func SessionDirectory(ctx context.Context, runner execx.Runner, cwd, sessionID string) (string, error)

SessionDirectory observes the invoking local OpenCode service's session location. sessionID is only a lookup key. Never start/discover a replacement service, query a caller-selected endpoint, request a directory, or use an outer response location (which can just reflect the server's defaults).

Types

type Catalog

type Catalog struct {
	Models  []Model
	Warning string
}

Catalog is the currently enabled, agent-capable model catalog for one repository.

func ReadCatalog

func ReadCatalog(ctx context.Context, runner execx.Runner, directory string) (Catalog, error)

ReadCatalog returns enabled models that accept text, emit text, and support tools. It verifies that OpenCode answered for directory and never includes raw command output in an error.

type LoadedSkill added in v0.10.0

type LoadedSkill struct {
	ID      string
	Content string
}

LoadedSkill is the safe subset of one live OpenCode skill. Its source location is deliberately not retained: compatibility depends on content, not where OpenCode loaded it from.

type Model

type Model struct {
	ID       string
	Variants []string
}

Model is the safe subset of an available OpenCode model. Provider settings, headers, credentials, account identifiers, and request bodies are never retained.

type ReleaseCheck added in v0.17.1

type ReleaseCheck func(ctx context.Context, removed string) error

ReleaseCheck rechecks observable activity before Git mutation after release. If removed is nonempty, the caller has already verified deletion of that checkout. Only remaining targets need delete access and cwd attribution. Bound merged cleanup also requests the non-loading global job probe.

func ReleaseLocations added in v0.17.0

func ReleaseLocations(ctx context.Context, runner execx.Runner, primary string, verify func(context.Context) error, checkJobs bool, targets ...string) (ReleaseCheck, error)

ReleaseLocations is called only after the run engine verifies disposable checkout ownership and removal prerequisites. These bounded observations are NOT atomic exclusion of host re-entry. No idle/completion hook calls this. All commands use the existing authenticated V2 CLI discovery, never a relay, service restart, session deletion or process termination. On Windows the runner must support concurrent persistent-terminal reads. Before #525 sequential handoffs could reload an earlier target through later session/terminal probes. Now probes that could load a target precede eviction. Bound cleanup supplies verify to recheck engine ownership before disposal and to keep retry advice on the bound path. Cleanup can use the returned check at later Git boundaries, under the same deadline. checkJobs also needs a late check on a ref-only retry, where there is no checkout to release or scan. Review replacement needs only this release.

type Runtime added in v0.16.0

type Runtime struct {
	Executable string
	Warning    string
}

Runtime binds all API reads/release calls to the V2 command whose version was checked. On Windows Local resolves a verified absolute native path first.

func Resolve added in v0.16.0

func Resolve(ctx context.Context, runner execx.Runner, directory string) (Runtime, error)

Resolve prefers opencode2, but also supports V2 installed as opencode. Raw process output is never included in errors because it may contain credentials.

func (Runtime) CheckPlugin added in v0.16.0

func (runtime Runtime) CheckPlugin(ctx context.Context, runner execx.Runner, directory, id string) error

CheckPlugin requires a live server component in the intended project scope.

func (Runtime) ReadCatalog added in v0.16.0

func (runtime Runtime) ReadCatalog(ctx context.Context, runner execx.Runner, directory string) (Catalog, error)

func (Runtime) ReadSkillCatalog added in v0.16.0

func (runtime Runtime) ReadSkillCatalog(ctx context.Context, runner execx.Runner, directory string) (SkillCatalog, error)

type SelectionCheck

type SelectionCheck struct {
	Role string
	Err  error
}

SelectionCheck reports whether one configured OpenCode role is present in the project-scoped live catalog.

func CheckSelections

func CheckSelections(roles config.Roles, catalog Catalog) []SelectionCheck

CheckSelections checks all six configured roles in configuration order. It never includes other catalog entries in diagnostics.

type SkillCatalog added in v0.10.0

type SkillCatalog struct {
	Skills []LoadedSkill
}

SkillCatalog is OpenCode's winning live skill set for one repository.

func ReadSkillCatalog added in v0.10.0

func ReadSkillCatalog(ctx context.Context, runner execx.Runner, directory string) (SkillCatalog, error)

ReadSkillCatalog returns the repository-scoped live OpenCode skill catalog. It verifies that OpenCode answered for directory and never includes command output or loaded skill content in an error.

Jump to

Keyboard shortcuts

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