config

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package config loads and merges git-courer configuration. Merge order: defaults → global (~/.config/git-courer/config.yaml) → project (.gcourer/config.yaml).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GlobalConfigPath

func GlobalConfigPath() string

GlobalConfigPath returns the platform-appropriate global config path.

func ProjectConfigPaths

func ProjectConfigPaths(workDir string) []string

ProjectConfigPaths returns possible project config paths (first match wins).

Types

type BackupConfig

type BackupConfig struct {
	Enabled bool `yaml:"enabled"` // [USER] Enable auto-backup
}

BackupConfig holds settings for the automatic backup system. [USER] Before every destructive _APPLY, git-courer creates a ref + optional stash. On success the backup is deleted. On failure it auto-restores and notifies the user.

type CommandsConfig

type CommandsConfig struct {
	EnabledOperations []string `yaml:"enabled_operations"` // [USER] List of enabled operation keys
}

CommandsConfig holds settings for enabled/disabled workflow commands. [USER] Which operations are allowed to run.

func (CommandsConfig) IsEnabled

func (c CommandsConfig) IsEnabled(operationKey string) bool

IsEnabled returns true if the given operation is in the list of enabled operations.

type CommitConfig

type CommitConfig struct {
	TTL                 DurationConfig `yaml:"ttl"`                  // [USER] Plan TTL
	MaxPlanRetries      int            `yaml:"max_plan_retries"`     // [USER] Max retries for plan
	LockFile            string         `yaml:"lock_file"`            // [INTERNAL] Lock file path
	PlanFile            string         `yaml:"plan_file"`            // [INTERNAL] Plan file path
	BlockerFile         string         `yaml:"blocker_file"`         // [INTERNAL] Blocker file path
	LogPath             string         `yaml:"log_path"`             // [USER] Log file path
	MaxLogLines         int            `yaml:"max_log_lines"`        // [USER] Max log lines
	BackgroundThreshold int            `yaml:"background_threshold"` // [USER] Background threshold
}

CommitConfig holds commit-related settings including plan TTL and file paths. [USER] Configure commit workflow behavior.

type Config

type Config struct {
	Ollama     OllamaConfig     `yaml:"ollama"`     // [USER] Ollama AI settings
	Git        GitConfig        `yaml:"git"`        // [USER] Git behavior settings
	Secrets    SecretsConfig    `yaml:"secrets"`    // [USER] Secrets detection
	Validation ValidationConfig `yaml:"validation"` // [USER] Validation behavior
	MCP        MCPConfig        `yaml:"mcp"`        // [USER] MCP server config
	Preview    PreviewConfig    `yaml:"preview"`    // [USER] Preview/confirmation settings
	Commit     CommitConfig     `yaml:"commit"`     // [USER] Commit workflow settings
	Release    ReleaseConfig    `yaml:"release"`    // [USER] Release workflow settings
	Commands   CommandsConfig   `yaml:"commands"`   // [USER] Enabled operations
	Backup     BackupConfig     `yaml:"backup"`     // [USER] Auto-backup settings
}

Config represents the git-courer configuration. [USER] fields are editable by users via config files. [INTERNAL] fields are managed by git-courer and should not be manually edited.

func Default

func Default() *Config

Default returns the default configuration.

func Load

func Load() (*Config, error)

Load loads configuration from the current directory.

func LoadFromDir

func LoadFromDir(workDir string) (*Config, error)

LoadFromDir loads configuration with cascade: defaults → global → project.

func (*Config) SaveGlobal

func (c *Config) SaveGlobal() error

SaveGlobal saves the config to the global config path.

type DurationConfig

type DurationConfig struct {
	time.Duration
}

DurationConfig wraps time.Duration for YAML unmarshaling.

func NewDurationConfig

func NewDurationConfig(d time.Duration) DurationConfig

NewDurationConfig creates a DurationConfig with the given duration.

func (DurationConfig) MarshalYAML

func (d DurationConfig) MarshalYAML() (interface{}, error)

MarshalYAML implements custom marshaling for DurationConfig.

func (*DurationConfig) UnmarshalYAML

func (d *DurationConfig) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements custom unmarshaling for DurationConfig.

type GitConfig

type GitConfig struct {
	WorkDir          string `yaml:"workdir"`            // [USER] Default working directory
	AutoAddSecrets   bool   `yaml:"auto_add_secrets"`   // [USER] Auto-stage detected secrets
	RequireCleanRepo bool   `yaml:"require_clean_repo"` // [USER] Require clean working tree
}

GitConfig holds git-related settings. [USER] Configure git behavior.

type MCPConfig

type MCPConfig struct {
	Name    string `yaml:"name"`    // [INTERNAL] MCP server name
	Version string `yaml:"version"` // [INTERNAL] MCP server version
}

MCPConfig holds MCP server settings. [INTERNAL] Managed by git-courer setup.

type OllamaConfig

type OllamaConfig struct {
	Host          string `yaml:"host"`           // [USER] Ollama server URL
	Model         string `yaml:"model"`          // [USER] Model to use
	ContextWindow int    `yaml:"context_window"` // [USER] Context window size (0 = default)
	AutoStart     bool   `yaml:"auto_start"`     // [USER] Auto-start Ollama if not running
	ModelsDir     string `yaml:"models_dir"`     // [USER] Custom models directory
}

OllamaConfig holds Ollama-related settings. [USER] Configure the Ollama AI backend.

type PreviewConfig

type PreviewConfig struct {
	Enabled    bool            `yaml:"enabled"`    // [USER] Enable preview mode
	Operations map[string]bool `yaml:"operations"` // [USER] Operations requiring preview
}

PreviewConfig holds preview/confirmation settings. [USER] Configure preview dialogs and confirmations.

func (PreviewConfig) IsRequired

func (p PreviewConfig) IsRequired(operationKey string) bool

IsRequired returns true if confirmation is required for the given operation key.

type ReleaseConfig

type ReleaseConfig struct {
	LogPath            string `yaml:"log_path"`              // [USER] Log file path
	MaxLogLines        int    `yaml:"max_log_lines"`         // [USER] Max log lines
	MaxCommitsPerChunk int    `yaml:"max_commits_per_chunk"` // [USER] Max commits per chunk
}

ReleaseConfig holds release-related settings. [USER] Configure release workflow behavior.

type SecretsConfig

type SecretsConfig struct {
	DetectionMode      string   `yaml:"detection_mode"`        // [USER] Detection mode: regex, ai, regex+ai
	Patterns           []string `yaml:"patterns"`              // [USER] Regex patterns for secrets
	UseLLMSecurityScan string   `yaml:"use_llm_security_scan"` // [USER] Use LLM for security scan
}

SecretsConfig holds secrets detection settings. [USER] Configure secrets detection.

type ValidationConfig

type ValidationConfig struct {
	RequireConfirmation bool `yaml:"require_confirmation"` // [USER] Ask before executing
	MaxCommitLength     int  `yaml:"max_commit_length"`    // [USER] Max commit message length
}

ValidationConfig holds validation settings.

Jump to

Keyboard shortcuts

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