containeropencodebx

package
v0.0.0-...-a77abd7 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package containeropencodebx implements the "opencode-sbx" subcommand, which generates a Docker Sandbox kit for opencode (spec.yaml + embedded global skills/agents/commands/plugins), validates it, packs it into a zip, and optionally creates the sandbox instance. Unlike the crush sbx kit, all tools are pre-baked into the base image; the kit is configuration-only and the opencode config is delivered via the OPENCODE_CONFIG_CONTENT env var.

Index

Constants

View Source
const (
	// DefaultOutputPath is the default path for the packed kit zip file.
	DefaultOutputPath = "opencode-sbx-kit.zip"

	// DefaultAgentImage is the default base image for the opencode sbx agent.
	// It extends docker/sandbox-templates:opencode with pre-baked Go tooling.
	DefaultAgentImage = "ghcr.io/dictybase/crusher:opencode-sbx-base"

	// DefaultGolangciLintVersion is the default golangci-lint version.
	// It is the only version flag retained because it is the sole value that
	// surfaces in the generated spec.yaml agentContext text. The gotestsum,
	// moxide, sem, and rtk version flags were removed because the packed kit
	// does not vary with them — the sandbox image ships fixed versions.
	DefaultGolangciLintVersion = "2.11.4"

	// DefaultProvider is the default AI provider.
	DefaultProvider = providerOpenRouter
)

Variables

This section is empty.

Functions

func Action

func Action(ctx context.Context, cmd *cli.Command) error

Action is the opencode-sbx subcommand entry point. Pipeline: normalize input → validate input → execute kit pipeline → fold into Pair. Printing is outside the pipeline.

func Command

func Command() *cli.Command

Command returns the CLI definition for the opencode-sbx subcommand.

func Execute

func Execute(input Input) IOE.IOEither[error, KitResult]

Execute runs the full pipeline: generate → validate → pack → optionally store secret + create.

func GenerateSpec

func GenerateSpec(input Input) IOE.IOEither[error, genState]

GenerateSpec renders the spec template from input. The ProviderConfig was already resolved during ValidateInput and is carried on input.ResolvedProvider, so the template data can be assembled inline.

func ValidateInput

func ValidateInput(input Input) E.Either[error, Input]

ValidateInput normalizes defaults, validates required fields and paths.

Types

type Input

type Input struct {
	OutputPath          string
	KitName             string
	APIKey              string
	Provider            string         // "openrouter" | "anthropic" | "openai" | "google"
	ResolvedProvider    ProviderConfig // set by validateProvider
	ShouldCreate        bool
	AgentImage          string
	GolangciLintVersion string
	Ctx                 context.Context
}

Input holds the raw CLI arguments before normalization or validation. The ResolvedProvider field is populated by validateProvider so downstream pipeline steps (spec generation) never need to re-lookup the provider.

func InputFromCommand

func InputFromCommand(ctx context.Context, cmd *cli.Command) Input

InputFromCommand reads CLI flags and constructs the opencode-sbx Input.

func NormalizeInput

func NormalizeInput(input Input) Input

NormalizeInput fills default values for blank fields.

type KitResult

type KitResult struct {
	OutputPath string
	KitName    string
	Created    bool
}

KitResult is the final output surfaced to the user.

type ProviderConfig

type ProviderConfig struct {
	ServiceDomain   string // exact hostname for network.serviceDomains
	ProviderDomain  string // same or broader, for network.allowedDomains
	AuthHeader      string // HTTP header name injected by the sbx proxy
	AuthValueFormat string // format string; %s is replaced with the credential
	APIKeyEnvVar    string // env var name on the host and inside the sandbox
}

ProviderConfig holds all template-rendering values for one AI provider.

Jump to

Keyboard shortcuts

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