config

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// TUIMotionAuto follows the terminal's own reduced-motion signal.
	TUIMotionAuto = "auto"
	// TUIMotionReduced stops decorative motion but keeps functional
	// indicators, which degrade to static glyphs.
	TUIMotionReduced = "reduced"
	// TUIMotionOff is the strictest setting: no decoration at all.
	TUIMotionOff = "off"
)

TUI motion modes, in decreasing order of movement.

View Source
const TUIDefaultTheme = "gocode-dark"

TUIDefaultTheme is the built-in theme a fresh config selects. The UI owns the theme registry; config only owns the default name.

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() string

func ConfigFilePath

func ConfigFilePath() string

func CopilotTokenPath added in v0.5.2

func CopilotTokenPath() string

CopilotTokenPath stores the GitHub OAuth token in the config dir (a credential, written owner-only).

func DataDir

func DataDir() string

func EnsureDirs

func EnsureDirs() error

EnsureDirs creates the app's config and data directories, owner-only.

func InlineAPIKeyWarnings added in v0.7.4

func InlineAPIKeyWarnings(cfg Config) []string

InlineAPIKeyWarnings reports every provider whose key is stored in config.toml instead of an environment variable. The key value itself is never included.

func LogDir added in v0.2.0

func LogDir() string

func LogFilePath added in v0.2.0

func LogFilePath() string

func Save added in v0.2.0

func Save(cfg Config) error

Save writes the configuration to the config.toml file.

func SaveToPath added in v0.2.0

func SaveToPath(cfg Config, path string) error

SaveToPath writes the configuration to a specific file path.

func SecretEnvNames added in v0.7.4

func SecretEnvNames(cfg Config) []string

SecretEnvNames returns every non-empty environment variable name that can hold a provider credential, plus the shell's extra scrub entries. Child processes started by GoCode get these variables removed.

func SessionDir

func SessionDir() string

func ValidateProviderBaseURL added in v0.7.4

func ValidateProviderBaseURL(raw string) (string, error)

ValidateProviderBaseURL checks an OpenAI-compatible endpoint. Endpoints must be absolute http(s) URLs without credentials, a query, or a fragment, and plain HTTP is only allowed for localhost/loopback targets. A trailing slash is trimmed.

Types

type Config

type Config struct {
	Provider    ProviderConfig    `toml:"provider"`
	Permissions PermissionsConfig `toml:"permissions"`
	Session     SessionConfig     `toml:"session"`
	Tools       ToolsConfig       `toml:"tools"`
	Context     ContextConfig     `toml:"context"`
	TUI         TUIConfig         `toml:"tui"`
	MCP         MCPConfig         `toml:"mcp"`
	// Hooks configures the hook engine: [[hooks.PreToolUse]] etc. with
	// name/matcher/command/timeout. Event names normalize case-insensitively
	// with underscores stripped; unknown events and keys are rejected at
	// load, matchers must compile, and hooks dedup by command per event.
	Hooks hooks.Config `toml:"hooks"`
}

Config represents top-level configuration options.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default configuration values.

func Load

func Load() (Config, error)

Load reads configuration from file or returns defaults if non-existent.

func LoadFromPath added in v0.2.0

func LoadFromPath(path string) (Config, error)

LoadFromPath reads configuration from a specific file path.

type ContextConfig added in v0.7.5

type ContextConfig struct {
	// AutoCompact summarizes older turns before the provider window overflows.
	// Truncation remains the last resort. On by default.
	AutoCompact bool `toml:"auto_compact"`
	// KeepRecentTokens is the approximate verbatim tail automatic compaction
	// preserves. Zero or negative uses the built-in default of 20000; it does
	// not affect manual /compact, which stays at two turns.
	KeepRecentTokens int `toml:"keep_recent_tokens"`
}

ContextConfig specifies automatic context management.

type CopilotConfig added in v0.5.2

type CopilotConfig struct {
	// OAuthTokenEnv names the env var holding the GitHub OAuth token, never written into config.toml.
	OAuthTokenEnv string `toml:"oauth_token_env"`
	DefaultModel  string `toml:"default_model"`
	// EditorVersion and EditorPluginVersion are sent as Copilot headers; requests without them are rejected.
	EditorVersion       string `toml:"editor_version"`
	EditorPluginVersion string `toml:"editor_plugin_version"`
}

CopilotConfig configures GitHub Copilot. Uses a long-lived GitHub OAuth token exchanged for a short-lived JWT; see internal/provider/copilot.go.

type GatewayConfig

type GatewayConfig struct {
	BaseURL      string `toml:"base_url"`
	APIKey       string `toml:"api_key"`
	APIKeyEnv    string `toml:"api_key_env"`
	DefaultModel string `toml:"default_model"`
}

GatewayConfig configures an OpenAI-compatible gateway or cloud provider endpoint.

type MCPConfig added in v0.2.0

type MCPConfig struct {
	Servers map[string]MCPServerConfig `toml:"servers"`
}

MCPConfig specifies Model Context Protocol server configurations.

type MCPServerConfig added in v0.2.0

type MCPServerConfig struct {
	Command string            `toml:"command"`
	Args    []string          `toml:"args"`
	Env     map[string]string `toml:"env,omitempty"`
	// RequestTimeoutSeconds bounds a single JSON-RPC request to this server.
	// Zero or negative uses the built-in default of 60 seconds.
	RequestTimeoutSeconds int `toml:"request_timeout_seconds"`
}

MCPServerConfig defines an individual MCP server command and arguments.

type OllamaConfig

type OllamaConfig struct {
	Host         string `toml:"host"`
	DefaultModel string `toml:"default_model"`
}

OllamaConfig configures local Ollama instance.

type PermissionsConfig added in v0.2.0

type PermissionsConfig struct {
	AutoApprove       []string `toml:"auto_approve"`
	Deny              []string `toml:"deny"`
	SensitivePatterns []string `toml:"sensitive_patterns"`
	// Mode selects the prompt policy: "normal" (default, prompt for gated
	// calls) or "yolo" (skip prompts for safe calls; dangerous calls are
	// refused without asking). The deny-list and redaction stay unconditional
	// in every mode; sysadmin is deliberately not offered.
	Mode string `toml:"mode"`
	// DangerousTools lists tool names always classified dangerous, on top of
	// the built-in classifier rules.
	DangerousTools []string `toml:"dangerous_tools"`
}

PermissionsConfig specifies granular tool permissions.

type ProviderConfig

type ProviderConfig struct {
	Default string `toml:"default"`
	// StreamUsage asks OpenAI-compatible gateways to report token usage on the
	// final stream chunk (stream_options.include_usage). Parsing usage is
	// always on; this only makes providers that hide it by default send it.
	// Off by default because some gateways reject unknown request fields.
	StreamUsage bool                     `toml:"stream_usage"`
	Ollama      OllamaConfig             `toml:"ollama"`
	OmniRoute   GatewayConfig            `toml:"omniroute"`
	OpenAI      GatewayConfig            `toml:"openai"`
	Gemini      GatewayConfig            `toml:"gemini"`
	Groq        GatewayConfig            `toml:"groq"`
	OpenRouter  GatewayConfig            `toml:"openrouter"`
	Anthropic   GatewayConfig            `toml:"anthropic"`
	Qwen        GatewayConfig            `toml:"qwen"`
	Kimi        GatewayConfig            `toml:"kimi"`
	Hermes      GatewayConfig            `toml:"hermes"`
	XAI         GatewayConfig            `toml:"xai"`
	Mistral     GatewayConfig            `toml:"mistral"`
	MiniMax     GatewayConfig            `toml:"minimax"`
	DeepSeek    GatewayConfig            `toml:"deepseek"`
	Together    GatewayConfig            `toml:"together"`
	Fireworks   GatewayConfig            `toml:"fireworks"`
	Cerebras    GatewayConfig            `toml:"cerebras"`
	Zhipu       GatewayConfig            `toml:"zhipu"`
	Nvidia      GatewayConfig            `toml:"nvidia"`
	Copilot     CopilotConfig            `toml:"copilot"`
	Custom      map[string]GatewayConfig `toml:"custom"`
}

ProviderConfig specifies provider settings.

type SessionConfig

type SessionConfig struct {
	// Persist controls whether conversations are written to the SQLite store.
	Persist bool `toml:"persist"`
}

SessionConfig specifies session settings.

type ShellConfig

type ShellConfig struct {
	TimeoutSeconds int `toml:"timeout_seconds"`
	MaxOutputBytes int `toml:"max_output_bytes"`
	// RedactSecrets controls masking of shell_exec command output only, before
	// that output becomes a tool result. Setting it false does not disable
	// redaction at the transcript boundary: tool results, tool-call arguments,
	// and session exports are always redacted (see tools.RedactToolOutput).
	RedactSecrets bool `toml:"redact_secrets"`
	// EnvScrub lists additional env var names or patterns to drop from
	// child process environments, on top of the built-in credential patterns.
	EnvScrub []string `toml:"env_scrub"`
}

type TUIConfig added in v0.7.5

type TUIConfig struct {
	// Motion gates animation: "auto" honours the terminal's reduced-motion
	// signal, while "reduced" and "off" force it down. Decorative motion
	// (shimmer, mascot springs) stops; functional indicators (the spinner
	// glyph, elapsed badges) become static rather than disappearing.
	Motion string `toml:"motion"`
	// SmoothStreaming paces streamed text and tool-argument previews into the
	// transcript instead of rendering them on arrival. Off by default
	// (render-on-arrival behavior); opt in with smooth_streaming = true.
	SmoothStreaming bool `toml:"smooth_streaming"`
	// ActiveTheme names a built-in or user theme. Matching is
	// case-insensitive; an unknown name falls back to the default with a
	// logged warning at startup.
	ActiveTheme string `toml:"active_theme"`
	// Transparent skips painting the app background, so the terminal's own
	// background shows through.
	Transparent bool `toml:"transparent"`
}

TUIConfig controls the rich TUI's animation and input behaviour.

type ToolsConfig

type ToolsConfig struct {
	Shell ShellConfig `toml:"shell"`
	// MaxToolIterations caps provider round-trips per user turn. Zero or
	// negative uses the built-in default.
	MaxToolIterations int `toml:"max_tool_iterations"`
	// MaxRepeatedToolCalls caps identical tool calls (same name and same
	// arguments) within one turn. Zero or negative uses the built-in default.
	MaxRepeatedToolCalls int `toml:"max_repeated_tool_calls"`
	// MaxContextTokens overrides the per-model context window; zero or
	// negative derives the budget from the active model's window (80%).
	MaxContextTokens int `toml:"max_context_tokens"`
	// VerifyCommand, when set, is run once after any provider round that
	// executed a tool able to modify the workspace. Empty disables auto-verify.
	VerifyCommand string `toml:"verify_command"`
	// VerifyTimeoutSeconds bounds one auto-verify run. Zero or negative uses
	// 120 seconds; it is only consulted when VerifyCommand is set.
	VerifyTimeoutSeconds int `toml:"verify_timeout_seconds"`
}

Jump to

Keyboard shortcuts

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