Help us shape the future of Go! Take the 2026 Go Developer Survey

setup

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 10 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 = []Client{Codex, Claude}

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 IsNpxEnvironment

func IsNpxEnvironment(env map[string]string) bool

IsNpxEnvironment reports whether npm is providing an ephemeral execution context rather than a persistent package installation. A non-nil env map is authoritative, including when a key is deliberately absent.

func ResolveNPMVersion

func ResolveNPMVersion(version string) (string, error)

ResolveNPMVersion returns a registry-safe package version for setup launchers and persistent installation commands. It removes one release-tag "v" prefix and maps empty or development versions to the explicit "latest" tag.

Types

type Client

type Client string

Client identifies a supported coding-agent configuration adapter.

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

func Detect

func Detect(home string) []Client

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

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 ResolveLauncher

func ResolveLauncher(opts Options) (Launcher, error)

ResolveLauncher returns a durable MCP command for the current installation context. Ephemeral npm execution uses a registry-safe, versioned npx command; persistent/source execution uses an absolute executable path. It never saves os.Executable when that path points into npx's disposable cache.

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
	Version    string
	Env        map[string]string
	Executable string
}

Options controls coding-client MCP registration. Env is authoritative when non-nil, allowing callers to distinguish ephemeral npx execution from a persistent executable without retaining a cache path.

type Report

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

Report contains the resolved launcher and ordered per-client effects.

func Run

func Run(opts Options) (Report, 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