Documentation
¶
Overview ¶
Package config loads and validates gitlab-reviewer settings with the precedence flags > environment variables > settings file > defaults.
Index ¶
- Variables
- func DefaultAgentsDir() string
- func DefaultCacheDir() string
- func DefaultClaudeAgentsDir() string
- func DefaultFile() string
- func DefaultLogFile() string
- func DefaultStateDir() string
- func UserAgentDirs() []string
- type Bedrock
- type Checkout
- type Config
- type Gate
- type GitLab
- type Instance
- type Log
- type MCPServer
- type Options
- type Publish
- type Result
- type Review
- type UI
Constants ¶
This section is empty.
Variables ¶
var Categories = []string{"bug", "security", "performance", "docs", "style", "design"}
Categories of findings the reviewer can be asked to produce.
var Severities = []string{"info", "minor", "major", "critical"}
Severity levels a finding can carry, ordered weakest to strongest.
Functions ¶
func DefaultAgentsDir ¶ added in v1.16.0
func DefaultAgentsDir() string
DefaultAgentsDir is where user-level review agent definitions live.
func DefaultCacheDir ¶
func DefaultCacheDir() string
DefaultCacheDir is where repository clones and worktrees are cached.
func DefaultClaudeAgentsDir ¶ added in v1.33.0
func DefaultClaudeAgentsDir() string
DefaultClaudeAgentsDir is Claude Code's user-scope subagents directory, ~/.claude/agents — the user-level counterpart of a repo's .claude/agents. Empty when the home directory cannot be resolved.
func DefaultLogFile ¶
func DefaultLogFile() string
DefaultLogFile is the default log destination; the TUI owns stdout so logs always go to a file.
func DefaultStateDir ¶
func DefaultStateDir() string
DefaultStateDir is where logs and raw review dumps are written.
func UserAgentDirs ¶ added in v1.33.0
func UserAgentDirs() []string
UserAgentDirs are the user-scope agent directories in increasing precedence: a definition in DefaultAgentsDir shadows a same-named one in DefaultClaudeAgentsDir.
Types ¶
type Checkout ¶
type Checkout struct {
Mode string `koanf:"mode"` // clone | path | root
Path string `koanf:"path"`
Root string `koanf:"root"`
Transport string `koanf:"transport"` // https | ssh
CacheDir string `koanf:"cache_dir"`
CacheMaxMB int `koanf:"cache_max_mb"`
Keep bool `koanf:"keep"`
CloneMissing bool `koanf:"clone_missing"`
// LocalOverlay globs select untracked files in the local clone (path
// and root modes) that are copied into the review worktree — team
// standards kept out of the repo, e.g. via .git/info/exclude.
LocalOverlay []string `koanf:"local_overlay"`
}
type Config ¶
type Config struct {
GitLab GitLab `koanf:"gitlab"`
Review Review `koanf:"review"`
Bedrock Bedrock `koanf:"bedrock"`
Checkout Checkout `koanf:"checkout"`
Publish Publish `koanf:"publish"`
Gate Gate `koanf:"gate"`
UI UI `koanf:"ui"`
Log Log `koanf:"log"`
}
func Default ¶
func Default() Config
Default returns the built-in defaults, the lowest-precedence layer.
func (Config) InstanceNames ¶ added in v1.5.0
InstanceNames returns the configured instance names in file order.
func (Config) ModelOptions ¶ added in v1.25.0
ModelOptions returns the model IDs to offer for review.model: review.models when configured, otherwise the curated list for the selected provider.
func (Config) Validate ¶
Validate checks internal consistency. It does not require a GitLab token; commands that talk to GitLab must additionally call ValidateGitLab.
func (Config) ValidateGitLab ¶
ValidateGitLab checks settings required to talk to GitLab at all. An empty project/group scope is fine: the TUI offers in-app selection.
func (Config) WithInstance ¶ added in v1.5.0
WithInstance returns a copy of the configuration narrowed to the named instance: its base URL and token replace the top-level gitlab settings. An instance with an empty token keeps gitlab.token as the fallback. Tokens named by token_env are resolved at load time; selecting an instance whose variable is unset is an error rather than a silent fallback to the shared token.
type Gate ¶ added in v1.29.0
type Gate struct {
// MinSeverity marks findings at or above it as blocking; empty disables
// the gate entirely.
MinSeverity string `koanf:"min_severity"`
// Approvals is what approving from the tool does while blocking findings
// remain: off (ignore the gate), warn (ask for confirmation), or block
// (refuse). Only consulted when min_severity is set.
Approvals string `koanf:"approvals"`
}
Gate ties the review outcome to a severity policy: findings at or above min_severity are "blocking". The headless review command exits non-zero while blocking findings remain, and approvals controls how the TUI/GUI approve action behaves. Advisory only: GitLab itself is not restricted.
type GitLab ¶
type GitLab struct {
BaseURL string `koanf:"base_url"`
Token string `koanf:"token"`
Projects []string `koanf:"projects"`
Groups []string `koanf:"groups"`
PerPage int `koanf:"per_page"`
// Instances are named GitLab instances to choose between (settings file
// only). When set, one instance is selected at startup — via --instance,
// default_instance, or an interactive prompt — and its connection
// settings replace gitlab.base_url and gitlab.token.
Instances []Instance `koanf:"instances"`
// DefaultInstance names the instance to use without prompting; the
// --instance flag and GITLAB_REVIEWER_GITLAB_DEFAULT_INSTANCE override it.
DefaultInstance string `koanf:"default_instance"`
}
type Instance ¶ added in v1.5.0
type Instance struct {
Name string `koanf:"name"`
BaseURL string `koanf:"base_url"`
// Token is the access token for this instance; empty falls back to
// gitlab.token (useful when one env-provided token covers an instance).
Token string `koanf:"token"`
// TokenEnv names an environment variable holding the token for this
// instance (e.g. WORK_GITLAB_TOKEN), keeping the secret out of the
// settings file. Consulted only when token is empty; the variable must
// be set whenever this instance is selected.
TokenEnv string `koanf:"token_env"`
}
Instance is one named GitLab instance in gitlab.instances.
type MCPServer ¶ added in v1.22.0
type MCPServer struct {
// Type is stdio, http, or sse; empty infers stdio when command is set
// and http when url is set.
Type string `koanf:"type"`
Command string `koanf:"command"`
Args []string `koanf:"args"`
Env map[string]string `koanf:"env"`
URL string `koanf:"url"`
// Headers are sent with every request to a remote server; values are
// treated as secrets and redacted from `config show`.
Headers map[string]string `koanf:"headers"`
// Tools narrows the allowed tools of this server to the named ones;
// empty allows all of the server's tools.
Tools []string `koanf:"tools"`
}
MCPServer is one MCP server definition in review.mcp_servers, mirroring Claude Code's .mcp.json entries: a local stdio server (command/args/env) or a remote http/sse one (url/headers).
type Options ¶
type Options struct {
// File is an explicit settings file path (--config). Empty = default
// XDG location, which is allowed to be absent.
File string
// Flags is the parsed flag set; nil skips the flag layer.
Flags *pflag.FlagSet
// LookupEnv overrides os.LookupEnv in tests.
LookupEnv func(string) (string, bool)
}
Options control loading; zero value means real environment and default paths.
type Publish ¶
type Publish struct {
Mode string `koanf:"mode"` // draft | immediate
AutoComment bool `koanf:"auto_comment"`
AutoMinSeverity string `koanf:"auto_min_severity"`
// MinSeverity is the publish floor: findings below it are never posted
// to GitLab — they stay visible in triage, marked below-threshold. The
// default (info) publishes everything.
MinSeverity string `koanf:"min_severity"`
FallbackToNote bool `koanf:"fallback_to_note"`
Attribution bool `koanf:"attribution"`
// Template is a Go text/template for the comment body with fields
// severity, category, title, body, file. Empty means the built-in
// "**[severity · category] title**" layout; set e.g. "{{.body}}" for
// comments with no machine-looking header.
Template string `koanf:"template"`
}
type Result ¶
type Result struct {
Config Config
// FilePath is the settings file that was read, "" if none existed.
FilePath string
// contains filtered or unexported fields
}
Result is a loaded configuration plus the merged koanf tree, kept so per-project overrides can be applied later.
func (*Result) ForProject ¶
ForProject returns the configuration with per-project overrides from the settings file's projects.<full/project/path> section merged over the review, checkout, publish, and gate sections.
type Review ¶
type Review struct {
Provider string `koanf:"provider"` // anthropic | bedrock
Model string `koanf:"model"`
// Models is the list offered by the `models` command and --model shell
// completion. Empty falls back to a curated list of common Claude
// models for the selected provider. Suggestions only: review.model
// accepts any string the claude CLI understands.
Models []string `koanf:"models"`
ClaudePath string `koanf:"claude_path"`
Timeout time.Duration `koanf:"timeout"`
MaxBudgetUSD float64 `koanf:"max_budget_usd"`
// Agents is the default agent selection for a review: builtin agent
// names (the category names) plus any custom agents by name. Empty
// falls back to the deprecated categories key, which defaults to all
// builtins.
Agents []string `koanf:"agents"`
// AgentConcurrency caps how many agent passes run at once.
AgentConcurrency int `koanf:"agent_concurrency"`
// Categories is deprecated: builtin agents subsumed it. It is kept as
// an alias for agents (each category name is a builtin agent).
Categories []string `koanf:"categories"`
Instructions string `koanf:"instructions"`
InstructionsFile string `koanf:"instructions_file"`
MaxDiffKB int `koanf:"max_diff_kb"`
Exclude []string `koanf:"exclude"`
Bare bool `koanf:"bare"`
// UseAgents lets the reviewer delegate to Claude Code subagents
// (project .claude/agents plus user-level ones). Write/exec tools
// stay denied for the whole session, subagents included.
UseAgents bool `koanf:"use_agents"`
Env map[string]string `koanf:"env"`
// MCPServers grants the review session named MCP servers, keyed by
// server name (settings file only — no flag or env form; per-project
// sections may add servers for just that project). Off by default:
// a server that reaches the network reopens the exfiltration channel
// the review sandbox exists to close, so grant only servers whose
// egress you trust and keep the grant per-project where possible.
MCPServers map[string]MCPServer `koanf:"mcp_servers"`
}
type UI ¶ added in v1.2.0
type UI struct {
// DiffView is the diff layout in the MR detail screen: unified or
// split (side-by-side). Toggleable per session with `v`.
DiffView string `koanf:"diff_view"`
// FileExplorer is the initial state of the changed-files tree in the
// MR detail screen: open or closed. Toggleable per session with `e`.
FileExplorer string `koanf:"file_explorer"`
}