config

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 10 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 MarkProjectInitialized

func MarkProjectInitialized() error

MarkProjectInitialized marks the current project as initialized

func Reset

func Reset()

Reset clears the global configuration.

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

UpdateAgentModel updates an agent's model in the config.

func UpdateTheme

func UpdateTheme(themeName string) error

UpdateTheme updates the theme.

func Validate

func Validate() error

Validate checks if the configuration is valid.

func WorkingDirectory

func WorkingDirectory() string

WorkingDirectory returns the current working directory.

Types

type Agent

type Agent struct {
	Model           models.ModelID  `json:"model"`
	MaxTokens       int64           `json:"maxTokens"`
	ReasoningEffort string          `json:"reasoningEffort"`      // For openai models low,medium,high
	Permission      map[string]any  `json:"permission,omitempty"` // tool name -> "allow" | {"pattern": "action"}
	Tools           map[string]bool `json:"tools,omitempty"`      // e.g., {"skill": false}
	Mode            AgentMode       `json:"mode,omitempty"`       // "agent" or "subagent"
	Name            string          `json:"name,omitempty"`
	Native          bool            `json:"native,omitempty"`
	Description     string          `json:"description,omitempty"`
	Prompt          string          `json:"prompt,omitempty"`
	Color           string          `json:"color,omitempty"`
	Hidden          bool            `json:"hidden,omitempty"`
}

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

type AgentMode

type AgentMode string
const (
	AgentModeAgent    AgentMode = "agent"
	AgentModeSubagent AgentMode = "subagent"
)

type AgentName

type AgentName = string

AgentName is a string alias to allow flexibility

const (
	AgentCoder      AgentName = "coder"
	AgentSummarizer AgentName = "summarizer"
	AgentExplorer   AgentName = "explorer"   // Replaces Task
	AgentDescriptor AgentName = "descriptor" // Replaces Title
	AgentWorkhorse  AgentName = "workhorse"
	AgentHivemind   AgentName = "hivemind"

	// Deprecated names (kept for migration logic)
	AgentTask  AgentName = "task"
	AgentTitle AgentName = "title"
)

Agent Constants

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"`
	DebugLSP           bool                              `json:"debugLSP,omitempty"`
	ContextPaths       []string                          `json:"contextPaths,omitempty"`
	TUI                TUIConfig                         `json:"tui"`
	Shell              ShellConfig                       `json:"shell,omitempty"`
	AutoCompact        bool                              `json:"autoCompact,omitempty"`
	DisableLSPDownload bool                              `json:"disableLSPDownload,omitempty"`
	SessionProvider    SessionProviderConfig             `json:"sessionProvider,omitempty"`

	// Depricated: use Rules instead, Needed for backward compatibility.
	Skills     *SkillsConfig     `json:"skills,omitempty"`
	Permission *PermissionConfig `json:"permission,omitempty"`
}

Config is the main configuration structure for the application.

func Get

func Get() *Config

Get returns the current configuration.

func Load

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

Load initializes the configuration.

func (*Config) WorkingDirectory

func (c *Config) WorkingDirectory() string

type Configurator

type Configurator interface {
	WorkingDirectory() string
}

Configurator interface for testability

type Data

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

Data defines storage configuration.

type LSPConfig

type LSPConfig struct {
	Disabled       bool              `json:"disabled"`
	Command        string            `json:"command"`
	Args           []string          `json:"args"`
	Extensions     []string          `json:"extensions,omitempty"`
	Env            map[string]string `json:"env,omitempty"`
	Initialization any               `json:"initialization,omitempty"`
}

LSPConfig defines configuration for Language Server Protocol integration.

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"
	MCPHttp  MCPType = "http"
)

Supported MCP types

type MySQLConfig

type MySQLConfig struct {
	DSN                string `json:"dsn,omitempty"`
	Host               string `json:"host,omitempty"`
	Port               int    `json:"port,omitempty"`
	Database           string `json:"database,omitempty"`
	Username           string `json:"username,omitempty"`
	Password           string `json:"password,omitempty"`
	MaxConnections     int    `json:"maxConnections,omitempty"`
	MaxIdleConnections int    `json:"maxIdleConnections,omitempty"`
	ConnectionTimeout  int    `json:"connectionTimeout,omitempty"`
}

MySQLConfig defines MySQL-specific configuration.

type PermissionConfig

type PermissionConfig struct {
	// Rules maps tool names to permission logic.
	Rules map[string]any `json:"rules,omitempty"` // tool name -> "allow" | {"pattern": "action"}

	// Depricated: use Rules instead, Needed for backward compatibility.
	Skill map[string]string `json:"skill,omitempty"`
}

PermissionConfig defines permission configuration using Rules. Each tool key maps to either a simple string ("allow"/"deny"/"ask") or an object with glob pattern keys (e.g., {"*": "ask", "git *": "allow"}).

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"`
	Disabled bool              `json:"disabled"`
	BaseURL  string            `json:"baseURL"`
	Headers  map[string]string `json:"headers,omitempty"`
}

Provider defines configuration for an LLM provider.

type ProviderType

type ProviderType string

ProviderType defines the type of session storage provider.

const (
	ProviderSQLite ProviderType = "sqlite"
	ProviderMySQL  ProviderType = "mysql"
)

type SessionProviderConfig

type SessionProviderConfig struct {
	Type  ProviderType `json:"type,omitempty"`
	MySQL MySQLConfig  `json:"mysql,omitempty"`
}

SessionProviderConfig defines configuration for session storage.

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 {
	Paths []string `json:"paths,omitempty"` // Custom skill paths
}

SkillsConfig defines configuration for skills.

type TUIConfig

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

TUIConfig defines the configuration for the Terminal User Interface.

Directories

Path Synopsis
Package mock_config is a generated GoMock package.
Package mock_config is a generated GoMock package.

Jump to

Keyboard shortcuts

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