config

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config loads Excise's optional excise.toml file.

Discovery order (first hit wins):

  1. ./excise.toml (project-local)
  2. $XDG_CONFIG_HOME/excise/excise.toml (XDG explicit)
  3. ~/.config/excise/excise.toml (XDG default)

A missing file is NOT an error — Load returns a Config populated entirely from defaults. The [llm] section governs v0.3's opt-in Ollama rerank; the table is optional, individual fields are optional, and any field omitted from the file inherits its default. This keeps the binary usable with no configuration at all.

Index

Constants

View Source
const (
	DefaultLLMHost       = "http://localhost:11434"
	DefaultLLMModel      = "llama3.2"
	DefaultLLMTopN       = 5
	DefaultLLMTimeoutSec = 20
)

Defaults — kept package-level so tests and the CLI can reference them directly, and so the README "what are the defaults" question has one place to point at.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	LLM LLM `toml:"llm"`

	// SourcePath records where the config was loaded from (empty if no file
	// was found and defaults are in use). Useful for debug output.
	SourcePath string `toml:"-"`
}

Config mirrors the top-level structure of excise.toml. Additional sections can be added without breaking older configs — unknown keys are ignored.

func Default

func Default() *Config

Default returns a Config populated with the v0.3 defaults.

func Load

func Load() (*Config, error)

Load discovers excise.toml on the standard search path, parses it, and fills missing fields with defaults. If no file is found, the defaults are returned with SourcePath="".

Validation: the host must parse as an absolute URL. TopN<=0 and TimeoutSec<=0 are coerced back to defaults rather than erroring — a typo shouldn't hard-block a mid-session run.

func LoadFrom

func LoadFrom(path string) (*Config, error)

LoadFrom reads from an explicit path (used by tests and an eventual `--config` flag). Empty path → same as Load.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks fields that must be well-formed. Currently only the host.

type LLM

type LLM struct {
	Host       string `toml:"host"`
	Model      string `toml:"model"`
	TopN       int    `toml:"top_n"`
	TimeoutSec int    `toml:"timeout_sec"`
}

LLM holds the Ollama-side knobs.

Jump to

Keyboard shortcuts

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