config

package
v0.0.0-...-8ed2a29 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: MIT Imports: 11 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 LoadGitHubToken

func LoadGitHubToken() (string, error)

Tries to load Github token from all possible locations

func MarkProjectInitialized

func MarkProjectInitialized() error

MarkProjectInitialized marks the current project as initialized

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 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 Agent

type Agent struct {
	Model           models.ModelID `json:"model"`
	MaxTokens       int64          `json:"maxTokens"`
	ReasoningEffort string         `json:"reasoningEffort"` // For openai models low,medium,heigh
}

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

type AgentConfig

type AgentConfig struct {
	CodingAgent        bool `json:"coding_agent,omitempty" mapstructure:"coding_agent"`
	DebuggingAgent     bool `json:"debugging_agent,omitempty" mapstructure:"debugging_agent"`
	DocumentationAgent bool `json:"documentation_agent,omitempty" mapstructure:"documentation_agent"`
}

AgentConfig controls Copilot agent features

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"`
	Copilot      CopilotConfig                     `json:"copilot,omitempty" mapstructure:"copilot"`
	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"`
	DetailedLogs bool                              `json:"detailedLogs,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) (*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. It returns an error if configuration loading fails.

type CopilotConfig

type CopilotConfig struct {
	// Core settings
	EnableCopilot   bool   `json:"enable_copilot" mapstructure:"enable_copilot"`
	ServerPath      string `json:"server_path,omitempty" mapstructure:"server_path"`
	NodePath        string `json:"node_path,omitempty" mapstructure:"node_path"`
	UseNativeBinary bool   `json:"use_native_binary,omitempty" mapstructure:"use_native_binary"`
	ReplaceGopls    bool   `json:"replace_gopls,omitempty" mapstructure:"replace_gopls"`

	// Authentication
	AuthToken string `json:"auth_token,omitempty" mapstructure:"auth_token"`

	// Feature flags
	ChatEnabled       bool `json:"chat_enabled,omitempty" mapstructure:"chat_enabled"`
	CompletionEnabled bool `json:"completion_enabled,omitempty" mapstructure:"completion_enabled"`

	// Installation
	AutoInstall bool              `json:"auto_install,omitempty" mapstructure:"auto_install"`
	ServerArgs  []string          `json:"server_args,omitempty" mapstructure:"server_args"`
	Environment map[string]string `json:"environment,omitempty" mapstructure:"environment"`

	// Performance
	Timeout         int  `json:"timeout,omitempty" mapstructure:"timeout"`
	RetryAttempts   int  `json:"retry_attempts,omitempty" mapstructure:"retry_attempts"`
	FallbackToGopls bool `json:"fallback_to_gopls,omitempty" mapstructure:"fallback_to_gopls"`

	// Logging and debugging
	LogLevel string `json:"log_level,omitempty" mapstructure:"log_level"`

	// Advanced settings
	Performance *PerformanceConfig `json:"performance,omitempty" mapstructure:"performance"`
	Security    *SecurityConfig    `json:"security,omitempty" mapstructure:"security"`
	AgentConfig *AgentConfig       `json:"agent_config,omitempty" mapstructure:"agent_config"`
}

CopilotConfig holds all Copilot-related configuration

type Data

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

Data defines storage configuration.

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

Supported MCP types

type PerformanceConfig

type PerformanceConfig struct {
	MaxCompletionTime   int  `json:"max_completion_time,omitempty" mapstructure:"max_completion_time"`
	DebounceDelay       int  `json:"debounce_delay,omitempty" mapstructure:"debounce_delay"`
	MaxParallelRequests int  `json:"max_parallel_requests,omitempty" mapstructure:"max_parallel_requests"`
	CacheEnabled        bool `json:"cache_enabled,omitempty" mapstructure:"cache_enabled"`
	CacheSize           int  `json:"cache_size,omitempty" mapstructure:"cache_size"`
}

PerformanceConfig controls performance-related 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"`
}

Provider defines configuration for an LLM provider.

type SecurityConfig

type SecurityConfig struct {
	DisableTelemetry bool     `json:"disable_telemetry,omitempty" mapstructure:"disable_telemetry"`
	PrivateMode      bool     `json:"private_mode,omitempty" mapstructure:"private_mode"`
	AllowedDomains   []string `json:"allowed_domains,omitempty" mapstructure:"allowed_domains"`
}

SecurityConfig controls security and privacy settings

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