config

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config handles configuration loading, saving, and credential management.

Index

Constants

View Source
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

View Source
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 DefaultDBPath

func DefaultDBPath() string

DefaultDBPath returns the default database path.

func GetAPIKeyForProvider added in v0.2.0

func GetAPIKeyForProvider(provider string) (string, error)

GetAPIKeyForProvider retrieves the API key for a specific provider from the keyring.

func GetGeminiAPIKey

func GetGeminiAPIKey() (string, error)

GetGeminiAPIKey retrieves the Gemini API key from the keyring.

func GetGitHubPAT

func GetGitHubPAT() (string, error)

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

func SaveConfig(cfg *Config, githubPAT, geminiAPIKey string) error

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

func SaveConfigFile(cfg *Config) error

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

func SetAPIKeyForProvider(provider, key string) error

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

func LoadConfig() (*Config, error)

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.

Jump to

Keyboard shortcuts

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