Documentation
¶
Overview ¶
Package config handles configuration management for cdev.
Package config provides centralized default configuration values.
Index ¶
- Variables
- func DefaultAuthRegistryPath() string
- func DefaultWorkspacesPath() string
- func EnsureConfigDir() (string, error)
- func GetConfigDir() (string, error)
- func SaveWorkspaces(configPath string, cfg *WorkspacesConfig) error
- func SkipDirectoriesSet(customDirs []string) map[string]bool
- func Validate(cfg *Config) error
- func ValidateWorkspaces(cfg *WorkspacesConfig) error
- type ClaudeConfig
- type Config
- type DebugConfig
- type DiscoverySettings
- type GitConfig
- type IndexerConfig
- type LimitsConfig
- type LogRotationConfig
- type LoggingConfig
- type PairingConfig
- type PermissionsConfig
- type RateLimitConfig
- type RepositoryConfig
- type SecurityConfig
- type ServerConfig
- type SessionMemoryConfig
- type WatcherConfig
- type WorkspaceDefaults
- type WorkspaceDefinition
- type WorkspaceManagerConfig
- type WorkspacesConfig
Constants ¶
This section is empty.
Variables ¶
var DefaultSkipDirectories = []string{
".git",
".svn",
".hg",
".cdev",
".claude",
"node_modules",
"vendor",
"__pycache__",
".pytest_cache",
".mypy_cache",
".tox",
".venv",
"venv",
".idea",
".vscode",
".vs",
"dist",
"build",
"target",
"coverage",
".coverage",
".nyc_output",
".next",
".nuxt",
".cache",
".parcel-cache",
".turbo",
}
DefaultSkipDirectories is the canonical list of directories to skip during file watching, indexing, and directory traversal. This is the single source of truth - all components should use these values.
Users can override via config.yaml: indexer.skip_directories or watcher.ignore_patterns
var DefaultWatcherIgnorePatterns = []string{
".git",
".cdev",
".claude",
"node_modules",
".venv",
"venv",
"__pycache__",
"*.pyc",
".DS_Store",
"Thumbs.db",
"dist",
"build",
"coverage",
".next",
".nuxt",
"*.log",
".idea",
".vscode",
"*.swp",
"*.swo",
"*~",
}
DefaultWatcherIgnorePatterns is the canonical list of patterns for file watcher. These include both directories and file patterns (e.g., *.pyc, *.swp).
Functions ¶
func DefaultAuthRegistryPath ¶
func DefaultAuthRegistryPath() string
DefaultAuthRegistryPath returns the default path for auth registry storage.
func DefaultWorkspacesPath ¶
func DefaultWorkspacesPath() string
DefaultWorkspacesPath returns the default path for workspaces.yaml.
func EnsureConfigDir ¶
EnsureConfigDir ensures the config directory exists.
func GetConfigDir ¶
GetConfigDir returns the user config directory for cdev.
func SaveWorkspaces ¶
func SaveWorkspaces(configPath string, cfg *WorkspacesConfig) error
SaveWorkspaces saves the workspaces configuration
func SkipDirectoriesSet ¶
SkipDirectoriesSet returns a map for O(1) lookups of skip directories. Uses the provided list if non-empty, otherwise falls back to defaults.
func ValidateWorkspaces ¶
func ValidateWorkspaces(cfg *WorkspacesConfig) error
ValidateWorkspaces validates the workspaces configuration
Types ¶
type ClaudeConfig ¶
type ClaudeConfig struct {
Command string `mapstructure:"command"`
Args []string `mapstructure:"args"`
TimeoutMinutes int `mapstructure:"timeout_minutes"`
SkipPermissions bool `mapstructure:"skip_permissions"`
}
ClaudeConfig holds Claude CLI configuration.
type Config ¶
type Config struct {
Server ServerConfig `mapstructure:"server"`
Repository RepositoryConfig `mapstructure:"repository"`
Watcher WatcherConfig `mapstructure:"watcher"`
Claude ClaudeConfig `mapstructure:"claude"`
Git GitConfig `mapstructure:"git"`
Logging LoggingConfig `mapstructure:"logging"`
Limits LimitsConfig `mapstructure:"limits"`
Pairing PairingConfig `mapstructure:"pairing"`
Indexer IndexerConfig `mapstructure:"indexer"`
Security SecurityConfig `mapstructure:"security"`
Permissions PermissionsConfig `mapstructure:"permissions"`
Debug DebugConfig `mapstructure:"debug"`
Discovery DiscoverySettings `mapstructure:"discovery"`
}
Config holds all configuration for the application.
type DebugConfig ¶
type DebugConfig struct {
Enabled bool `mapstructure:"enabled"` // Enable debug endpoints (default: false)
PprofEnabled bool `mapstructure:"pprof_enabled"` // Enable /debug/pprof/* endpoints (default: true when debug enabled)
}
DebugConfig holds debug and profiling configuration.
type DiscoverySettings ¶
type DiscoverySettings struct {
SearchPaths []string `mapstructure:"search_paths"`
MaxDepth int `mapstructure:"max_depth"`
TimeoutSeconds int `mapstructure:"timeout_seconds"`
CacheTTLMinutes int `mapstructure:"cache_ttl_minutes"`
}
DiscoverySettings holds workspace discovery configuration from config.yaml.
type GitConfig ¶
type GitConfig struct {
Enabled bool `mapstructure:"enabled"`
Command string `mapstructure:"command"`
DiffOnChange bool `mapstructure:"diff_on_change"`
}
GitConfig holds Git configuration.
type IndexerConfig ¶
type IndexerConfig struct {
Enabled bool `mapstructure:"enabled"`
SkipDirectories []string `mapstructure:"skip_directories"`
}
IndexerConfig holds repository indexer configuration.
type LimitsConfig ¶
type LimitsConfig struct {
MaxFileSizeKB int `mapstructure:"max_file_size_kb"`
MaxDiffSizeKB int `mapstructure:"max_diff_size_kb"`
MaxLogBuffer int `mapstructure:"max_log_buffer"`
MaxPromptLen int `mapstructure:"max_prompt_len"`
}
LimitsConfig holds various limits.
type LogRotationConfig ¶
type LogRotationConfig struct {
Enabled bool `mapstructure:"enabled"` // Enable log rotation for Claude JSONL logs
MaxSizeMB int `mapstructure:"max_size_mb"` // Max size in MB before rotation
MaxBackups int `mapstructure:"max_backups"` // Number of old logs to keep
MaxAgeDays int `mapstructure:"max_age_days"` // Days to keep old logs (0 = no limit)
Compress bool `mapstructure:"compress"` // Compress rotated logs with gzip
}
LogRotationConfig holds log rotation configuration.
type LoggingConfig ¶
type LoggingConfig struct {
Level string `mapstructure:"level"`
Format string `mapstructure:"format"`
Rotation LogRotationConfig `mapstructure:"rotation"`
}
LoggingConfig holds logging configuration.
type PairingConfig ¶
type PairingConfig struct {
TokenExpirySecs int `mapstructure:"token_expiry_secs"`
ShowQRInTerminal bool `mapstructure:"show_qr_in_terminal"`
}
PairingConfig holds pairing/QR code configuration.
type PermissionsConfig ¶
type PermissionsConfig struct {
SessionMemory SessionMemoryConfig `mapstructure:"session_memory"`
}
PermissionsConfig holds permission hook bridge configuration.
type RateLimitConfig ¶
type RateLimitConfig struct {
Enabled bool `mapstructure:"enabled"` // Enable rate limiting
RequestsPerMinute int `mapstructure:"requests_per_minute"` // Max requests per minute per IP
}
RateLimitConfig holds rate limiting configuration.
type RepositoryConfig ¶
type RepositoryConfig struct {
Path string `mapstructure:"path"`
}
RepositoryConfig holds repository-related configuration.
type SecurityConfig ¶
type SecurityConfig struct {
RequireAuth bool `mapstructure:"require_auth"` // If true, require token for WebSocket connections
RequirePairingApproval bool `mapstructure:"require_pairing_approval"` // If true, pairing exchange requires local approve/reject
TokenExpirySecs int `mapstructure:"token_expiry_secs"` // Pairing token expiry in seconds
CdevAccessToken string `mapstructure:"cdev_access_token"` // Optional access token gate for cdev web endpoints
AllowedOrigins []string `mapstructure:"allowed_origins"` // Allowed origins for CORS/WebSocket (empty = localhost only)
BindLocalhostOnly bool `mapstructure:"bind_localhost_only"` // If true, only bind to localhost
RequireSecureTransport bool `mapstructure:"require_secure_transport"` // If true, require TLS/WSS for non-localhost use
TLSCertFile string `mapstructure:"tls_cert_file"` // Optional TLS certificate file path
TLSKeyFile string `mapstructure:"tls_key_file"` // Optional TLS key file path
TrustedProxies []string `mapstructure:"trusted_proxies"` // Optional trusted reverse-proxy CIDRs
RateLimit RateLimitConfig `mapstructure:"rate_limit"` // Rate limiting configuration
}
SecurityConfig holds security-related configuration.
type ServerConfig ¶
type ServerConfig struct {
Port int `mapstructure:"port"` // Unified port for HTTP and WebSocket (default: 16180)
Host string `mapstructure:"host"` // Bind address (default: 127.0.0.1)
ExternalURL string `mapstructure:"external_url"` // Optional: public URL for tunnels (e.g., https://tunnel.devtunnels.ms)
Headless bool `mapstructure:"headless"` // If true, run as background daemon; if false (default), run in terminal mode
}
ServerConfig holds server-related configuration.
type SessionMemoryConfig ¶
type SessionMemoryConfig struct {
Enabled bool `mapstructure:"enabled"` // Enable session memory for "Allow for Session" functionality
TTLSeconds int `mapstructure:"ttl_seconds"` // Idle timeout for session memory in seconds (default: 3600)
MaxPatterns int `mapstructure:"max_patterns"` // Max patterns per session (default: 100)
}
SessionMemoryConfig holds session memory configuration for the permission system.
type WatcherConfig ¶
type WatcherConfig struct {
Enabled bool `mapstructure:"enabled"`
DebounceMS int `mapstructure:"debounce_ms"`
IgnorePatterns []string `mapstructure:"ignore_patterns"`
}
WatcherConfig holds file watcher configuration.
type WorkspaceDefaults ¶
type WorkspaceDefaults struct {
Watcher WatcherConfig `mapstructure:"watcher" yaml:"watcher"`
Git GitConfig `mapstructure:"git" yaml:"git"`
Logging LoggingConfig `mapstructure:"logging" yaml:"logging"`
Limits LimitsConfig `mapstructure:"limits" yaml:"limits"`
}
WorkspaceDefaults holds default settings for all workspaces.
type WorkspaceDefinition ¶
type WorkspaceDefinition struct {
ID string `mapstructure:"id" yaml:"id"`
Name string `mapstructure:"name" yaml:"name"`
Path string `mapstructure:"path" yaml:"path"`
Port int `mapstructure:"port" yaml:"port"`
AutoStart bool `mapstructure:"auto_start" yaml:"auto_start"`
ConfigFile string `mapstructure:"config_file,omitempty" yaml:"config_file,omitempty"`
CreatedAt time.Time `mapstructure:"created_at" yaml:"created_at"`
LastAccessed time.Time `mapstructure:"last_accessed" yaml:"last_accessed"`
}
WorkspaceDefinition represents a configured workspace.
type WorkspaceManagerConfig ¶
type WorkspaceManagerConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
Port int `mapstructure:"port" yaml:"port"`
Host string `mapstructure:"host" yaml:"host"`
AutoStartWorkspaces bool `mapstructure:"auto_start_workspaces" yaml:"auto_start_workspaces"`
LogLevel string `mapstructure:"log_level" yaml:"log_level"`
MaxConcurrentWorkspaces int `mapstructure:"max_concurrent_workspaces" yaml:"max_concurrent_workspaces"`
AutoStopIdleMinutes int `mapstructure:"auto_stop_idle_minutes" yaml:"auto_stop_idle_minutes"`
PortRangeStart int `mapstructure:"port_range_start" yaml:"port_range_start"`
PortRangeEnd int `mapstructure:"port_range_end" yaml:"port_range_end"`
RestartOnCrash bool `mapstructure:"restart_on_crash" yaml:"restart_on_crash"`
MaxRestartAttempts int `mapstructure:"max_restart_attempts" yaml:"max_restart_attempts"`
RestartBackoffSeconds int `mapstructure:"restart_backoff_seconds" yaml:"restart_backoff_seconds"`
}
WorkspaceManagerConfig holds workspace manager configuration.
type WorkspacesConfig ¶
type WorkspacesConfig struct {
Manager WorkspaceManagerConfig `mapstructure:"manager" yaml:"manager"`
Workspaces []WorkspaceDefinition `mapstructure:"workspaces" yaml:"workspaces"`
Defaults WorkspaceDefaults `mapstructure:"defaults" yaml:"defaults"`
}
WorkspacesConfig represents the complete workspaces.yaml file.
func DefaultWorkspacesConfig ¶
func DefaultWorkspacesConfig() *WorkspacesConfig
DefaultWorkspacesConfig returns a copy of the default workspaces configuration.
func LoadWorkspaces ¶
func LoadWorkspaces(configPath string) (*WorkspacesConfig, error)
LoadWorkspaces loads the workspaces configuration from workspaces.yaml