config

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config loads and validates the agentdex user configuration (config.cue), resolves the XDG paths it lives under, resolves the per-cache TTLs, and maps the configuration together with the global flags into the agentdex library options and the modelsdev client options. It is the one place where config.cue and flags are read; the library and the modelsdev client stay configuration-agnostic and option-driven.

Index

Constants

View Source
const DefaultTTL = 24 * time.Hour

DefaultTTL is the built-in cache TTL applied when neither a section ttl nor cache_ttl is configured. It mirrors the library defaults so the resolved value is explicit at the call site rather than left implicit in two packages.

Variables

View Source
var ErrConfig = errors.New("invalid configuration")

ErrConfig marks a configuration fault: a malformed config.cue, a value that violates the schema, or an unparseable duration.

Functions

func Path

func Path() string

Path resolves the config.cue location from $XDG_CONFIG_HOME with the documented home fallback, not a platform-specific user-dir helper. Returns "" only when neither XDG_CONFIG_HOME nor a home directory can be determined.

Types

type Config

type Config struct {
	CatalogModule string
	CatalogDir    string
	CatalogTTL    time.Duration
	ModelsURL     string
	ModelsTTL     time.Duration
	SearchDirs    []string
	BinPaths      map[string]string
	Color         string
}

Config is the resolved, typed configuration: defaults applied, durations parsed into the per-cache TTLs. Decoupled from config.cue's wire shape so callers never re-parse strings.

func Load

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

Load reads, validates, and resolves config.cue at path. A missing file is a clean empty configuration: schema defaults still materialise. A syntax error, schema violation, or unparseable duration is an ErrConfig.

func (*Config) Options

func (c *Config) Options(f Flags) []agentdex.Option

Options builds the agentdex.Open options from the resolved configuration and the global flags. When catalog.dir is set it is the sole catalog source (module omitted); otherwise catalog.module is used — the two are mutually exclusive in the library. Force-refresh is owned by Index.Refresh.

type Flags

type Flags struct {
	SearchDirs []string
	BinPaths   map[string]string
}

Flags carries the global flag values that feed into option mapping. SearchDirs is the repeated --search-dir values; BinPaths the parsed id=path map from --bin-path. Both merge with config.cue counterparts; flags win on collision.

Jump to

Keyboard shortcuts

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