Documentation
¶
Index ¶
- Constants
- type CodexAuthJSON
- type CodexConfig
- type CodexConfigTOML
- type CodexProvider
- type Config
- type ConfigurationApplier
- type ExtendedConfig
- type GitHubAsset
- type GitHubRelease
- type History
- type HistoryEntry
- type Manager
- func (m *Manager) CheckForUpdate(currentVersion string) (latestVersion string, hasUpdate bool, err error)
- func (m *Manager) ClearCurrentProfile() error
- func (m *Manager) CopyProfile(srcName, destName string) error
- func (m *Manager) DeleteProfile(name string) error
- func (m *Manager) GetCachedLatestVersion() string
- func (m *Manager) GetConfigDir() string
- func (m *Manager) GetCurrentProfile() (*Profile, error)
- func (m *Manager) GetCurrentProfileName() (string, error)
- func (m *Manager) GetEmptyConfig() Config
- func (m *Manager) GetHistory() ([]HistoryEntry, error)
- func (m *Manager) GetLatestRelease() (*GitHubRelease, error)
- func (m *Manager) GetPreviousProfileName() (string, error)
- func (m *Manager) GetProfilesDir() string
- func (m *Manager) GetTemplatesDir() string
- func (m *Manager) Initialize() error
- func (m *Manager) ListProfiles() ([]Profile, error)
- func (m *Manager) LoadProfile(name string) (*Profile, error)
- func (m *Manager) LoadUpdateCache() (*UpdateCache, error)
- func (m *Manager) ProfileExists(name string) bool
- func (m *Manager) RenameProfile(oldName, newName string) error
- func (m *Manager) SaveProfile(profile *Profile) error
- func (m *Manager) SaveUpdateCache(cache *UpdateCache) error
- func (m *Manager) SetCurrentProfile(name string) error
- func (m *Manager) ShouldCheckUpdate() bool
- type Profile
- type State
- type UpdateCache
Constants ¶
const ( ConfigDirName = ".codex-switch" ProfilesDirName = "profiles" TemplatesDirName = "templates" StateFileName = "state.yaml" ConfigFileName = "config.yaml" HistoryFileName = "history.yaml" UpdateCacheFileName = "update_cache.yaml" ExportExtension = ".cxs" // GitHub repository info for update checking GitHubRepoOwner = "HoBeedzc" GitHubRepoName = "codex-switch" GitHubAPIURL = "https://api.github.com/repos/" + GitHubRepoOwner + "/" + GitHubRepoName + "/releases/latest" // Default update check interval DefaultCheckIntervalHours = 24 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodexAuthJSON ¶
type CodexAuthJSON struct {
OpenAIAPIKey string `json:"OPENAI_API_KEY,omitempty"`
}
CodexAuthJSON represents the structure of ~/.codex/auth.json
type CodexConfig ¶
type CodexConfig struct {
ConfigName string `yaml:"config_name,omitempty" toml:"config_name,omitempty"`
ModelProvider string `yaml:"model_provider,omitempty" toml:"model_provider,omitempty"`
Model string `yaml:"model,omitempty" toml:"model,omitempty"`
ModelReasoningEffort string `yaml:"model_reasoning_effort,omitempty" toml:"model_reasoning_effort,omitempty"`
WireAPI string `yaml:"wire_api,omitempty" toml:"wire_api,omitempty"`
EnvKey string `yaml:"env_key,omitempty" toml:"env_key,omitempty"`
BaseURL string `yaml:"base_url,omitempty" toml:"base_url,omitempty"`
DisableResponseStorage bool `yaml:"disable_response_storage,omitempty" toml:"disable_response_storage,omitempty"`
RequiresOpenAIAuth bool `yaml:"requires_openai_auth,omitempty" toml:"requires_openai_auth,omitempty"`
}
CodexConfig represents the codex-specific configuration
type CodexConfigTOML ¶
type CodexConfigTOML struct {
ModelProvider string `toml:"model_provider"`
Model string `toml:"model"`
ModelReasoningEffort string `toml:"model_reasoning_effort"`
DisableResponseStorage bool `toml:"disable_response_storage"`
RequiresOpenAIAuth bool `toml:"requires_openai_auth"`
ModelProviders map[string]CodexProvider `toml:"model_providers"`
}
CodexConfigTOML represents the structure of ~/.codex/config.toml
type CodexProvider ¶
type CodexProvider struct {
Name string `toml:"name"`
BaseURL string `toml:"base_url"`
WireAPI string `toml:"wire_api"`
EnvKey string `toml:"env_key"`
}
CodexProvider represents a model provider configuration
type Config ¶
type Config struct {
APIKey string `yaml:"api_key,omitempty"`
BaseURL string `yaml:"base_url,omitempty"`
Model string `yaml:"model,omitempty"`
ModelReasoningEffort string `yaml:"model_reasoning_effort,omitempty"`
DisableResponseStorage bool `yaml:"disable_response_storage"`
RequiresOpenAIAuth bool `yaml:"requires_openai_auth"`
}
type ConfigurationApplier ¶
type ConfigurationApplier struct {
// contains filtered or unexported fields
}
ConfigurationApplier handles applying configuration profiles to external systems
func NewConfigurationApplier ¶
func NewConfigurationApplier(manager *Manager) (*ConfigurationApplier, error)
NewConfigurationApplier creates a new configuration applier
func (*ConfigurationApplier) ApplyProfile ¶
func (ca *ConfigurationApplier) ApplyProfile(profileName string) error
ApplyProfile applies the specified profile's configuration to external systems
func (*ConfigurationApplier) ClearCodexConfig ¶
func (ca *ConfigurationApplier) ClearCodexConfig() error
ClearCodexConfig removes all codex configuration files
func (*ConfigurationApplier) ReadCurrentCodexConfig ¶
func (ca *ConfigurationApplier) ReadCurrentCodexConfig() (*ExtendedConfig, error)
ReadCurrentCodexConfig reads the current Codex configuration from the actual files
func (*ConfigurationApplier) SaveCurrentConfigToProfile ¶
func (ca *ConfigurationApplier) SaveCurrentConfigToProfile(profileName string) error
SaveCurrentConfigToProfile saves the current Codex configuration back to the profile
type ExtendedConfig ¶
type ExtendedConfig struct {
Config `yaml:",inline"`
CodexConfig *CodexConfig `yaml:"codex_config,omitempty"`
}
ExtendedConfig extends the base config with real switching capabilities
type GitHubAsset ¶
type GitHubAsset struct {
Name string `json:"name"`
BrowserDownloadURL string `json:"browser_download_url"`
Size int64 `json:"size"`
}
GitHubAsset represents a release asset
type GitHubRelease ¶
type GitHubRelease struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
PublishedAt string `json:"published_at"`
Assets []GitHubAsset `json:"assets"`
}
GitHubRelease represents the GitHub release API response
type History ¶
type History struct {
Entries []HistoryEntry `yaml:"entries"`
}
type HistoryEntry ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) CheckForUpdate ¶
func (m *Manager) CheckForUpdate(currentVersion string) (latestVersion string, hasUpdate bool, err error)
CheckForUpdate checks GitHub for the latest version and updates the cache Returns the latest version and whether an update is available
func (*Manager) ClearCurrentProfile ¶
ClearCurrentProfile clears the current profile state (for empty mode)
func (*Manager) CopyProfile ¶
func (*Manager) DeleteProfile ¶
func (*Manager) GetCachedLatestVersion ¶
GetCachedLatestVersion returns the cached latest version without making network request
func (*Manager) GetConfigDir ¶
func (*Manager) GetCurrentProfile ¶
func (*Manager) GetCurrentProfileName ¶
func (*Manager) GetEmptyConfig ¶
GetEmptyConfig returns an empty configuration template
func (*Manager) GetHistory ¶
func (m *Manager) GetHistory() ([]HistoryEntry, error)
func (*Manager) GetLatestRelease ¶
func (m *Manager) GetLatestRelease() (*GitHubRelease, error)
GetLatestRelease fetches the latest release info from GitHub (exported for update command)
func (*Manager) GetPreviousProfileName ¶
func (*Manager) GetProfilesDir ¶
func (*Manager) GetTemplatesDir ¶
func (*Manager) Initialize ¶
func (*Manager) ListProfiles ¶
func (*Manager) LoadUpdateCache ¶
func (m *Manager) LoadUpdateCache() (*UpdateCache, error)
LoadUpdateCache loads the update cache from file
func (*Manager) ProfileExists ¶
ProfileExists checks if a profile with the given name exists
func (*Manager) RenameProfile ¶
func (*Manager) SaveProfile ¶
func (*Manager) SaveUpdateCache ¶
func (m *Manager) SaveUpdateCache(cache *UpdateCache) error
SaveUpdateCache saves the update cache to file
func (*Manager) SetCurrentProfile ¶
func (*Manager) ShouldCheckUpdate ¶
ShouldCheckUpdate determines if an update check is needed based on cache