opencode

package
v0.0.0-...-4f7fa88 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package opencode is the client adapter for OpenCode.

Index

Constants

View Source
const (
	OpenCodeProjectionFile  = ".agentplugins-opencode.json"
	OpenCodeMCPObjectKind   = nativeconfig.OpenCodeMCPObjectKind
	OpenCodeV2MCPObjectKind = nativeconfig.OpenCodeV2MCPObjectKind
)

Variables

This section is empty.

Functions

func ActivateOpenCodeNativeWithKernel

func ActivateOpenCodeNativeWithKernel(ctx context.Context, request domain.ActivationRequest, kernel nativeconfig.Kernel) error

func ApplyOpenCodeNative

func ApplyOpenCodeNative(configRoot, activePath string, previous, desired []domain.NativeObjectOwnership) error

func ApplyOpenCodeNativeWithOps

func ApplyOpenCodeNativeWithOps(configRoot, activePath string, previous, desired []domain.NativeObjectOwnership, rename openCodeRenameFunc, removeAll func(string) error) (resultErr error)

func ApplyOpenCodeNativeWithRename

func ApplyOpenCodeNativeWithRename(configRoot, activePath string, previous, desired []domain.NativeObjectOwnership, rename openCodeRenameFunc) (resultErr error)

func BuildOpenCodeNativeObjects

func BuildOpenCodeNativeObjects(stagingRoot string, envelope domain.PackageEnvelope, plan domain.DeliveryPlan) ([]domain.NativeObjectOwnership, error)

func DeactivateOpenCodeNativeWithKernel

func DeactivateOpenCodeNativeWithKernel(ctx context.Context, request domain.DeactivationRequest, kernel nativeconfig.Kernel) error

func DesiredOpenCodeCodec

func DesiredOpenCodeCodec(host domain.OpenCodeHostAuthority) (nativeconfig.Codec, error)

DesiredOpenCodeCodec reads only the immutable prepared profile. Missing or unknown authority never selects a default dialect for desired effects.

func InspectOpenCodeRegistry

func InspectOpenCodeRegistry(plan domain.DeliveryPlan, managed *domain.ClientBinding, kernel nativeconfig.Kernel) (clients.RegistryFinding, error)

func NeutralOpenCodeServer

func NeutralOpenCodeServer(server domain.MCPServer) (nativeconfig.Server, error)

func ProjectOpenCodeNative

func ProjectOpenCodeNative(root string, envelope domain.PackageEnvelope, plan domain.DeliveryPlan, dataRoot string) error

func VerifyOpenCodeNativeObjects

func VerifyOpenCodeNativeObjects(configRoot, activePath string, objects []domain.NativeObjectOwnership, kernel nativeconfig.Kernel, allowMissing bool) error

Types

type Adapter

type Adapter struct{}

Adapter implements the client contract for OpenCode.

func New

func New() *Adapter

New builds the adapter. The composition root registers it in clients/all.

func (*Adapter) Activate

Activate installs or verifies managed OpenCode skills and MCP servers through the native config kernel.

func (*Adapter) AutomaticallyActivates

func (*Adapter) AutomaticallyActivates(_ clients.Env, request domain.ActivationRequest) bool

AutomaticallyActivates reports that Activate will write managed OpenCode native objects for this exact request.

func (*Adapter) Deactivate

Deactivate removes managed OpenCode native objects.

func (*Adapter) DetectSurfaces

func (*Adapter) DetectSurfaces(host clients.Host) clients.Detection

DetectSurfaces probes the OpenCode CLI, its XDG configuration directory and the desktop application.

func (*Adapter) ID

func (*Adapter) ID() domain.ClientID

ID reports the client this adapter serves.

func (*Adapter) InspectNativeRegistry

func (*Adapter) InspectNativeRegistry(ctx context.Context, env clients.Env, _ domain.DetectedClient, plan domain.DeliveryPlan, managed *domain.ClientBinding) (clients.RegistryFinding, error)

func (*Adapter) OwnedOpenCodeNativeRequirements

func (*Adapter) OwnedOpenCodeNativeRequirements(objects []domain.NativeObjectOwnership) (skills, config bool)

Prior MCP receipts also require the config codec when the desired set is empty. Directory skill removal does not use that codec.

func (*Adapter) Project

Project writes OpenCode's native projection and records the objects it owns.

func (*Adapter) ProjectActiveNative

func (*Adapter) ProjectActiveNative(_ context.Context, root string, envelope domain.PackageEnvelope, plan domain.DeliveryPlan, _ string) ([]domain.NativeObjectOwnership, error)

func (*Adapter) RefinePlan

func (*Adapter) RefinePlan(_ context.Context, in clients.PlanInput, plan *domain.DeliveryPlan) error

func (*Adapter) UsesNativeRegistryExecutable

func (*Adapter) UsesNativeRegistryExecutable() bool

func (*Adapter) UsesOpenCodeHostProfile

func (*Adapter) UsesOpenCodeHostProfile() bool

UsesOpenCodeHostProfile opts native mutations into explicit runtime authority.

func (*Adapter) VerifierAvailable

func (*Adapter) VerifierAvailable(_ domain.DetectedClient, plan domain.DeliveryPlan, _ string) bool

VerifierAvailable reports that an exact native configuration listing can be observed. It does not need a client executable.

type NativeTransitions

type NativeTransitions struct {
	PackageVerifier interface {
		Verify(context.Context, string, string) error
	}
	State  ports.NativeTransitionState
	Kernel nativeconfig.Kernel
}

NativeTransitions consumes only stored roots and receipt/state authority. It never resolves a host and never acquires the outer operation lock itself.

func (NativeTransitions) HoldsActivation

func (t NativeTransitions) HoldsActivation(installationID, bindingID string) (bool, error)

func (NativeTransitions) Pending

func (NativeTransitions) PersistPrepared

func (NativeTransitions) Reconcile

func (NativeTransitions) Recover

func (t NativeTransitions) Recover(ctx context.Context) error

type OpenCodeProjection

type OpenCodeProjection struct {
	ResolvedCWD map[string]bool                `json:"resolved_cwd,omitempty"`
	Dialect     opencodehost.Dialect           `json:"dialect,omitempty"`
	Version     int                            `json:"version"`
	ConfigPath  string                         `json:"config_path"`
	ConfigJSON  string                         `json:"config_json"`
	ConfigJSONC string                         `json:"config_jsonc"`
	PackageRoot string                         `json:"package_root"`
	DataRoot    string                         `json:"data_root,omitempty"`
	MCPServers  map[string]nativeconfig.Server `json:"mcp_servers,omitempty"`
}

func ReadOpenCodeProjection

func ReadOpenCodeProjection(root string) (OpenCodeProjection, error)

type PendingNativeTransition

type PendingNativeTransition struct {
	OperationID, InstallationID, BindingID, TargetPath, Phase, Digest, Root string
	// AuthorityDigest remains stable through the recorder's phase advances.
	AuthorityDigest string
}

Jump to

Keyboard shortcuts

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