Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultProvider = "openai"
)

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"`
}

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"`
	CommitTypes []CommitTypeConfig `yaml:"commitTypes,omitempty"`
	LockFiles   []string           `yaml:"lockFiles,omitempty"`
	Limits      Limits             `yaml:"limits,omitempty"`

	// Enterprise-style provider configuration. Preferred over legacy flat fields below.
	Providers map[string]ProviderSettings `yaml:"providers,omitempty"`

	PromptTemplate string `yaml:"promptTemplate,omitempty"`
	TicketPattern  string `yaml:"ticketPattern,omitempty"`

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

func LoadOrCreateConfig

func LoadOrCreateConfig() (*Config, error)

func (*Config) GetProviderSettings added in v0.9.0

func (cfg *Config) GetProviderSettings(name string) ProviderSettings

GetProviderSettings fetches settings from the Providers map and fills defaults.

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.

type LimitSettings added in v0.9.0

type LimitSettings struct {
	Enabled  bool `yaml:"enabled,omitempty"`
	MaxChars int  `yaml:"maxChars,omitempty"`
}

type Limits added in v0.9.0

type Limits struct {
	Diff   LimitSettings `yaml:"diff,omitempty"`
	Prompt LimitSettings `yaml:"prompt,omitempty"`
}

type ProviderSettings added in v0.9.0

type ProviderSettings struct {
	APIKey  string `yaml:"apiKey,omitempty"`
	Model   string `yaml:"model,omitempty"`
	BaseURL string `yaml:"baseURL,omitempty"`
}

ProviderSettings holds credentials and routing for a provider.

Jump to

Keyboard shortcuts

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