Documentation
¶
Index ¶
- Constants
- func AtomicWrite(path string, data []byte, perm os.FileMode) error
- func AuthPath() (string, error)
- func ConfigDir() (string, error)
- func ExtensionConfigDir(name string) (string, error)
- func HistoryPath() (string, error)
- func IntOr(v, fallback int) int
- func ModelsPath() (string, error)
- func NeedsSetup() bool
- func NormalizeProvider(name string) string
- func ReadExtensionConfig(name string) (string, error)
- func RunSetup(writeModels func(path string) error, modelDefaults map[string]string) error
- func Save(s Settings) error
- func SaveTo(s Settings, path string) error
- func SessionsDir() (string, error)
- func SettingsPath() (string, error)
- type AgentSettings
- type Auth
- type BashSettings
- type ExtensionSettings
- type GitSettings
- type LocalDefaults
- type Settings
- type SubAgentSettings
- type ToolSettings
Constants ¶
const DefaultMaxTurns = 30
DefaultMaxTurns is the application-wide default for agent max turns. Used as the fallback in config.IntOr(settings.Agent.MaxTurns, config.DefaultMaxTurns).
const DefaultSubAgentMaxTurns = 30
DefaultSubAgentMaxTurns is the default max turns for sub-agent dispatch (SubAgentSettings.MaxTurns zero value).
Variables ¶
This section is empty.
Functions ¶
func AtomicWrite ¶ added in v0.16.8
AtomicWrite writes data to path using a temp file + rename pattern. Creates parent directories with 0o700 if needed.
func ExtensionConfigDir ¶ added in v0.16.26
ExtensionConfigDir returns the namespaced config directory for an extension: ~/.config/piglet/extensions/<name>/. It does not create the directory.
func HistoryPath ¶ added in v0.16.24
HistoryPath returns ~/.config/piglet/history.
func ModelsPath ¶ added in v0.5.0
ModelsPath returns the path to models.yaml in the config dir.
func NeedsSetup ¶ added in v0.5.0
func NeedsSetup() bool
NeedsSetup returns true if config.yaml or models.yaml is missing.
func NormalizeProvider ¶
NormalizeProvider resolves aliases to canonical provider names.
func ReadExtensionConfig ¶ added in v0.5.0
ReadExtensionConfig reads a markdown config file for the named extension. Looks for ~/.config/piglet/extensions/<name>/<name>.md first, falling back to ~/.config/piglet/<name>.md for backward compatibility. Returns empty string (not error) if the file doesn't exist.
func RunSetup ¶ added in v0.5.0
RunSetup runs the interactive first-time setup flow. writeModels is called to write the default models.yaml file. modelDefaults maps provider key → default model ID (used during key detection).
func SessionsDir ¶
SessionsDir returns ~/.config/piglet/sessions/.
func SettingsPath ¶
SettingsPath returns ~/.config/piglet/config.yaml.
Types ¶
type AgentSettings ¶ added in v0.4.0
type AgentSettings struct {
MaxTurns int `yaml:"maxTurns,omitempty"` // default DefaultMaxTurns
BgMaxTurns int `yaml:"bgMaxTurns,omitempty"` // default 5
AutoTitle *bool `yaml:"autoTitle,omitempty"` // default true; pointer distinguishes false from unset
CompactKeepRecent int `yaml:"compactKeepRecent,omitempty"` // default 6
CompactAt int `yaml:"compactAt,omitempty"` // token threshold for auto-compact; 0 = disabled
MaxMessages int `yaml:"maxMessages,omitempty"` // hard cap on messages; 0 = unlimited
MaxTokens int `yaml:"maxTokens,omitempty"` // output token limit; 0 = use model default
MaxRetries int `yaml:"maxRetries,omitempty"` // retry attempts on error; 0 = use default (3)
ToolConcurrency int `yaml:"toolConcurrency,omitempty"` // max parallel tool calls; 0 = use default (10)
}
AgentSettings controls agent loop behavior. Zero values use defaults.
func (AgentSettings) AutoTitleEnabled ¶ added in v0.4.0
func (a AgentSettings) AutoTitleEnabled() bool
AutoTitleEnabled returns whether auto-title generation is on (default true).
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth manages API key resolution. Priority: runtime overrides → stored credentials → environment variables → command values.
func NewAuth ¶
NewAuth creates an Auth that persists to the given path. Pass "" for in-memory only (tests).
func NewAuthDefault ¶
NewAuthDefault creates an Auth using the default auth path.
func (*Auth) GetAPIKey ¶
GetAPIKey returns the API key for a provider. Resolution order: runtime override → stored credential → env var → empty.
func (*Auth) SetRuntimeKey ¶
SetRuntimeKey sets a runtime API key override (not persisted).
type BashSettings ¶ added in v0.4.0
type BashSettings struct {
DefaultTimeout int `yaml:"defaultTimeout,omitempty"` // seconds, default 30
MaxTimeout int `yaml:"maxTimeout,omitempty"` // seconds, default 300
MaxStdout int `yaml:"maxStdout,omitempty"` // bytes, default 100000
MaxStderr int `yaml:"maxStderr,omitempty"` // bytes, default 50000
}
BashSettings controls the bash tool limits. Zero values use defaults.
type ExtensionSettings ¶ added in v0.16.8
type ExtensionSettings struct {
RepoURL string `yaml:"repoUrl,omitempty"`
Official []string `yaml:"official,omitempty"`
}
ExtensionSettings controls extension installation defaults.
type GitSettings ¶ added in v0.4.0
type GitSettings struct {
MaxDiffStatFiles int `yaml:"maxDiffStatFiles,omitempty"` // default 30
MaxLogLines int `yaml:"maxLogLines,omitempty"` // default 5
MaxDiffHunkLines int `yaml:"maxDiffHunkLines,omitempty"` // default 50
CommandTimeout int `yaml:"commandTimeout,omitempty"` // seconds, default 5
}
GitSettings controls git context in the system prompt. Zero values use defaults.
type LocalDefaults ¶ added in v0.17.0
type LocalDefaults struct {
ContextWindow int `yaml:"contextWindow,omitempty"`
MaxTokens int `yaml:"maxTokens,omitempty"`
}
LocalDefaults holds default values for ad-hoc local model connections.
type Settings ¶
type Settings struct {
DefaultProvider string `yaml:"defaultProvider,omitempty"`
DefaultModel string `yaml:"defaultModel,omitempty"`
SmallModel string `yaml:"smallModel,omitempty"`
SystemPrompt string `yaml:"systemPrompt,omitempty"` // base identity; overridden by prompt.md
Theme string `yaml:"theme,omitempty"`
Extensions []string `yaml:"extensions,omitempty"`
Providers map[string]string `yaml:"providers,omitempty"` // provider name → base URL override
Agent AgentSettings `yaml:"agent,omitempty"`
Git GitSettings `yaml:"git,omitempty"`
Tools ToolSettings `yaml:"tools,omitempty"`
Bash BashSettings `yaml:"bash,omitempty"`
Shortcuts map[string]string `yaml:"shortcuts,omitempty"` // action → keybind (e.g. "model": "ctrl+p")
PromptOrder map[string]int `yaml:"promptOrder,omitempty"` // section title → order override
RTK *bool `yaml:"rtk,omitempty"` // nil = auto-detect; true/false = explicit
Debug bool `yaml:"debug,omitempty"` // log all request/response payloads
Safeguard *bool `yaml:"safeguard,omitempty"` // nil/true = enabled; false = disabled
MouseCapture *bool `yaml:"mouseCapture,omitempty"` // nil/true = TUI captures mouse for scrolling; false = terminal handles (native text selection)
DisabledExtensions []string `yaml:"disabled_extensions,omitempty"` // extensions to skip during loading
AllowProjectExtensions *bool `yaml:"allowProjectExtensions,omitempty"` // default false; must opt-in for security
SubAgent SubAgentSettings `yaml:"subagent,omitempty"`
ExtInstall ExtensionSettings `yaml:"extInstall,omitempty"`
LocalServers []string `yaml:"localServers,omitempty"` // URLs of local model servers to probe on startup
LocalDefaults LocalDefaults `yaml:"localDefaults,omitempty"`
DeferredToolsNote string `yaml:"deferredToolsNote,omitempty"` // instruction shown when deferred tools are present
}
Settings holds user configuration.
func DefaultSettings ¶ added in v0.17.0
func DefaultSettings() Settings
DefaultSettings returns a Settings with all defaults applied. Useful for testing and for code that needs a baseline configuration.
func (Settings) IsExtensionDisabled ¶ added in v0.16.16
IsExtensionDisabled reports whether the named extension is in the disabled list.
func (Settings) MouseCaptureEnabled ¶ added in v0.23.0
MouseCaptureEnabled reports whether TUI mouse capture is on. Default (nil) is true.
func (Settings) ResolveDefaultModel ¶ added in v0.9.0
ResolveDefaultModel returns the first non-empty value from the default model cascade: PIGLET_DEFAULT_MODEL env → DefaultModel config.
func (Settings) ResolveSmallModel ¶ added in v0.9.0
ResolveSmallModel returns the first non-empty value from the small model cascade: PIGLET_SMALL_MODEL env → SmallModel config → PIGLET_DEFAULT_MODEL env → DefaultModel config.
type SubAgentSettings ¶ added in v0.5.0
type SubAgentSettings struct {
MaxTurns int `yaml:"maxTurns,omitempty"` // default DefaultSubAgentMaxTurns
}
SubAgentSettings controls the dispatch tool's sub-agent defaults.
type ToolSettings ¶ added in v0.5.0
type ToolSettings struct {
ReadLimit int `yaml:"readLimit,omitempty"` // max lines per read; default 2000
GrepLimit int `yaml:"grepLimit,omitempty"` // max grep matches; default 100
}
ToolSettings controls built-in tool defaults. Zero values use defaults.