providers

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package providers contains installation provider implementations.

Package providers contains installation provider implementations.

Package providers contains installation provider implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatInstallError

func FormatInstallError(manager, operation, stderr string) string

FormatInstallError formats an installation error with helpful hints based on the error content.

func ProgressWriter added in v1.2.0

func ProgressWriter(ctx context.Context) io.Writer

ProgressWriter returns the writer associated with the context, or io.Discard if none was set. Callers should use the returned writer unconditionally.

func WithProgressWriter added in v1.2.0

func WithProgressWriter(ctx context.Context, w io.Writer) context.Context

WithProgressWriter returns a new context that carries the given writer. Providers use it to tee the subprocess stdout/stderr while they run, so callers can surface live output for long-running installs or updates.

Passing nil is a no-op: the returned context is the input context, so a previously attached writer is NOT cleared. To actually silence streaming after one was attached, start from a context that never had one. This asymmetry lets middleware attach a writer safely without worrying about downstream code accidentally clobbering it with nil.

Providers always still capture the full output into Result.Output, so callers that ignore the stream lose no information.

The returned writer is safe for concurrent calls to Write — providers use it to tee BOTH cmd.Stdout and cmd.Stderr, which os/exec writes to from separate goroutines. Internally Write calls serialize on a mutex so concurrent writes produce non-interleaved byte sequences per call.

Types

type BrewProvider

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

BrewProvider handles Homebrew-based installations.

func NewBrewProvider

func NewBrewProvider(p platform.Platform) *BrewProvider

NewBrewProvider creates a new Homebrew provider.

func (*BrewProvider) GetLatestVersion

func (p *BrewProvider) GetLatestVersion(ctx context.Context, method catalog.InstallMethodDef) (agent.Version, error)

GetLatestVersion returns the latest version of a brew package.

Results are cached process-wide with a short TTL to avoid re-running `brew info --json=v2 <pkg>` once per agent per refresh. Concurrent callers for the same package coalesce via a per-key sync.Once so only one subprocess is launched at a time.

func (*BrewProvider) Install

func (p *BrewProvider) Install(ctx context.Context, agentDef catalog.AgentDef, method catalog.InstallMethodDef, force bool) (*Result, error)

Install installs an agent via Homebrew.

func (*BrewProvider) IsAvailable

func (p *BrewProvider) IsAvailable() bool

IsAvailable returns true if brew is available.

func (*BrewProvider) Method

func (p *BrewProvider) Method() agent.InstallMethod

Method returns the install method this provider handles.

func (*BrewProvider) Name

func (p *BrewProvider) Name() string

Name returns the provider name.

func (*BrewProvider) Uninstall

func (p *BrewProvider) Uninstall(ctx context.Context, inst *agent.Installation, method catalog.InstallMethodDef) error

Uninstall removes a Homebrew-installed agent.

func (*BrewProvider) Update

func (p *BrewProvider) Update(ctx context.Context, inst *agent.Installation, agentDef catalog.AgentDef, method catalog.InstallMethodDef) (*Result, error)

Update updates a Homebrew-installed agent.

type NPMProvider

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

NPMProvider handles npm-based installations.

func NewNPMProvider

func NewNPMProvider(p platform.Platform) *NPMProvider

NewNPMProvider creates a new NPM provider.

func (*NPMProvider) GetLatestVersion

func (p *NPMProvider) GetLatestVersion(ctx context.Context, method catalog.InstallMethodDef) (agent.Version, error)

GetLatestVersion returns the latest version of an npm package from the registry.

func (*NPMProvider) Install

func (p *NPMProvider) Install(ctx context.Context, agentDef catalog.AgentDef, method catalog.InstallMethodDef, force bool) (*Result, error)

Install installs an agent via npm.

func (*NPMProvider) IsAvailable

func (p *NPMProvider) IsAvailable() bool

IsAvailable returns true if npm is available.

func (*NPMProvider) Method

func (p *NPMProvider) Method() agent.InstallMethod

Method returns the install method this provider handles.

func (*NPMProvider) Name

func (p *NPMProvider) Name() string

Name returns the provider name.

func (*NPMProvider) Uninstall

func (p *NPMProvider) Uninstall(ctx context.Context, inst *agent.Installation, method catalog.InstallMethodDef) error

Uninstall removes an npm-installed agent.

func (*NPMProvider) Update

func (p *NPMProvider) Update(ctx context.Context, inst *agent.Installation, agentDef catalog.AgentDef, method catalog.InstallMethodDef) (*Result, error)

Update updates an npm-installed agent.

type NativeProvider

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

NativeProvider handles native binary installations (shell scripts, direct downloads).

func NewNativeProvider

func NewNativeProvider(p platform.Platform) *NativeProvider

NewNativeProvider creates a new native provider.

func (*NativeProvider) Install

func (p *NativeProvider) Install(ctx context.Context, agentDef catalog.AgentDef, method catalog.InstallMethodDef, force bool) (*Result, error)

Install installs an agent via native method.

func (*NativeProvider) IsAvailable

func (p *NativeProvider) IsAvailable() bool

IsAvailable returns true - native install is always available.

func (*NativeProvider) Method

func (p *NativeProvider) Method() agent.InstallMethod

Method returns the install method this provider handles.

func (*NativeProvider) Name

func (p *NativeProvider) Name() string

Name returns the provider name.

func (*NativeProvider) Uninstall

func (p *NativeProvider) Uninstall(ctx context.Context, inst *agent.Installation, method catalog.InstallMethodDef) error

Uninstall removes a native-installed agent.

func (*NativeProvider) Update

func (p *NativeProvider) Update(ctx context.Context, inst *agent.Installation, agentDef catalog.AgentDef, method catalog.InstallMethodDef) (*Result, error)

Update updates a native-installed agent.

type PipProvider

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

PipProvider handles pip/pipx/uv-based installations.

func NewPipProvider

func NewPipProvider(p platform.Platform) *PipProvider

NewPipProvider creates a new pip provider.

func (*PipProvider) GetLatestVersion

func (p *PipProvider) GetLatestVersion(ctx context.Context, method catalog.InstallMethodDef) (agent.Version, error)

GetLatestVersion returns the latest version of a pip package from PyPI.

func (*PipProvider) Install

func (p *PipProvider) Install(ctx context.Context, agentDef catalog.AgentDef, method catalog.InstallMethodDef, force bool) (*Result, error)

Install installs an agent via pip/pipx/uv.

func (*PipProvider) IsAvailable

func (p *PipProvider) IsAvailable() bool

IsAvailable returns true if pip, pipx, or uv is available.

func (*PipProvider) Method

func (p *PipProvider) Method() agent.InstallMethod

Method returns the install method this provider handles.

func (*PipProvider) Name

func (p *PipProvider) Name() string

Name returns the provider name.

func (*PipProvider) Uninstall

func (p *PipProvider) Uninstall(ctx context.Context, inst *agent.Installation, method catalog.InstallMethodDef) error

Uninstall removes a pip/pipx/uv-installed agent.

func (*PipProvider) Update

func (p *PipProvider) Update(ctx context.Context, inst *agent.Installation, agentDef catalog.AgentDef, method catalog.InstallMethodDef) (*Result, error)

Update updates a pip/pipx/uv-installed agent.

type Result

type Result struct {
	AgentID        string
	AgentName      string
	Method         agent.InstallMethod
	Version        agent.Version
	FromVersion    agent.Version // For updates
	InstallPath    string
	ExecutablePath string
	Duration       time.Duration
	Output         string
	WasUpdated     bool // For updates
}

Result represents the result of an install or update operation.

Jump to

Keyboard shortcuts

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