config

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 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.

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), 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, err error)

ResolveRole returns the model name and provider 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 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. 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"`
}

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