setup

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package setup owns local coding-client detection and MCP registration.

Index

Constants

This section is empty.

Variables

View Source
var AllClients = adapterClients()

AllClients lists supported adapters in deterministic application order.

Functions

func CheckRegistration

func CheckRegistration(client Client, home string) (bool, string, error)

CheckRegistration reports whether the selected client has a GitContribute MCP entry without changing its configuration.

func CodexSkillInstalled added in v0.8.0

func CodexSkillInstalled(home string) (bool, string, error)

CodexSkillInstalled reports whether the managed discovery skill is current.

func CodexSkillPath added in v0.8.0

func CodexSkillPath(home string) string

CodexSkillPath returns the managed discovery skill path for a home directory.

func ResolveNPMVersion

func ResolveNPMVersion(version string) (string, error)

ResolveNPMVersion returns a registry-safe package version for CLI installation and private runtime directory names. It removes one release-tag "v" prefix and maps empty or development versions to the explicit "latest" tag.

func ValidateLauncher added in v0.15.0

func ValidateLauncher(launcher Launcher) error

ValidateLauncher checks the durable command shape accepted by the current GitContribute MCP server. It does not execute the command.

Types

type ActivationRollbackError added in v0.9.0

type ActivationRollbackError struct {
	Cause    error
	Rollback error
}

ActivationRollbackError reports an activation failure whose rollback could not safely restore every registration.

func (*ActivationRollbackError) Error added in v0.9.0

func (e *ActivationRollbackError) Error() string

func (*ActivationRollbackError) Unwrap added in v0.9.0

func (e *ActivationRollbackError) Unwrap() []error

Unwrap exposes both the activation and rollback failures.

type Client

type Client string

Client identifies a supported coding-agent configuration adapter.

const (
	Codex  Client = "codex"
	Claude Client = "claude"
	Devin  Client = "devin"
)

func Detect

func Detect(home string) []Client

Detect returns supported coding clients whose configuration directories are present under home. Detection performs no writes.

type CodexSkillResult added in v0.8.0

type CodexSkillResult struct {
	Path   string `json:"path,omitempty"`
	Status string `json:"status"`
	Error  string `json:"error,omitempty"`
}

CodexSkillResult reports the managed discovery-skill effect.

type Launcher

type Launcher struct {
	Command string   `json:"command"`
	Args    []string `json:"args"`
}

Launcher is the exact process command stored in a coding client's MCP configuration.

func CanonicalLauncher added in v0.15.0

func CanonicalLauncher(executable string) (Launcher, error)

CanonicalLauncher returns the current MCP launcher for an already resolved durable executable path.

func ReadCommand added in v0.13.0

func ReadCommand(client Client, home string) (Launcher, error)

ReadCommand reads the durable launcher stored in a client-owned config. Parsing remains inside the client adapter; callers receive the product-owned Launcher contract rather than a client-specific representation.

func ReadCommandFile added in v0.13.0

func ReadCommandFile(client Client, path string) (Launcher, error)

ReadCommandFile is the path-oriented form used by setup-owned tests and recovery tooling. The config parser remains owned by the selected adapter.

func ResolveLauncher

func ResolveLauncher(opts Options) (Launcher, error)

ResolveLauncher returns a durable absolute MCP command. The setup application must first install an ephemeral package-runner executable into a stable product-owned location and pass that path explicitly.

type Operation

type Operation string

Operation identifies whether client-owned MCP entries are configured or removed.

const (
	Configure Operation = "setup"
	Remove    Operation = "remove"
)

type Options

type Options struct {
	Operation  Operation
	Clients    []Client
	All        bool
	DryRun     bool
	Home       string
	Executable string
}

Options controls coding-client MCP registration.

type RegistrationInspection added in v0.15.0

type RegistrationInspection struct {
	Client   Client             `json:"client"`
	Path     string             `json:"path"`
	Status   RegistrationStatus `json:"status"`
	Launcher Launcher           `json:"launcher,omitempty"`
	Message  string             `json:"message,omitempty"`
}

RegistrationInspection is a read-only, client-neutral view of one MCP entry.

func InspectRegistration added in v0.15.0

func InspectRegistration(client Client, home string) (RegistrationInspection, error)

InspectRegistration parses and validates the complete GitContribute launcher without changing client-owned configuration.

type RegistrationStatus added in v0.15.0

type RegistrationStatus string

RegistrationStatus describes whether an existing GitContribute MCP entry satisfies the current launcher contract.

const (
	RegistrationAbsent  RegistrationStatus = "absent"
	RegistrationCurrent RegistrationStatus = "current"
	RegistrationStale   RegistrationStatus = "stale"
)

type Report

type Report struct {
	Operation  Operation        `json:"operation"`
	DryRun     bool             `json:"dry_run"`
	Launcher   Launcher         `json:"launcher"`
	Results    []Result         `json:"results"`
	CodexSkill CodexSkillResult `json:"codex_skill,omitempty"`
}

func ActivateExisting added in v0.9.0

func ActivateExisting(ctx context.Context, opts Options) (Report, error)

ActivateExisting updates a set of existing GitContribute registrations as one rollback-safe operation. It never creates a new client registration or changes the optional Codex discovery skill. If activation or verification is interrupted, every selected client configuration is restored.

func ActivateExistingAndVerify added in v0.9.0

func ActivateExistingAndVerify(ctx context.Context, opts Options, verify func() error) (_ Report, returnErr error)

ActivateExistingAndVerify keeps the registration snapshots until verify succeeds, allowing callers to include executable and schema checks in the same rollback boundary.

func RepairExisting added in v0.15.0

func RepairExisting(ctx context.Context, home string, clients []Client) (_ Report, returnErr error)

RepairExisting rewrites existing registrations to the canonical MCP arguments while preserving each registration's durable executable path. The selected registrations are repaired as one rollback-safe operation.

func Run

func Run(opts Options) (_ Report, returnErr error)

Run validates every selected client, resolves one shared launcher, and then applies or plans each client-owned registration. Dry-run mode performs no writes. Per-client parse/write failures are returned in Report.Results so independent clients can be reported together.

type Result

type Result struct {
	Client Client `json:"client"`
	Path   string `json:"path"`
	Status string `json:"status"`
	Error  string `json:"error,omitempty"`
}

Result describes the registration effect for one coding client.

Jump to

Keyboard shortcuts

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