config

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is set at build time via -ldflags

Functions

func EnsureExists

func EnsureExists() (bool, error)

EnsureExists creates the config directory and default config file if they don't exist. Returns true if a new config file was created.

func GetConfigPath

func GetConfigPath() string

GetConfigPath returns the path to the config file

func Save

func Save(cfg *Config) error

Save writes the config to disk (package-level convenience function)

Types

type CLIConfig

type CLIConfig struct {
	DefaultProvider string `json:"defaultProvider,omitempty" yaml:"defaultProvider,omitempty"`
}

CLIConfig contains CLI-specific configuration

type Config

type Config struct {
	Providers    map[string]Provider `json:"providers" yaml:"providers"`
	Router       RouterConfig        `json:"router,omitempty" yaml:"router,omitempty"`
	CLI          CLIConfig           `json:"cli,omitempty" yaml:"cli,omitempty"`
	Optimization OptimizationConfig  `json:"optimization,omitempty" yaml:"optimization,omitempty"`
}

Config is the main configuration for CCL

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration with optimization settings. Providers are loaded from the YAML template via EnsureExists or Load.

func Init

func Init() (*Config, error)

Init initializes config directory and loads or creates config

func Load

func Load() (*Config, error)

Load reads and parses the config file (package-level convenience function)

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader handles configuration loading with injectable paths

func NewLoader

func NewLoader() *Loader

NewLoader creates a Loader with default paths

func NewLoaderWithPaths

func NewLoaderWithPaths(homeDir, configFile string) *Loader

NewLoaderWithPaths creates a Loader with custom paths (for testing)

func (*Loader) ConfigPath

func (l *Loader) ConfigPath() string

ConfigPath returns the path to the config file for this loader

func (*Loader) EnsureExists

func (l *Loader) EnsureExists() (bool, error)

EnsureExists creates the config directory and copies the example config if needed. Returns true if a new config file was created.

func (*Loader) Init

func (l *Loader) Init() (*Config, error)

Init initializes config directory and loads or creates config. Uses EnsureExists to create defaults if needed, then loads the config.

func (*Loader) Load

func (l *Loader) Load() (*Config, error)

Load reads and parses the config file

func (*Loader) Save

func (l *Loader) Save(cfg *Config) error

Save writes the config to disk

type OptimizationConfig

type OptimizationConfig struct {
	DisableNonessentialTraffic bool `json:"disableNonessentialTraffic,omitempty" yaml:"disableNonessentialTraffic,omitempty"`
	DisableAutoupdater         bool `json:"disableAutoupdater,omitempty" yaml:"disableAutoupdater,omitempty"`
	DisableTelemetry           bool `json:"disableTelemetry,omitempty" yaml:"disableTelemetry,omitempty"`
	DisableErrorReporting      bool `json:"disableErrorReporting,omitempty" yaml:"disableErrorReporting,omitempty"`
	DisableCostWarnings        bool `json:"disableCostWarnings,omitempty" yaml:"disableCostWarnings,omitempty"`
	APITimeoutMs               int  `json:"apiTimeoutMs,omitempty" yaml:"apiTimeoutMs,omitempty"`
	MaxOutputTokens            int  `json:"maxOutputTokens,omitempty" yaml:"maxOutputTokens,omitempty"`
	NodeMaxOldSpaceSize        int  `json:"nodeMaxOldSpaceSize,omitempty" yaml:"nodeMaxOldSpaceSize,omitempty"`
}

OptimizationConfig defines Claude Code optimization and performance settings

type Provider

type Provider struct {
	APIKey         string            `json:"apiKey,omitempty" yaml:"apiKey,omitempty"`
	AuthToken      string            `json:"authToken,omitempty" yaml:"authToken,omitempty"`
	OAuthToken     string            `json:"oauthToken,omitempty" yaml:"oauthToken,omitempty"`
	BaseURL        string            `json:"baseUrl,omitempty" yaml:"baseUrl,omitempty"`
	Model          string            `json:"model,omitempty" yaml:"model,omitempty"`
	SmallFastModel string            `json:"smallFastModel,omitempty" yaml:"smallFastModel,omitempty"`
	Transformer    TransformerConfig `json:"transformer,omitempty" yaml:"transformer,omitempty"`
}

Provider defines an LLM provider configuration

func (Provider) ToProviderConfig

func (p Provider) ToProviderConfig() ProviderConfig

ToProviderConfig converts a config Provider to a runtime ProviderConfig

type ProviderConfig

type ProviderConfig struct {
	BaseURL        string
	AuthToken      string
	APIKey         string
	OAuthToken     string
	Model          string
	SmallFastModel string
}

ProviderConfig holds the configuration for a provider

type ProviderRegistry

type ProviderRegistry struct {
	// contains filtered or unexported fields
}

ProviderRegistry manages provider configurations with dependency injection

func NewProviderRegistryFromConfig

func NewProviderRegistryFromConfig(cfg *Config) *ProviderRegistry

NewProviderRegistryFromConfig creates a registry from a loaded Config. The Config should already have interpolated environment variables (via Load/Init).

func (*ProviderRegistry) Get

func (r *ProviderRegistry) Get(name string) (ProviderConfig, bool)

Get retrieves a provider configuration by name

type ProviderRegistryInterface

type ProviderRegistryInterface interface {
	Get(name string) (ProviderConfig, bool)
}

ProviderRegistryInterface defines the contract for provider registry operations

type ResponseFormat

type ResponseFormat struct {
	Type       string         `json:"type" yaml:"type"`
	JSONSchema map[string]any `json:"jsonSchema,omitempty" yaml:"jsonSchema,omitempty"`
}

ResponseFormat defines structured output configuration

type RouterConfig

type RouterConfig struct {
	Default              string `json:"default,omitempty" yaml:"default,omitempty"`
	Background           string `json:"background,omitempty" yaml:"background,omitempty"`
	LongContext          string `json:"longContext,omitempty" yaml:"longContext,omitempty"`
	Think                string `json:"think,omitempty" yaml:"think,omitempty"`
	WebSearch            string `json:"webSearch,omitempty" yaml:"webSearch,omitempty"`
	LongContextThreshold int    `json:"longContextThreshold,omitempty" yaml:"longContextThreshold,omitempty"`
}

RouterConfig defines model routing configuration

type TransformRule

type TransformRule struct {
	ModelPattern   string `json:"modelPattern,omitempty" yaml:"modelPattern,omitempty"`
	MessagePattern string `json:"messagePattern,omitempty" yaml:"messagePattern,omitempty"`
	TokenRange     struct {
		Min int `json:"min,omitempty" yaml:"min,omitempty"`
		Max int `json:"max,omitempty" yaml:"max,omitempty"`
	} `json:"tokenRange,omitempty" yaml:"tokenRange,omitempty"`

	SetModel       string            `json:"setModel,omitempty" yaml:"setModel,omitempty"`
	SetMaxTokens   int               `json:"setMaxTokens,omitempty" yaml:"setMaxTokens,omitempty"`
	SetTemperature float64           `json:"setTemperature,omitempty" yaml:"setTemperature,omitempty"`
	AddHeaders     map[string]string `json:"addHeaders,omitempty" yaml:"addHeaders,omitempty"`
	ModifyBody     map[string]any    `json:"modifyBody,omitempty" yaml:"modifyBody,omitempty"`

	ResponseFormat *ResponseFormat `json:"responseFormat,omitempty" yaml:"responseFormat,omitempty"`
}

TransformRule defines a conditional transformation rule

type TransformerConfig

type TransformerConfig struct {
	Use   []string        `json:"use,omitempty" yaml:"use,omitempty"`
	Rules []TransformRule `json:"rules,omitempty" yaml:"rules,omitempty"`
}

TransformerConfig defines request/response transformation settings

Jump to

Keyboard shortcuts

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