Documentation
¶
Index ¶
- func Exists() bool
- func GetConfigDir() (string, error)
- func GetConfigPath() (string, error)
- func GetDiagnosticsDir() string
- func NeedsSetup() bool
- func ResolveValue(value string) (string, error)
- func Save(cfg *Config) error
- type AskConfig
- type Config
- type DiagnosticsConfig
- type EditConfig
- type ExecConfig
- type ImageConfig
- type ImageFluxConfig
- type ImageGeminiConfig
- type ImageOpenAIConfig
- type ProviderConfig
- type ProviderType
- type ThemeConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConfigDir ¶
GetConfigDir returns the XDG config directory for term-llm. Uses $XDG_CONFIG_HOME if set, otherwise ~/.config
func GetConfigPath ¶
GetConfigPath returns the path where the config file should be located
func GetDiagnosticsDir ¶ added in v0.0.11
func GetDiagnosticsDir() string
GetDiagnosticsDir returns the XDG data directory for term-llm diagnostics. Uses $XDG_DATA_HOME if set, otherwise ~/.local/share
func ResolveValue ¶ added in v0.0.15
ResolveValue handles magic URL schemes in config values: - op://vault/item/field -> 1Password secret (via `op read`) - srv://record/path -> DNS SRV lookup + path (always HTTPS) - $(...) -> shell command output - ${VAR} or $VAR -> environment variable - literal string -> returned as-is
Types ¶
type AskConfig ¶
type AskConfig struct {
Provider string `mapstructure:"provider"` // Override provider for ask
Model string `mapstructure:"model"` // Override model for ask
Instructions string `mapstructure:"instructions"` // Custom system prompt for ask
MaxTurns int `mapstructure:"max_turns"` // Max agentic turns (default 20)
}
type Config ¶
type Config struct {
DefaultProvider string `mapstructure:"default_provider"`
Providers map[string]ProviderConfig `mapstructure:"providers"`
Diagnostics DiagnosticsConfig `mapstructure:"diagnostics"`
Exec ExecConfig `mapstructure:"exec"`
Ask AskConfig `mapstructure:"ask"`
Edit EditConfig `mapstructure:"edit"`
Image ImageConfig `mapstructure:"image"`
Theme ThemeConfig `mapstructure:"theme"`
}
func (*Config) ApplyOverrides ¶ added in v0.0.6
ApplyOverrides applies provider and model overrides to the config. If provider is non-empty, it overrides the global provider. If model is non-empty, it overrides the model for the active provider.
func (*Config) GetActiveProviderConfig ¶ added in v0.0.15
func (c *Config) GetActiveProviderConfig() *ProviderConfig
GetActiveProviderConfig returns the config for the default provider. Returns nil if the default provider is not configured.
func (*Config) GetProviderConfig ¶ added in v0.0.15
func (c *Config) GetProviderConfig(name string) *ProviderConfig
GetProviderConfig returns the config for the specified provider name. Returns nil if the provider is not configured.
type DiagnosticsConfig ¶ added in v0.0.11
type DiagnosticsConfig struct {
Enabled bool `mapstructure:"enabled"` // Enable diagnostic data collection
Dir string `mapstructure:"dir"` // Override default directory
}
DiagnosticsConfig configures diagnostic data collection
type EditConfig ¶ added in v0.0.5
type EditConfig struct {
Provider string `mapstructure:"provider"` // Override provider for edit
Model string `mapstructure:"model"` // Override model for edit
Instructions string `mapstructure:"instructions"` // Custom instructions for edits
ShowLineNumbers bool `mapstructure:"show_line_numbers"` // Show line numbers in diff
ContextLines int `mapstructure:"context_lines"` // Lines of context in diff
Editor string `mapstructure:"editor"` // Override $EDITOR
DiffFormat string `mapstructure:"diff_format"` // "auto", "udiff", or "replace" (default: auto)
}
type ExecConfig ¶
type ExecConfig struct {
Provider string `mapstructure:"provider"` // Override provider for exec
Model string `mapstructure:"model"` // Override model for exec
Suggestions int `mapstructure:"suggestions"` // Number of command suggestions (default 3)
Instructions string `mapstructure:"instructions"` // Custom context for suggestions
}
type ImageConfig ¶ added in v0.0.3
type ImageConfig struct {
Provider string `mapstructure:"provider"` // default image provider: gemini, openai, flux
OutputDir string `mapstructure:"output_dir"` // default save directory
Gemini ImageGeminiConfig `mapstructure:"gemini"`
OpenAI ImageOpenAIConfig `mapstructure:"openai"`
Flux ImageFluxConfig `mapstructure:"flux"`
}
ImageConfig configures image generation settings
type ImageFluxConfig ¶ added in v0.0.3
type ImageFluxConfig struct {
APIKey string `mapstructure:"api_key"`
Model string `mapstructure:"model"` // flux-2-pro for generation, flux-kontext-pro for editing
}
ImageFluxConfig configures Flux (Black Forest Labs) image generation
type ImageGeminiConfig ¶ added in v0.0.3
type ImageGeminiConfig struct {
APIKey string `mapstructure:"api_key"`
Model string `mapstructure:"model"`
}
ImageGeminiConfig configures Gemini image generation
type ImageOpenAIConfig ¶ added in v0.0.3
type ImageOpenAIConfig struct {
APIKey string `mapstructure:"api_key"`
Model string `mapstructure:"model"`
}
ImageOpenAIConfig configures OpenAI image generation
type ProviderConfig ¶ added in v0.0.15
type ProviderConfig struct {
// Type of provider - inferred from key name for built-ins, required for custom
Type ProviderType `mapstructure:"type"`
// Common fields
APIKey string `mapstructure:"api_key"`
Model string `mapstructure:"model"`
Credentials string `mapstructure:"credentials"` // "api_key", "claude", "codex", "gemini-cli"
// Search behavior - nil means auto (use native if available)
UseNativeSearch *bool `mapstructure:"use_native_search"`
// OpenAI-compatible specific
BaseURL string `mapstructure:"base_url"` // Base URL - /chat/completions is appended
URL string `mapstructure:"url"` // Full URL - used as-is without appending endpoint
// OpenRouter specific
AppURL string `mapstructure:"app_url"`
AppTitle string `mapstructure:"app_title"`
// Runtime fields (populated after credential resolution)
ResolvedAPIKey string `mapstructure:"-"`
AccountID string `mapstructure:"-"`
OAuthCreds *credentials.GeminiOAuthCredentials `mapstructure:"-"`
ResolvedURL string `mapstructure:"-"` // Resolved URL (after srv:// lookup)
// contains filtered or unexported fields
}
ProviderConfig is a unified configuration for any provider
func (*ProviderConfig) ResolveForInference ¶ added in v0.0.15
func (cfg *ProviderConfig) ResolveForInference() error
ResolveForInference performs lazy resolution of expensive config values (op://, srv://, $()). Call this before creating a provider for inference.
type ProviderType ¶ added in v0.0.15
type ProviderType string
ProviderType defines the supported provider implementations
const ( ProviderTypeAnthropic ProviderType = "anthropic" ProviderTypeOpenAI ProviderType = "openai" ProviderTypeGemini ProviderType = "gemini" ProviderTypeOpenRouter ProviderType = "openrouter" ProviderTypeZen ProviderType = "zen" ProviderTypeClaudeBin ProviderType = "claude-bin" ProviderTypeOpenAICompat ProviderType = "openai_compatible" )
func InferProviderType ¶ added in v0.0.15
func InferProviderType(name string, explicit ProviderType) ProviderType
InferProviderType returns the provider type for a given provider name Explicit type takes precedence, then built-in names, then defaults to openai_compatible
type ThemeConfig ¶
type ThemeConfig struct {
Primary string `mapstructure:"primary"` // main accent (commands, highlights)
Secondary string `mapstructure:"secondary"` // secondary accent (headers, borders)
Success string `mapstructure:"success"` // success states
Error string `mapstructure:"error"` // error states
Warning string `mapstructure:"warning"` // warnings
Muted string `mapstructure:"muted"` // dimmed text
Text string `mapstructure:"text"` // primary text
Spinner string `mapstructure:"spinner"` // loading spinner
}
ThemeConfig allows customization of UI colors Colors can be ANSI color numbers (0-255) or hex codes (#RRGGBB)