config

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package config handles application configuration from environment variables

Index

Constants

View Source
const (
	EnvAPIKey      = "ANTHROPIC_API_KEY"
	EnvBaseURL     = "ANTHROPIC_BASE_URL"
	EnvOpusModel   = "ANTHROPIC_DEFAULT_OPUS_MODEL"
	EnvSonnetModel = "ANTHROPIC_DEFAULT_SONNET_MODEL"
	EnvHaikuModel  = "ANTHROPIC_DEFAULT_HAIKU_MODEL"
	EnvMaxTokens   = "CLAUDE_CODE_MAX_OUTPUT_TOKENS"
)

Environment variable names

Variables

This section is empty.

Functions

func ConfigFilePath

func ConfigFilePath() string

ConfigFilePath returns the path to the user's config file, respecting XDG_CONFIG_HOME.

func LoadConfigFile

func LoadConfigFile(path string) (map[string]string, error)

LoadConfigFile reads the config file at path and returns its key-value pairs. If the file does not exist, an empty map is returned without error.

func LoadSystemPromptFile

func LoadSystemPromptFile(path string) (string, error)

LoadSystemPromptFile reads a markdown file and returns its content as a string. If the file does not exist, it returns an empty string and no error.

Types

type Config

type Config struct {
	APIKey      string
	BaseURL     string
	OpusModel   string
	SonnetModel string
	HaikuModel  string
	MaxTokens   int // 0 means use the API client's default
}

Config holds the application configuration

func (Config) AvailableModels

func (c Config) AvailableModels() []string

AvailableModels returns configured model values in priority order (opus, sonnet, haiku).

func (Config) DefaultModel

func (c Config) DefaultModel() string

DefaultModel returns the highest-priority configured model (opus > sonnet > haiku).

func (Config) Validate

func (c Config) Validate() error

Validate checks that all required fields are set

type Loader

type Loader interface {
	Load() (Config, error)
}

Loader defines the interface for loading configuration

func NewEnvLoader

func NewEnvLoader() Loader

NewEnvLoader creates a loader that reads from environment variables, falling back to ~/.config/monkey/config.toml (or $XDG_CONFIG_HOME/monkey/config.toml).

func NewEnvLoaderWithConfigFile

func NewEnvLoaderWithConfigFile(path string) Loader

NewEnvLoaderWithConfigFile creates a loader that reads from environment variables, falling back to the specified config file path.

Jump to

Keyboard shortcuts

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