config

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderOpenAI     = "openai"
	ProviderOpenRouter = "openrouter"
	ProviderLocal      = "local"

	DebugNone   = "none"
	DebugScreen = "screen"
	DebugFile   = "file"

	// ToolCalling modes control whether the AI can use read-only tools.
	ToolCallingNever           = "never"            // Tools disabled entirely
	ToolCallingAlwaysPrompt    = "always_prompt"    // Prompt the user before every tool call
	ToolCallingDangerousPrompt = "dangerous_prompt" // Only prompt when a tool hits a safety rule
	ToolCallingAlwaysAllow     = "always_allow"     // Execute all tools without prompting
)

Provider name constants.

Variables

This section is empty.

Functions

func ApplyAction

func ApplyAction(cfg *Config, action, key, value string) error

ApplyAction applies an LLM-initiated config change and saves the result. The action/key/value correspond to the structured response from the LLM (e.g. action="set_model", key="model", value="gpt-4o").

This is the single source of truth for config mutations triggered by the LLM, used by both the single-shot CLI path and the interactive REPL.

func Dir added in v0.1.3

func Dir() (string, error)

func DisplayValue added in v0.1.4

func DisplayValue(action, key, value string) string

DisplayValue masks sensitive config values before printing them to the user.

func ParseBool

func ParseBool(s string) (bool, error)

ParseBool parses a string as a boolean, accepting "true" or "false" (case-insensitive, trimmed). Any other value returns an error.

This is stricter than strconv.ParseBool — it rejects "1", "0", "yes", "no", etc. — because config values come from LLM responses and user input where only "true"/"false" are documented as valid.

func Path added in v0.1.3

func Path() (string, error)

func RedactSecret added in v0.1.4

func RedactSecret(secret string) string

RedactSecret masks a secret for display purposes. Returns an empty string if the input is empty, preserving the unset state.

func Save

func Save(cfg *Config) error

func ValidToolCallingMode added in v0.1.4

func ValidToolCallingMode(mode string) bool

ValidToolCallingMode returns true if the given mode is a valid tool_calling value.

Types

type Config

type Config struct {
	Provider         ProviderConfig `toml:"provider"`
	Safety           SafetyConfig   `toml:"safety"`
	History          HistoryConfig  `toml:"history"`
	Debug            string         `toml:"debug"`              // "none", "screen", or "file"
	DebugLogPayloads bool           `toml:"debug_log_payloads"` // Only used for debug=file
}

func DefaultConfig

func DefaultConfig() *Config

func Load

func Load() (*Config, error)

func RedactedCopy added in v0.1.4

func RedactedCopy(cfg *Config) *Config

RedactedCopy returns a copy of cfg with provider API keys masked for display.

type HistoryConfig added in v0.1.4

type HistoryConfig struct {
	IncludeLLMOutput  bool `toml:"include_llm_output"`
	IncludeDebug      bool `toml:"include_debug"`
	AskOnError        bool `toml:"ask_on_error"`
	AutoCheckOnError  bool `toml:"auto_check_on_error"`
	RetryMaxAttempts  int  `toml:"retry_max_attempts"`
	RetryContextDepth int  `toml:"retry_context_depth"`
}

type ProviderConfig

type ProviderConfig struct {
	Default    string         `toml:"default"`
	Model      string         `toml:"model"`
	OpenAI     ProviderDetail `toml:"openai"`
	OpenRouter ProviderDetail `toml:"openrouter"`
	Local      ProviderDetail `toml:"local"`
}

type ProviderDetail

type ProviderDetail struct {
	APIKey  string `toml:"api_key"`
	BaseURL string `toml:"base_url"`
}

type SafetyConfig

type SafetyConfig struct {
	AlwaysConfirm     bool     `toml:"always_confirm"`
	ToolCalling       string   `toml:"tool_calling"`
	MinCertainty      int      `toml:"min_certainty"`
	AllowlistPrefixes []string `toml:"allowlist_prefixes"`
	WhitelistPrefixes []string `toml:"whitelist_prefixes,omitempty"` // Deprecated: use allowlist_prefixes
}

Jump to

Keyboard shortcuts

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