adapters

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectCommandKeys

func CollectCommandKeys(doc JSONDocument) []string

CollectCommandKeys returns command strings from native entries for diagnostics.

func DecodeServerDefinitionEntry added in v0.4.0

func DecodeServerDefinitionEntry(entry map[string]json.RawMessage) (store.Server, error)

DecodeServerDefinitionEntry extracts a store.Server definition from one native server entry.

func ManagedDiff added in v0.4.0

func ManagedDiff(current planner.ClientState, desired planner.ClientState) planner.Plan

ManagedDiff compares desired state against the managed subset of current state.

func ReadStateFromMCPServers

func ReadStateFromMCPServers(doc JSONDocument, client string) (planner.ClientState, error)

ReadStateFromMCPServers decodes state from a top-level mcpServers key.

func ReadStateFromServerMap added in v0.3.0

func ReadStateFromServerMap(doc JSONDocument, topLevelKey string, client string) (planner.ClientState, error)

ReadStateFromServerMap decodes state from a top-level server object key.

func WriteStateToMCPServers

func WriteStateToMCPServers(path string, doc JSONDocument, desired planner.ClientState) error

WriteStateToMCPServers updates mcpServers while preserving unknown top-level keys.

func WriteStateToServerMap added in v0.3.0

func WriteStateToServerMap(path string, doc JSONDocument, topLevelKey string, desired planner.ClientState) error

WriteStateToServerMap updates a top-level server object while preserving unknown top-level keys.

Types

type Adapter

type Adapter interface {
	Name() string
	Detect(workspace string) (string, error)
	Read(path string) (planner.ClientState, error)
	Apply(current planner.ClientState, desired planner.ClientState) (planner.Plan, error)
	Write(path string, desired planner.ClientState) error
	Validate(path string) error
}

Adapter is the contract every client adapter must implement.

type HarnessResult

type HarnessResult struct {
	Before planner.ClientState
	Plan   planner.Plan
	After  planner.ClientState
}

HarnessResult captures before/after planning and write behavior for adapter tests.

func RunHarness

func RunHarness(adapter Adapter, path string, desired planner.ClientState, dryRun bool) (HarnessResult, error)

RunHarness executes read->apply->(optional write)->validate for adapter tests.

type JSONDocument

type JSONDocument map[string]json.RawMessage

JSONDocument preserves unknown top-level keys while manipulating mcpServers.

func DeepCopyDocument

func DeepCopyDocument(doc JSONDocument) JSONDocument

DeepCopyDocument clones the top-level raw map to avoid mutation surprises.

func ReadJSONDocument

func ReadJSONDocument(path string) (JSONDocument, error)

ReadJSONDocument reads a JSON object document from disk.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry resolves adapters by client name.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty adapter registry.

func (*Registry) Get

func (r *Registry) Get(client string) (Adapter, error)

Get returns an adapter by client name.

func (*Registry) Names

func (r *Registry) Names() []string

Names returns registered adapter names in sorted order.

func (*Registry) Register

func (r *Registry) Register(adapter Adapter)

Register adds or replaces an adapter by normalized name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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