Documentation
¶
Index ¶
- Variables
- func EnsureExists() (bool, error)
- func GetConfigPath() string
- func Save(cfg *Config) error
- func SetDefaultProvider(name string) error
- func StoreInContext(ctx context.Context, cfg *Config) context.Context
- type CLIConfig
- type Config
- type Loader
- type OptimizationConfig
- type Provider
- type ResponseFormat
- type RouterConfig
- type TransformRule
- type TransformerConfig
Constants ¶
This section is empty.
Variables ¶
var Version = "dev"
Version is set at build time via -ldflags
Functions ¶
func EnsureExists ¶
EnsureExists is a package-level convenience that calls (*Loader).EnsureExists with the default loader.
func SetDefaultProvider ¶ added in v0.4.0
SetDefaultProvider updates only the cli.defaultProvider field in the config file on disk. It uses yaml.Node to preserve comments and env-var templates.
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 FromContext ¶ added in v0.3.2
FromContext extracts the config from a context. Returns nil if not present.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles configuration loading with injectable paths
func NewLoaderWithPaths ¶
NewLoaderWithPaths creates a Loader with custom paths (for testing)
func (*Loader) ConfigPath ¶
ConfigPath returns the path to the config file for this loader
func (*Loader) EnsureExists ¶
EnsureExists creates the config directory and writes the default config file if one doesn't already exist. Returns true if a new file was created.
func (*Loader) Init ¶
Init initializes config directory and loads or creates config. Uses EnsureExists to create defaults if needed, then loads the config.
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 GetProvider ¶ added in v0.3.2
GetProvider retrieves a provider configuration by name from the config.
func (Provider) AuthCredential ¶ added in v0.4.2
AuthCredential returns the preferred auth token for the Anthropic-compatible endpoint: AuthToken takes precedence over APIKey. OAuth is handled separately.
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
func (TransformerConfig) HasRules ¶ added in v0.4.0
func (t TransformerConfig) HasRules() bool
HasRules reports whether the transformer has any rules configured.