config

package
v0.2.1 Latest Latest
Warning

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

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

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

View Source
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

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 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"`
	Project      ProjectSettings  `yaml:"project,omitempty"`
	Behavior     BehaviorSettings `yaml:"behavior,omitempty"`
	Feedback     FeedbackSettings `yaml:"feedback,omitempty"`
}

func GetDefaultConfig

func GetDefaultConfig() *Config

func LoadConfig

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

func MergeWithDefaults

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

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 GitSettings struct {
	DefaultRemote     string `yaml:"defaultRemote,omitempty"`
	DefaultMainBranch string `yaml:"defaultMainBranch,omitempty"`
}

type LoggingSettings

type LoggingSettings struct {
	Enable           *bool  `yaml:"enable,omitempty"`
	DefaultAILogFile string `yaml:"defaultAILogFile,omitempty"`
}

type ProjectSettings added in v0.2.1

type ProjectSettings struct {
	Provider string `yaml:"provider,omitempty"`
}

type ProjectState added in v0.1.1

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

type RunSettings added in v0.2.1

type RunSettings struct {
	Examples map[string]ExampleSettings `yaml:"examples,omitempty"`
}

type SystemPromptSettings added in v0.2.1

type SystemPromptSettings struct {
	DefaultOutputFiles map[string]string `yaml:"defaultOutputFiles,omitempty"`
}

type ValidationRule

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

type VerificationCheck added in v0.2.1

type VerificationCheck struct {
	Name        string   `yaml:"name"`
	Description string   `yaml:"description,omitempty"`
	Command     string   `yaml:"command"`
	Args        []string `yaml:"args,omitempty"`
}

Jump to

Keyboard shortcuts

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