config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	AppName    = "codeany"
	ConfigDir  = ".codeany"
	ConfigFile = "settings.json"
	MemoryDir  = "memory"
	SessionDir = "sessions"
)

Variables

This section is empty.

Functions

func EnsureDirs

func EnsureDirs() error

EnsureDirs creates necessary directories

func GlobalConfigDir

func GlobalConfigDir() string

GlobalConfigDir returns ~/.codeany/

func GlobalConfigPath

func GlobalConfigPath() string

GlobalConfigPath returns ~/.codeany/settings.json

func MemoryPath

func MemoryPath() string

MemoryPath returns the global memory directory

func ProjectConfigPath

func ProjectConfigPath() string

ProjectConfigPath returns .codeany/settings.json in CWD

func ProjectMemoryPath

func ProjectMemoryPath() string

ProjectMemoryPath returns project-specific memory directory

func SessionPath

func SessionPath() string

SessionPath returns the sessions 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"`

	// 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 HookConfig struct {
	PreToolUse  []HookRule `json:"preToolUse,omitempty"`
	PostToolUse []HookRule `json:"postToolUse,omitempty"`
}

type HookRule

type HookRule struct {
	Matcher string `json:"matcher"`
	Command string `json:"command"`
}

type PermissionRules

type PermissionRules struct {
	AlwaysAllow map[string]bool `json:"alwaysAllow"` // tool name -> always allow
	// contains filtered or unexported fields
}

PermissionRules stores persistent permission rules

func LoadPermissionRules

func LoadPermissionRules() *PermissionRules

LoadPermissionRules loads rules from disk

func (*PermissionRules) IsAllowed

func (pr *PermissionRules) IsAllowed(toolName string) bool

IsAllowed checks if a tool is always allowed

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

Jump to

Keyboard shortcuts

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