config

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists() bool

Exists returns true if a config file exists

func GetConfigDir

func GetConfigDir() (string, error)

GetConfigDir returns the XDG config directory for term-llm. Uses $XDG_CONFIG_HOME if set, otherwise ~/.config

func GetConfigPath

func GetConfigPath() (string, error)

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 NeedsSetup

func NeedsSetup() bool

NeedsSetup returns true if config file doesn't exist

func Save

func Save(cfg *Config) error

Save writes the config to disk

Types

type AnthropicConfig

type AnthropicConfig struct {
	APIKey      string `mapstructure:"api_key"`
	Model       string `mapstructure:"model"`
	Credentials string `mapstructure:"credentials"` // "api_key" (default) or "claude"
}

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
}

type Config

type Config struct {
	Provider     string             `mapstructure:"provider"`
	Diagnostics  DiagnosticsConfig  `mapstructure:"diagnostics"`
	Exec         ExecConfig         `mapstructure:"exec"`
	Ask          AskConfig          `mapstructure:"ask"`
	Edit         EditConfig         `mapstructure:"edit"`
	Image        ImageConfig        `mapstructure:"image"`
	Theme        ThemeConfig        `mapstructure:"theme"`
	Anthropic    AnthropicConfig    `mapstructure:"anthropic"`
	OpenAI       OpenAIConfig       `mapstructure:"openai"`
	OpenRouter   OpenRouterConfig   `mapstructure:"openrouter"`
	Gemini       GeminiConfig       `mapstructure:"gemini"`
	Zen          ZenConfig          `mapstructure:"zen"`
	Ollama       OllamaConfig       `mapstructure:"ollama"`
	LMStudio     LMStudioConfig     `mapstructure:"lmstudio"`
	OpenAICompat OpenAICompatConfig `mapstructure:"openai-compat"`
}

func Load

func Load() (*Config, error)

func (*Config) ApplyOverrides added in v0.0.6

func (c *Config) ApplyOverrides(provider, model string)

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.

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 GeminiConfig

type GeminiConfig struct {
	APIKey      string `mapstructure:"api_key"`
	Model       string `mapstructure:"model"`
	Credentials string `mapstructure:"credentials"` // "api_key" (default) or "gemini-cli"
	// OAuth credentials populated at runtime when using gemini-cli
	OAuthCreds *credentials.GeminiOAuthCredentials
}

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 LMStudioConfig added in v0.0.8

type LMStudioConfig struct {
	BaseURL string `mapstructure:"base_url"` // Default: http://localhost:1234/v1
	Model   string `mapstructure:"model"`
	APIKey  string `mapstructure:"api_key"` // Optional, LM Studio ignores it
}

LMStudioConfig configures the LM Studio provider (OpenAI-compatible)

type OllamaConfig added in v0.0.8

type OllamaConfig struct {
	BaseURL string `mapstructure:"base_url"` // Default: http://localhost:11434/v1
	Model   string `mapstructure:"model"`
	APIKey  string `mapstructure:"api_key"` // Optional, Ollama ignores it
}

OllamaConfig configures the Ollama provider (OpenAI-compatible)

type OpenAICompatConfig added in v0.0.8

type OpenAICompatConfig struct {
	BaseURL string `mapstructure:"base_url"` // Required - no default
	Model   string `mapstructure:"model"`
	APIKey  string `mapstructure:"api_key"` // Optional
}

OpenAICompatConfig configures a generic OpenAI-compatible server

type OpenAIConfig

type OpenAIConfig struct {
	APIKey      string `mapstructure:"api_key"`
	Model       string `mapstructure:"model"`
	Credentials string `mapstructure:"credentials"` // "api_key" (default) or "codex"
	AccountID   string // Populated at runtime when using Codex OAuth credentials
}

type OpenRouterConfig added in v0.0.10

type OpenRouterConfig struct {
	APIKey   string `mapstructure:"api_key"`
	Model    string `mapstructure:"model"`
	AppURL   string `mapstructure:"app_url"`
	AppTitle string `mapstructure:"app_title"`
}

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)

type ZenConfig added in v0.0.2

type ZenConfig struct {
	APIKey string `mapstructure:"api_key"` // Optional: leave empty for free tier
	Model  string `mapstructure:"model"`
}

ZenConfig configures the OpenCode Zen provider Zen provides free access to models like GLM 4.7 via opencode.ai API key is optional - leave empty for free tier access

Jump to

Keyboard shortcuts

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