Documentation
¶
Index ¶
- Constants
- func EnsureDirs() error
- func GlobalConfigDir() string
- func GlobalConfigPath() string
- func MemoryPath() string
- func ProjectConfigPath() string
- func ProjectMemoryPath() string
- func SessionPath() string
- type Config
- type HookConfig
- type HookRule
- type PermRule
- type PermissionRules
- func (pr *PermissionRules) AddAllowRule(tool, pattern string)
- func (pr *PermissionRules) AddDenyRule(tool, pattern string)
- func (pr *PermissionRules) FormatRules() string
- func (pr *PermissionRules) IsAllowed(toolName string) bool
- func (pr *PermissionRules) IsAllowedWithInput(toolName string, input map[string]interface{}) (allowed bool, denied bool)
- func (pr *PermissionRules) RemoveAlwaysAllow(toolName string)
- func (pr *PermissionRules) SetAlwaysAllow(toolName string)
- type YAMLConfig
Constants ¶
const ( AppName = "codeany" ConfigDir = ".codeany" ConfigFile = "settings.json" MemoryDir = "memory" SessionDir = "sessions" )
Variables ¶
This section is empty.
Functions ¶
func GlobalConfigPath ¶
func GlobalConfigPath() string
GlobalConfigPath returns ~/.codeany/settings.json
func ProjectConfigPath ¶
func ProjectConfigPath() string
ProjectConfigPath returns .codeany/settings.json in CWD
func ProjectMemoryPath ¶
func ProjectMemoryPath() string
ProjectMemoryPath returns project-specific memory directory
Types ¶
type Config ¶
type Config struct {
// Model settings
Model string `json:"model,omitempty"`
SmallModel string `json:"smallModel,omitempty"`
// API settings
APIKey string `json:"apiKey,omitempty"`
BaseURL string `json:"baseURL,omitempty"`
Provider string `json:"provider,omitempty"` // "anthropic" or "openai" (auto-detected if empty)
// Permission settings
PermissionMode string `json:"permissionMode,omitempty"`
// Tool settings
AllowedTools []string `json:"allowedTools,omitempty"`
// MCP servers
MCPServers map[string]types.MCPServerConfig `json:"mcpServers,omitempty"`
// Custom system prompt
SystemPrompt string `json:"systemPrompt,omitempty"`
AppendSystemPrompt string `json:"appendSystemPrompt,omitempty"`
// Hooks
Hooks *HookConfig `json:"hooks,omitempty"`
// UI
Theme string `json:"theme,omitempty"`
// Proxy
ProxyURL string `json:"proxyURL,omitempty"`
// Max turns
MaxTurns int `json:"maxTurns,omitempty"`
// Budget
MaxBudgetUSD float64 `json:"maxBudgetUSD,omitempty"`
// Custom headers
CustomHeaders map[string]string `json:"customHeaders,omitempty"`
}
Config represents the application configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a config with sensible defaults
func Load ¶
func Load() *Config
Load loads configuration from all sources (env -> global config -> project config -> CLI flags)
func (*Config) GetPermissionMode ¶
func (c *Config) GetPermissionMode() types.PermissionMode
GetPermissionMode converts string to types.PermissionMode
type HookConfig ¶
type PermRule ¶ added in v0.4.1
type PermRule struct {
Tool string `json:"tool"` // tool name (e.g., "Bash", "Edit", "*")
Pattern string `json:"pattern,omitempty"` // pattern to match against input (e.g., "git *", "src/**")
}
PermRule is a pattern-based permission rule
type PermissionRules ¶
type PermissionRules struct {
AlwaysAllow map[string]bool `json:"alwaysAllow"` // tool name -> always allow
AllowRules []PermRule `json:"allowRules,omitempty"` // pattern-based allow rules
DenyRules []PermRule `json:"denyRules,omitempty"` // pattern-based deny rules
// contains filtered or unexported fields
}
PermissionRules stores persistent permission rules
func LoadPermissionRules ¶
func LoadPermissionRules() *PermissionRules
LoadPermissionRules loads rules from disk
func (*PermissionRules) AddAllowRule ¶ added in v0.4.1
func (pr *PermissionRules) AddAllowRule(tool, pattern string)
AddAllowRule adds a pattern-based allow rule
func (*PermissionRules) AddDenyRule ¶ added in v0.4.1
func (pr *PermissionRules) AddDenyRule(tool, pattern string)
AddDenyRule adds a pattern-based deny rule
func (*PermissionRules) FormatRules ¶ added in v0.4.1
func (pr *PermissionRules) FormatRules() string
FormatRules returns a readable summary
func (*PermissionRules) IsAllowed ¶
func (pr *PermissionRules) IsAllowed(toolName string) bool
IsAllowed checks if a tool call is allowed by rules
func (*PermissionRules) IsAllowedWithInput ¶ added in v0.4.1
func (pr *PermissionRules) IsAllowedWithInput(toolName string, input map[string]interface{}) (allowed bool, denied bool)
IsAllowedWithInput checks allow/deny rules with input pattern matching
func (*PermissionRules) RemoveAlwaysAllow ¶ added in v0.4.1
func (pr *PermissionRules) RemoveAlwaysAllow(toolName string)
RemoveAlwaysAllow removes an always-allow entry
func (*PermissionRules) SetAlwaysAllow ¶
func (pr *PermissionRules) SetAlwaysAllow(toolName string)
SetAlwaysAllow marks a tool as always allowed and saves to disk
type YAMLConfig ¶
type YAMLConfig struct {
DefaultModel string `yaml:"default_model"`
PermissionMode string `yaml:"permission_mode"`
MaxIterations int `yaml:"max_iterations"`
Models map[string]struct {
APIKey string `yaml:"api_key"`
BaseURL string `yaml:"base_url"`
} `yaml:"models"`
}
YAMLConfig represents the legacy YAML config format