config

package
v0.1.36 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config loads and validates cr's non-secret configuration.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotConfigured means config.yml does not exist.
	ErrNotConfigured = errors.New("config: not configured")
	// ErrProfileNotFound means the requested profile is absent.
	ErrProfileNotFound = errors.New("config: profile not found")
	// ErrInvalid means the config file is malformed or violates the schema.
	ErrInvalid = errors.New("config: invalid")
	// ErrUnsupported means the config uses a known v2-only option.
	ErrUnsupported = errors.New("config: not supported in v1")
)

Functions

func Path

func Path() (string, error)

Path resolves the default cr config.yml path without creating it.

func Save

func Save(path string, cfg File) error

Save validates and atomically writes config.yml.

func Validate

func Validate(cfg File) error

Validate checks a config file after defaults have been applied.

Types

type CredentialRef

type CredentialRef struct {
	Purpose  string `json:"purpose"`
	Ref      string `json:"ref"`
	Mode     string `json:"mode"`
	Provider string `json:"provider,omitempty"`
}

CredentialRef is one declared non-secret pointer into the credential store.

func CredentialRefs

func CredentialRefs(profile Profile) ([]CredentialRef, error)

CredentialRefs returns all credential-store refs declared by profile.

type DataConfig

type DataConfig struct {
	Retention RetentionConfig `yaml:"retention,omitempty" json:"retention"`
}

DataConfig carries non-secret durable data policy.

type File

type File struct {
	DefaultProfile string             `yaml:"default_profile" json:"default_profile"`
	Keyring        KeyringConfig      `yaml:"keyring,omitempty" json:"keyring"`
	Profiles       map[string]Profile `yaml:"profiles" json:"profiles"`
	Data           DataConfig         `yaml:"data,omitempty" json:"data"`
}

File is the root config.yml schema.

func Load

func Load(path string) (File, error)

Load reads and validates config.yml.

type GitAuthMode

type GitAuthMode string

GitAuthMode identifies how git-host credentials are obtained.

const (
	GitAuthModePAT         GitAuthMode = "pat"
	GitAuthModeOAuthDevice GitAuthMode = "oauth_device"
	GitAuthModeGitHubApp   GitAuthMode = "github_app"
)

Git auth modes.

func (GitAuthMode) Supported

func (m GitAuthMode) Supported() bool

Supported reports whether m is implemented in v1.

func (GitAuthMode) Valid

func (m GitAuthMode) Valid() bool

Valid reports whether m is a known git auth mode.

type GitConfig

type GitConfig struct {
	Host          string      `yaml:"host" json:"host"`
	AuthMode      GitAuthMode `yaml:"auth_mode" json:"auth_mode"`
	CredentialRef string      `yaml:"credential_ref" json:"credential_ref"`
	IdentityCache string      `yaml:"identity_cache,omitempty" json:"identity_cache,omitempty"`
}

GitConfig identifies the user's git-host credentials.

type KeyringConfig

type KeyringConfig struct {
	Backend string `yaml:"backend,omitempty" json:"backend,omitempty"`
}

KeyringConfig carries non-secret keyring backend preferences.

type LLMAdapter

type LLMAdapter string

LLMAdapter identifies the concrete LLM adapter.

const (
	LLMAdapterClaudeCLI    LLMAdapter = "claude_cli"
	LLMAdapterAnthropicAPI LLMAdapter = "anthropic_api"
	LLMAdapterCodexCLI     LLMAdapter = "codex_cli"
	LLMAdapterOpenAIAPI    LLMAdapter = "openai_api"
)

LLM adapters.

func (LLMAdapter) Valid

func (a LLMAdapter) Valid() bool

Valid reports whether a is a known LLM adapter.

type LLMAuth

type LLMAuth string

LLMAuth identifies how the LLM adapter authenticates.

const (
	LLMAuthSubscription LLMAuth = "subscription"
	LLMAuthAPIKey       LLMAuth = "api_key"
)

LLM auth modes.

func (LLMAuth) Valid

func (a LLMAuth) Valid() bool

Valid reports whether a is a known LLM auth mode.

type LLMConfig

type LLMConfig struct {
	Provider      LLMProvider `yaml:"provider" json:"provider"`
	Auth          LLMAuth     `yaml:"auth" json:"auth"`
	Adapter       LLMAdapter  `yaml:"adapter" json:"adapter"`
	CredentialRef string      `yaml:"credential_ref,omitempty" json:"credential_ref,omitempty"`
}

LLMConfig identifies the LLM provider and adapter.

type LLMProvider

type LLMProvider string

LLMProvider identifies the model provider family.

const (
	LLMProviderAnthropic LLMProvider = "anthropic"
	LLMProviderOpenAI    LLMProvider = "openai"
)

LLM providers.

func (LLMProvider) Valid

func (p LLMProvider) Valid() bool

Valid reports whether p is a known LLM provider.

type Profile

type Profile struct {
	Git                 GitConfig            `yaml:"git" json:"git"`
	ReviewerCredentials *ReviewerCredentials `yaml:"reviewer_credentials,omitempty" json:"reviewer_credentials,omitempty"`
	LLM                 LLMConfig            `yaml:"llm" json:"llm"`
	AgentSources        []string             `yaml:"agent_sources,omitempty" json:"agent_sources,omitempty"`
	ReviewPolicy        ReviewPolicy         `yaml:"review_policy,omitempty" json:"review_policy"`
}

Profile is one named review profile.

func ResolveProfile

func ResolveProfile(cfg File, requestedName string) (string, Profile, error)

ResolveProfile returns the requested profile, or the default profile when requestedName is empty.

type ResolveThreadsPolicy

type ResolveThreadsPolicy string

ResolveThreadsPolicy identifies profile-level thread-resolution behavior.

const (
	ResolveThreadsAuto  ResolveThreadsPolicy = "auto"
	ResolveThreadsNever ResolveThreadsPolicy = "never"
)

Thread-resolution policies.

func (ResolveThreadsPolicy) Valid

func (p ResolveThreadsPolicy) Valid() bool

Valid reports whether p is a known thread-resolution policy.

type RetentionConfig

type RetentionConfig struct {
	MaxAgeDays  *int                 `yaml:"max_age_days,omitempty" json:"max_age_days"`
	Enforcement RetentionEnforcement `yaml:"enforcement,omitempty" json:"enforcement"`
}

RetentionConfig controls run-data lifecycle behavior.

func (RetentionConfig) MaxAgeDaysValue

func (r RetentionConfig) MaxAgeDaysValue() int

MaxAgeDaysValue returns the configured max age, applying the default when max_age_days was omitted. A configured zero still means keep forever.

type RetentionEnforcement

type RetentionEnforcement string

RetentionEnforcement identifies when retention is applied.

const (
	RetentionAtWrite    RetentionEnforcement = "at_write"
	RetentionManualOnly RetentionEnforcement = "manual_only"
)

Retention enforcement policies.

func (RetentionEnforcement) Valid

func (e RetentionEnforcement) Valid() bool

Valid reports whether e is a known retention enforcement policy.

type ReviewMajorEvent

type ReviewMajorEvent string

ReviewMajorEvent identifies how major findings affect the review event.

const (
	ReviewMajorEventComment        ReviewMajorEvent = "comment"
	ReviewMajorEventRequestChanges ReviewMajorEvent = "request_changes"
)

Review major-event policies.

func (ReviewMajorEvent) Valid

func (e ReviewMajorEvent) Valid() bool

Valid reports whether e is a known major-event policy.

type ReviewPolicy

type ReviewPolicy struct {
	MajorEvent       ReviewMajorEvent     `yaml:"major_event,omitempty" json:"major_event"`
	AllowSelfApprove bool                 `yaml:"allow_self_approve,omitempty" json:"allow_self_approve"`
	ResolveThreads   ResolveThreadsPolicy `yaml:"resolve_threads,omitempty" json:"resolve_threads,omitempty"`
	ResolveAfter     string               `yaml:"resolve_after,omitempty" json:"resolve_after,omitempty"`
}

ReviewPolicy carries profile-level review policy toggles.

type ReviewerCredentials

type ReviewerCredentials struct {
	AuthMode      GitAuthMode `yaml:"auth_mode" json:"auth_mode"`
	CredentialRef string      `yaml:"credential_ref" json:"credential_ref"`
	IdentityCache string      `yaml:"identity_cache,omitempty" json:"identity_cache,omitempty"`
}

ReviewerCredentials optionally identifies separate posting credentials.

Jump to

Keyboard shortcuts

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