agentsetup

package
v1.53.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 10 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"
	CodexDisplayName = "Codex CLI"
)
View Source
const (
	// Cursor requires the user to run a slash command from inside the agent to install the Stripe plugin.
	ClientCursor            = "cursor"
	CursorBinaryName        = "cursor"
	CursorDisplayName       = "Cursor"
	CursorManualInstruction = "run /add-plugin stripe inside Cursor"
)
View Source
const (
	ClientGrok      = "grok"
	GrokBinaryName  = "grok"
	GrokPluginName  = "stripe"
	GrokDisplayName = "Grok"
)
View Source
const (
	// Kiro requires the user to add the Stripe plugin manually via the website
	ClientKiro            = "kiro"
	KiroBinaryName        = "kiro-cli"
	KiroDisplayName       = "Kiro"
	KiroManualInstruction = "add plugin by visiting https://kiro.dev/launch/powers/add/?name=stripe"
)
View Source
const (
	ClientOpenclaw      = "openclaw"
	OpenclawBinaryName  = "openclaw"
	OpenclawPluginName  = "stripe"
	OpenclawDisplayName = "OpenClaw"
)
View Source
const (
	StatusNotDetected = "not_detected"
	StatusInstalled   = "installed"
	StatusMissing     = "missing"
	StatusUnknown     = "unknown"
	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 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 runs a command silently. Plugin installs run behind a spinner, so streaming subprocess stdio to the terminal would interleave with our animation. On failure, return a single line from the subprocess output.

func SupportedProviderIDs

func SupportedProviderIDs(providers map[string]Provider) string

Types

type ClaudeProvider

type ClaudeProvider struct {
	ProviderConfig
}

ClaudeProvider detects and configures the Stripe plugin for Claude Code.

func (ClaudeProvider) Apply

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

Apply installs the Stripe Claude Code plugin. On failure it silently refreshes the official marketplace and retries once.

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 {
	ProviderConfig
}

CodexProvider detects and installs the Stripe plugin for Codex CLI.

Detection selects the first available supported marketplace, and installation runs `codex plugin add stripe@<marketplace>` using that selection.

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 GrokProvider added in v1.52.0

type GrokProvider struct {
	ProviderConfig
}

GrokProvider detects and installs the Stripe plugin for Grok Build (xAI).

func (GrokProvider) Apply added in v1.52.0

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

Apply installs (or updates) the Stripe Grok plugin. Unlike Codex's `plugin add` (see codex.go), `grok plugin install`/`update` exit non-zero on failure and 0 on success, so the exit code can be trusted without a post-install re-check.

func (GrokProvider) Detect added in v1.52.0

func (p GrokProvider) Detect() Status

func (GrokProvider) ID added in v1.52.0

func (p GrokProvider) ID() string

func (GrokProvider) Plan added in v1.52.0

func (p GrokProvider) Plan(status Status, force 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 ManualProvider added in v1.53.1

type ManualProvider struct {
	ProviderConfig
	ManualInstruction string
}

func (ManualProvider) Apply added in v1.53.1

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

func (ManualProvider) Detect added in v1.53.1

func (p ManualProvider) Detect() Status

func (ManualProvider) ID added in v1.53.1

func (p ManualProvider) ID() string

func (ManualProvider) Plan added in v1.53.1

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

type OpenclawProvider added in v1.53.1

type OpenclawProvider struct {
	ProviderConfig
}

OpenclawProvider detects and installs the Stripe plugin for Openclaw.

func (OpenclawProvider) Apply added in v1.53.1

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

Apply runs each command in the plan in order. The install step is already the last entry in plan.Commands (see Plan), so there is nothing left to run after this loop.

func (OpenclawProvider) Detect added in v1.53.1

func (p OpenclawProvider) Detect() Status

func (OpenclawProvider) ID added in v1.53.1

func (p OpenclawProvider) ID() string

func (OpenclawProvider) Plan added in v1.53.1

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

Plan for Openclaw, installing and updating the plugin requires either cloning or pulling the repo beforehand, however installing the plugin after uses the same command `openclaw plugins install`.

type Plan

type Plan struct {
	Action string `json:"action"`
	// Commands holds the commands to run based on the Action
	Commands [][]string `json:"commands,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 NewClaudeProvider

func NewClaudeProvider(scanner Scanner, runCommand RunCommandFunc) Provider

NewClaudeProvider returns a Claude Code setup provider.

func NewCodexProvider

func NewCodexProvider(scanner Scanner, runCommand RunCommandFunc) Provider

NewCodexProvider returns a Codex CLI setup provider.

func NewCursorProvider

func NewCursorProvider(scanner Scanner) Provider

func NewGrokProvider added in v1.52.0

func NewGrokProvider(scanner Scanner, runCommand RunCommandFunc) Provider

NewGrokProvider returns a Grok Build setup provider.

func NewKiroProvider added in v1.53.1

func NewKiroProvider(scanner Scanner) Provider

func NewManualProvider added in v1.53.1

func NewManualProvider(scanner Scanner, client, binaryName, displayName, manualInstruction string) Provider

NewManualProvider returns a setup provider for a client whose plugin must be installed manually; these clients have no CLI installer to run.

func NewOpenclawProvider added in v1.53.1

func NewOpenclawProvider(scanner Scanner, runCommand RunCommandFunc) Provider

NewOpenclawProvider returns a Openclaw setup provider.

type ProviderConfig added in v1.52.1

type ProviderConfig struct {
	Scanner     Scanner
	Client      string
	BinaryName  string
	DisplayName string
	RunCommand  RunCommandFunc
	RunOutput   RunOutputFunc
}

ProviderConfig holds the configuration for a provider.

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 captures output silently and returns a concise error on failure.

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