config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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.

View Source
const (

	// CurrentV is the currently supported version, points to v0
	CurrentV = v0
)

Variables

This section is empty.

Functions

func AddStringFlag

func AddStringFlag(cmd *cobra.Command, fs FlagSet, key string, target *string)

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

func AddUintFlag(cmd *cobra.Command, fs FlagSet, registryKey string, target *uint)

AddUintFlag registers a uint flag on cmd from the given FlagSet.

func BindRegisteredFlags

func BindRegisteredFlags(v *viper.Viper, cmd *cobra.Command, fs FlagSet, registryKeys []string)

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

func InitViper(configDir string) (*viper.Viper, error)

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):

  1. CLI flags (once bound via BindRegisteredFlags)
  2. Environment variables (TAPES_PROXY_LISTEN, TAPES_API_LISTEN, etc.)
  3. config.toml file values
  4. Defaults from NewDefaultConfig()

func IsValidConfigKey

func IsValidConfigKey(key string) bool

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

func ParseConfigTOML(data []byte) (*Config, error)

ParseConfigTOML parses raw TOML bytes into a Config. Returns an error if the version field is present and not equal to CurrentConfigVersion.

func PresetConfig

func PresetConfig(name string) (*Config, error)

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 NewConfiger(override string) (*Configer, error)

func (*Configer) GetConfigValue

func (c *Configer) GetConfigValue(key string) (string, error)

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) GetTarget

func (c *Configer) GetTarget() string

func (*Configer) LoadConfig

func (c *Configer) LoadConfig() (*Config, error)

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

func (c *Configer) SaveConfig(cfg *Config) error

SaveConfig persists the configuration to config.toml in the target .tapes/ directory.

func (*Configer) SetConfigValue

func (c *Configer) SetConfigValue(key string, value string) error

SetConfigValue loads the config, sets the given key to the given value, and saves it. Returns an error if the key is not a valid config key.

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

type FlagSet map[string]Flag

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.

Jump to

Keyboard shortcuts

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