Documentation
¶
Overview ¶
Package config handles configuration loading, saving, and credential management.
Index ¶
- Constants
- Variables
- func ClearConfig() error
- func DefaultDBPath() string
- func GetAPIKeyForProvider(provider string) (string, error)
- func GetGeminiAPIKey() (string, error)
- func GetGitHubPAT() (string, error)
- func IsConfigured() bool
- func SaveConfig(cfg *Config, githubPAT, geminiAPIKey string) error
- func SaveConfigFile(cfg *Config) error
- func SetAPIKeyForProvider(provider, key string) error
- func SetKeyringBackend(kb KeyringBackend)
- type Config
- type KeyringBackend
- type ProviderConfig
Constants ¶
const ( // KeyringService is the service name used for keyring storage. KeyringService = "repog" // KeyringGitHubPAT is the keyring key for the GitHub PAT. KeyringGitHubPAT = "github_pat" // KeyringGeminiAPIKey is the keyring key for the Gemini API key. KeyringGeminiAPIKey = "gemini_api_key" // KeyringOpenAIAPIKey is the keyring key for the OpenAI API key. KeyringOpenAIAPIKey = "openai_api_key" // KeyringOpenRouterAPIKey is the keyring key for the OpenRouter API key. KeyringOpenRouterAPIKey = "openrouter_api_key" // KeyringAnthropicAPIKey is the keyring key for the Anthropic API key. KeyringAnthropicAPIKey = "anthropic_api_key" // KeyringVoyageAIAPIKey is the keyring key for the Voyage AI API key. KeyringVoyageAIAPIKey = "voyageai_api_key" // ConfigVersion is the current config file version. ConfigVersion = 3 )
Variables ¶
var ErrNotConfigured = errors.New("repog is not configured — run `repog init` first")
ErrNotConfigured is returned when repog has not been initialised.
Functions ¶
func ClearConfig ¶
func ClearConfig() error
ClearConfig removes the config file and deletes keyring entries.
func GetAPIKeyForProvider ¶ added in v0.2.0
GetAPIKeyForProvider retrieves the API key for a specific provider from the keyring.
func GetGeminiAPIKey ¶
GetGeminiAPIKey retrieves the Gemini API key from the keyring.
func GetGitHubPAT ¶
GetGitHubPAT retrieves the GitHub PAT from the keyring.
func IsConfigured ¶
func IsConfigured() bool
IsConfigured returns true if config file exists and both secrets are present in the keyring.
func SaveConfig ¶
SaveConfig writes config to disk and stores secrets in the keyring. Deprecated: Use SaveConfigFile and SetAPIKeyForProvider for new multi-provider setup.
func SaveConfigFile ¶ added in v0.2.0
SaveConfigFile writes the config file to disk without storing API keys. Use SetAPIKeyForProvider to store API keys in the keyring separately.
func SetAPIKeyForProvider ¶ added in v0.2.0
SetAPIKeyForProvider stores the API key for a specific provider in the keyring.
func SetKeyringBackend ¶
func SetKeyringBackend(kb KeyringBackend)
SetKeyringBackend sets the keyring backend (for testing).
Types ¶
type Config ¶
type Config struct {
DBPath string `yaml:"db_path"`
ConfigVersion int `yaml:"config_version"`
Embedding ProviderConfig `yaml:"embedding"`
Generation ProviderConfig `yaml:"generation"`
}
Config represents the on-disk configuration.
func LoadConfig ¶
LoadConfig reads config from disk. Returns ErrNotConfigured if config file does not exist or required secrets are missing from the keyring. Automatically migrates v2 configs to v3 with Gemini defaults.
type KeyringBackend ¶
type KeyringBackend interface {
Set(service, key, value string) error
Get(service, key string) (string, error)
Delete(service, key string) error
}
KeyringBackend defines the interface for keyring operations. This allows mocking in tests.
type ProviderConfig ¶ added in v0.2.0
type ProviderConfig struct {
Provider string `yaml:"provider"` // gemini, ollama, openrouter
Model string `yaml:"model"` // model name
Dimensions int `yaml:"dimensions,omitempty"` // embedding dimensions (embedding only)
MaxTokens int `yaml:"max_tokens,omitempty"` // custom max token limit (embedding only, 0 = use model default)
BaseURL string `yaml:"base_url,omitempty"` // custom base URL (ollama/openrouter)
Fallback string `yaml:"fallback,omitempty"` // fallback model (LLM only)
}
ProviderConfig represents configuration for an AI provider
func DefaultEmbeddingConfig ¶ added in v0.2.0
func DefaultEmbeddingConfig() ProviderConfig
DefaultEmbeddingConfig returns the default Gemini embedding configuration.
func DefaultGenerationConfig ¶ added in v0.2.0
func DefaultGenerationConfig() ProviderConfig
DefaultGenerationConfig returns the default Gemini generation configuration.