config

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoDefaultRole = errors.New("no default model role configured")

ErrNoDefaultRole is returned when no default role is configured.

Functions

func APIKeys

func APIKeys() map[string]string

APIKeys returns detected API keys from environment variables. For Anthropic, checks ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN (Ollama compatibility).

func BaseURLs

func BaseURLs() map[string]string

BaseURLs returns provider base URLs from environment variables. Supports ANTHROPIC_BASE_URL (Ollama compatibility), OPENAI_BASE_URL, and GEMINI_BASE_URL.

func SaveDefaultRole added in v0.0.23

func SaveDefaultRole(model, provider string) error

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

type A2AAgentConfig struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

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 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"`
	ExtraHeaders    map[string]string     `json:"extraHeaders,omitempty"`
	InsecureSkipTLS bool                  `json:"insecureSkipTLS,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
	Compactor       *CompactorConfig      `json:"compactor,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.

func Load

func Load() (Config, error)

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

func LoadFrom(cwd string) (Config, error)

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) 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.

func (*Config) Save added in v0.0.23

func (c *Config) Save() error

Save writes the config to the global ~/.pi-go/config.json file. It does not overwrite project-level config.

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 MCPConfig

type MCPConfig struct {
	Servers []MCPServer `json:"servers"`
}

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)
}

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

func LoadMCPServersFrom(cwd string) []MCPServer

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"`
}

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.

Jump to

Keyboard shortcuts

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