config

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config loads TOML configuration and environment-backed runtime overrides for the kb CLI.

Index

Constants

View Source
const (
	// DefaultDotEnvPath is the local dotenv file loaded by the CLI entrypoint.
	DefaultDotEnvPath = ".env"

	// ProjectConfigFileName is the default repository-local kb config file.
	ProjectConfigFileName = "kb.toml"

	// EnvConfigPath overrides the config file path.
	EnvConfigPath = "APP_CONFIG"

	// EnvFirecrawlAPIKey stores the Firecrawl API key override.
	EnvFirecrawlAPIKey = "FIRECRAWL_API_KEY"

	// EnvFirecrawlAPIURL stores the Firecrawl API URL override.
	EnvFirecrawlAPIURL = "FIRECRAWL_API_URL"

	// EnvOpenRouterAPIKey stores the OpenRouter API key override.
	EnvOpenRouterAPIKey = "OPENROUTER_API_KEY"

	// EnvOpenRouterAPIURL stores the OpenRouter API URL override.
	EnvOpenRouterAPIURL = "OPENROUTER_API_URL"

	// EnvYouTubeProxy stores the YouTube proxy URL override.
	EnvYouTubeProxy = "YOUTUBE_PROXY"

	// EnvYouTubeYTDLPPath stores the yt-dlp executable path override.
	EnvYouTubeYTDLPPath = "YOUTUBE_YT_DLP_PATH"

	// EnvYouTubeCookiesFile stores the YouTube cookies file override.
	EnvYouTubeCookiesFile = "YOUTUBE_COOKIES_FILE"

	// EnvYouTubeUserAgent stores the YouTube user agent override.
	EnvYouTubeUserAgent = "YOUTUBE_USER_AGENT"
)

Variables

This section is empty.

Functions

func ApplyEnvOverrides

func ApplyEnvOverrides(cfg *Config)

ApplyEnvOverrides overlays config values that are sourced from environment variables at runtime.

func DiscoverProjectConfigPath added in v0.0.6

func DiscoverProjectConfigPath(cwd string) (string, bool, error)

DiscoverProjectConfigPath walks up from cwd looking for kb.toml.

func LoadDotEnvIfPresent

func LoadDotEnvIfPresent(path string) error

LoadDotEnvIfPresent loads a local dotenv file without overriding env vars already supplied by the shell or process manager.

func ResolveVaultRoot added in v0.0.6

func ResolveVaultRoot(configPath string, cfg VaultConfig) (string, error)

ResolveVaultRoot resolves cfg.Root relative to the directory containing configPath when cfg.Root is relative.

Types

type AppConfig

type AppConfig struct {
	Name string `toml:"name"`
	Env  string `toml:"env"`
}

AppConfig contains the application identity and environment.

func (AppConfig) Validate

func (c AppConfig) Validate() error

Validate ensures application identity settings are usable.

type Config

type Config struct {
	App        AppConfig        `toml:"app"`
	Log        LogConfig        `toml:"log"`
	Vault      VaultConfig      `toml:"vault"`
	Firecrawl  FirecrawlConfig  `toml:"firecrawl"`
	OpenRouter OpenRouterConfig `toml:"openrouter"`
	YouTube    YouTubeConfig    `toml:"youtube"`
}

Config contains the complete TOML-backed runtime configuration.

func Default

func Default() Config

Default returns a sane starting configuration.

func Load

func Load(path string) (Config, error)

Load reads and validates the TOML config file, then overlays runtime secrets from the environment.

func (Config) Validate

func (c Config) Validate() error

Validate ensures the config is internally consistent before runtime startup.

type FirecrawlConfig

type FirecrawlConfig struct {
	APIKey string `toml:"api_key"`
	APIURL string `toml:"api_url"`
}

FirecrawlConfig controls URL scraping API access.

type LogConfig

type LogConfig struct {
	Level string `toml:"level"`
}

LogConfig controls structured logging output.

func (LogConfig) Validate

func (c LogConfig) Validate() error

Validate ensures the log level is supported.

type OpenRouterConfig

type OpenRouterConfig struct {
	APIKey   string `toml:"api_key"`
	APIURL   string `toml:"api_url"`
	STTModel string `toml:"stt_model"`
}

OpenRouterConfig controls the STT fallback provider.

type VaultConfig added in v0.0.6

type VaultConfig struct {
	Root       string   `toml:"root"`
	TopicGlobs []string `toml:"topic_globs"`
}

VaultConfig controls vault root discovery and topic enumeration.

func (VaultConfig) Validate added in v0.0.6

func (c VaultConfig) Validate() error

Validate ensures vault discovery settings are usable.

type YouTubeConfig added in v0.0.6

type YouTubeConfig struct {
	YTDLPPath     string `toml:"yt_dlp_path"`
	Proxy         string `toml:"proxy"`
	CookiesFile   string `toml:"cookies_file"`
	UserAgent     string `toml:"user_agent"`
	RetryAttempts int    `toml:"retry_attempts"`
	RetryBackoff  string `toml:"retry_backoff"`
}

YouTubeConfig controls YouTube network access and retry behavior.

func (YouTubeConfig) RetryBackoffDuration added in v0.0.6

func (c YouTubeConfig) RetryBackoffDuration() (time.Duration, error)

RetryBackoffDuration parses the configured retry backoff.

func (YouTubeConfig) Validate added in v0.0.6

func (c YouTubeConfig) Validate() error

Validate ensures YouTube runtime settings are usable.

Jump to

Keyboard shortcuts

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