config

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package config provides configuration management for ralphex with embedded defaults.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfigDir added in v0.5.0

func DefaultConfigDir() string

DefaultConfigDir returns the default configuration directory path. returns ~/.config/ralphex/ on all platforms. if os.UserHomeDir() fails, falls back to ./.config/ralphex/ silently - this allows the tool to work even in unusual environments.

Types

type ColorConfig added in v0.2.0

type ColorConfig struct {
	Task       string // task execution phase
	Review     string // review phase
	Codex      string // codex external review
	ClaudeEval string // claude evaluation of codex output
	Warn       string // warning messages
	Error      string // error messages
	Signal     string // completion/failure signals
	Timestamp  string // timestamp prefix
	Info       string // informational messages
}

ColorConfig holds RGB values for output colors. each field stores comma-separated RGB values (e.g., "255,0,0" for red).

type Config

type Config struct {
	ClaudeCommand string `json:"claude_command"`
	ClaudeArgs    string `json:"claude_args"`

	CodexEnabled         bool   `json:"codex_enabled"`
	CodexEnabledSet      bool   `json:"-"` // tracks if codex_enabled was explicitly set in config
	CodexCommand         string `json:"codex_command"`
	CodexModel           string `json:"codex_model"`
	CodexReasoningEffort string `json:"codex_reasoning_effort"`
	CodexTimeoutMs       int    `json:"codex_timeout_ms"`
	CodexTimeoutMsSet    bool   `json:"-"` // tracks if codex_timeout_ms was explicitly set in config
	CodexSandbox         string `json:"codex_sandbox"`

	IterationDelayMs    int  `json:"iteration_delay_ms"`
	IterationDelayMsSet bool `json:"-"` // tracks if iteration_delay_ms was explicitly set in config
	TaskRetryCount      int  `json:"task_retry_count"`
	TaskRetryCountSet   bool `json:"-"` // tracks if task_retry_count was explicitly set in config

	PlansDir  string   `json:"plans_dir"`
	WatchDirs []string `json:"watch_dirs"` // directories to watch for progress files

	// error patterns to detect in executor output (e.g., rate limit messages)
	ClaudeErrorPatterns []string `json:"claude_error_patterns"`
	CodexErrorPatterns  []string `json:"codex_error_patterns"`

	// output colors (RGB values as comma-separated strings)
	Colors ColorConfig `json:"-"`

	// prompts (loaded separately from files)
	TaskPrompt         string `json:"-"`
	ReviewFirstPrompt  string `json:"-"`
	ReviewSecondPrompt string `json:"-"`
	CodexPrompt        string `json:"-"`
	MakePlanPrompt     string `json:"-"`

	// custom agents (loaded separately from files)
	CustomAgents []CustomAgent `json:"-"`
	// contains filtered or unexported fields
}

Config holds all configuration settings for ralphex. Fields ending in *Set track whether that field was explicitly set in config. This allows distinguishing explicit false/0 from "not set", enabling proper merge behavior where local config can override global config with zero values.

*Set fields:

  • CodexEnabledSet: tracks if codex_enabled was explicitly set
  • CodexTimeoutMsSet: tracks if codex_timeout_ms was explicitly set
  • IterationDelayMsSet: tracks if iteration_delay_ms was explicitly set
  • TaskRetryCountSet: tracks if task_retry_count was explicitly set

func Load

func Load(configDir string) (*Config, error)

Load loads all configuration from the specified directory. If configDir is empty, uses the default location (~/.config/ralphex/). It also auto-detects .ralphex/ in the current working directory for local overrides. It installs defaults if needed, parses config file, loads prompts and agents.

func LoadReadOnly added in v0.6.0

func LoadReadOnly(configDir string) (*Config, error)

LoadReadOnly loads configuration without installing defaults. use this in tests or tools that should not modify user's config directory. if config files don't exist, embedded defaults are used.

func (*Config) LocalDir added in v0.3.0

func (c *Config) LocalDir() string

LocalDir returns the local project config directory if one was detected. returns empty string if no local config was used.

type CustomAgent

type CustomAgent struct {
	Name   string // filename without extension
	Prompt string // contents of the agent file
}

CustomAgent represents a user-defined review agent.

type Prompts added in v0.3.0

type Prompts struct {
	Task         string
	ReviewFirst  string
	ReviewSecond string
	Codex        string
	MakePlan     string
}

Prompts holds all loaded prompt templates for different phases of execution. Each prompt can be customized by placing a .txt file in the prompts directory.

type ResetResult added in v0.5.0

type ResetResult struct {
	ConfigReset  bool
	PromptsReset bool
	AgentsReset  bool
}

ResetResult holds the result of the reset operation.

func Reset added in v0.5.0

func Reset(configDir string, stdin io.Reader, stdout io.Writer) (ResetResult, error)

Reset is a package-level function that creates a defaultsInstaller and calls Reset. this is the public API for resetting configuration.

type Values added in v0.3.0

type Values struct {
	ClaudeCommand        string
	ClaudeArgs           string
	ClaudeErrorPatterns  []string // patterns to detect in claude output (e.g., rate limit messages)
	CodexEnabled         bool
	CodexEnabledSet      bool // tracks if codex_enabled was explicitly set
	CodexCommand         string
	CodexModel           string
	CodexReasoningEffort string
	CodexTimeoutMs       int
	CodexTimeoutMsSet    bool // tracks if codex_timeout_ms was explicitly set
	CodexSandbox         string
	CodexErrorPatterns   []string // patterns to detect in codex output (e.g., rate limit messages)
	IterationDelayMs     int
	IterationDelayMsSet  bool // tracks if iteration_delay_ms was explicitly set
	TaskRetryCount       int
	TaskRetryCountSet    bool // tracks if task_retry_count was explicitly set
	PlansDir             string
	WatchDirs            []string // directories to watch for progress files
}

Values holds scalar configuration values. Fields ending in *Set (e.g., CodexEnabledSet) track whether that field was explicitly set in config. This allows distinguishing explicit false/0 from "not set", enabling proper merge behavior where local config can override global config with zero values.

Jump to

Keyboard shortcuts

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