Documentation
¶
Index ¶
- Constants
- func AddBoolFlag(cmd *cobra.Command, fs FlagSet, registryKey string, target *bool)
- func AddIntFlag(cmd *cobra.Command, fs FlagSet, registryKey string, target *int)
- func AddStringFlag(cmd *cobra.Command, fs FlagSet, key string, target *string)
- func AddStringSliceFlag(cmd *cobra.Command, fs FlagSet, key string, target *[]string)
- func AddUintFlag(cmd *cobra.Command, fs FlagSet, registryKey string, target *uint)
- func BindRegisteredFlags(v *viper.Viper, cmd *cobra.Command, fs FlagSet, registryKeys []string)
- func ExplicitConfigKeySet(v *viper.Viper, key string) bool
- func GetRegisteredStringSlice(v *viper.Viper, cmd *cobra.Command, fs FlagSet, registryKey string) ([]string, error)
- func InitViper(configDir string) (*viper.Viper, error)
- func IsRegisteredFlagExplicitlySet(v *viper.Viper, cmd *cobra.Command, fs FlagSet, registryKey string) bool
- func IsValidConfigKey(key string) bool
- func RedactDSN(dsn string) string
- func ValidConfigKeys() []string
- func ValidPresetNames() []string
- func ValidateCassetteSources(sources []string) error
- type APIConfig
- type ClientConfig
- type Config
- type Configer
- type Flag
- type FlagSet
- type IngestConfig
- type LoggingConfig
- type OpenCodeConfig
- type ProxyConfig
- type StorageConfig
- type TelemetryConfig
- type UpdateConfig
Constants ¶
const ( FlagProxyListen = "proxy-listen" FlagAPIListen = "api-listen" FlagAPIWebUI = "api-web-ui" FlagUpstream = "upstream" FlagProvider = "provider" FlagPostgres = "postgres" FlagProject = "project" FlagAPITarget = "api-target" FlagProxyTarget = "proxy-target" FlagTelemetryDisabled = "telemetry-disabled" FlagUpdateCheckDisabled = "update-check-disabled" FlagLogLevel = "log-level" FlagLogFormat = "log-format" FlagLogColor = "log-color" FlagCassettes = "cassettes" FlagIngestListen = "ingest-listen" // Standalone subcommand variants use "listen" as the flag name // but bind to different viper keys depending on the service. FlagProxyListenStandalone = "proxy-listen-standalone" FlagAPIListenStandalone = "api-listen-standalone" FlagIngestListenStandalone = "ingest-listen-standalone" // Derive worker (`tapes serve derive-worker`) tunables. FlagDeriveWorkerPoll = "derive-worker-poll-interval" FlagDeriveWorkerDebounce = "derive-worker-debounce" FlagDeriveWorkerSweep = "derive-worker-sweep-interval" FlagDeriveWorkerSweepWindow = "derive-worker-sweep-window" //nolint:gosec // flag registry key, not a credential FlagDeriveWorkerMaxDeriveLag = "derive-worker-max-derive-lag" FlagDeriveWorkerMetricsListen = "derive-worker-metrics-listen" FlagDeriveWorkerWaitForDB = "derive-worker-wait-for-db" )
Flag registry keys. Use these constants when calling AddStringFlag, AddUintFlag, AddBoolFlag, and BindRegisteredFlags to avoid typos or drift from one command to another.
const (
// CurrentV is the currently supported version, points to v0
CurrentV = v0
)
Variables ¶
This section is empty.
Functions ¶
func AddBoolFlag ¶ added in v0.8.0
AddBoolFlag registers a bool flag on cmd from the given FlagSet.
func AddIntFlag ¶ added in v0.18.0
AddIntFlag registers an int flag on cmd from the given FlagSet.
func AddStringFlag ¶
AddStringFlag registers a string flag on cmd from the given FlagSet. The flag's name, shorthand, default, and description all come from the FlagSet entry so they cannot drift across commands.
func AddStringSliceFlag ¶ added in v0.30.0
AddStringSliceFlag registers a comma-separated, repeatable string-list flag.
func AddUintFlag ¶
AddUintFlag registers a uint flag on cmd from the given FlagSet.
func BindRegisteredFlags ¶
BindRegisteredFlags binds already-registered flags to viper using definitions from the given FlagSet. Call this in PreRunE after InitViper to connect flags to the viper precedence chain (flag > env > config file > default).
func ExplicitConfigKeySet ¶ added in v0.11.0
ExplicitConfigKeySet reports whether a config key was supplied through the environment or the loaded config file.
func GetRegisteredStringSlice ¶ added in v0.30.0
func GetRegisteredStringSlice(v *viper.Viper, cmd *cobra.Command, fs FlagSet, registryKey string) ([]string, error)
GetRegisteredStringSlice resolves a string-list flag using the normal precedence chain. Environment values use CSV so they have the same concise list form as a StringSlice flag while still allowing quoted commas.
func InitViper ¶
InitViper creates and returns a configured *viper.Viper. It sets defaults from NewDefaultConfig(), reads the config.toml file (if found via dotdir resolution), and binds environment variables with the TAPES_ prefix.
Config precedence (highest to lowest):
- CLI flags (once bound via BindRegisteredFlags)
- Environment variables (TAPES_PROXY_LISTEN, TAPES_API_LISTEN, etc.)
- config.toml file values
- Defaults from NewDefaultConfig()
func IsRegisteredFlagExplicitlySet ¶ added in v0.11.0
func IsRegisteredFlagExplicitlySet(v *viper.Viper, cmd *cobra.Command, fs FlagSet, registryKey string) bool
IsRegisteredFlagExplicitlySet reports whether a registered flag's value came from a CLI flag, environment variable, or config file rather than defaults.
func IsValidConfigKey ¶
IsValidConfigKey returns true if the given key is a supported configuration key.
func RedactDSN ¶ added in v0.14.0
RedactDSN masks the password in a database connection string so the string can be logged safely. URL DSNs (postgres://user:pass@host/db, including the libpq-style ?password=... query parameter) and keyword/value DSNs (host=... password=...) are supported. Strings without a password are returned unchanged.
func ValidConfigKeys ¶
func ValidConfigKeys() []string
ValidConfigKeys returns the sorted list of all supported configuration key names.
func ValidPresetNames ¶
func ValidPresetNames() []string
ValidPresetNames returns the list of recognized preset names.
func ValidateCassetteSources ¶ added in v0.30.0
ValidateCassetteSources checks configured full OpenAPI source URLs. Resolution and metadata admission are runtime concerns so unreachable sources remain retryable.
Types ¶
type APIConfig ¶
type APIConfig struct {
Listen string `toml:"listen,omitempty" mapstructure:"listen"`
WebUI bool `toml:"web_ui,omitempty" mapstructure:"web_ui"`
}
APIConfig holds API server settings.
type ClientConfig ¶
type ClientConfig struct {
ProxyTarget string `toml:"proxy_target,omitempty" mapstructure:"proxy_target"`
APITarget string `toml:"api_target,omitempty" mapstructure:"api_target"`
}
ClientConfig holds settings for CLI commands that connect to the running proxy and API servers (e.g. tapes search, tapes deck). Values are full URLs (scheme + host + port).
type Config ¶
type Config struct {
Version int `toml:"version" mapstructure:"version"`
Storage StorageConfig `toml:"storage" mapstructure:"storage"`
Proxy ProxyConfig `toml:"proxy" mapstructure:"proxy"`
API APIConfig `toml:"api" mapstructure:"api"`
Ingest IngestConfig `toml:"ingest" mapstructure:"ingest"`
Client ClientConfig `toml:"client" mapstructure:"client"`
OpenCode OpenCodeConfig `toml:"opencode" mapstructure:"opencode"`
Logging LoggingConfig `toml:"logging" mapstructure:"logging"`
Telemetry TelemetryConfig `toml:"telemetry" mapstructure:"telemetry"`
Update UpdateConfig `toml:"update" mapstructure:"update"`
// Cassettes contains exact OpenAPI document URLs for externally managed cassettes.
Cassettes []string `toml:"cassettes" mapstructure:"cassettes"`
}
Config represents the persistent tapes configuration stored as config.toml in the .tapes/ directory. The TOML layout uses sections for logical grouping.
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig returns a Config with sane defaults for all fields. This is the single source of truth for default values.
func ParseConfigTOML ¶
ParseConfigTOML parses raw TOML bytes into a Config. Returns an error if the version field is present and not equal to CurrentConfigVersion.
func PresetConfig ¶
PresetConfig returns a Config with sane defaults for the named provider preset. Supported presets: "openai", "anthropic", "ollama". Returns an error if the preset name is not recognized.
func (*Config) ValidateCassettes ¶ added in v0.30.0
ValidateCassettes checks this config's cassette OpenAPI source URLs.
type Configer ¶
type Configer struct {
// contains filtered or unexported fields
}
func NewConfiger ¶
func (*Configer) GetConfigValue ¶
GetConfigValue loads the config and returns the string representation of the given key. Returns an error if the key is not a valid config key.
func (*Configer) LoadConfig ¶
LoadConfig loads the configuration from config.toml in the target .tapes/ directory. If the file does not exist, returns DefaultConfig() so callers always receive a fully-populated Config with sane defaults. Fields explicitly set in the file override the defaults.
func (*Configer) SaveConfig ¶
SaveConfig persists the configuration to config.toml in the target .tapes/ directory.
type Flag ¶
type Flag struct {
// Name is the long flag name (e.g. "upstream").
Name string
// Shorthand is the one-letter short flag (e.g. "u"). Empty for no shorthand.
Shorthand string
// ViperKey is the dotted config key this flag maps to (e.g. "proxy.upstream").
ViperKey string
// Description is the help text shown in --help output.
Description string
}
Flag is the single source of truth for a CLI flag. Commands reference flags by registry key rather than hard-coding names, shorthands, defaults, and descriptions inline. This prevents flag drift when the same logical flag appears on multiple commands (e.g., --upstream on both "tapes serve" and "tapes serve proxy").
type FlagSet ¶
FlagSet is a mapping of flag names to Flag structs that hold their name, shorthand, viper key, etc.
type IngestConfig ¶ added in v0.3.0
type IngestConfig struct {
Listen string `toml:"listen,omitempty" mapstructure:"listen"`
}
IngestConfig holds ingest server settings for sidecar mode.
type LoggingConfig ¶ added in v0.30.0
type LoggingConfig struct {
Level string `toml:"level,omitempty" mapstructure:"level"`
Format string `toml:"format,omitempty" mapstructure:"format"`
Color string `toml:"color,omitempty" mapstructure:"color"`
}
LoggingConfig holds process-wide logging settings.
type OpenCodeConfig ¶
type OpenCodeConfig struct {
Provider string `toml:"provider,omitempty" mapstructure:"provider"`
Model string `toml:"model,omitempty" mapstructure:"model"`
}
OpenCodeConfig holds OpenCode agent settings for provider and model selection.
type ProxyConfig ¶
type ProxyConfig struct {
Provider string `toml:"provider,omitempty" mapstructure:"provider"`
Upstream string `toml:"upstream,omitempty" mapstructure:"upstream"`
Listen string `toml:"listen,omitempty" mapstructure:"listen"`
Project string `toml:"project,omitempty" mapstructure:"project"`
}
ProxyConfig holds proxy-specific settings.
type StorageConfig ¶
type StorageConfig struct {
PostgresDSN string `toml:"postgres_dsn,omitempty" mapstructure:"postgres_dsn"`
}
StorageConfig holds shared storage settings used by both proxy and API.
type TelemetryConfig ¶ added in v0.2.0
type TelemetryConfig struct {
Disabled bool `toml:"disabled,omitempty" mapstructure:"disabled"`
}
TelemetryConfig holds anonymous telemetry settings.
type UpdateConfig ¶ added in v0.25.0
type UpdateConfig struct {
Disabled bool `toml:"disabled,omitempty" mapstructure:"disabled"`
}
UpdateConfig holds update-check settings.