opencode

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 39 Imported by: 0

Documentation

Overview

Package opencode implements provider.Spawner for sst's opencode.

One process per turn (SendRespawnQueue):

XDG_DATA_HOME=<instance dir> OPENCODE_CONFIG_CONTENT=<json> \
opencode run --format json --thinking --auto [-s <sid>] [-m <model>] <prompt on stdin>

Flags are checked against packages/opencode/src/cli/cmd/run.ts (commit 7945de2): positional message / piped stdin, -s/--session, -m/--model, --format json, --thinking (without it reasoning parts are not emitted), --auto. OPENCODE_CONFIG_CONTENT is merged as the "local" layer (src/config/config.ts) and carries: permission allow-all, wick's MCP server (type remote, {env:...} substitution so the token stays in env) and the wick system prompt as an extra `instructions` file, which leaves the project's AGENTS.md untouched.

Account isolation: opencode has no data-dir env of its own; it resolves $XDG_DATA_HOME/opencode (packages/core/src/global.ts) and keeps auth.json there, so each instance runs with its own XDG_DATA_HOME (provider.OpencodeEnv).

Gate/hook capability is OFF (opencode plugins are JS, not a command hook).

Index

Constants

View Source
const (
	// DefaultServerIdle is the idle window when the instance sets none.
	DefaultServerIdle = cliserver.DefaultIdle
	// DefaultServerTurns caps turns running at once on one server; the
	// rest queue. Two keeps a server under ~800 MB on the 3.6 GB host.
	DefaultServerTurns = 2
)

Variables

View Source
var ErrNoModel = errors.New("no model")

ErrNoModel is returned when a spawn has no model to pass.

Functions

func ShutdownServers

func ShutdownServers()

ShutdownServers kills every opencode server. Called on wick shutdown so no server outlives the process that supervises it.

Types

type Spawner

type Spawner struct {
	Binary    string // empty → "opencode"
	ExtraArgs []string
	// MCPToken is the per-session credential for wick's MCP server.
	MCPToken string
}

Spawner spawns `opencode run --format json`, one process per turn.

func (Spawner) Spawn

Spawn starts one opencode run with opt.InitialMessage as the prompt.

Jump to

Keyboard shortcuts

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