config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package config resolves gskill's layered configuration. Precedence, lowest to highest, is: built-in defaults, user config file, project config file, GSKILL_-prefixed environment variables, then explicit flags. Storage paths follow the platform convention (XDG on Linux, the OS equivalents elsewhere) and may be overridden with GSKILL_CONFIG_DIR / GSKILL_CACHE_DIR.

Index

Constants

View Source
const (
	StoreScopeGlobal  = "global"
	StoreScopeProject = "project"
)

Store scope values accepted for StoreScope (empty = auto-detect).

View Source
const (
	PrivacyFull     = "full"
	PrivacyMinimal  = "minimal"
	PrivacyDisabled = "disabled"
)

Privacy modes accepted for PrivacyProjectRegistry.

View Source
const (
	// EnvPrefix is the prefix for environment-variable overrides.
	EnvPrefix = "GSKILL_"
)

Variables

This section is empty.

Functions

func CacheDir

func CacheDir() (string, error)

CacheDir returns the gskill cache directory, honoring GSKILL_CACHE_DIR and otherwise following the platform convention.

func DefaultMap

func DefaultMap() map[string]any

DefaultMap returns the built-in configuration defaults.

func Dir

func Dir() (string, error)

Dir returns the gskill configuration directory, honoring GSKILL_CONFIG_DIR and otherwise following the platform convention.

func ParseFlexDuration added in v0.4.0

func ParseFlexDuration(s string) (time.Duration, error)

ParseFlexDuration parses a duration that may use a whole-day suffix ("30d") in addition to the standard time.ParseDuration units. Negative durations are rejected.

Types

type Config

type Config struct {
	LogLevel  string
	LogFormat string
	Offline   bool
	NoCache   bool
	Jobs      int
	// Repositories are the known skill repositories an unscoped `find` searches
	// (FR-038). Configured in a config file (TOML array) or via
	// GSKILL_REPOSITORIES (comma-separated).
	Repositories []string
	// StoreScope selects the physical content-store location: "global"
	// (user-level store under the gskill home) or "project" (legacy
	// <project>/.gskill/store). Empty means auto-detect per project. Distinct
	// from the installer's agent-target scope.
	StoreScope string
	// StoreVerifyOnUse re-hashes a global store object's content on every
	// activation when true (the default).
	StoreVerifyOnUse bool
	// StoreGCGracePeriod is the minimum age before an unreferenced global
	// store object becomes eligible for garbage collection.
	StoreGCGracePeriod time.Duration
	// StoreLockTimeout bounds how long a contended global-store or project
	// lock is waited on before failing.
	StoreLockTimeout time.Duration
	// ProjectsRegistry enables the advisory per-user project registry.
	ProjectsRegistry bool
	// PrivacyProjectRegistry controls how much project detail the registry
	// records: "full", "minimal" (no absolute paths), or "disabled".
	PrivacyProjectRegistry string
}

Config is the resolved, layered gskill configuration.

func Default added in v0.4.0

func Default() *Config

Default returns the built-in defaults as a resolved Config, with no file, environment, or flag layers consulted.

func Load

func Load(s Sources) (*Config, error)

Load merges the configuration layers in Sources and returns the result.

type Sources

type Sources struct {
	// Defaults seeds the lowest layer. When nil, DefaultMap is used.
	Defaults map[string]any
	// UserFile and ProjectFile are optional TOML config paths. A missing file
	// is skipped without error.
	UserFile    string
	ProjectFile string
	// Environ is a list of "KEY=VALUE" entries (as from os.Environ); only
	// GSKILL_-prefixed entries are consulted. When nil, the process environment
	// is used.
	Environ []string
	// Flags is the highest-precedence layer of explicitly set flag values.
	Flags map[string]any
}

Sources are the inputs to Load. Empty fields are skipped; later layers override earlier ones in the documented precedence order.

Jump to

Keyboard shortcuts

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