config

package
v0.0.0-...-f318275 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxRetries       = 3
	DefaultMaxDiffLines     = 10
	DefaultCommitMsgTimeout = 30 * time.Second
	DefaultRequestTimeout   = 30 * time.Second
	DefaultLogFilePerms     = os.FileMode(0o666)
	DefaultLogDirPerms      = os.FileMode(0o755)
	DefaultPermissionsMask  = os.FileMode(0o777)
	DefaultLineLength       = 72

	// Common time formats
	TimeFormatRFC3339 = "2006-01-02T15:04:05Z07:00"
	TimeFormatUnix    = "2006-01-02 15:04:05"
	TimeFormatSimple  = "2006-01-02"
)

Variables

This section is empty.

Functions

func ParseFlags

func ParseFlags(cfg *Config) error

func SetDefaults

func SetDefaults()

Types

type CLIConfig

type CLIConfig struct {
	Command string
}

type Config

type Config struct {
	Logging   LoggingConfig `mapstructure:"logging"`
	Git       GitConfig     `mapstructure:"git"`
	LLM       LLMConfig     `mapstructure:"llm"`
	Functions []LLMFunction `mapstructure:"functions"`
	Command   string        `mapstructure:"command"`
	Version   VersionConfig `mapstructure:"version"`
	NoConfirm bool          `mapstructure:"no_confirm"`
}

func Load

func Load() (*Config, error)

type EnvironmentConfig

type EnvironmentConfig struct {
	Name       string      `mapstructure:"name"`
	TimeFormat string      `mapstructure:"timeformat"`
	Output     string      `mapstructure:"output"`
	Level      string      `mapstructure:"level"`
	Path       string      `mapstructure:"file_path,omitempty"`
	FilePerms  os.FileMode `mapstructure:"file_perms,omitempty"`
	DirPerms   os.FileMode `mapstructure:"dir_perms,omitempty"`
}

func (*EnvironmentConfig) Validate

func (c *EnvironmentConfig) Validate() error

type FunctionParameters

type FunctionParameters struct {
	Type       string              `mapstructure:"type"       yaml:"type"`
	Properties map[string]Property `mapstructure:"properties" yaml:"properties"`
	Required   []string            `mapstructure:"required"   yaml:"required"`
}

type GitConfig

type GitConfig struct {
	IncludeGitignore    bool     `mapstructure:"include_gitignore"`
	Ignore              []string `mapstructure:"ignore"`
	MaxDiffLines        int      `mapstructure:"max_diff_lines"`
	PreferredLineLength int      `mapstructure:"preferred_line_length"`
}

type LLMConfig

type LLMConfig struct {
	Provider         string
	Model            string
	BaseURL          string        `mapstructure:"base_url"`
	APIKey           string        `mapstructure:"api_key,omitempty"` // Make API key optional
	MaxRetries       int           `mapstructure:"max_retries"`
	CommitMsgTimeout time.Duration `mapstructure:"commit_msg_timeout"`
	RequestTimeout   time.Duration `mapstructure:"request_timeout"`
}

type LLMFunction

type LLMFunction struct {
	Name         string             `mapstructure:"name"          yaml:"name"`
	Description  string             `mapstructure:"description"   yaml:"description"`
	Parameters   FunctionParameters `mapstructure:"parameters"    yaml:"parameters"`
	SystemPrompt string             `mapstructure:"system_prompt" yaml:"system_prompt"` //nolint:tagliatelle // Following OpenAI API spec
	UserPrompt   string             `mapstructure:"user_prompt"   yaml:"user_prompt"`   //nolint:tagliatelle // Following OpenAI API spec
}

func FindFunction

func FindFunction(functions []LLMFunction, name string) *LLMFunction

type LoggingConfig

type LoggingConfig struct {
	Environment  string              `mapstructure:"environment"`
	TimeFormat   string              `mapstructure:"timeformat"`
	Output       string              `mapstructure:"output"`
	Level        string              `mapstructure:"level"`
	Path         string              `mapstructure:"file_path"`
	FilePerms    os.FileMode         `mapstructure:"file_perms"`
	DirPerms     os.FileMode         `mapstructure:"dir_perms"`
	Environments []EnvironmentConfig `mapstructure:"environments"`
}

func LoadInitialLogging

func LoadInitialLogging() (*LoggingConfig, error)

func (*LoggingConfig) ActiveEnvironment

func (c *LoggingConfig) ActiveEnvironment() *EnvironmentConfig

func (*LoggingConfig) ToLoggerConfig

func (c *LoggingConfig) ToLoggerConfig() logger.Config

type Property

type Property struct {
	Type        string    `mapstructure:"type"            yaml:"type"`
	Description string    `mapstructure:"description"     yaml:"description"`
	Enum        []string  `mapstructure:"enum,omitempty"  yaml:"enum,omitempty"`
	Items       *Property `mapstructure:"items,omitempty" yaml:"items,omitempty"`
}

type VersionConfig

type VersionConfig struct {
	Current    string        `mapstructure:"current"`
	Git        VersionGit    `mapstructure:"git"`
	Prerelease []string      `mapstructure:"prerelease"`
	Files      []VersionFile `mapstructure:"files"`
	Alpha      bool          `mapstructure:"alpha"`
	Beta       bool          `mapstructure:"beta"`
	RC         bool          `mapstructure:"rc"`
}

func (*VersionConfig) Validate

func (v *VersionConfig) Validate() error

type VersionFile

type VersionFile struct {
	Path    string   `yaml:"path"`
	Replace []string `yaml:"replace"`
}

type VersionGit

type VersionGit struct {
	Commit  bool `yaml:"commit"`
	Tag     bool `yaml:"tag"`
	Signage bool `yaml:"signage"`
}

Jump to

Keyboard shortcuts

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