Documentation
¶
Overview ¶
internal/config/config.go
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
- func FindRepoRootConfigPath(execClient *exec.ExecutorClient) (string, error)
- func UpdateAndSaveConfig(cfgToSave *Config, filePath string) error
- type AICollaborationPreferences
- type AISettings
- type BehaviorSettings
- type Config
- type DescribeSettings
- type ExampleSettings
- type ExportSettings
- type FeedbackSettings
- type GitSettings
- type LoggingSettings
- type ProjectSettings
- type ProjectState
- type RunSettings
- type SystemPromptSettings
- type ValidationRule
- type VerificationCheck
Constants ¶
const ( DefaultConfigFileName = ".contextvibes.yaml" DefaultCodemodFilename = "codemod.json" DefaultDescribeOutputFile = "contextvibes.md" StrategicKickoffFilename = "docs/strategic_kickoff_protocol.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
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 BehaviorSettings ¶ added in v0.2.1
type BehaviorSettings struct {
DualOutput bool `yaml:"dualOutput,omitempty"`
}
type Config ¶
type Config struct {
Git GitSettings `yaml:"git,omitempty"`
Logging LoggingSettings `yaml:"logging,omitempty"`
SystemPrompt SystemPromptSettings `yaml:"systemPrompt,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"`
Run RunSettings `yaml:"run,omitempty"`
Export ExportSettings `yaml:"export,omitempty"`
Describe DescribeSettings `yaml:"describe,omitempty"`
Project ProjectSettings `yaml:"project,omitempty"`
Behavior BehaviorSettings `yaml:"behavior,omitempty"`
Feedback FeedbackSettings `yaml:"feedback,omitempty"`
}
func GetDefaultConfig ¶
func GetDefaultConfig() *Config
func LoadConfig ¶
func MergeWithDefaults ¶
type DescribeSettings ¶ added in v0.4.0
type ExampleSettings ¶ added in v0.2.1
type ExampleSettings struct {
Verify []VerificationCheck `yaml:"verify,omitempty"`
}
type ExportSettings ¶ added in v0.2.1
type ExportSettings struct {
ExcludePatterns []string `yaml:"excludePatterns,omitempty"`
}
type FeedbackSettings ¶ added in v0.2.1
type FeedbackSettings struct {
DefaultRepository string `yaml:"defaultRepository,omitempty"`
Repositories map[string]string `yaml:"repositories,omitempty"`
}
FeedbackSettings configures the 'feedback' command.
type GitSettings ¶
type LoggingSettings ¶
type ProjectSettings ¶ added in v0.2.1
type ProjectSettings struct {
Provider string `yaml:"provider,omitempty"`
}
type ProjectState ¶ added in v0.1.1
type RunSettings ¶ added in v0.2.1
type RunSettings struct {
Examples map[string]ExampleSettings `yaml:"examples,omitempty"`
}