Documentation
¶
Overview ¶
Package setup provides interactive configuration wizards for first-run experience.
Package setup provides interactive configuration wizards including Bubble Tea TUI components.
Package setup provides profile management for CLASP configuration.
Package setup provides interactive configuration wizards including Bubble Tea TUI components.
Package setup provides secure input handling for sensitive data like API keys.
Package setup provides interactive configuration wizards for first-run experience.
Index ¶
- Variables
- func ApplyConfigToEnv() error
- func FormatProfileDetails(profile *Profile) string
- func FormatProfileInfo(profile *Profile, isActive bool) string
- func GetConfigPath() string
- func GetProfilePath(name string) string
- func HasProfiles() bool
- func IsTTY() bool
- func MaskAPIKeyForDisplay(key string) string
- func NeedsSetup() bool
- func QuickCheck() (bool, string)
- func RunModelPicker(models []ModelInfo, provider, tier string) (string, error)
- func RunProfileSelector(profiles []*Profile, activeProfile string) (selectedProfile string, createNew, canceled bool, err error)
- func RunSecureInput(prompt, placeholder string, showLast4 bool) (string, error)
- func SelectOrCreateProfile() (profileName string, createNew, canceled bool)
- func WarnCLIAPIKey() string
- type ClaudeCodeConfig
- type ConfigFile
- type DiagnosticResult
- type Doctor
- type GlobalConfig
- type ModelInfo
- type ModelPicker
- type Profile
- type ProfileItem
- type ProfileManager
- func (pm *ProfileManager) ApplyProfileToEnv(profile *Profile) error
- func (pm *ProfileManager) CreateProfile(profile *Profile) error
- func (pm *ProfileManager) DeleteProfile(name string) error
- func (pm *ProfileManager) EnsureDirectories() error
- func (pm *ProfileManager) ExportProfile(name string) ([]byte, error)
- func (pm *ProfileManager) GetActiveProfile() (*Profile, error)
- func (pm *ProfileManager) GetGlobalConfig() (*GlobalConfig, error)
- func (pm *ProfileManager) GetGlobalConfigPath() string
- func (pm *ProfileManager) GetProfile(name string) (*Profile, error)
- func (pm *ProfileManager) GetProfilesDir() string
- func (pm *ProfileManager) ImportProfile(data []byte, newName string) error
- func (pm *ProfileManager) ListProfiles() ([]*Profile, error)
- func (pm *ProfileManager) MigrateOldConfig() error
- func (pm *ProfileManager) ProfileExists(name string) bool
- func (pm *ProfileManager) RenameProfile(oldName, newName string) error
- func (pm *ProfileManager) SaveGlobalConfig(config *GlobalConfig) error
- func (pm *ProfileManager) SetActiveProfile(name string) error
- func (pm *ProfileManager) UpdateProfile(profile *Profile) error
- type ProfileSelector
- type ProfileSelectorMode
- type ProfileSelectorResult
- type SecureInput
- type TierMapping
- type Wizard
- func (w *Wizard) FetchModelsPublic(provider, apiKey, baseURL, azureEndpoint string) ([]string, error)
- func (w *Wizard) Run() (*config.Config, error)
- func (w *Wizard) RunProfileCreate(profileName string) (*Profile, error)
- func (w *Wizard) RunProfileDelete(name string) error
- func (w *Wizard) RunProfileExport(name, outputPath string) error
- func (w *Wizard) RunProfileImport(inputPath, newName string) error
- func (w *Wizard) RunProfileList() error
- func (w *Wizard) RunProfileShow(name string) error
- func (w *Wizard) RunProfileUse(name string) error
Constants ¶
This section is empty.
Variables ¶
var ErrCanceled = fmt.Errorf("setup canceled")
ErrCanceled is returned when the user cancels the model picker (Ctrl+C or Esc).
Functions ¶
func ApplyConfigToEnv ¶
func ApplyConfigToEnv() error
ApplyConfigToEnv applies saved config to environment variables.
func FormatProfileDetails ¶ added in v0.13.0
FormatProfileDetails returns detailed profile information.
func FormatProfileInfo ¶ added in v0.13.0
FormatProfileInfo returns a formatted string with profile information.
func GetConfigPath ¶
func GetConfigPath() string
GetConfigPath returns the path to the CLASP config file.
func GetProfilePath ¶
GetProfilePath returns the path to a specific profile.
func HasProfiles ¶ added in v0.49.0
func HasProfiles() bool
HasProfiles checks if any profiles exist.
func MaskAPIKeyForDisplay ¶ added in v0.17.1
MaskAPIKeyForDisplay masks an API key for safe display.
func NeedsSetup ¶
func NeedsSetup() bool
NeedsSetup checks if configuration is missing and setup is required.
func QuickCheck ¶ added in v0.46.0
QuickCheck performs a minimal set of checks for startup validation.
func RunModelPicker ¶ added in v0.17.1
RunModelPicker runs the Bubble Tea model picker and returns the selected model. Returns ErrCanceled if the user presses Ctrl+C or Esc to cancel. Returns empty string with nil error only if no models were selected but not canceled.
func RunProfileSelector ¶ added in v0.49.0
func RunProfileSelector(profiles []*Profile, activeProfile string) (selectedProfile string, createNew, canceled bool, err error)
RunProfileSelector runs the Bubble Tea profile selector. Returns the selected profile name, or empty string for create new / canceled. The second return value indicates whether to create a new profile.
func RunSecureInput ¶ added in v0.17.1
RunSecureInput runs the secure input and returns the entered value. Returns empty string if canceled.
func SelectOrCreateProfile ¶ added in v0.49.0
SelectOrCreateProfile shows the profile selector TUI if profiles exist, otherwise returns that a new profile should be created. Returns: profileName (if selected), createNew (if should create), canceled (if user quit)
func WarnCLIAPIKey ¶ added in v0.17.1
func WarnCLIAPIKey() string
WarnCLIAPIKey prints a warning if API key is passed via command line.
Types ¶
type ClaudeCodeConfig ¶ added in v0.34.9
type ClaudeCodeConfig struct {
// SkipPermissions enables --dangerously-skip-permissions flag (default: true)
SkipPermissions bool `json:"skip_permissions"`
// AdditionalArgs contains extra arguments to pass to Claude Code
AdditionalArgs []string `json:"additional_args,omitempty"`
}
ClaudeCodeConfig represents Claude Code CLI configuration.
type ConfigFile ¶
type ConfigFile struct {
Provider string `json:"provider"`
Model string `json:"model,omitempty"`
APIKey string `json:"api_key,omitempty"`
BaseURL string `json:"base_url,omitempty"`
AzureEndpoint string `json:"azure_endpoint,omitempty"`
AzureDeployment string `json:"azure_deployment,omitempty"`
ModelAliases map[string]string `json:"model_aliases,omitempty"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
// Claude Code settings
ClaudeCodeConfig *ClaudeCodeConfig `json:"claude_code,omitempty"`
}
ConfigFile represents the saved configuration format.
func LoadConfig ¶
func LoadConfig() (*ConfigFile, error)
LoadConfig loads configuration from the saved config file.
type DiagnosticResult ¶ added in v0.46.0
type DiagnosticResult struct {
Name string
Status string // "ok", "warning", "error"
Message string
Fix string // Suggested fix if status is not ok
}
DiagnosticResult represents the result of a single diagnostic check.
type Doctor ¶ added in v0.46.0
type Doctor struct {
// contains filtered or unexported fields
}
Doctor runs comprehensive diagnostics on the CLASP installation.
func (*Doctor) PrintResults ¶ added in v0.46.0
PrintResults formats and prints diagnostic results.
func (*Doctor) Run ¶ added in v0.46.0
func (d *Doctor) Run() []DiagnosticResult
Run executes all diagnostic checks and returns results.
type GlobalConfig ¶ added in v0.13.0
type GlobalConfig struct {
ActiveProfile string `json:"active_profile"`
LastUsed string `json:"last_used,omitempty"`
}
GlobalConfig holds global settings and active profile reference.
type ModelInfo ¶ added in v0.17.1
type ModelInfo struct {
ID string // Model ID (e.g., "gpt-4o")
Name string // Display name (e.g., "GPT-4o")
Desc string // Short description
Provider string // Provider name
InputPrice float64 // Price per 1M input tokens in USD
OutputPrice float64 // Price per 1M output tokens in USD
ContextSize int // Context window size in tokens
IsRecommended bool // Whether this is a recommended model
}
ModelInfo contains metadata about a model.
func GetKnownModels ¶ added in v0.17.1
GetKnownModels returns model metadata for known providers.
func MergeModelLists ¶ added in v0.17.1
MergeModelLists merges fetched models with known model metadata.
func (ModelInfo) Description ¶ added in v0.17.1
func (ModelInfo) FilterValue ¶ added in v0.17.1
Implement list.Item interface
type ModelPicker ¶ added in v0.17.1
type ModelPicker struct {
// contains filtered or unexported fields
}
ModelPicker is a Bubble Tea model for fuzzy model selection.
func NewModelPicker ¶ added in v0.17.1
func NewModelPicker(models []ModelInfo, provider, tier string) *ModelPicker
NewModelPicker creates a new fuzzy model picker.
func (*ModelPicker) Canceled ¶ added in v0.50.14
func (m *ModelPicker) Canceled() bool
Canceled returns true if the user canceled the selection.
func (*ModelPicker) Init ¶ added in v0.17.1
func (m *ModelPicker) Init() tea.Cmd
Init initializes the model picker.
func (*ModelPicker) Selected ¶ added in v0.17.1
func (m *ModelPicker) Selected() *ModelInfo
Selected returns the selected model, or nil if canceled.
func (*ModelPicker) Update ¶ added in v0.17.1
Update handles input and updates the model picker state.
func (*ModelPicker) View ¶ added in v0.17.1
func (m *ModelPicker) View() string
View renders the model picker with visible filter input.
type Profile ¶ added in v0.13.0
type Profile struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
// Provider configuration
Provider string `json:"provider"`
APIKey string `json:"api_key,omitempty"`
APIKeyEnv string `json:"api_key_env,omitempty"` // Reference to env var instead of storing key
BaseURL string `json:"base_url,omitempty"`
// Azure-specific
AzureEndpoint string `json:"azure_endpoint,omitempty"`
AzureDeployment string `json:"azure_deployment,omitempty"`
// Model configuration
DefaultModel string `json:"default_model,omitempty"`
// Per-tier model mappings
TierMappings map[string]TierMapping `json:"tier_mappings,omitempty"`
// Default parameters
Temperature *float64 `json:"temperature,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
// Server preferences
Port int `json:"port,omitempty"`
// Feature flags
RateLimitEnabled bool `json:"rate_limit_enabled,omitempty"`
CacheEnabled bool `json:"cache_enabled,omitempty"`
CircuitBreakerEnabled bool `json:"circuit_breaker_enabled,omitempty"`
// Claude Code settings
ClaudeCode *ClaudeCodeConfig `json:"claude_code,omitempty"`
// Timestamps
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
Profile represents a saved CLASP configuration profile.
type ProfileItem ¶ added in v0.49.0
ProfileItem represents a profile in the selector list.
func (ProfileItem) Description ¶ added in v0.49.0
func (p ProfileItem) Description() string
func (ProfileItem) FilterValue ¶ added in v0.49.0
func (p ProfileItem) FilterValue() string
Implement list.Item interface
func (ProfileItem) Title ¶ added in v0.49.0
func (p ProfileItem) Title() string
type ProfileManager ¶ added in v0.13.0
type ProfileManager struct {
// contains filtered or unexported fields
}
ProfileManager handles profile CRUD operations.
func NewProfileManager ¶ added in v0.13.0
func NewProfileManager() *ProfileManager
NewProfileManager creates a new profile manager.
func (*ProfileManager) ApplyProfileToEnv ¶ added in v0.13.0
func (pm *ProfileManager) ApplyProfileToEnv(profile *Profile) error
ApplyProfileToEnv applies profile settings to environment variables.
func (*ProfileManager) CreateProfile ¶ added in v0.13.0
func (pm *ProfileManager) CreateProfile(profile *Profile) error
CreateProfile creates a new profile.
func (*ProfileManager) DeleteProfile ¶ added in v0.13.0
func (pm *ProfileManager) DeleteProfile(name string) error
DeleteProfile removes a profile.
func (*ProfileManager) EnsureDirectories ¶ added in v0.13.0
func (pm *ProfileManager) EnsureDirectories() error
EnsureDirectories creates necessary directories if they don't exist.
func (*ProfileManager) ExportProfile ¶ added in v0.13.0
func (pm *ProfileManager) ExportProfile(name string) ([]byte, error)
ExportProfile exports a profile to JSON. API keys are never included in exports for security. Instead, use api_key_env to reference environment variables.
func (*ProfileManager) GetActiveProfile ¶ added in v0.13.0
func (pm *ProfileManager) GetActiveProfile() (*Profile, error)
GetActiveProfile returns the currently active profile.
func (*ProfileManager) GetGlobalConfig ¶ added in v0.13.0
func (pm *ProfileManager) GetGlobalConfig() (*GlobalConfig, error)
GetGlobalConfig retrieves the global configuration.
func (*ProfileManager) GetGlobalConfigPath ¶ added in v0.13.0
func (pm *ProfileManager) GetGlobalConfigPath() string
GetGlobalConfigPath returns the global config file path.
func (*ProfileManager) GetProfile ¶ added in v0.13.0
func (pm *ProfileManager) GetProfile(name string) (*Profile, error)
GetProfile retrieves a profile by name.
func (*ProfileManager) GetProfilesDir ¶ added in v0.13.0
func (pm *ProfileManager) GetProfilesDir() string
GetProfilesDir returns the profiles directory path.
func (*ProfileManager) ImportProfile ¶ added in v0.13.0
func (pm *ProfileManager) ImportProfile(data []byte, newName string) error
ImportProfile imports a profile from JSON.
func (*ProfileManager) ListProfiles ¶ added in v0.13.0
func (pm *ProfileManager) ListProfiles() ([]*Profile, error)
ListProfiles returns all available profiles.
func (*ProfileManager) MigrateOldConfig ¶ added in v0.13.0
func (pm *ProfileManager) MigrateOldConfig() error
MigrateOldConfig migrates from old config.json format to new profile system.
func (*ProfileManager) ProfileExists ¶ added in v0.13.0
func (pm *ProfileManager) ProfileExists(name string) bool
ProfileExists checks if a profile exists.
func (*ProfileManager) RenameProfile ¶ added in v0.50.0
func (pm *ProfileManager) RenameProfile(oldName, newName string) error
RenameProfile renames a profile.
func (*ProfileManager) SaveGlobalConfig ¶ added in v0.13.0
func (pm *ProfileManager) SaveGlobalConfig(config *GlobalConfig) error
SaveGlobalConfig saves the global configuration.
func (*ProfileManager) SetActiveProfile ¶ added in v0.13.0
func (pm *ProfileManager) SetActiveProfile(name string) error
SetActiveProfile sets the active profile.
func (*ProfileManager) UpdateProfile ¶ added in v0.13.0
func (pm *ProfileManager) UpdateProfile(profile *Profile) error
UpdateProfile updates an existing profile.
type ProfileSelector ¶ added in v0.49.0
type ProfileSelector struct {
// contains filtered or unexported fields
}
ProfileSelector is a Bubble Tea model for profile selection.
func NewProfileSelector ¶ added in v0.49.0
func NewProfileSelector(profiles []*Profile, activeProfile string) *ProfileSelector
NewProfileSelector creates a new profile selector.
func (*ProfileSelector) Init ¶ added in v0.49.0
func (m *ProfileSelector) Init() tea.Cmd
Init initializes the profile selector.
func (*ProfileSelector) Result ¶ added in v0.49.0
func (m *ProfileSelector) Result() ProfileSelectorResult
Result returns the result of the selection.
func (*ProfileSelector) Selected ¶ added in v0.49.0
func (m *ProfileSelector) Selected() *Profile
Selected returns the selected profile, or nil if canceled or creating new.
func (*ProfileSelector) Update ¶ added in v0.49.0
Update handles input and updates the profile selector state.
func (*ProfileSelector) View ¶ added in v0.49.0
func (m *ProfileSelector) View() string
View renders the profile selector.
type ProfileSelectorMode ¶ added in v0.50.0
type ProfileSelectorMode int
ProfileSelectorMode represents the current mode of the selector.
const ( ModeSelect ProfileSelectorMode = iota ModeRename ModeDeleteConfirm )
type ProfileSelectorResult ¶ added in v0.49.0
type ProfileSelectorResult int
ProfileSelectorResult represents the result of the profile selector.
const ( ProfileResultSelected ProfileSelectorResult = iota ProfileResultCreateNew ProfileResultCanceled ProfileResultRenamed ProfileResultDeleted )
type SecureInput ¶ added in v0.17.1
type SecureInput struct {
// contains filtered or unexported fields
}
SecureInput provides password-style masked input for API keys.
func NewSecureInput ¶ added in v0.17.1
func NewSecureInput(prompt, placeholder string, showLast4 bool) *SecureInput
NewSecureInput creates a new password-style input for API keys.
func (*SecureInput) Canceled ¶ added in v0.50.14
func (s *SecureInput) Canceled() bool
Canceled returns true if the user pressed Esc or Ctrl+C.
func (*SecureInput) Init ¶ added in v0.17.1
func (s *SecureInput) Init() tea.Cmd
Init initializes the secure input.
func (*SecureInput) Submitted ¶ added in v0.17.1
func (s *SecureInput) Submitted() bool
Submitted returns true if the user pressed Enter.
func (*SecureInput) Update ¶ added in v0.17.1
Update handles input and updates the secure input state.
func (*SecureInput) Value ¶ added in v0.17.1
func (s *SecureInput) Value() string
Value returns the entered value.
func (*SecureInput) View ¶ added in v0.17.1
func (s *SecureInput) View() string
View renders the secure input.
type TierMapping ¶ added in v0.13.0
type TierMapping struct {
Provider string `json:"provider,omitempty"`
Model string `json:"model"`
APIKey string `json:"api_key,omitempty"`
APIKeyEnv string `json:"api_key_env,omitempty"`
BaseURL string `json:"base_url,omitempty"`
}
TierMapping represents model mapping for a specific tier.
type Wizard ¶
type Wizard struct {
// contains filtered or unexported fields
}
Wizard handles the interactive setup process.
func (*Wizard) FetchModelsPublic ¶
func (w *Wizard) FetchModelsPublic(provider, apiKey, baseURL, azureEndpoint string) ([]string, error)
FetchModelsPublic is a public wrapper for fetchModels.
func (*Wizard) RunProfileCreate ¶ added in v0.13.0
RunProfileCreate runs the interactive profile creation wizard.
func (*Wizard) RunProfileDelete ¶ added in v0.13.0
RunProfileDelete removes a profile.
func (*Wizard) RunProfileExport ¶ added in v0.13.0
RunProfileExport exports a profile to a file.
func (*Wizard) RunProfileImport ¶ added in v0.13.0
RunProfileImport imports a profile from a file.
func (*Wizard) RunProfileList ¶ added in v0.13.0
RunProfileList displays all profiles.
func (*Wizard) RunProfileShow ¶ added in v0.13.0
RunProfileShow displays details for a specific or active profile.
func (*Wizard) RunProfileUse ¶ added in v0.13.0
RunProfileUse switches to a different profile.