config

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxPromptSize = 200 * 1024

DefaultMaxPromptSize is the default maximum prompt size in bytes (200KB)

Variables

This section is empty.

Functions

func DataDir

func DataDir() string

DataDir returns the roborev data directory. Uses ROBOREV_DATA_DIR env var if set, otherwise ~/.roborev

func GetDisplayName

func GetDisplayName(repoPath string) string

GetDisplayName returns the display name for a repo, or empty if not set

func GlobalConfigPath

func GlobalConfigPath() string

GlobalConfigPath returns the path to the global config file

func IsBranchExcluded

func IsBranchExcluded(repoPath, branch string) bool

IsBranchExcluded checks if a branch should be excluded from reviews

func ReadRoborevID

func ReadRoborevID(repoPath string) (string, error)

ReadRoborevID reads and validates the .roborev-id file from a repo. Returns the ID if valid, empty string if file doesn't exist or is invalid. If invalid, the error describes why.

func ResolveAgent

func ResolveAgent(explicit string, repoPath string, globalCfg *Config) string

ResolveAgent determines which agent to use based on config priority: 1. Explicit agent parameter (if non-empty) 2. Per-repo config 3. Global config 4. Default ("codex")

func ResolveAgentForWorkflow added in v0.19.0

func ResolveAgentForWorkflow(cli, repoPath string, globalCfg *Config, workflow, level string) string

ResolveAgentForWorkflow determines which agent to use based on workflow and level. Priority (Option A - layer wins first, then specificity): 1. CLI explicit 2. Repo {workflow}_agent_{level} 3. Repo {workflow}_agent 4. Repo agent 5. Global {workflow}_agent_{level} 6. Global {workflow}_agent 7. Global default_agent 8. "codex"

func ResolveFixReasoning added in v0.21.0

func ResolveFixReasoning(explicit string, repoPath string) (string, error)

ResolveFixReasoning determines reasoning level for fix. Priority: explicit > per-repo config > default (standard)

func ResolveJobTimeout

func ResolveJobTimeout(repoPath string, globalCfg *Config) int

ResolveJobTimeout determines job timeout based on config priority: 1. Per-repo config (if set and > 0) 2. Global config (if set and > 0) 3. Default (30 minutes)

func ResolveMaxPromptSize added in v0.20.0

func ResolveMaxPromptSize(repoPath string, globalCfg *Config) int

ResolveMaxPromptSize determines the maximum prompt size based on config priority: 1. Per-repo config (max_prompt_size in .roborev.toml) 2. Global config (default_max_prompt_size in config.toml) 3. Default (200KB)

func ResolveModel added in v0.17.0

func ResolveModel(explicit string, repoPath string, globalCfg *Config) string

ResolveModel determines which model to use based on config priority: 1. Explicit model parameter (if non-empty) 2. Per-repo config (model in .roborev.toml) 3. Global config (default_model in config.toml) 4. Default (empty string, agent uses its default)

func ResolveModelForWorkflow added in v0.19.0

func ResolveModelForWorkflow(cli, repoPath string, globalCfg *Config, workflow, level string) string

ResolveModelForWorkflow determines which model to use based on workflow and level. Same priority as ResolveAgentForWorkflow, but returns empty string as default.

func ResolveRefineReasoning

func ResolveRefineReasoning(explicit string, repoPath string) (string, error)

ResolveRefineReasoning determines reasoning level for refine. Priority: explicit > per-repo config > default (standard)

func ResolveRepoIdentity

func ResolveRepoIdentity(repoPath string, getRemoteURL func(repoPath, remoteName string) string) string

ResolveRepoIdentity determines the unique identity for a repository. Resolution order: 1. .roborev-id file in repo root (if exists and valid) 2. Git remote "origin" URL 3. Any git remote URL 4. Fallback: local://{absolute_path}

Note: Credentials are stripped from git remote URLs to prevent secrets from being persisted in the database or synced to PostgreSQL.

The getRemoteURL parameter allows injection of git remote lookup for testing. Pass nil to use the default git.GetRemoteURL function.

func ResolveReviewReasoning

func ResolveReviewReasoning(explicit string, repoPath string) (string, error)

ResolveReviewReasoning determines reasoning level for reviews. Priority: explicit > per-repo config > default (thorough)

func SaveGlobal

func SaveGlobal(cfg *Config) error

SaveGlobal saves the global configuration

func ValidateRoborevID

func ValidateRoborevID(id string) string

ValidateReporevID validates the content of a .roborev-id file. Returns empty string if valid, or an error message if invalid.

Types

type Config

type Config struct {
	ServerAddr         string `toml:"server_addr"`
	MaxWorkers         int    `toml:"max_workers"`
	ReviewContextCount int    `toml:"review_context_count"`
	DefaultAgent       string `toml:"default_agent"`
	DefaultModel       string `toml:"default_model"` // Default model for agents (format varies by agent)
	JobTimeoutMinutes  int    `toml:"job_timeout_minutes"`

	// Workflow-specific agent/model configuration
	ReviewAgent         string `toml:"review_agent"`
	ReviewAgentFast     string `toml:"review_agent_fast"`
	ReviewAgentStandard string `toml:"review_agent_standard"`
	ReviewAgentThorough string `toml:"review_agent_thorough"`
	RefineAgent         string `toml:"refine_agent"`
	RefineAgentFast     string `toml:"refine_agent_fast"`
	RefineAgentStandard string `toml:"refine_agent_standard"`
	RefineAgentThorough string `toml:"refine_agent_thorough"`
	ReviewModel         string `toml:"review_model"`
	ReviewModelFast     string `toml:"review_model_fast"`
	ReviewModelStandard string `toml:"review_model_standard"`
	ReviewModelThorough string `toml:"review_model_thorough"`
	RefineModel         string `toml:"refine_model"`
	RefineModelFast     string `toml:"refine_model_fast"`
	RefineModelStandard string `toml:"refine_model_standard"`
	RefineModelThorough string `toml:"refine_model_thorough"`
	FixAgent            string `toml:"fix_agent"`
	FixAgentFast        string `toml:"fix_agent_fast"`
	FixAgentStandard    string `toml:"fix_agent_standard"`
	FixAgentThorough    string `toml:"fix_agent_thorough"`
	FixModel            string `toml:"fix_model"`
	FixModelFast        string `toml:"fix_model_fast"`
	FixModelStandard    string `toml:"fix_model_standard"`
	FixModelThorough    string `toml:"fix_model_thorough"`
	AllowUnsafeAgents   *bool  `toml:"allow_unsafe_agents"` // nil = not set, allows commands to choose their own default

	// Agent commands
	CodexCmd      string `toml:"codex_cmd"`
	ClaudeCodeCmd string `toml:"claude_code_cmd"`
	CursorCmd     string `toml:"cursor_cmd"`

	// API keys (optional - agents use subscription auth by default)
	AnthropicAPIKey string `toml:"anthropic_api_key"`

	// Hooks configuration
	Hooks []HookConfig `toml:"hooks"`

	// Sync configuration for PostgreSQL
	Sync SyncConfig `toml:"sync"`

	// Analysis settings
	DefaultMaxPromptSize int `toml:"default_max_prompt_size"` // Max prompt size in bytes before falling back to paths (default: 200KB)
}

Config holds the daemon configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration

func LoadGlobal

func LoadGlobal() (*Config, error)

LoadGlobal loads the global configuration from the default path

func LoadGlobalFrom

func LoadGlobalFrom(path string) (*Config, error)

LoadGlobalFrom loads the global configuration from a specific path

type HookConfig added in v0.22.0

type HookConfig struct {
	Event   string `toml:"event"`   // "review.failed", "review.completed", "review.*"
	Command string `toml:"command"` // shell command with {var} templates
	Type    string `toml:"type"`    // "beads" for built-in, empty for command
}

HookConfig defines a hook that runs on review events

type RepoConfig

type RepoConfig struct {
	Agent              string   `toml:"agent"`
	Model              string   `toml:"model"` // Model for agents (format varies by agent)
	ReviewContextCount int      `toml:"review_context_count"`
	ReviewGuidelines   string   `toml:"review_guidelines"`
	JobTimeoutMinutes  int      `toml:"job_timeout_minutes"`
	ExcludedBranches   []string `toml:"excluded_branches"`
	DisplayName        string   `toml:"display_name"`
	ReviewReasoning    string   `toml:"review_reasoning"` // Reasoning level for reviews: thorough, standard, fast
	RefineReasoning    string   `toml:"refine_reasoning"` // Reasoning level for refine: thorough, standard, fast
	FixReasoning       string   `toml:"fix_reasoning"`    // Reasoning level for fix: thorough, standard, fast

	// Workflow-specific agent/model configuration
	ReviewAgent         string `toml:"review_agent"`
	ReviewAgentFast     string `toml:"review_agent_fast"`
	ReviewAgentStandard string `toml:"review_agent_standard"`
	ReviewAgentThorough string `toml:"review_agent_thorough"`
	RefineAgent         string `toml:"refine_agent"`
	RefineAgentFast     string `toml:"refine_agent_fast"`
	RefineAgentStandard string `toml:"refine_agent_standard"`
	RefineAgentThorough string `toml:"refine_agent_thorough"`
	ReviewModel         string `toml:"review_model"`
	ReviewModelFast     string `toml:"review_model_fast"`
	ReviewModelStandard string `toml:"review_model_standard"`
	ReviewModelThorough string `toml:"review_model_thorough"`
	RefineModel         string `toml:"refine_model"`
	RefineModelFast     string `toml:"refine_model_fast"`
	RefineModelStandard string `toml:"refine_model_standard"`
	RefineModelThorough string `toml:"refine_model_thorough"`
	FixAgent            string `toml:"fix_agent"`
	FixAgentFast        string `toml:"fix_agent_fast"`
	FixAgentStandard    string `toml:"fix_agent_standard"`
	FixAgentThorough    string `toml:"fix_agent_thorough"`
	FixModel            string `toml:"fix_model"`
	FixModelFast        string `toml:"fix_model_fast"`
	FixModelStandard    string `toml:"fix_model_standard"`
	FixModelThorough    string `toml:"fix_model_thorough"`

	// Hooks configuration (per-repo)
	Hooks []HookConfig `toml:"hooks"`

	// Analysis settings
	MaxPromptSize int `toml:"max_prompt_size"` // Max prompt size in bytes before falling back to paths (overrides global default)
}

RepoConfig holds per-repo overrides

func LoadRepoConfig

func LoadRepoConfig(repoPath string) (*RepoConfig, error)

LoadRepoConfig loads per-repo config from .roborev.toml

type SyncConfig

type SyncConfig struct {
	// Enabled enables sync to PostgreSQL
	Enabled bool `toml:"enabled"`

	// PostgresURL is the connection string for PostgreSQL.
	// Supports environment variable expansion via ${VAR} syntax.
	PostgresURL string `toml:"postgres_url"`

	// Interval is how often to sync (e.g., "5m", "1h"). Default: 1h
	Interval string `toml:"interval"`

	// MachineName is a friendly name for this machine (optional)
	MachineName string `toml:"machine_name"`

	// ConnectTimeout is the connection timeout (e.g., "5s"). Default: 5s
	ConnectTimeout string `toml:"connect_timeout"`

	// RepoNames provides custom display names for synced repos by identity.
	// Example: {"git@github.com:org/repo.git": "my-project"}
	RepoNames map[string]string `toml:"repo_names"`
}

SyncConfig holds configuration for PostgreSQL sync

func (*SyncConfig) GetRepoDisplayName added in v0.18.0

func (c *SyncConfig) GetRepoDisplayName(identity string) string

GetRepoDisplayName returns the configured display name for a repo identity, or empty string if no override is configured.

func (*SyncConfig) PostgresURLExpanded

func (c *SyncConfig) PostgresURLExpanded() string

PostgresURLExpanded returns the PostgreSQL URL with environment variables expanded. Returns empty string if URL is not set.

func (*SyncConfig) Validate

func (c *SyncConfig) Validate() []string

Validate checks the sync configuration for common issues. Returns a list of warnings (non-fatal issues).

Jump to

Keyboard shortcuts

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