config

package
v0.1.0-dev.20260212004109 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config provides centralized configuration for the devlore ecosystem. Both lore and writ consume configuration from this package.

Configuration is loaded from ~/.config/devlore/config.yaml with support for:

  • Environment variable overrides (DEVLORE_*, LORE_*, WRIT_*)
  • CLI flag overrides (applied by callers)
  • Native keystore for API keys

Index

Constants

View Source
const (
	VerbosityQuiet   = "quiet"   // Errors only
	VerbosityNormal  = "normal"  // Default output (empty string treated as normal)
	VerbosityVerbose = "verbose" // Extra output
)

Verbosity levels for output control.

View Source
const (
	DefaultModelProvider = "ollama"
	DefaultModelName     = "llama3.1:8b"
	DefaultModelEndpoint = "http://localhost:11434"
)

Default model settings (Ollama local inference).

View Source
const (
	DefaultRegistryURL    = "https://github.com/NobleFactor/devlore-registry.git"
	DefaultRegistryBranch = "develop" // develop branch has AI assets; main is release-only
)

Default registry settings.

Variables

This section is empty.

Functions

func Path

func Path() string

Path returns the path to the shared devlore config file. ~/.config/devlore/config.yaml

func Save

func Save(cfg *Config) error

Save writes configuration to the config file. API keys are stored in the native keystore, not the config file.

Types

type Config

type Config struct {
	// Shared runtime options
	Verbosity string `yaml:"verbosity,omitempty" json:"verbosity,omitempty"` // quiet, normal, verbose
	DryRun    bool   `yaml:"dry_run,omitempty" json:"dry_run,omitempty"`

	// Shared resources
	Model    ModelConfig    `yaml:"model,omitempty" json:"model,omitempty"`
	Registry RegistryConfig `yaml:"registry,omitempty" json:"registry,omitempty"`

	// Tool-specific
	Lore LoreConfig `yaml:"lore,omitempty" json:"lore,omitempty"`
	Writ WritConfig `yaml:"writ,omitempty" json:"writ,omitempty"`
}

Config is the root configuration for the devlore ecosystem. Shared options and resources are at the top level. Tool-specific settings are nested under lore and writ.

func Load

func Load() (*Config, error)

Load reads configuration from the config file and applies environment overrides. API keys are loaded from the native keystore if not in config/env.

Precedence (lowest to highest):

  1. Config file
  2. Environment variables
  3. Native keystore (for API key only)
  4. CLI flags (applied by caller via ApplyCLIFlags methods)

type CorporateSource

type CorporateSource struct {
	Name string `yaml:"name" json:"name"`
	URL  string `yaml:"url" json:"url"`
}

CorporateSource represents an organization-specific documentation source.

type LoreConfig

type LoreConfig struct {
	Preferences Preferences `yaml:"preferences,omitempty" json:"preferences,omitempty"`
	Sources     Sources     `yaml:"sources,omitempty" json:"sources,omitempty"`
}

LoreConfig contains lore-specific configuration. Note: verbosity and dry_run are shared options at the Config root level.

type ModelConfig

type ModelConfig struct {
	Provider string `yaml:"provider" json:"provider"`                     // ollama, anthropic, openai, groq, gemini, github
	Name     string `yaml:"name" json:"name"`                             // Model identifier (e.g., claude-sonnet-4-20250514)
	Endpoint string `yaml:"endpoint,omitempty" json:"endpoint,omitempty"` // Custom endpoint URL
	APIKey   string `yaml:"api_key,omitempty" json:"api_key,omitempty"`   // API key (prefer keystore)
}

ModelConfig configures the AI/LLM provider. This is shared across lore and writ for AI-assisted features.

func (ModelConfig) WithDefaults

func (c ModelConfig) WithDefaults() ModelConfig

WithDefaults returns a copy of the config with defaults applied.

type Preferences

type Preferences struct {
	ConsultUserBeforeChanges bool   `yaml:"consult_user_before_changes,omitempty" json:"consult_user_before_changes,omitempty"`
	ValidateExistingPackages bool   `yaml:"validate_existing_packages,omitempty" json:"validate_existing_packages,omitempty"`
	SearchInternet           string `yaml:"search_internet,omitempty" json:"search_internet,omitempty"` // always, on-demand, never
}

Preferences controls AI-assisted behavior.

type RegistryConfig

type RegistryConfig struct {
	// URL is the registry repository URL.
	// Default: https://github.com/NobleFactor/devlore-registry.git
	URL string `yaml:"url,omitempty" json:"url,omitempty"`

	// Branch is the git branch to use.
	// Default: develop (for demo phase; main for releases)
	Branch string `yaml:"branch,omitempty" json:"branch,omitempty"`

	// ForceTags forces tag resolution even on non-main branches.
	// When true, "latest" always resolves to the "latest" tag.
	// Default: false
	ForceTags bool `yaml:"force_tags,omitempty" json:"force_tags,omitempty"`
}

RegistryConfig configures the devlore package registry. This is shared across lore and writ.

func (RegistryConfig) WithDefaults

func (c RegistryConfig) WithDefaults() RegistryConfig

WithDefaults returns a copy of the config with defaults applied.

type Sources

type Sources struct {
	Corporate      []CorporateSource `yaml:"corporate,omitempty" json:"corporate,omitempty"`
	TrustedDomains []string          `yaml:"trusted_domains,omitempty" json:"trusted_domains,omitempty"`
	BlockedDomains []string          `yaml:"blocked_domains,omitempty" json:"blocked_domains,omitempty"`
}

Sources configures documentation sources for AI-assisted features.

type WritConfig

type WritConfig struct {
	// Segments are custom segment names beyond built-in OS, DISTRO, ARCH.
	// Example: ["ROLE", "SITE"]
	Segments []string `yaml:"segments,omitempty" json:"segments,omitempty"`

	// Vars are template variables and segment value overrides.
	// Example: {"USER_NAME": "John Doe", "ROLE": "desktop"}
	Vars map[string]string `yaml:"vars,omitempty" json:"vars,omitempty"`
}

WritConfig contains writ-specific configuration. Note: verbosity and dry_run are shared options at the Config root level.

Jump to

Keyboard shortcuts

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