config

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultProvider       = "phind"
	DefaultOpenAIModel    = "chatgpt-4o-latest"
	DefaultGeminiModel    = "models/gemini-2.0-flash"
	DefaultAnthropicModel = "claude-3-7-sonnet-latest"
	DefaultDeepseekModel  = "deepseek-chat"
	DefaultPhindModel     = "Phind-70B"
	DefaultOllamaModel    = "llama2"
	DefaultOllamaBaseURL  = "http://localhost:11434"
)

Variables

View Source
var (
	DefaultAuthorName  = "ai-commit"
	DefaultAuthorEmail = "ai-commit@example.com"
)

Functions

func ResolveAPIKey

func ResolveAPIKey(flagVal, envVar, configVal, provider string) (string, error)

Types

type CommitTypeConfig added in v0.4.0

type CommitTypeConfig struct {
	Type  string `yaml:"type,omitempty"`
	Emoji string `yaml:"emoji,omitempty"`
}

CommitTypeConfig holds a commit type + its optional emoji. This is loaded from config.yaml so we can easily add/delete as needed.

type Config

type Config struct {
	Prompt           string             `yaml:"prompt,omitempty"`
	CommitType       string             `yaml:"commitType,omitempty"`
	Template         string             `yaml:"template,omitempty"`
	SemanticRelease  bool               `yaml:"semanticRelease,omitempty"`
	InteractiveSplit bool               `yaml:"interactiveSplit,omitempty"`
	EnableEmoji      bool               `yaml:"enableEmoji,omitempty"`
	Provider         string             `yaml:"provider,omitempty" validate:"omitempty,oneof=openai gemini anthropic deepseek phind ollama"`
	CommitTypes      []CommitTypeConfig `yaml:"commitTypes,omitempty"`
	LockFiles        []string           `yaml:"lockFiles,omitempty"`

	OpenAIAPIKey    string `yaml:"openAiApiKey,omitempty"`
	OpenAIModel     string `yaml:"openaiModel,omitempty"`
	GeminiAPIKey    string `yaml:"geminiApiKey,omitempty"`
	GeminiModel     string `yaml:"geminiModel,omitempty"`
	AnthropicAPIKey string `yaml:"anthropicApiKey,omitempty"`
	AnthropicModel  string `yaml:"anthropicModel,omitempty"`
	DeepseekAPIKey  string `yaml:"deepseekApiKey,omitempty"`
	DeepseekModel   string `yaml:"deepseekModel,omitempty"`
	PhindAPIKey     string `yaml:"phindApiKey,omitempty"`
	PhindModel      string `yaml:"phindModel,omitempty"`
	OllamaBaseURL   string `yaml:"ollamaBaseURL,omitempty"`
	OllamaModel     string `yaml:"ollamaModel,omitempty"`
	PromptTemplate  string `yaml:"promptTemplate,omitempty"`

	AuthorName  string `yaml:"authorName,omitempty"`
	AuthorEmail string `yaml:"authorEmail,omitempty"`
}

func LoadOrCreateConfig

func LoadOrCreateConfig() (*Config, error)

LoadOrCreateConfig reads the config from ~/.config/<binary>/config.yaml or creates a default one.

func (*Config) Validate

func (cfg *Config) Validate() error

type ConfigManager added in v0.4.0

type ConfigManager struct {
	Config *Config
	Flags  map[string]interface{}
}

ConfigManager handles merging CLI flags into the Config struct. Priority: CLI flags > Config file > Default values.

func NewConfigManager added in v0.4.0

func NewConfigManager(cfg *Config) *ConfigManager

NewConfigManager creates a new ConfigManager instance.

func (*ConfigManager) MergeConfiguration added in v0.4.0

func (cm *ConfigManager) MergeConfiguration() *Config

MergeConfiguration uses reflection to merge CLI flag values into the Config struct. It only overrides fields if the CLI flag value is non-zero.

func (*ConfigManager) RegisterFlag added in v0.4.0

func (cm *ConfigManager) RegisterFlag(key string, value interface{})

RegisterFlag registers a CLI flag value with the corresponding config key. The key should match the YAML tag used in the Config struct.

Jump to

Keyboard shortcuts

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