config

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config loads the cascading YAML config that drives local-review.

Cascade (lowest precedence first):

  1. Built-in defaults (compiled in)
  2. Org config (optional URL, fetched + cached) -- v1: stub, see TODO
  3. ~/.local-review.yml (per-user)
  4. .local-review.yml (project root) (per-repo)
  5. CLI flags (per-invocation)

Each layer is a partial YAML; later layers shallow-merge over earlier ones.

Index

Constants

This section is empty.

Variables

View Source
var ErrAllLLMsDisabled = errors.New("all LLMs are explicitly disabled; at least one must be enabled for multi-LLM mode")

Validate checks the configuration for common errors. Returns an error if the config is invalid. Note: This should be called explicitly by commands that need validation (e.g., multi), not automatically in Load(), to avoid breaking v0-only users. ErrAllLLMsDisabled is returned by Validate when every configured LLM has an explicit `enabled: false`. The runner tolerates this specifically when `--only` is set: `--only` is an explicit allow-list that overrides config-level enable/disable for agent SELECTION, so an all-disabled config is fine in that case (the user opted into the named agents). Without the sentinel the runner couldn't tell this benign case apart from a genuinely misconfigured default run.

Functions

func FindRepoConfig

func FindRepoConfig(start string) string

FindRepoConfig walks up from start looking for a .local-review.yml. Returns "" when none is found (not an error).

Types

type Config

type Config struct {
	Provider Provider `yaml:"provider"` // v0: single-LLM API mode
	Review   Review   `yaml:"review"`
	Org      Org      `yaml:"org"`

	// v0.1: multi-LLM support
	LLMs    map[string]LLMConfig `yaml:"llms"`
	Merge   MergeConfig          `yaml:"merge"`
	Storage StorageConfig        `yaml:"storage"`

	// v0.8: prompt-pack customization (issue #55). Lets teams ship
	// their own house rules without forking the binary.
	Prompts PromptsConfig `yaml:"prompts"`
}

Config is the resolved (post-cascade) configuration.

func Defaults

func Defaults() Config

Defaults returns the built-in starting point.

func Load

func Load(repoConfigPath string) (Config, error)

Load resolves the cascade.

repoConfigPath is the path to the project-level .local-review.yml (typically found by walking up from cwd). Either path may be empty / missing.

func (*Config) Validate

func (c *Config) Validate() error

type LLMConfig

type LLMConfig struct {
	Enabled    *bool  `yaml:"enabled"`
	CLIPath    string `yaml:"cli_path"`        // path to CLI binary (auto-detect if empty)
	Model      string `yaml:"model"`           // model name passed to the agent CLI
	APIKeyEnv  string `yaml:"api_key_env"`     // env var name for API key
	APIKey     string `yaml:"api_key"`         // DEPRECATED: use environment variable instead
	TimeoutSec int    `yaml:"timeout_seconds"` // per-call timeout
}

LLMConfig holds configuration for a single LLM (v0.1+).

Note: a `mode: cli|api` field shipped in v0.1's example config but was never wired through to the orchestrator (multi-LLM always invokes via CLI). It was removed in v0.5.x. Existing YAML configs with a `mode:` line still load — yaml.v3 silently ignores unknown fields. The "API fallback when CLI auth fails" idea is parked in do-not-merge/v06-fully-local-ollama-preset.md.

type MergeConfig

type MergeConfig struct {
	PreferredLLM       string `yaml:"preferred_llm"`       // "auto" or specific LLM name
	Deduplicate        *bool  `yaml:"deduplicate"`         // remove duplicate findings
	ConsensusThreshold int    `yaml:"consensus_threshold"` // N LLMs agreeing = "Confirmed by N"
}

MergeConfig controls how multi-LLM reviews are merged (v0.1+).

type Org

type Org struct {
	ConfigURL string `yaml:"config_url"`
}

Org is reserved for org-wide config delivery (v1: stub).

type PromptsConfig added in v0.8.0

type PromptsConfig struct {
	PackDir string `yaml:"pack_dir"` // directory of override <language>.md files
	Prepend string `yaml:"prepend"`  // text spliced BEFORE the pack body
	Append  string `yaml:"append"`   // text spliced AFTER the pack body
}

PromptsConfig customises the language prompt packs the binary ships with. Issue #55: teams want to tune review tone, severity bar, or add house rules without forking. Three knobs, all optional, all composable:

  • PackDir: directory of override files keyed by language id. A `go.md` in this directory replaces the embedded `go.md`. Files not present fall through to the embedded pack of the same name.
  • Prepend / Append: free-form text spliced before/after whatever pack content was loaded. Survives an upstream pack update — the prepend/append text is yours, the pack body keeps tracking upstream improvements.

All three apply to BOTH the single-LLM fallback path AND the per-LLM CLI invocations (claude/gemini/codex), so a team's house rules reach every reviewer.

type Provider

type Provider struct {
	BaseURL    string `yaml:"base_url"`        // e.g. https://api.openai.com/v1
	Model      string `yaml:"model"`           // e.g. gpt-4o, claude-3-5-sonnet
	APIKey     string `yaml:"api_key"`         // DEPRECATED: use environment variable instead
	APIKeyEnv  string `yaml:"api_key_env"`     // env var name to read; defaults to LOCAL_REVIEW_API_KEY
	TimeoutSec int    `yaml:"timeout_seconds"` // per-call timeout, default 60
}

Provider holds LLM endpoint settings. Defaults to OpenAI; any OpenAI-compatible endpoint works (Anthropic via /v1/chat/completions, Together, Groq, OpenRouter, Ollama, vLLM, etc.).

type Review

type Review struct {
	MinSeverity  string   `yaml:"min_severity"` // "nit"|"info"|"warning"|"major"|"critical"
	MaxFindings  int      `yaml:"max_findings"` // hard cap to avoid noise
	IncludeGlobs []string `yaml:"include"`      // file globs to consider
	ExcludeGlobs []string `yaml:"exclude"`      // file globs to drop
	PromptPack   string   `yaml:"prompt_pack"`  // override auto-detection
}

Review holds tuning knobs for what gets surfaced.

type StorageConfig

type StorageConfig struct {
	BasePath string `yaml:"base_path"` // base directory for reviews
}

StorageConfig controls where reviews are saved (v0.1+).

Jump to

Keyboard shortcuts

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