config

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 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 IsDefaultReviewType added in v0.27.0

func IsDefaultReviewType(rt string) bool

IsDefaultReviewType returns true if the review type represents the standard (non-specialized) code review. The canonical name is "default"; "general" and "review" are accepted as backward-compatible aliases.

func NormalizeMinSeverity added in v0.26.0

func NormalizeMinSeverity(value string) (string, error)

NormalizeMinSeverity validates and normalizes a minimum severity level string. Returns the canonical form (critical, high, medium, low) or an error if invalid. Returns empty string (no error) for empty input.

func NormalizeReasoning added in v0.26.0

func NormalizeReasoning(value string) (string, error)

NormalizeReasoning validates and normalizes a reasoning level string. Returns the canonical form (thorough, standard, fast) or an error if invalid. Returns empty string (no error) for empty input.

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 CIConfig added in v0.26.0

type CIConfig struct {
	// Enabled enables the CI poller
	Enabled bool `toml:"enabled"`

	// PollInterval is how often to poll for PRs (e.g., "5m", "10m"). Default: 5m
	PollInterval string `toml:"poll_interval"`

	// Repos is the list of GitHub repos to poll in "owner/repo" format
	Repos []string `toml:"repos"`

	// ReviewTypes is the list of review types to run for each PR (e.g., ["security", "default"]).
	// Defaults to ["security"] if empty.
	ReviewTypes []string `toml:"review_types"`

	// Agents is the list of agents to run for each PR (e.g., ["codex", "gemini"]).
	// Defaults to auto-detection if empty.
	Agents []string `toml:"agents"`

	// Model overrides the model for CI reviews (empty = use workflow resolution)
	Model string `toml:"model"`

	// SynthesisAgent is the agent used to synthesize multiple review outputs into one comment.
	// Defaults to the first available agent.
	SynthesisAgent string `toml:"synthesis_agent"`

	// SynthesisModel overrides the model used for synthesis.
	SynthesisModel string `toml:"synthesis_model"`

	// MinSeverity filters out findings below this severity level during synthesis.
	// Valid values: critical, high, medium, low. Empty means no filter (include all).
	MinSeverity string `toml:"min_severity"`

	// GitHub App authentication (optional — comments appear as bot instead of personal account)
	GitHubAppID             int64  `toml:"github_app_id"`
	GitHubAppPrivateKey     string `toml:"github_app_private_key"` // PEM file path or inline; supports ${ENV_VAR}
	GitHubAppInstallationID int64  `toml:"github_app_installation_id"`

	// Multi-installation: map of owner → installation_id
	GitHubAppInstallations map[string]int64 `toml:"github_app_installations"`
}

CIConfig holds configuration for the CI poller that watches GitHub PRs

func (*CIConfig) GitHubAppConfigured added in v0.26.0

func (c *CIConfig) GitHubAppConfigured() bool

GitHubAppConfigured returns true if GitHub App authentication can be used. Requires app ID, private key, and at least one installation ID (singular or map).

func (*CIConfig) GitHubAppPrivateKeyResolved added in v0.26.0

func (c *CIConfig) GitHubAppPrivateKeyResolved() (string, error)

GitHubAppPrivateKeyResolved expands env vars in the private key value, reads the file if it's a path, and returns the PEM content.

func (*CIConfig) InstallationIDForOwner added in v0.26.0

func (c *CIConfig) InstallationIDForOwner(owner string) int64

InstallationIDForOwner returns the installation ID for a GitHub owner. Checks the normalized installations map first (skipping non-positive values), then falls back to the singular field. Owner comparison is case-insensitive.

func (*CIConfig) NormalizeInstallations added in v0.26.0

func (c *CIConfig) NormalizeInstallations() error

NormalizeInstallations lowercases all keys in GitHubAppInstallations so lookups are case-insensitive via direct map access. Returns an error if two keys collide after lowercasing (e.g., "wesm" and "Wesm").

func (*CIConfig) ResolvedAgents added in v0.26.0

func (c *CIConfig) ResolvedAgents() []string

ResolvedAgents returns the list of agents to use. Defaults to [""] (empty = auto-detect) if empty.

func (*CIConfig) ResolvedReviewTypes added in v0.26.0

func (c *CIConfig) ResolvedReviewTypes() []string

ResolvedReviewTypes returns the list of review types to use. Defaults to ["security"] if empty.

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"`
	SecurityAgent         string `toml:"security_agent"`
	SecurityAgentFast     string `toml:"security_agent_fast"`
	SecurityAgentStandard string `toml:"security_agent_standard"`
	SecurityAgentThorough string `toml:"security_agent_thorough"`
	SecurityModel         string `toml:"security_model"`
	SecurityModelFast     string `toml:"security_model_fast"`
	SecurityModelStandard string `toml:"security_model_standard"`
	SecurityModelThorough string `toml:"security_model_thorough"`
	DesignAgent           string `toml:"design_agent"`
	DesignAgentFast       string `toml:"design_agent_fast"`
	DesignAgentStandard   string `toml:"design_agent_standard"`
	DesignAgentThorough   string `toml:"design_agent_thorough"`
	DesignModel           string `toml:"design_model"`
	DesignModelFast       string `toml:"design_model_fast"`
	DesignModelStandard   string `toml:"design_model_standard"`
	DesignModelThorough   string `toml:"design_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"`

	// CI poller configuration
	CI CIConfig `toml:"ci"`

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

	// UI preferences
	HideAddressedByDefault bool `toml:"hide_addressed_by_default"`
	AutoFilterRepo         bool `toml:"auto_filter_repo"`
}

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 RepoCIConfig added in v0.26.0

type RepoCIConfig struct {
	// Agents overrides the list of agents for CI reviews of this repo.
	Agents []string `toml:"agents"`

	// ReviewTypes overrides the list of review types for CI reviews of this repo.
	ReviewTypes []string `toml:"review_types"`

	// Reasoning overrides the reasoning level for CI reviews (thorough, standard, fast).
	Reasoning string `toml:"reasoning"`

	// MinSeverity overrides the minimum severity filter for CI synthesis.
	MinSeverity string `toml:"min_severity"`
}

RepoCIConfig holds per-repo CI overrides (used by the CI poller for this repo). These override the global [ci] settings when reviewing this specific repo.

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

	// CI-specific overrides (used by CI poller for this repo)
	CI RepoCIConfig `toml:"ci"`

	// 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"`
	SecurityAgent         string `toml:"security_agent"`
	SecurityAgentFast     string `toml:"security_agent_fast"`
	SecurityAgentStandard string `toml:"security_agent_standard"`
	SecurityAgentThorough string `toml:"security_agent_thorough"`
	SecurityModel         string `toml:"security_model"`
	SecurityModelFast     string `toml:"security_model_fast"`
	SecurityModelStandard string `toml:"security_model_standard"`
	SecurityModelThorough string `toml:"security_model_thorough"`
	DesignAgent           string `toml:"design_agent"`
	DesignAgentFast       string `toml:"design_agent_fast"`
	DesignAgentStandard   string `toml:"design_agent_standard"`
	DesignAgentThorough   string `toml:"design_agent_thorough"`
	DesignModel           string `toml:"design_model"`
	DesignModelFast       string `toml:"design_model_fast"`
	DesignModelStandard   string `toml:"design_model_standard"`
	DesignModelThorough   string `toml:"design_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