Documentation
¶
Index ¶
- Constants
- func AddStringFlag(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 InitViper(configDir string) (*viper.Viper, error)
- func IsValidConfigKey(key string) bool
- func ValidConfigKeys() []string
- func ValidPresetNames() []string
- type APIConfig
- type ClientConfig
- type Config
- type Configer
- type EmbeddingConfig
- type Flag
- type FlagSet
- type IngestConfig
- type OpenCodeConfig
- type ProxyConfig
- type StorageConfig
- type TelemetryConfig
- type VectorStoreConfig
Constants ¶
const ( FlagProxyListen = "proxy-listen" FlagAPIListen = "api-listen" FlagUpstream = "upstream" FlagProvider = "provider" FlagSQLite = "sqlite" FlagPostgres = "postgres" FlagProject = "project" FlagVectorStoreProv = "vector-store-provider" FlagVectorStoreTgt = "vector-store-target" FlagEmbeddingProv = "embedding-provider" FlagEmbeddingTgt = "embedding-target" FlagEmbeddingModel = "embedding-model" FlagEmbeddingDims = "embedding-dimensions" FlagAPITarget = "api-target" FlagProxyTarget = "proxy-target" FlagKafkaBrokers = "kafka-brokers" FlagKafkaTopic = "kafka-topic" FlagKafkaClientID = "kafka-client-id" FlagTelemetryDisabled = "telemetry-disabled" FlagUpdateCheckDisabled = "update-check-disabled" 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" )
Flag registry keys. Use these constants when calling AddStringFlag, AddUintFlag, 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 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 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 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 IsValidConfigKey ¶
IsValidConfigKey returns true if the given key is a supported configuration key.
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.
Types ¶
type APIConfig ¶
type APIConfig struct {
Listen string `toml:"listen,omitempty" mapstructure:"listen"`
}
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 chat, tapes search, tapes checkout). 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"`
VectorStore VectorStoreConfig `toml:"vector_store" mapstructure:"vector_store"`
Embedding EmbeddingConfig `toml:"embedding" mapstructure:"embedding"`
OpenCode OpenCodeConfig `toml:"opencode" mapstructure:"opencode"`
Telemetry TelemetryConfig `toml:"telemetry" mapstructure:"telemetry"`
}
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.
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 EmbeddingConfig ¶
type EmbeddingConfig struct {
Provider string `toml:"provider,omitempty" mapstructure:"provider"`
Target string `toml:"target,omitempty" mapstructure:"target"`
Model string `toml:"model,omitempty" mapstructure:"model"`
Dimensions uint `toml:"dimensions,omitempty" mapstructure:"dimensions"`
}
EmbeddingConfig holds embedding provider settings.
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" and "tapes chat").
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 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 {
SQLitePath string `toml:"sqlite_path,omitempty" mapstructure:"sqlite_path"`
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 VectorStoreConfig ¶
type VectorStoreConfig struct {
Provider string `toml:"provider,omitempty" mapstructure:"provider"`
Target string `toml:"target,omitempty" mapstructure:"target"`
}
VectorStoreConfig holds vector store settings.