config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config manages the configuration for the contextvibes CLI application.

It defines the structure of the configuration, provides functions to load configuration from a YAML file (defaulting to '.contextvibes.yaml' in the project root), and offers a way to get default configuration values.

The primary components are:

  • Config: The main struct holding all configuration settings, including Git behavior, logging preferences, and validation rules for branch names and commit messages.
  • GitSettings, LoggingSettings, ValidationRule: Sub-structs organizing related configuration items.
  • GetDefaultConfig(): Returns a pointer to a Config struct populated with sensible default values.
  • LoadConfig(filePath string): Attempts to load configuration from the specified YAML file. Returns nil if the file doesn't exist, allowing graceful fallback to defaults.
  • FindRepoRootConfigPath(execClient *exec.ExecutorClient): Locates the configuration file by searching upwards from the current directory to the Git repository root.
  • MergeWithDefaults(loadedCfg *Config, defaultConfig *Config): Merges a loaded user configuration with the default configuration, giving precedence to user-defined values.

Constants are also defined for default filenames (e.g., DefaultConfigFileName, DefaultCodemodFilename, DefaultDescribeOutputFile, UltimateDefaultAILogFilename) and default patterns for validation. These constants are intended to be used by CLI commands to ensure consistent default behavior.

The typical flow involves: 1. Attempting to find and load a user-defined '.contextvibes.yaml' file. 2. If found and valid, merging it with the application's default configuration. 3. If not found or invalid, using the application's default configuration directly. The resulting configuration is then used throughout the application, particularly by the cmd package to influence command behavior.

Index

Constants

View Source
const (
	DefaultConfigFileName        = ".contextvibes.yaml"
	DefaultCodemodFilename       = "codemod.json"
	DefaultDescribeOutputFile    = "contextvibes.md"
	DefaultBranchNamePattern     = `^((feature|fix|docs|format)/.+)$`
	DefaultCommitMessagePattern  = `^(BREAKING|feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([a-zA-Z0-9\-_/]+\))?:\s.+`
	DefaultGitRemote             = "origin"
	DefaultGitMainBranch         = "main"
	UltimateDefaultAILogFilename = "contextvibes_ai_trace.log"
)

Variables

This section is empty.

Functions

func FindRepoRootConfigPath

func FindRepoRootConfigPath(execClient *exec.ExecutorClient) (string, error)

func UpdateAndSaveConfig added in v0.1.1

func UpdateAndSaveConfig(cfgToSave *Config, filePath string) error

Types

type AICollaborationPreferences added in v0.1.1

type AICollaborationPreferences struct {
	CodeProvisioningStyle string `yaml:"codeProvisioningStyle,omitempty"`
	MarkdownDocsStyle     string `yaml:"markdownDocsStyle,omitempty"`
	DetailedTaskMode      string `yaml:"detailedTaskMode,omitempty"`
	ProactiveDetailLevel  string `yaml:"proactiveDetailLevel,omitempty"`
	AIProactivity         string `yaml:"aiProactivity,omitempty"`
}

type AISettings added in v0.1.1

type AISettings struct {
	CollaborationPreferences AICollaborationPreferences `yaml:"collaborationPreferences,omitempty"`
}

type Config

type Config struct {
	Git        GitSettings     `yaml:"git,omitempty"`
	Logging    LoggingSettings `yaml:"logging,omitempty"`
	Validation struct {
		BranchName    ValidationRule `yaml:"branchName,omitempty"`
		CommitMessage ValidationRule `yaml:"commitMessage,omitempty"`
	} `yaml:"validation,omitempty"`
	ProjectState ProjectState `yaml:"projectState,omitempty"`
	AI           AISettings   `yaml:"ai,omitempty"`
}

func GetDefaultConfig

func GetDefaultConfig() *Config

func LoadConfig

func LoadConfig(filePath string) (*Config, error)

func MergeWithDefaults

func MergeWithDefaults(loadedCfg *Config, defaultConfig *Config) *Config

type GitSettings

type GitSettings struct {
	DefaultRemote     string `yaml:"defaultRemote,omitempty"`
	DefaultMainBranch string `yaml:"defaultMainBranch,omitempty"`
}

type LoggingSettings

type LoggingSettings struct {
	DefaultAILogFile string `yaml:"defaultAILogFile,omitempty"`
}

type ProjectState added in v0.1.1

type ProjectState struct {
	StrategicKickoffCompleted *bool  `yaml:"strategicKickoffCompleted,omitempty"`
	LastStrategicKickoffDate  string `yaml:"lastStrategicKickoffDate,omitempty"`
}

type ValidationRule

type ValidationRule struct {
	Enable  *bool  `yaml:"enable,omitempty"`
	Pattern string `yaml:"pattern,omitempty"`
}

Jump to

Keyboard shortcuts

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