config

package
v0.0.202 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool

Debug indicates whether debug logging is enabled

View Source
var Verbose bool

Verbose indicates whether verbose logging is enabled

Functions

func DebugLog

func DebugLog(format string, args ...interface{})

DebugLog prints debug information if debug mode is enabled

func DecryptConfig

func DecryptConfig(data []byte, password string) ([]byte, error)

DecryptConfig decrypts the configuration data

func EncryptConfig

func EncryptConfig(path string, password string) error

EncryptConfig encrypts the configuration file

func EnsureComandaDir added in v0.0.89

func EnsureComandaDir() (string, error)

EnsureComandaDir creates the ~/.comanda directory if it doesn't exist

func EnsureLoopStateDir added in v0.0.102

func EnsureLoopStateDir() (string, error)

EnsureLoopStateDir creates the ~/.comanda/loop-states directory if it doesn't exist

func GenerateBearerToken

func GenerateBearerToken() (string, error)

GenerateBearerToken generates a secure random bearer token

func GetComandaDir added in v0.0.89

func GetComandaDir() (string, error)

GetComandaDir returns the path to the .comanda directory in the user's home

func GetEnvPath

func GetEnvPath() string

GetEnvPath returns the environment file path, checking in order: 1. COMANDA_ENV environment variable (explicit override) 2. ~/.comanda/config.yaml (preferred default) 3. .env in current directory (legacy fallback)

func GetLoopStateDir added in v0.0.102

func GetLoopStateDir() (string, error)

GetLoopStateDir returns the path to the loop-states directory

func GetMemoryPath added in v0.0.73

func GetMemoryPath(envConfig *EnvConfig) string

GetMemoryPath returns the memory file path by checking in order: 1. COMANDA_MEMORY environment variable 2. memory_file setting in .env config 3. COMANDA.md in current directory 4. COMANDA.md in parent directories (up to 5 levels) 5. ~/.comanda/COMANDA.md (user-level default) Returns empty string if no memory file is found

func InitializeUserMemoryFile added in v0.0.73

func InitializeUserMemoryFile() (string, error)

InitializeUserMemoryFile creates the default user-level memory file if it doesn't exist

func IsEncrypted

func IsEncrypted(data []byte) bool

IsEncrypted checks if the file content is encrypted

func PromptPassword

func PromptPassword(prompt string) (string, error)

PromptPassword prompts the user for a password securely

func SaveEnvConfig

func SaveEnvConfig(path string, config *EnvConfig) error

SaveEnvConfig saves the environment configuration to .env file

func ValidateModelMode

func ValidateModelMode(mode ModelMode) bool

ValidateModelMode checks if a mode is valid

func VerboseLog

func VerboseLog(format string, args ...interface{})

VerboseLog prints verbose information if verbose mode is enabled

Types

type CORS added in v0.0.16

type CORS struct {
	Enabled        bool     `yaml:"enabled"`
	AllowedOrigins []string `yaml:"allowedOrigins"`
	AllowedMethods []string `yaml:"allowedMethods"`
	AllowedHeaders []string `yaml:"allowedHeaders"`
	MaxAge         int      `yaml:"maxAge"`
}

CORS holds Cross-Origin Resource Sharing settings

type DatabaseConfig

type DatabaseConfig struct {
	Type     DatabaseType `yaml:"type"`
	Host     string       `yaml:"host"`
	Port     int          `yaml:"port"`
	User     string       `yaml:"user"`
	Password string       `yaml:"password"`
	Database string       `yaml:"database"`
}

DatabaseConfig represents a database connection configuration

func (*DatabaseConfig) GetConnectionString

func (c *DatabaseConfig) GetConnectionString() string

GetConnectionString returns a connection string for the specified database

type DatabaseType

type DatabaseType string

DatabaseType represents supported database types

const (
	PostgreSQL DatabaseType = "postgres"
)

type EnvConfig

type EnvConfig struct {
	Providers              map[string]*Provider      `yaml:"providers"` // Changed to store pointers to Provider
	Server                 *ServerConfig             `yaml:"server,omitempty"`
	Databases              map[string]DatabaseConfig `yaml:"databases,omitempty"` // Added database configurations
	Tool                   *ToolConfig               `yaml:"tool,omitempty"`      // Global tool execution settings
	Security               *SecurityConfig           `yaml:"security,omitempty"`  // Global security settings
	Indexes                map[string]*IndexEntry    `yaml:"indexes,omitempty"`   // Registered codebase indexes
	DefaultGenerationModel string                    `yaml:"default_generation_model,omitempty"`
	MemoryFile             string                    `yaml:"memory_file,omitempty"`          // Path to COMANDA.md memory file
	IndexEncryptionKey     string                    `yaml:"index_encryption_key,omitempty"` // Key for encrypting codebase indexes
}

EnvConfig represents the complete environment configuration

func LoadEncryptedEnvConfig

func LoadEncryptedEnvConfig(path string, password string) (*EnvConfig, error)

LoadEncryptedEnvConfig loads an encrypted environment configuration

func LoadEnvConfig

func LoadEnvConfig(path string) (*EnvConfig, error)

LoadEnvConfig loads the environment configuration from .env file

func LoadEnvConfigWithPassword

func LoadEnvConfigWithPassword(path string) (*EnvConfig, error)

LoadEnvConfigWithPassword attempts to load the config, prompting for password if encrypted

func (*EnvConfig) AddDatabase

func (c *EnvConfig) AddDatabase(name string, config DatabaseConfig)

AddDatabase adds or updates a database configuration

func (*EnvConfig) AddModelToProvider

func (c *EnvConfig) AddModelToProvider(providerName string, model Model) error

AddModelToProvider adds a model to a specific provider

func (*EnvConfig) AddProvider

func (c *EnvConfig) AddProvider(name string, provider Provider)

AddProvider adds or updates a provider configuration

func (*EnvConfig) GetAllConfiguredModels added in v0.0.35

func (c *EnvConfig) GetAllConfiguredModels() []string

GetAllConfiguredModels returns a list of all configured models across all providers

func (*EnvConfig) GetDatabaseConfig

func (c *EnvConfig) GetDatabaseConfig(name string) (*DatabaseConfig, error)

GetDatabaseConfig retrieves configuration for a specific database

func (*EnvConfig) GetModelConfig

func (c *EnvConfig) GetModelConfig(providerName, modelName string) (*Model, error)

GetModelConfig retrieves configuration for a specific model

func (*EnvConfig) GetProviderConfig

func (c *EnvConfig) GetProviderConfig(providerName string) (*Provider, error)

GetProviderConfig retrieves configuration for a specific provider

func (*EnvConfig) GetServerConfig

func (c *EnvConfig) GetServerConfig() *ServerConfig

GetServerConfig retrieves the server configuration

func (*EnvConfig) GetToolConfig added in v0.0.92

func (c *EnvConfig) GetToolConfig() *ToolConfig

GetToolConfig returns the global tool configuration, or nil if not set

func (*EnvConfig) IsAgenticToolsAllowed added in v0.0.99

func (c *EnvConfig) IsAgenticToolsAllowed() bool

IsAgenticToolsAllowed returns whether agentic tool use is allowed globally. When enabled (the default), agents can execute shell commands and write files within allowed_paths. Set security.allow_agentic_tools: false to disable.

func (*EnvConfig) ResolveConfiguredModel added in v0.0.178

func (c *EnvConfig) ResolveConfiguredModel(modelName string) (string, *Model, error)

ResolveConfiguredModel finds a configured model by its user-facing name across all providers.

func (*EnvConfig) SetToolConfig added in v0.0.92

func (c *EnvConfig) SetToolConfig(tool *ToolConfig)

SetToolConfig sets the global tool configuration

func (*EnvConfig) UpdateAPIKey

func (c *EnvConfig) UpdateAPIKey(providerName, apiKey string) error

UpdateAPIKey updates the API key for a specific provider

func (*EnvConfig) UpdateModelModes

func (c *EnvConfig) UpdateModelModes(providerName, modelName string, modes []ModelMode) error

UpdateModelModes updates the modes for a specific model

func (*EnvConfig) UpdateServerConfig

func (c *EnvConfig) UpdateServerConfig(serverConfig ServerConfig)

UpdateServerConfig updates the server configuration

type IndexEntry added in v0.0.143

type IndexEntry struct {
	Path        string `yaml:"path"`                // Source repository path
	IndexPath   string `yaml:"index_path"`          // Where index file is stored
	LastIndexed string `yaml:"last_indexed"`        // ISO8601 timestamp
	ContentHash string `yaml:"content_hash"`        // Hash of index content
	Format      string `yaml:"format"`              // summary, structured, full
	FileCount   int    `yaml:"file_count"`          // Number of files indexed
	SizeBytes   int64  `yaml:"size_bytes"`          // Size of index file
	VarPrefix   string `yaml:"var_prefix"`          // Variable prefix for workflows
	Encrypted   bool   `yaml:"encrypted,omitempty"` // Whether index is encrypted
	Languages   string `yaml:"languages,omitempty"` // Detected languages
}

IndexEntry represents a registered codebase index

type Model

type Model struct {
	Name   string      `yaml:"name"`
	Target string      `yaml:"target,omitempty"`
	Type   string      `yaml:"type"`
	Modes  []ModelMode `yaml:"modes"`
}

Model represents a single model configuration

func (*Model) HasMode

func (m *Model) HasMode(mode ModelMode) bool

HasMode checks if a model supports a specific mode

type ModelMode

type ModelMode string

ModelMode represents the supported modes for a model

const (
	TextMode   ModelMode = "text"
	VisionMode ModelMode = "vision"
	MultiMode  ModelMode = "multi"
	FileMode   ModelMode = "file" // Added for file handling support
)

func GetSupportedModes

func GetSupportedModes() []ModelMode

GetSupportedModes returns all supported model modes

type OpenAICompatConfig added in v0.0.84

type OpenAICompatConfig struct {
	Enabled bool   `yaml:"enabled"`
	Prefix  string `yaml:"prefix"` // API prefix, default: "/v1"
}

OpenAICompatConfig holds OpenAI API compatibility settings

type Provider

type Provider struct {
	APIKey            string  `yaml:"api_key"`
	Models            []Model `yaml:"models"`
	SupportsWorktrees bool    `yaml:"supports_worktrees,omitempty"`
}

Provider represents a provider's configuration

type SecurityConfig added in v0.0.99

type SecurityConfig struct {
	AllowAgenticTools bool `yaml:"allow_agentic_tools"` // Allow agentic tool use in loops (default true)
}

SecurityConfig represents global security settings

type ServerConfig

type ServerConfig struct {
	Port         int                `yaml:"port"`
	DataDir      string             `yaml:"dataDir"`
	RuntimeDir   string             `yaml:"runtimeDir"` // Directory for runtime files like uploads and YAML processing
	Enabled      bool               `yaml:"enabled"`
	BearerToken  string             `yaml:"bearerToken"`
	CORS         CORS               `yaml:"cors"`
	OpenAICompat OpenAICompatConfig `yaml:"openai_compat,omitempty"`
}

ServerConfig holds configuration for the HTTP server

type ToolConfig added in v0.0.92

type ToolConfig struct {
	Allowlist []string `yaml:"allowlist,omitempty"` // Additional commands to allow globally
	Denylist  []string `yaml:"denylist,omitempty"`  // Additional commands to deny globally
	Timeout   int      `yaml:"timeout,omitempty"`   // Default timeout in seconds (0 = use system default of 30)
}

ToolConfig represents global tool execution settings

Jump to

Keyboard shortcuts

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