Documentation
¶
Overview ¶
Package agentsetup contains helpers for detecting and configuring AI coding agent integrations.
Index ¶
- Constants
- func ClaudeInstallCommand() (string, []string)
- func ClaudeMarketplaceUpdateCommand() (string, []string)
- func DefaultProviders() map[string]Provider
- func RunCommand(ctx context.Context, name string, args ...string) error
- func SupportedProviderIDs(providers map[string]Provider) string
- type ClaudeProvider
- type CodexProvider
- type CursorProvider
- type HomeDirFunc
- type LookPathFunc
- type Plan
- type PluginStatus
- type Provider
- type ReadDirFunc
- type ReadFileFunc
- type RunCommandFunc
- type RunOutputFunc
- type Scanner
- type StatFunc
- type Status
- type WorkDirFunc
Constants ¶
const ( ClientClaudeCode = "claude-code" ClaudeBinaryName = "claude" TargetClaudePlugin = "stripe@claude-plugins-official" ClaudeMarketplace = "claude-plugins-official" ClaudeDisplayName = "Claude Code" )
const ( ClientCodex = "codex" CodexBinaryName = "codex" CodexPluginName = "stripe" CodexMarketplace = "openai-curated" TargetCodexPlugin = "stripe@openai-curated" CodexDisplayName = "Codex CLI" )
const ( ClientCursor = "cursor" CursorBinaryName = "cursor" CursorDisplayName = "Cursor" )
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 ¶
ClaudeInstallCommand returns the command used to install the Stripe Claude Code plugin.
func ClaudeMarketplaceUpdateCommand ¶
ClaudeMarketplaceUpdateCommand returns the command used to refresh Claude's official plugin marketplace metadata.
func DefaultProviders ¶
DefaultProviders returns production setup providers keyed by client id.
func RunCommand ¶
RunCommand streams a command through the current process stdio.
func SupportedProviderIDs ¶
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 ¶
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
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) Detect ¶
func (p CodexProvider) Detect() Status
func (CodexProvider) ID ¶
func (p CodexProvider) ID() string
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 ¶
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
type HomeDirFunc ¶
HomeDirFunc matches os.UserHomeDir and exists to make status parsing testable.
type LookPathFunc ¶
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 ¶
ReadDirFunc matches os.ReadDir and exists to make directory listing testable.
type ReadFileFunc ¶
ReadFileFunc matches os.ReadFile and exists to make status parsing testable.
type RunCommandFunc ¶
RunCommandFunc runs a command. The production implementation streams stdio.
type RunOutputFunc ¶
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 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 ¶
WorkDirFunc matches os.Getwd and exists to make local plugin scope testable.