Documentation
¶
Overview ¶
Package config loads and validates configuration from YAML/env and provides helpers for loading role/system messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadMsg ¶
LoadMsg loads a system/role message.
Supported inputs:
- raw strings
- http(s) URLs
- file:// paths
For markdown files loaded via file://, YAML frontmatter is stripped.
func MergeRolesFromDir ¶
MergeRolesFromDir merges role definitions from ~/.config/yai/roles into cfg.
func StripYAMLFrontmatter ¶
StripYAMLFrontmatter removes YAML frontmatter from markdown content.
func WriteConfigFile ¶
WriteConfigFile creates the config file at path if it does not exist.
Types ¶
type API ¶
type API struct {
Name string
APIKey string `yaml:"api-key"`
APIKeyEnv string `yaml:"api-key-env"`
APIKeyCmd string `yaml:"api-key-cmd"`
Version string `yaml:"version"` // not used
BaseURL string `yaml:"base-url"`
Models map[string]Model `yaml:"models"`
User string `yaml:"user"`
}
API represents an API endpoint and its models.
type Config ¶
Config is the application configuration (settings + runtime-only options).
Settings fields are promoted for ergonomic access, but runtime fields are explicitly excluded from YAML/env parsing.
type FormatText ¶
FormatText is a map[format]formatting_text.
func (*FormatText) UnmarshalYAML ¶
func (ft *FormatText) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML conforms with yaml.Unmarshaler.
type MCPServerConfig ¶
type MCPServerConfig struct {
Type string `yaml:"type"`
Command string `yaml:"command"`
Env []string `yaml:"env"`
Args []string `yaml:"args"`
URL string `yaml:"url"`
}
MCPServerConfig holds configuration for an MCP server.
type Model ¶
type Model struct {
Name string
API string
MaxChars int64 `yaml:"max-input-chars"`
Aliases []string `yaml:"aliases"`
Fallback string `yaml:"fallback"`
ThinkingBudget int `yaml:"thinking-budget,omitempty"`
}
Model represents the LLM model used in the API call.
type Runtime ¶
type Runtime struct {
AskModel bool
ShowHelp bool
ResetSettings bool
Prefix string
Version bool
EditSettings bool
Dirs bool
SettingsPath string
ContinueLast bool
Continue string
Title string
ShowLast bool
Show string
List bool
ListRoles bool
Delete []string
DeleteOlderThan time.Duration
MCPList bool
MCPListTools bool
OpenEditor bool
CacheReadFromID string
CacheWriteToID, CacheWriteToTitle string
}
Runtime holds CLI/runtime-only options that should not be loaded from the settings file.
type Settings ¶
type Settings struct {
API string `yaml:"default-api" env:"API"`
Model string `yaml:"default-model" env:"MODEL"`
Format bool `yaml:"format" env:"FORMAT"`
FormatText FormatText `yaml:"format-text"`
FormatAs string `yaml:"format-as" env:"FORMAT_AS"`
Raw bool `yaml:"raw" env:"RAW"`
Quiet bool `yaml:"quiet" env:"QUIET"`
MaxTokens int64 `yaml:"max-tokens" env:"MAX_TOKENS"`
MaxCompletionTokens int64 `yaml:"max-completion-tokens" env:"MAX_COMPLETION_TOKENS"`
MaxInputChars int64 `yaml:"max-input-chars" env:"MAX_INPUT_CHARS"`
Temperature float64 `yaml:"temp" env:"TEMP"`
Stop []string `yaml:"stop" env:"STOP"`
TopP float64 `yaml:"topp" env:"TOPP"`
TopK int64 `yaml:"topk" env:"TOPK"`
NoLimit bool `yaml:"no-limit" env:"NO_LIMIT"`
CachePath string `yaml:"cache-path" env:"CACHE_PATH"`
NoCache bool `yaml:"no-cache" env:"NO_CACHE"`
IncludePromptArgs bool `yaml:"include-prompt-args" env:"INCLUDE_PROMPT_ARGS"`
IncludePrompt int `yaml:"include-prompt" env:"INCLUDE_PROMPT"`
MaxRetries int `yaml:"max-retries" env:"MAX_RETRIES"`
WordWrap int `yaml:"word-wrap" env:"WORD_WRAP"`
Fanciness uint `yaml:"fanciness" env:"FANCINESS"`
StatusText string `yaml:"status-text" env:"STATUS_TEXT"`
HTTPProxy string `yaml:"http-proxy" env:"HTTP_PROXY"`
APIs APIs `yaml:"apis"`
System string `yaml:"system"`
Role string `yaml:"role" env:"ROLE"`
Theme string `yaml:"theme" env:"THEME"`
User string `yaml:"user" env:"USER"`
Roles map[string][]string `yaml:"roles"`
MCPServers map[string]MCPServerConfig `yaml:"mcp-servers"`
MCPDisable []string `yaml:"mcp-disable" env:"MCP_DISABLE"`
MCPTimeout time.Duration `yaml:"mcp-timeout" env:"MCP_TIMEOUT"`
MCPAllowNonTTY bool `yaml:"mcp-allow-non-tty" env:"MCP_ALLOW_NON_TTY"`
MCPNoInheritEnv bool `yaml:"mcp-no-inherit-env" env:"MCP_NO_INHERIT_ENV"`
RequestTimeout time.Duration `yaml:"request-timeout" env:"REQUEST_TIMEOUT"`
}
Settings holds persisted configuration loaded from the YAML settings file and environment variables.