Documentation
¶
Index ¶
- Variables
- func APIKeys() map[string]string
- func BaseURLs() map[string]string
- func SaveDefaultRole(model, provider string) error
- type A2AAgentConfig
- type A2AConfig
- type AutoCompactConfig
- type CompactorConfig
- type Config
- type HookConfig
- type MCPConfig
- type MCPServer
- type MemoryConfig
- type PalaceConfig
- type RoleConfig
Constants ¶
This section is empty.
Variables ¶
var ErrNoDefaultRole = errors.New("no default model role configured")
ErrNoDefaultRole is returned when no default role is configured.
Functions ¶
func APIKeys ¶
APIKeys returns detected API keys from environment variables. For Anthropic, checks ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN (Ollama compatibility).
func BaseURLs ¶
BaseURLs returns provider base URLs from environment variables. Supports ANTHROPIC_BASE_URL (Ollama compatibility), OPENAI_BASE_URL, GEMINI_BASE_URL, and OLLAMA_HOST (Ollama server address override).
func SaveDefaultRole ¶ added in v0.0.23
SaveDefaultRole updates the "default" role in the global config and saves it. If the default role doesn't exist, it creates it. If a model is already set, it updates only the model field (preserving provider, advisor, etc.).
Types ¶
type A2AAgentConfig ¶ added in v0.0.15
A2AAgentConfig defines a single A2A-capable agent endpoint.
type A2AConfig ¶ added in v0.0.15
type A2AConfig struct {
Agents []A2AAgentConfig `json:"agents,omitempty"`
}
A2AConfig holds configuration for A2A agent connections.
type AutoCompactConfig ¶ added in v0.0.48
type AutoCompactConfig struct {
Enabled *bool `json:"enabled,omitempty"`
// ShedPercent is the context-window share at which superseded tool results
// are dropped. Cheap: no LLM call, prompt cache preserved.
ShedPercent int `json:"shed_percent,omitempty"`
// SummarizePercent is the share at which a summarizing rebuild runs.
// Clamped to 95 — beyond that the summarization request itself may not fit.
SummarizePercent int `json:"summarize_percent,omitempty"`
// KeepUserMessageTokens caps user messages carried across a rebuild.
KeepUserMessageTokens int `json:"keep_user_message_tokens,omitempty"`
// KeepRecentEvents is the conversation tail compaction never touches.
KeepRecentEvents int `json:"keep_recent_events,omitempty"`
}
AutoCompactConfig holds user-overridable auto-compaction settings. When nil in config, the session package's two-stage defaults apply: shed superseded tool results at 60% of the context window, run a full summarizing rebuild at 88%.
type CompactorConfig ¶ added in v0.0.4
type CompactorConfig struct {
Enabled *bool `json:"enabled,omitempty"`
SourceCodeFiltering string `json:"source_code_filtering,omitempty"` // "none", "minimal", "aggressive"
MaxChars int `json:"max_chars,omitempty"`
MaxLines int `json:"max_lines,omitempty"`
}
CompactorConfig holds user-overridable compaction settings. When nil in config, defaults are applied by the tools package.
type Config ¶
type Config struct {
Roles map[string]RoleConfig `json:"roles,omitempty"`
DefaultModel string `json:"defaultModel,omitempty"` // deprecated: use roles
DefaultProvider string `json:"defaultProvider"`
ThinkingLevel string `json:"thinkingLevel"`
Theme string `json:"theme"`
BaseURLs map[string]string `json:"baseURLs,omitempty"` // provider → base URL; overridden by env
ExtraHeaders map[string]string `json:"extraHeaders,omitempty"`
InsecureSkipTLS bool `json:"insecureSkipTLS,omitempty"`
// CACertPath is a PEM bundle trusted in addition to the system roots, for
// TLS-intercepting corporate proxies. Prefer it over insecureSkipTLS,
// which turns verification off for every endpoint.
CACertPath string `json:"caCertPath,omitempty"`
// DisableSystemCAs narrows trust to caCertPath alone.
DisableSystemCAs bool `json:"disableSystemCAs,omitempty"`
// TraceHTTP logs every LLM request and response in full — headers and
// bodies — to the session log and to OTel span events. Equivalent to
// --trace-http, which can enable it but never turn it off.
//
// The resulting log contains the entire conversation, system prompt and
// tool output in cleartext. Credentials are masked; nothing else is.
TraceHTTP bool `json:"traceHTTP,omitempty"`
Tools map[string]any `json:"tools,omitempty"`
MCP *MCPConfig `json:"mcp,omitempty"`
Hooks []HookConfig `json:"hooks,omitempty"`
MaxDailyTokens int64 `json:"maxDailyTokens,omitempty"` // 0 = unlimited
// ContextWindow overrides the model's context window in tokens. Needed for
// models absent from the embedded catalog (notably the opencode ones):
// auto-compaction measures a percentage of the window, so it stays off
// rather than guess at an unknown budget.
ContextWindow int64 `json:"contextWindow,omitempty"`
Compactor *CompactorConfig `json:"compactor,omitempty"`
AutoCompact *AutoCompactConfig `json:"autoCompact,omitempty"`
Memory *MemoryConfig `json:"memory,omitempty"`
Palace *PalaceConfig `json:"palace,omitempty"`
A2A *A2AConfig `json:"a2a,omitempty"`
}
Config holds all pi-go configuration.
func Defaults ¶
func Defaults() Config
Defaults returns a Config with default values. The default model is the latest top-tier entry in the embedded OpenAI catalog (modeldata/llm-prices-openai.json): gpt-5.6-sol is the current frontier at the time of writing. Bump this in lockstep with the catalog.
func Load ¶
Load reads config from global (~/.pi-go/config.json) and project (.pi-go/config.json) relative to the current process working directory.
func LoadFrom ¶ added in v0.0.25
LoadFrom reads config from global (~/.pi-go/config.json) and the nearest project .pi-go/config.json relative to cwd, merging project overrides onto global. MCP servers are also loaded from separate .pi-go/mcp.json files if present.
func (*Config) ResolveBaseURLs ¶ added in v0.0.46
ResolveBaseURLs returns provider base URLs from the config's baseURLs map merged with the environment, environment winning. This lets a self-hosted endpoint (e.g. an Ollama server on the LAN) live in config.json instead of requiring a shell export, while keeping the env vars usable as a per-shell or CI override. An empty env var does not mask a configured value.
func (*Config) ResolveRole ¶
func (c *Config) ResolveRole(role string) (model string, prov string, advisorModel string, advisorMaxUses int, advisorCaching bool, err error)
ResolveRole returns the model name, provider, and advisor settings for a given role. Falls back: requested role → "default" role → error.
type HookConfig ¶
type HookConfig struct {
Event string `json:"event"`
Command string `json:"command"`
Tools []string `json:"tools,omitempty"`
Timeout int `json:"timeout,omitempty"`
}
HookConfig defines a shell command hook for tool call events.
type MCPServer ¶
type MCPServer struct {
Name string `json:"name"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
URL string `json:"url,omitempty"` // HTTP transport (e.g., cloudflare-api)
Headers map[string]string `json:"headers,omitempty"` // Custom HTTP headers for the URL (Streamable HTTP) transport
}
func LoadMCPServers ¶ added in v0.0.22
func LoadMCPServers() []MCPServer
LoadMCPServers reads MCP server configurations from standalone mcp.json files relative to the current process working directory.
func LoadMCPServersFrom ¶ added in v0.0.25
LoadMCPServersFrom reads MCP server configurations from standalone mcp.json files relative to cwd. Resolution order: project .pi-go/mcp.json overrides global ~/.pi-go/mcp.json. Supports both the Claude Desktop object format (servers keyed by name) and the legacy array format.
type MemoryConfig ¶ added in v0.0.10
type MemoryConfig struct {
Enabled *bool `json:"enabled,omitempty"`
DBPath string `json:"db_path,omitempty"`
TokenBudget int `json:"token_budget,omitempty"`
CompressionRole string `json:"compression_model_role,omitempty"`
MaxPending int `json:"max_pending_observations,omitempty"`
LookbackHours int `json:"context_lookback_hours,omitempty"`
ExcludedTools []string `json:"excluded_tools,omitempty"`
ExcludedProjects []string `json:"excluded_projects,omitempty"`
}
MemoryConfig holds settings for the persistent memory system.
func MemoryDefaults ¶ added in v0.0.10
func MemoryDefaults() MemoryConfig
MemoryDefaults returns a MemoryConfig with default values.
type PalaceConfig ¶ added in v0.0.15
type PalaceConfig struct {
Enabled *bool `json:"enabled,omitempty"`
DBPath string `json:"db_path,omitempty"`
ModelPath string `json:"model_path,omitempty"`
// OllamaURL overrides the embedding daemon address. Empty uses the palace
// default (http://localhost:11434).
OllamaURL string `json:"ollama_url,omitempty"`
// OllamaModel overrides the embedding model. Empty uses the palace default.
// Changing it invalidates every stored vector — embeddings from different
// models are not comparable — so a change means re-running `pi memory mine`.
OllamaModel string `json:"ollama_model,omitempty"`
// LocalEmbedder forces the slower in-process model instead of Ollama.
LocalEmbedder bool `json:"local_embedder,omitempty"`
}
PalaceConfig holds settings for the MemPalace memory system.
type RoleConfig ¶
type RoleConfig struct {
Model string `json:"model"`
Provider string `json:"provider,omitempty"`
AdvisorModel string `json:"advisorModel,omitempty"` // Advisor model for advisor tool (e.g., "claude-opus-4-7")
AdvisorMaxUses int `json:"advisorMaxUses,omitempty"` // Max advisor calls per request (0 = unlimited)
AdvisorCaching bool `json:"advisorCaching,omitempty"` // Enable advisor prompt caching
}
RoleConfig maps a role to a specific model and optional provider override.