config

package
v0.21.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package config manages application configuration from various sources.

Index

Constants

View Source
const (
	// InitFlagFilename is the name of the file that indicates whether the project has been initialized
	InitFlagFilename = "init"
)
View Source
const (
	MaxTokensFallbackDefault = 4096
)

Application constants

Variables

This section is empty.

Functions

func ConfigFileFormat added in v0.2.0

func ConfigFileFormat() string

ConfigFileFormat returns the format ("json" or "toml") of the active config file.

func DeleteLSP

func DeleteLSP(language string) error

func DeleteMCPServer

func DeleteMCPServer(name string) error

func DetectPreferredProjectContextPath added in v0.9.0

func DetectPreferredProjectContextPath(workDir string) (string, bool)

DetectPreferredProjectContextPath returns the highest-priority project context file that already exists in the working directory.

func IsPrioritizedProjectContextPath added in v0.9.0

func IsPrioritizedProjectContextPath(path string) bool

IsPrioritizedProjectContextPath reports whether the path belongs to the exclusive project context file family where only one file should be used.

func LoadGitHubToken

func LoadGitHubToken() (string, error)

LoadGitHubToken loads a GitHub OAuth token from the saved Copilot login, environment variables, or compatible external tooling.

func MarkProjectInitialized

func MarkProjectInitialized() error

MarkProjectInitialized marks the current project as initialized

func OverrideAgentModel added in v0.9.0

func OverrideAgentModel(agentName AgentName, modelID models.ModelID) error

OverrideAgentModel updates the selected agent model only for the current process. The change is kept in memory and is not persisted to the config file.

func Reload added in v0.2.0

func Reload() error

Reload re-reads the config file and updates the global config. It resets the global config and reloads from disk.

func ResolveConfigFilePath added in v0.2.0

func ResolveConfigFilePath() (string, error)

ResolveConfigFilePath finds the active config file path.

func ResolveProjectInitializationContextPath added in v0.9.0

func ResolveProjectInitializationContextPath(workDir string) string

ResolveProjectInitializationContextPath returns the preferred existing project context file, or the default file to create if none exists yet.

func ShouldShowInitDialog

func ShouldShowInitDialog() (bool, error)

ShouldShowInitDialog checks if the initialization dialog should be shown for the current directory

func UpdateAgentModel

func UpdateAgentModel(agentName AgentName, modelID models.ModelID) error

func UpdateAutoCompact

func UpdateAutoCompact(enabled bool) error

func UpdateDebug

func UpdateDebug(enabled bool) error

func UpdateInternalTools added in v0.21.1

func UpdateInternalTools(internalToolsCfg InternalToolsConfig) error

UpdateInternalTools updates internal tools configuration and persists it to the config file.

func UpdateLSP

func UpdateLSP(language string, lsp LSPConfig) error

func UpdateMCPServer

func UpdateMCPServer(name string, server MCPServer) error

func UpdateMesnada

func UpdateMesnada(mesnadaCfg MesnadaConfig) error

func UpdateProvider

func UpdateProvider(name models.ModelProvider, apiKey string, baseURL string, disabled bool) error

func UpdateRemembrances added in v0.7.0

func UpdateRemembrances(remembrancesCfg RemembrancesConfig) error

UpdateRemembrances updates remembrances configuration and persists it to the config file.

func UpdateShell

func UpdateShell(path string, args []string) error

func UpdateSkillsEnabled

func UpdateSkillsEnabled(enabled bool) error

func UpdateTheme

func UpdateTheme(themeName string) error

UpdateTheme updates the theme in the configuration and writes it to the config file.

func Validate

func Validate() error

Validate checks if the configuration is valid and applies defaults where needed.

func WorkingDirectory

func WorkingDirectory() string

WorkingDirectory returns the current working directory from the configuration.

Types

type APIServerConfig added in v0.7.0

type APIServerConfig struct {
	Enabled     bool   `json:"enabled,omitempty"`
	Host        string `json:"host,omitempty"`
	Port        int    `json:"port,omitempty"`
	RequireAuth bool   `json:"requireAuth,omitempty"`
}

APIServerConfig holds configuration for the HTTP API server (WebUI backend).

type Agent

type Agent struct {
	Model                models.ModelID `json:"model"`
	MaxTokens            int64          `json:"maxTokens"`
	ReasoningEffort      string         `json:"reasoningEffort"`                // For openai models low,medium,heigh
	AutoCompact          bool           `json:"autoCompact,omitempty"`          // enable auto-compaction when context fills up
	AutoCompactThreshold float64        `json:"autoCompactThreshold,omitempty"` // 0.0-1.0, default 0.85
}

Agent defines configuration for different LLM models and their token limits.

type AgentName

type AgentName string
const (
	AgentCoder      AgentName = "coder"
	AgentSummarizer AgentName = "summarizer"
	AgentTask       AgentName = "task"
	AgentTitle      AgentName = "title"
)

type Config

type Config struct {
	Data          Data                              `json:"data"`
	WorkingDir    string                            `json:"wd,omitempty"`
	MCPServers    map[string]MCPServer              `json:"mcpServers,omitempty"`
	Providers     map[models.ModelProvider]Provider `json:"providers,omitempty"`
	LSP           map[string]LSPConfig              `json:"lsp,omitempty"`
	Agents        map[AgentName]Agent               `json:"agents,omitempty"`
	Debug         bool                              `json:"debug,omitempty"`
	LogFile       string                            `json:"logFile,omitempty"`
	DebugLSP      bool                              `json:"debugLSP,omitempty"`
	ContextPaths  []string                          `json:"contextPaths,omitempty"`
	Skills        SkillsConfig                      `json:"skills,omitempty"`
	TUI           TUIConfig                         `json:"tui"`
	Mesnada       MesnadaConfig                     `json:"mesnada,omitempty"`
	Shell         ShellConfig                       `json:"shell,omitempty"`
	AutoCompact   bool                              `json:"autoCompact,omitempty"`
	Remembrances  RemembrancesConfig                `json:"remembrances,omitempty"`
	Server        APIServerConfig                   `json:"server,omitempty"`
	Lua           LuaConfig                         `json:"lua,omitempty"`
	MCPGateway    MCPGatewayConfig                  `json:"mcpGateway,omitempty"`
	InternalTools InternalToolsConfig               `json:"internalTools,omitempty"`
}

Config is the main configuration structure for the application.

func Get

func Get() *Config

Get returns the current configuration. It's safe to call this function multiple times.

func Load

func Load(workingDir string, debug bool, logFile ...string) (*Config, error)

Load initializes the configuration from environment variables and config files. If debug is true, debug mode is enabled and log level is set to debug. If logFile is provided, all logs are written to the specified file. It returns an error if configuration loading fails.

type Data

type Data struct {
	Directory string `json:"directory,omitempty"`
}

Data defines storage configuration.

type InternalToolsConfig added in v0.20.0

type InternalToolsConfig struct {
	// Fetch tool
	FetchEnabled   bool `json:"fetchEnabled,omitempty"`
	FetchMaxSizeMB int  `json:"fetchMaxSizeMB,omitempty"`

	// Google Custom Search
	GoogleSearchEnabled  bool   `json:"googleSearchEnabled,omitempty"`
	GoogleAPIKey         string `json:"googleApiKey,omitempty"`
	GoogleSearchEngineID string `json:"googleSearchEngineId,omitempty"`

	// Brave Search
	BraveSearchEnabled bool   `json:"braveSearchEnabled,omitempty"`
	BraveAPIKey        string `json:"braveApiKey,omitempty"`

	// Perplexity AI Search
	PerplexitySearchEnabled bool   `json:"perplexitySearchEnabled,omitempty"`
	PerplexityAPIKey        string `json:"perplexityApiKey,omitempty"`

	// Context7 library docs (no API key required)
	Context7Enabled bool `json:"context7Enabled,omitempty"`
}

InternalToolsConfig defines configuration for Pando's built-in tool integrations.

type LSPConfig

type LSPConfig struct {
	Disabled bool     `json:"enabled"`
	Command  string   `json:"command"`
	Args     []string `json:"args"`
	Options  any      `json:"options"`
}

LSPConfig defines configuration for Language Server Protocol integration.

type LuaConfig added in v0.8.0

type LuaConfig struct {
	Enabled         bool   `json:"enabled,omitempty" toml:"Enabled"`
	ScriptPath      string `json:"script_path,omitempty" toml:"ScriptPath"`
	Timeout         string `json:"timeout,omitempty" toml:"Timeout"` // e.g. "5s"
	StrictMode      bool   `json:"strict_mode,omitempty" toml:"StrictMode"`
	HotReload       bool   `json:"hot_reload,omitempty" toml:"HotReload"`
	LogFilteredData bool   `json:"log_filtered_data,omitempty" toml:"LogFilteredData"`
}

LuaConfig defines configuration for the Lua scripting engine.

type MCPGatewayConfig added in v0.8.0

type MCPGatewayConfig struct {
	Enabled            bool `json:"enabled,omitempty" toml:"Enabled"`
	FavoriteThreshold  int  `json:"favorite_threshold,omitempty" toml:"FavoriteThreshold"`
	MaxFavorites       int  `json:"max_favorites,omitempty" toml:"MaxFavorites"`
	FavoriteWindowDays int  `json:"favorite_window_days,omitempty" toml:"FavoriteWindowDays"`
	DecayDays          int  `json:"decay_days,omitempty" toml:"DecayDays"`
}

MCPGatewayConfig defines configuration for the MCP gateway subsystem.

type MCPServer

type MCPServer struct {
	Command string            `json:"command"`
	Env     []string          `json:"env"`
	Args    []string          `json:"args"`
	Type    MCPType           `json:"type"`
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers"`
}

MCPServer defines the configuration for a Model Control Protocol server.

type MCPType

type MCPType string

MCPType defines the type of MCP (Model Control Protocol) server.

const (
	MCPStdio          MCPType = "stdio"
	MCPSse            MCPType = "sse"
	MCPStreamableHTTP MCPType = "streamable-http"
)

Supported MCP types

type MesnadaACPConfig

type MesnadaACPConfig struct {
	Enabled        bool                   `json:"enabled,omitempty"`
	DefaultAgent   string                 `json:"defaultAgent,omitempty"`
	AutoPermission bool                   `json:"autoPermission,omitempty"`
	Server         MesnadaACPServerConfig `json:"server,omitempty"`
}

MesnadaACPConfig holds ACP agent configuration

type MesnadaACPServerConfig added in v0.7.0

type MesnadaACPServerConfig struct {
	Enabled        bool     `json:"enabled,omitempty"`
	Transports     []string `json:"transports,omitempty"` // ["stdio", "http"]
	Host           string   `json:"host,omitempty"`
	Port           int      `json:"port,omitempty"`
	MaxSessions    int      `json:"maxSessions,omitempty"`
	SessionTimeout string   `json:"sessionTimeout,omitempty"`
	RequireAuth    bool     `json:"requireAuth,omitempty"`
}

MesnadaACPServerConfig holds configuration for the ACP server.

type MesnadaConfig

type MesnadaConfig struct {
	Enabled      bool                      `json:"enabled,omitempty"`
	Server       MesnadaServerConfig       `json:"server,omitempty"`
	Orchestrator MesnadaOrchestratorConfig `json:"orchestrator,omitempty"`
	ACP          MesnadaACPConfig          `json:"acp,omitempty"`
	TUI          MesnadaTUIConfig          `json:"tui,omitempty"`
}

MesnadaConfig holds all mesnada integration configuration

type MesnadaOrchestratorConfig

type MesnadaOrchestratorConfig struct {
	StorePath        string `json:"storePath,omitempty"`
	LogDir           string `json:"logDir,omitempty"`
	MaxParallel      int    `json:"maxParallel,omitempty"`
	DefaultEngine    string `json:"defaultEngine,omitempty"`
	DefaultModel     string `json:"defaultModel,omitempty"`
	DefaultMCPConfig string `json:"defaultMcpConfig,omitempty"`
	PersonaPath      string `json:"personaPath,omitempty"`
}

MesnadaOrchestratorConfig holds orchestrator settings

type MesnadaServerConfig

type MesnadaServerConfig struct {
	Host string `json:"host,omitempty"`
	Port int    `json:"port,omitempty"`
}

MesnadaServerConfig holds mesnada HTTP server configuration

type MesnadaTUIConfig

type MesnadaTUIConfig struct {
	Enabled bool `json:"enabled,omitempty"`
	WebUI   bool `json:"webui,omitempty"`
}

MesnadaTUIConfig holds mesnada TUI settings

type ProjectInitFlag

type ProjectInitFlag struct {
	Initialized bool `json:"initialized"`
}

ProjectInitFlag represents the initialization status for a project directory

type Provider

type Provider struct {
	APIKey   string `json:"apiKey"`
	BaseURL  string `json:"baseURL,omitempty"`
	Disabled bool   `json:"disabled"`
	// UseOAuth enables OAuth mode for the anthropic provider (claude.ai OAuth instead of API key).
	UseOAuth bool `json:"useOAuth,omitempty"`
}

Provider defines configuration for an LLM provider.

type RemembrancesConfig added in v0.7.0

type RemembrancesConfig struct {
	Enabled                   bool   `json:"enabled" toml:"Enabled"`
	DocumentEmbeddingProvider string `json:"document_embedding_provider" toml:"DocumentEmbeddingProvider"`
	DocumentEmbeddingModel    string `json:"document_embedding_model" toml:"DocumentEmbeddingModel"`
	// DocumentEmbeddingBaseURL and DocumentEmbeddingAPIKey are used when DocumentEmbeddingProvider is "openai-compatible".
	DocumentEmbeddingBaseURL string `json:"document_embedding_base_url" toml:"DocumentEmbeddingBaseURL"`
	DocumentEmbeddingAPIKey  string `json:"document_embedding_api_key" toml:"DocumentEmbeddingAPIKey"`
	CodeEmbeddingProvider    string `json:"code_embedding_provider" toml:"CodeEmbeddingProvider"`
	CodeEmbeddingModel       string `json:"code_embedding_model" toml:"CodeEmbeddingModel"`
	// CodeEmbeddingBaseURL and CodeEmbeddingAPIKey are used when CodeEmbeddingProvider is "openai-compatible".
	CodeEmbeddingBaseURL string `json:"code_embedding_base_url" toml:"CodeEmbeddingBaseURL"`
	CodeEmbeddingAPIKey  string `json:"code_embedding_api_key" toml:"CodeEmbeddingAPIKey"`
	UseSameModel         bool   `json:"use_same_model" toml:"UseSameModel"`
	ChunkSize            int    `json:"chunk_size" toml:"ChunkSize"`
	ChunkOverlap         int    `json:"chunk_overlap" toml:"ChunkOverlap"`
	IndexWorkers         int    `json:"index_workers" toml:"IndexWorkers"`
}

RemembrancesConfig defines configuration for the remembrances system.

type ShellConfig

type ShellConfig struct {
	Path string   `json:"path,omitempty"`
	Args []string `json:"args,omitempty"`
}

ShellConfig defines the configuration for the shell used by the bash tool.

type SkillsConfig

type SkillsConfig struct {
	Enabled bool     `json:"enabled,omitempty"`
	Paths   []string `json:"paths,omitempty"`
}

SkillsConfig defines configuration for skill discovery and prompt injection.

type TUIConfig

type TUIConfig struct {
	Theme string `json:"theme,omitempty"`
}

TUIConfig defines the configuration for the Terminal User Interface.

Jump to

Keyboard shortcuts

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