agentsetup

package
v1.43.7 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package agentsetup contains helpers for detecting and configuring AI coding agent integrations.

Index

Constants

View Source
const (
	ClientClaudeCode   = "claude-code"
	ClaudeBinaryName   = "claude"
	TargetClaudePlugin = "stripe@claude-plugins-official"
	ClaudeMarketplace  = "claude-plugins-official"
	ClaudeDisplayName  = "Claude Code"
)
View Source
const (
	ClientCodex       = "codex"
	CodexBinaryName   = "codex"
	CodexPluginName   = "stripe"
	CodexMarketplace  = "openai-curated"
	TargetCodexPlugin = "stripe@openai-curated"
	CodexDisplayName  = "Codex CLI"
)
View Source
const (
	ClientCursor      = "cursor"
	CursorBinaryName  = "cursor"
	CursorDisplayName = "Cursor"
)
View Source
const (
	StatusNotDetected = "not_detected"
	StatusInstalled   = "installed"
	StatusMissing     = "missing"
	StatusError       = "error"

	ActionNone      = "none"
	ActionInstall   = "install"
	ActionReinstall = "reinstall"
	// ActionManual means setup cannot be automated and the user must perform a
	// step themselves (e.g. Cursor plugins are installed from inside Cursor).
	ActionManual = "manual"
)

Variables

This section is empty.

Functions

func ClaudeInstallCommand

func ClaudeInstallCommand() (string, []string)

ClaudeInstallCommand returns the command used to install the Stripe Claude Code plugin.

func ClaudeMarketplaceUpdateCommand

func ClaudeMarketplaceUpdateCommand() (string, []string)

ClaudeMarketplaceUpdateCommand returns the command used to refresh Claude's official plugin marketplace metadata.

func DefaultProviders

func DefaultProviders() map[string]Provider

DefaultProviders returns production setup providers keyed by client id.

func RunCommand

func RunCommand(ctx context.Context, name string, args ...string) error

RunCommand streams a command through the current process stdio.

func SupportedProviderIDs

func SupportedProviderIDs(providers map[string]Provider) string

Types

type ClaudeProvider

type ClaudeProvider struct {
	Scanner    Scanner
	RunCommand RunCommandFunc
	RunOutput  RunOutputFunc
}

ClaudeProvider detects and configures the Stripe plugin for Claude Code.

func NewClaudeProvider

func NewClaudeProvider(scanner Scanner, runCommand RunCommandFunc) ClaudeProvider

NewClaudeProvider returns a Claude Code setup provider.

func (ClaudeProvider) Apply

func (p ClaudeProvider) Apply(ctx context.Context, out io.Writer, plan Plan) error

Apply installs the Stripe Claude Code plugin, refreshing the official plugin marketplace and retrying once if the first attempt fails.

func (ClaudeProvider) Detect

func (p ClaudeProvider) Detect() Status

func (ClaudeProvider) ID

func (p ClaudeProvider) ID() string

func (ClaudeProvider) Plan

func (p ClaudeProvider) Plan(status Status, force bool) Plan

type CodexProvider

type CodexProvider struct {
	Scanner    Scanner
	RunCommand RunCommandFunc
	RunOutput  RunOutputFunc
}

CodexProvider detects and installs the Stripe plugin for Codex CLI.

Codex has a real plugin CLI, so detection runs `codex plugin list --json` and installation runs `codex plugin add stripe@openai-curated`.

func (CodexProvider) Apply

func (p CodexProvider) Apply(ctx context.Context, _ io.Writer, plan Plan) error

func (CodexProvider) Detect

func (p CodexProvider) Detect() Status

func (CodexProvider) ID

func (p CodexProvider) ID() string

func (CodexProvider) Plan

func (p CodexProvider) Plan(status Status, force bool) Plan

type CursorProvider

type CursorProvider struct {
	Scanner Scanner
}

CursorProvider detects the Stripe plugin for Cursor.

Unlike Claude Code, Cursor has no `cursor plugin` CLI and no JSON registry: the `cursor` binary is only the editor launcher, and installed plugins are recorded as a directory tree under ~/.cursor/plugins/cache/<marketplace>/ <plugin>/<hash>/ (a `.cache-complete` marker plus a .cursor-plugin/plugin.json metadata file). Detection therefore walks the filesystem.

Cursor plugins are installed from inside Cursor via the `/add-plugin stripe` slash command; there is no shell CLI installer. This provider therefore detects the plugin from disk and, when it is missing, points the user at the in-app command rather than shelling out.

func (CursorProvider) Apply

func (p CursorProvider) Apply(_ context.Context, _ io.Writer, _ Plan) error

Apply is a no-op for Cursor: the plugin is installed from inside Cursor, so the setup flow surfaces the ActionManual instruction rather than calling Apply.

func (CursorProvider) Detect

func (p CursorProvider) Detect() Status

func (CursorProvider) ID

func (p CursorProvider) ID() string

func (CursorProvider) Plan

func (p CursorProvider) Plan(status Status, _ bool) Plan

type HomeDirFunc

type HomeDirFunc func() (string, error)

HomeDirFunc matches os.UserHomeDir and exists to make status parsing testable.

type LookPathFunc

type LookPathFunc func(string) (string, error)

LookPathFunc matches exec.LookPath and exists to make detection testable.

type Plan

type Plan struct {
	Action  string   `json:"action"`
	Command []string `json:"command,omitempty"`
	// Manual holds the instruction shown for ActionManual plans.
	Manual string `json:"manual,omitempty"`
}

Plan describes the next setup action for a provider.

type PluginStatus

type PluginStatus struct {
	Installed bool   `json:"installed"`
	ID        string `json:"id,omitempty"`
	Version   string `json:"version,omitempty"`
	Scope     string `json:"scope,omitempty"`
	Project   string `json:"project_path,omitempty"`
	StatePath string `json:"state_path,omitempty"`
}

PluginStatus is the plugin-specific part of a client setup status.

type Provider

type Provider interface {
	ID() string
	Detect() Status
	Plan(Status, bool) Plan
	Apply(context.Context, io.Writer, Plan) error
}

Provider detects and configures Stripe tooling for one AI coding client.

func NewCodexProvider

func NewCodexProvider(scanner Scanner, runCommand RunCommandFunc) Provider

NewCodexProvider returns a Codex CLI setup provider.

func NewCursorProvider

func NewCursorProvider(scanner Scanner, _ RunCommandFunc) Provider

NewCursorProvider returns a Cursor setup provider. The RunCommandFunc argument is accepted for signature parity with the other providers but is unused, because Cursor has no CLI installer.

type ReadDirFunc

type ReadDirFunc func(string) ([]os.DirEntry, error)

ReadDirFunc matches os.ReadDir and exists to make directory listing testable.

type ReadFileFunc

type ReadFileFunc func(string) ([]byte, error)

ReadFileFunc matches os.ReadFile and exists to make status parsing testable.

type RunCommandFunc

type RunCommandFunc func(context.Context, string, ...string) error

RunCommandFunc runs a command. The production implementation streams stdio.

type RunOutputFunc

type RunOutputFunc func(context.Context, string, ...string) ([]byte, error)

RunOutputFunc runs a command and returns its standard output. It exists so Codex detection (which shells out to `codex plugin list --json`) is testable.

type Scanner

type Scanner struct {
	LookPath LookPathFunc
	ReadFile ReadFileFunc
	HomeDir  HomeDirFunc
	WorkDir  WorkDirFunc
	ReadDir  ReadDirFunc
	Stat     StatFunc
}

Scanner scans local agent installations without mutating them.

func DefaultScanner

func DefaultScanner() Scanner

DefaultScanner returns a Scanner backed by the real OS.

type StatFunc

type StatFunc func(string) (os.FileInfo, error)

StatFunc matches os.Stat and exists to make file existence checks testable.

type Status

type Status struct {
	Client         string       `json:"client"`
	DisplayName    string       `json:"display_name"`
	Detected       bool         `json:"detected"`
	ExecutablePath string       `json:"executable_path,omitempty"`
	Plugin         PluginStatus `json:"plugin"`
	Status         string       `json:"status"`
	Error          string       `json:"error,omitempty"`
}

Status is the read-only setup status for one AI coding client.

type WorkDirFunc

type WorkDirFunc func() (string, error)

WorkDirFunc matches os.Getwd and exists to make local plugin scope testable.

Jump to

Keyboard shortcuts

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