commands

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAssetNotFound = errors.New("asset not found")

ErrAssetNotFound is returned when no asset is found in the lock file

Functions

func IsMarketplaceReference added in v0.8.0

func IsMarketplaceReference(input string) bool

IsMarketplaceReference checks if input matches the plugin@marketplace pattern

func NewAddCommand

func NewAddCommand() *cobra.Command

NewAddCommand creates the add command

func NewClientsCommand added in v0.11.0

func NewClientsCommand() *cobra.Command

NewClientsCommand creates the clients command

func NewConfigCommand

func NewConfigCommand() *cobra.Command

NewConfigCommand creates the config command

func NewInitCommand

func NewInitCommand() *cobra.Command

NewInitCommand creates the init command

func NewInstallCommand

func NewInstallCommand() *cobra.Command

NewInstallCommand creates the install command

func NewListCommand added in v0.14.1

func NewListCommand() *cobra.Command

NewListCommand creates a new list command

func NewProfileCommand added in v0.7.0

func NewProfileCommand() *cobra.Command

NewProfileCommand creates the profile command with subcommands

func NewRemoveCommand

func NewRemoveCommand() *cobra.Command

NewRemoveCommand creates the remove command (deprecated: use 'sx vault remove')

func NewReportUsageCommand

func NewReportUsageCommand() *cobra.Command

NewReportUsageCommand creates the report-usage command

func NewRoleCommand added in v0.11.1

func NewRoleCommand() *cobra.Command

NewRoleCommand creates the role command with subcommands

func NewServeCommand

func NewServeCommand() *cobra.Command

NewServeCommand creates the serve command

func NewUninstallCommand

func NewUninstallCommand() *cobra.Command

NewUninstallCommand creates the uninstall command

func NewUpdateCommand

func NewUpdateCommand() *cobra.Command

NewUpdateCommand creates the update command

func NewUpdateTemplatesCommand

func NewUpdateTemplatesCommand() *cobra.Command

NewUpdateTemplatesCommand creates the update-templates command (hidden)

func NewVaultCommand added in v0.6.0

func NewVaultCommand() *cobra.Command

NewVaultCommand creates a new vault command

func PrintClientsSection added in v0.11.0

func PrintClientsSection(out *ui.Output, clientInfos []ClientInfo)

PrintClientsSection outputs styled client information to the given writer. Used by both 'sx clients' and 'sx config' commands.

func PrintClientsSectionWriter added in v0.11.0

func PrintClientsSectionWriter(w io.Writer, clientInfos []ClientInfo)

PrintClientsSectionWriter outputs styled client information to the given io.Writer. Used for compatibility with existing code that uses io.Writer.

func RunDefaultCommand

func RunDefaultCommand(cmd *cobra.Command, args []string) error

RunDefaultCommand runs the default command (install if lock file exists)

func ValidateMarketplaceReference added in v0.8.0

func ValidateMarketplaceReference(ref MarketplaceReference) error

ValidateMarketplaceReference validates that a marketplace reference doesn't contain path traversal characters

func WithPrompter

func WithPrompter(ctx context.Context, prompter Prompter) context.Context

WithPrompter returns a context with the given prompter (for testing)

Types

type AssetInfo

type AssetInfo struct {
	Name             string      `json:"name"`
	Version          string      `json:"version"`
	InstalledVersion string      `json:"installedVersion,omitempty"` // If different from Version
	Type             string      `json:"type"`
	Clients          []string    `json:"clients"`
	Status           AssetStatus `json:"status"`
}

type AssetStatus

type AssetStatus string

AssetStatus represents the installation status of an asset

const (
	StatusInstalled    AssetStatus = "installed"     // Installed and matches lock file
	StatusOutdated     AssetStatus = "outdated"      // Installed but different version
	StatusNotInstalled AssetStatus = "not_installed" // In lock file but not installed
	StatusOrphaned     AssetStatus = "orphaned"      // Installed but not in lock file
)

type AssetUninstallPlan

type AssetUninstallPlan struct {
	Name       string
	Version    string
	Type       asset.Type
	IsGlobal   bool
	Repository string   // Empty for global scope
	Path       string   // Path within repo (if path-scoped)
	Clients    []string // client IDs that have this installed
	LockEntry  *lockfile.Asset
}

AssetUninstallPlan contains info needed to uninstall one asset

type ClientInfo

type ClientInfo struct {
	ID             string   `json:"id"`
	Name           string   `json:"name"`
	Installed      bool     `json:"installed"`
	Enabled        bool     `json:"enabled"`
	ForceEnabled   bool     `json:"forceEnabled,omitempty"`  // explicitly force-enabled in config
	ForceDisabled  bool     `json:"forceDisabled,omitempty"` // explicitly force-disabled in config
	Version        string   `json:"version,omitempty"`
	Directory      string   `json:"directory"`
	HooksInstalled bool     `json:"hooksInstalled"`
	Supports       []string `json:"supports"`
}

type ClientsOutput added in v0.11.0

type ClientsOutput struct {
	Clients []ClientInfo `json:"clients"`
}

ClientsOutput represents the output for the clients command

type CodexNotifyEvent added in v0.12.3

type CodexNotifyEvent struct {
	Type                 string   `json:"type"`
	TurnID               string   `json:"turn-id"`
	InputMessages        []string `json:"input-messages"`
	LastAssistantMessage string   `json:"last-assistant-message"`
}

CodexNotifyEvent represents the JSON payload from Codex notify hook

type ConfigInfo

type ConfigInfo struct {
	Path          string `json:"path"`
	Exists        bool   `json:"exists"`
	Profile       string `json:"profile,omitempty"`
	Type          string `json:"type,omitempty"`
	RepositoryURL string `json:"repositoryUrl,omitempty"`
	ServerURL     string `json:"serverUrl,omitempty"`
}

type ConfigOutput

type ConfigOutput struct {
	Version      VersionInfo   `json:"version"`
	Platform     PlatformInfo  `json:"platform"`
	Config       ConfigInfo    `json:"config"`
	Directories  DirectoryInfo `json:"directories"`
	Clients      []ClientInfo  `json:"clients"`
	CurrentScope *scope.Scope  `json:"currentScope,omitempty"`
	Assets       []ScopeAssets `json:"assets"`
	RecentLogs   []string      `json:"recentLogs"`
}

ConfigOutput represents the full config output for JSON serialization

type CopilotPostToolUseEvent added in v0.12.3

type CopilotPostToolUseEvent struct {
	ToolName string         `json:"toolName"`
	ToolArgs map[string]any `json:"toolArgs"`
}

CopilotPostToolUseEvent represents the JSON payload from GitHub Copilot postToolUse hook

type DirectoryInfo

type DirectoryInfo struct {
	Config         string `json:"config"`
	Cache          string `json:"cache"`
	Assets         string `json:"assets"`
	GitRepos       string `json:"gitRepos"`
	LockFiles      string `json:"lockFiles"`
	InstalledState string `json:"installedState"`
	LogFile        string `json:"logFile"`
}

type MarketplaceReference added in v0.8.0

type MarketplaceReference struct {
	PluginName  string
	Marketplace string
}

MarketplaceReference represents a parsed plugin@marketplace reference

func ParseMarketplaceReference added in v0.8.0

func ParseMarketplaceReference(input string) MarketplaceReference

ParseMarketplaceReference splits plugin@marketplace into its parts

type PlatformInfo

type PlatformInfo struct {
	OS         string `json:"os"`
	Arch       string `json:"arch"`
	WorkingDir string `json:"workingDir"`
}

type PostToolUseEvent

type PostToolUseEvent struct {
	ToolName  string         `json:"tool_name"`
	ToolInput map[string]any `json:"tool_input"`
}

PostToolUseEvent represents the JSON payload from Claude Code PostToolUse hook

type Prompter

type Prompter interface {
	Prompt(message string) (string, error)
	PromptWithDefault(message, defaultValue string) (string, error)
	Confirm(message string) (bool, error)
}

Prompter provides an interface for interactive prompts This abstraction allows for: 1. Easy testing via mocking 2. Future UI improvements (e.g., switching to a TUI library) without changing all call sites

type ScopeAssets

type ScopeAssets struct {
	Scope           string      `json:"scope"`
	TrackerPath     string      `json:"trackerPath"`
	LockFileVersion string      `json:"lockFileVersion,omitempty"`
	InstalledAt     string      `json:"installedAt,omitempty"`
	Assets          []AssetInfo `json:"assets"`
}

type Section added in v0.9.0

type Section = utils.MarkdownSection

Section is an alias for utils.MarkdownSection for convenience

type StdPrompter

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

StdPrompter implements Prompter using standard I/O

func NewStdPrompter

func NewStdPrompter(in io.Reader, out io.Writer) *StdPrompter

NewStdPrompter creates a new standard I/O prompter

func (*StdPrompter) Confirm

func (p *StdPrompter) Confirm(message string) (bool, error)

Confirm asks a yes/no question

func (*StdPrompter) Prompt

func (p *StdPrompter) Prompt(message string) (string, error)

Prompt displays a prompt and reads user input

func (*StdPrompter) PromptWithDefault

func (p *StdPrompter) PromptWithDefault(message, defaultValue string) (string, error)

PromptWithDefault displays a prompt with a default value

type UninstallOptions

type UninstallOptions struct {
	All         bool
	Yes         bool
	DryRun      bool
	Verbose     bool
	ClientsFlag string
}

UninstallOptions contains options for the uninstall command

type UninstallPlan

type UninstallPlan struct {
	Assets     []AssetUninstallPlan
	GitContext *gitutil.GitContext
	TargetBase string // tracking base for updating tracker
}

UninstallPlan contains the complete uninstall plan

type UninstallResult

type UninstallResult struct {
	AssetName  string
	Repository string // Empty for global scope
	Path       string // Path within repo (if path-scoped)
	ClientID   string
	Success    bool
	Error      error
}

UninstallResult tracks what was uninstalled

type VersionInfo

type VersionInfo struct {
	Version string `json:"version"`
	Commit  string `json:"commit"`
	Date    string `json:"date"`
}

Jump to

Keyboard shortcuts

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