config

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config provides configuration file support for llm-semantic commands. It enables YAML-based configuration with profile switching for code/docs/memory indexes.

Package config provides configuration file support for llm-semantic commands. This file contains config-specific error constructors following the SemanticError pattern.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrConfigEmpty

func ErrConfigEmpty(path string) *semantic.SemanticError

ErrConfigEmpty creates an error for when the config file is empty

func ErrConfigInvalidYAML

func ErrConfigInvalidYAML(path string, cause error) *semantic.SemanticError

ErrConfigInvalidYAML creates an error for invalid YAML syntax It extracts line/column information from goccy/go-yaml errors when available

func ErrConfigMissingSemantic

func ErrConfigMissingSemantic(path string) *semantic.SemanticError

ErrConfigMissingSemantic creates an error for when the semantic: section is missing

func ErrConfigNotFound

func ErrConfigNotFound(path string) *semantic.SemanticError

ErrConfigNotFound creates an error for when the config file doesn't exist

func ErrConfigPathEmpty

func ErrConfigPathEmpty() *semantic.SemanticError

ErrConfigPathEmpty creates an error for when the config path is empty or whitespace

func ErrConfigPermissionDenied

func ErrConfigPermissionDenied(path string, cause error) *semantic.SemanticError

ErrConfigPermissionDenied creates an error for when the config file cannot be read

func ErrNoProfilesDefined

func ErrNoProfilesDefined() *semantic.SemanticError

ErrNoProfilesDefined creates an error for when no profiles section exists

func ErrProfileInvalidValue

func ErrProfileInvalidValue(profile, field, expected, actual string) *semantic.SemanticError

ErrProfileInvalidValue creates an error for invalid profile field values

func ErrProfileNotFound

func ErrProfileNotFound(name string, available []string) *semantic.SemanticError

ErrProfileNotFound creates an error for when the profile doesn't exist

func IsValidProfile

func IsValidProfile(profile string) bool

IsValidProfile checks if the given profile name is valid. Empty string is valid (defaults to "code").

func ResolveFloatValue

func ResolveFloatValue(explicit, configValue, defaultValue float64) float64

ResolveFloatValue returns the first non-zero value from explicit, config, or default. This implements the precedence: explicit > config > default.

func ResolveIntValue

func ResolveIntValue(explicit, configValue, defaultValue int) int

ResolveIntValue returns the first non-zero value from explicit, config, or default. This implements the precedence: explicit > config > default.

func ResolveValue

func ResolveValue(explicit, configValue string) string

ResolveValue returns the explicit value if non-empty, otherwise the config value. This implements the precedence: explicit > config > default.

func ValidProfiles

func ValidProfiles() []string

ValidProfiles returns the list of valid profile names.

func WrapReadError

func WrapReadError(path string, err error) *semantic.SemanticError

WrapReadError wraps an os error from reading a config file with appropriate SemanticError

Types

type ProfileConfig

type ProfileConfig struct {
	Collection string
	Storage    string
	Enabled    bool
	MinScore   float64
	MaxResults int
	StaleDays  int
}

ProfileConfig represents resolved configuration for a specific profile. It contains only the fields relevant for a single profile context.

type SemanticConfig

type SemanticConfig struct {
	// General settings (apply to all profiles)
	Enabled    bool    `yaml:"enabled"`
	AutoUpdate bool    `yaml:"auto_update"`
	MaxResults int     `yaml:"max_results"`
	MinScore   float64 `yaml:"min_score"`
	StaleDays  int     `yaml:"stale_days"`

	// Code profile settings
	CodeCollection string `yaml:"code_collection"`
	CodeEnabled    bool   `yaml:"code_enabled"`
	CodeStorage    string `yaml:"code_storage"`

	// Docs profile settings
	DocsCollection string `yaml:"docs_collection"`
	DocsEnabled    bool   `yaml:"docs_enabled"`
	DocsStorage    string `yaml:"docs_storage"`

	// Memory profile settings
	MemoryCollection string `yaml:"memory_collection"`
	MemoryEnabled    bool   `yaml:"memory_enabled"`
	MemoryStorage    string `yaml:"memory_storage"`

	// Sprints profile settings
	SprintsCollection string `yaml:"sprints_collection"`
	SprintsEnabled    bool   `yaml:"sprints_enabled"`
	SprintsStorage    string `yaml:"sprints_storage"`
}

SemanticConfig represents the semantic configuration from a YAML file. Configuration is read from the "semantic:" key in the YAML file.

func LoadConfig

func LoadConfig(path string) (*SemanticConfig, error)

LoadConfig loads semantic configuration from a YAML file. It reads the "semantic:" section and ignores other sections. Returns an error if the file doesn't exist or contains invalid YAML.

func (*SemanticConfig) GetProfileConfig

func (c *SemanticConfig) GetProfileConfig(profile string) ProfileConfig

GetProfileConfig returns the resolved configuration for a specific profile. Valid profiles are: "code" (default), "docs", "memory". Unknown profiles fall back to "code".

Jump to

Keyboard shortcuts

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