config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config loads the user's settings and locates the state directory.

Index

Constants

View Source
const (
	ColumnWorking         = "working"
	ColumnWorkingFallback = "working-fallback"
	ColumnNeedsMe         = "needs-me"
	ColumnReviewed        = "reviewed"
	ColumnReady           = "ready"
	ColumnInProgress      = "in-progress"
	ColumnInReview        = "in-review"
	ColumnCompleted       = "completed"
)
View Source
const DefaultMCPPort = 47800
View Source
const DefaultPRDailyCap = 5
View Source
const DefaultSlackRedirectPort = 53682

DefaultSlackRedirectPort is the login callback port registered in the Slack app.

View Source
const MinSlackTurnChars = 2000

MinSlackTurnChars is the smallest cap Chars returns, which holds a parent and a reply.

View Source
const StatEvery = 2 * time.Second

StatEvery is how often a Holder looks at the config file.

View Source
const UserHomeVar = "LOOP_USER_HOME"

UserHomeVar names an absolute directory Home returns instead of the user's, so an isolated daemon finds no agent home of the user while HOME, which the Keychain needs, stays real.

Variables

This section is empty.

Functions

func DaemonSocket

func DaemonSocket() string

func Dir

func Dir() string

func ExpandHome

func ExpandHome(p string) string

func Home

func Home() string

func ParseDays

func ParseDays(s string) (time.Duration, error)

func Path

func Path() string

func ProfilesDir

func ProfilesDir() string

ProfilesDir holds the review profiles named by a bare name.

func ResolveProfile

func ResolveProfile(v string) string

ResolveProfile turns a profile setting into a directory: a bare name lives under ProfilesDir, anything else is a path.

func StateDir

func StateDir() string

StateDir holds the inventory database, the state lock and the logs.

Types

type ApprovalConfig

type ApprovalConfig struct {
	Default string `json:"default,omitempty"`
	Window  *Days  `json:"window,omitempty"`
}

type Brief

type Brief struct {
	Enabled      bool       `json:"enabled"`
	Tier         turns.Tier `json:"tier"`
	MaxDiffBytes int        `json:"max_diff_bytes"`
}

Brief previews each pull request with one headless call of the agent, outside the sweeps.

type Classify

type Classify struct {
	DailyCap int `json:"daily_cap"`
}

type Cleanup

type Cleanup struct {
	Idle           Days `json:"idle"`
	AskedIdle      Days `json:"asked_idle"`
	WorkspaceGrace Days `json:"workspace_grace"` // counted in working time
	ManualIdle     Days `json:"manual_idle"`
	StaleWorkspace Days `json:"stale_workspace"`
	// Disposable names ignored files and directories a tool recreates, so
	// removing a workspace that holds them loses nothing.
	Disposable []string `json:"disposable"`
}

Cleanup holds the thresholds of the session and workspace cleanup workflows.

type Config

type Config struct {
	// ProjectsDir is where `review` clones a repository that is not
	// registered in the workspace manager yet. No default: a wrong guess
	// clones duplicates.
	ProjectsDir string `json:"projects_dir"`
	// WorkspaceManagers are the enabled workspace managers in the order a new
	// worktree picks them: the first that hosts the agent and honors the
	// session's launch policy owns it.
	WorkspaceManagers  []string `json:"workspace_managers"`
	Agent              string   `json:"agent"`
	ReviewPrefix       string   `json:"review_prefix"`
	Rounds             Rounds   `json:"rounds"`
	AutomatedReviewers []string `json:"automated_reviewers"`
	// Owners restricts automated follow-ups to these GitHub owners. Empty
	// means the owners of every repository the workspace manager knows.
	Owners []string `json:"owners"`
	// TrustedAuthors are logins whose pull requests pass the author
	// association check of automated rounds, such as a bot with no
	// association to the repository.
	TrustedAuthors []string `json:"trusted_authors"`
	// FollowupsWithoutWorkspace lets a follow-up review recreate the review
	// workspace the user deleted; off, the sweep only logs the follow-up.
	FollowupsWithoutWorkspace bool `json:"followups_without_workspace"`
	// AddressWithoutWorkspace lets a triage round on a pull request I
	// develop create its author workspace when it has none; off, the sweep
	// only records the round it would start.
	AddressWithoutWorkspace bool `json:"address_without_workspace"`
	// AgentHome is the agent's own configuration directory (CLAUDE_CONFIG_DIR
	// for Claude Code), "" for the agent's default.
	AgentHome string `json:"agent_home"`
	// Profile is the directory with the reviewer's judgment.
	Profile string `json:"profile"`
	// AgentModels pins, per agent, a model tier to one of that agent's
	// own model names; the loop hands the name to the agent unread.
	AgentModels map[string]map[turns.Tier]string `json:"agent_models"`
	// AddressReviews starts a triage round in the author workspace when
	// someone reviews a pull request I develop.
	AddressReviews bool `json:"address_reviews"`
	// AddressSkipReviewers lists logins whose reviews never start a triage
	// round.
	AddressSkipReviewers []string `json:"address_skip_reviewers"`
	// AddressChecks starts a triage round when checks fail on the head of a
	// pull request I develop; IgnoreChecks names checks that never do.
	AddressChecks bool     `json:"address_checks"`
	IgnoreChecks  []string `json:"ignore_checks"`
	// Projects override settings for the pull requests of matching
	// repositories; the first match wins.
	Projects []Project `json:"projects"`
	Scope    Scope     `json:"scope"`
	Stalled  Stalled   `json:"stalled"`
	Sweep    Sweep     `json:"sweep"`
	HTTP     HTTP      `json:"http"`
	MCP      MCP       `json:"mcp"`
	Brief    Brief     `json:"brief"`
	// Views holds each view sink's own settings by sink name.
	Views    map[string]SinkConfig `json:"views"`
	Cleanup  Cleanup               `json:"cleanup"`
	Nudge    Nudge                 `json:"nudge"`
	Classify Classify              `json:"classify"`
	// Workflows override each workflow's manifest by workflow name.
	Workflows map[string]WorkflowConfig `json:"workflows"`
	// ProjectSettings maps an intent to a predicate over its pull request's
	// facts: where it does not hold, the intent's sessions start without the
	// checkout's own agent settings. An intent it does not name loads them.
	ProjectSettings map[string]string `json:"project_settings"`
	// Plugins switch each compiled-in plugin by provider id.
	Plugins map[string]Plugin `json:"plugins"`
	// Placement is the rules that place units; the first match wins.
	Placement []PlacementRule `json:"placement,omitempty"`
	GTD       GTD             `json:"gtd"`
	// Notifications sets the menu bar's daily digest.
	Notifications Notifications `json:"notifications"`
	Slack         Slack         `json:"slack"`
	Dossiers      Dossiers      `json:"dossiers"`
	// Proposals sets the rules that propose drafts on their own.
	Proposals Proposals `json:"proposals"`
	Items     Items     `json:"items"`
	Headless  Headless  `json:"headless"`
}

func Defaults

func Defaults() Config

func Load

func Load() (Config, error)

func LoadFile

func LoadFile(file string) (Config, error)

func (Config) AgentHomes

func (c Config) AgentHomes() []string

AgentHomes lists every agent home the settings name.

func (Config) Column

func (c Config) Column(sink, status string) string

Column is sink's column for status, "" when unset.

func (Config) For

func (c Config) For(owner, repo string) Config

For returns the settings that apply to a pull request of owner/repo.

func (Config) PlacementMap

func (c Config) PlacementMap() placement.Map

PlacementMap is c's placement rules as the placement service reads them.

func (Config) PluginEnabled

func (c Config) PluginEnabled(id string) bool

PluginEnabled says whether the plugin id is on: a missing entry or a nil Enabled is.

func (Config) ProjectSettingsFor

func (c Config) ProjectSettingsFor(intent string, pr expr.Facts) bool

ProjectSettingsFor says whether a session of intent on the pull request whose facts pr resolves loads the checkout's own agent settings. Without the facts, an intent that has a predicate does not.

func (Config) WithColumns

func (c Config) WithColumns(defaults map[string]map[string]string) Config

WithColumns is c with, for each sink in defaults, the default of each column c leaves out.

type Days

type Days time.Duration

Days is a duration written as "2d", "36h" or "90m" in the config.

func (Days) MarshalJSON

func (d Days) MarshalJSON() ([]byte, error)

MarshalJSON writes the form ParseDays reads: "2d", "36h", "2m".

func (*Days) UnmarshalJSON

func (d *Days) UnmarshalJSON(b []byte) error

type Dossiers

type Dossiers struct {
	ArchiveAfter Days  `json:"archive_after"` // after the unit or project resolved
	PurgeAfter   Days  `json:"purge_after"`   // after the archive
	SoftCapMB    int64 `json:"soft_cap_mb"`   // per dossier, reported by doctor
	TotalCapMB   int64 `json:"total_cap_mb"`  // dossiers and archives, reported by doctor
	MaxFileMB    int64 `json:"max_file_mb"`   // a larger file is refused, linked instead
	CompactAtKB  int64 `json:"compact_at_kb"` // log/ size that triggers compaction
}

Dossiers sets the dossiers' lifecycle and quotas; a value of zero or less keeps its default.

type GTD

type GTD struct {
	StaleWaitingDays int      `json:"stale_waiting_days"` // working days
	Areas            []string `json:"areas"`
	Contexts         []string `json:"contexts"`
}

GTD holds the entries' settings: when a waiting entry goes stale, and the areas and contexts offered.

type HTTP

type HTTP struct {
	Port int `json:"port"`
}

type Headless

type Headless struct {
	Tier       turns.Tier `json:"tier"`
	PerCallUSD float64    `json:"per_call_usd"`
	PerDayUSD  float64    `json:"per_day_usd"`
}

Headless caps the headless turns: the model tier of their calls, what one call may cost and what they may cost in a day; a cost of zero leaves it uncapped.

type Holder

type Holder struct {
	// contains filtered or unexported fields
}

Holder is the one configuration a serve holds. Config is the config the serve started with, except that the profile setting follows the file; every other change makes Stale true until the serve restarts.

func NewHolder

func NewHolder(cfg Config, opts HolderOptions) *Holder

NewHolder holds cfg, the config just loaded from opts.Path.

func (*Holder) Break

func (h *Holder) Break(err error)

Break records that no config has loaded yet, so Err answers err until Rebase.

func (*Holder) Config

func (h *Holder) Config() Config

Config is the config the serve runs with and the profile now in force.

func (*Holder) Err

func (h *Holder) Err() error

Err is the failure recorded by Break, nil once a config has loaded.

func (*Holder) Rebase

func (h *Holder) Rebase(cfg Config)

Rebase makes cfg, just loaded, the config the serve runs with.

func (*Holder) Stale

func (h *Holder) Stale() bool

Stale reports that the file changed in a way only a restart applies.

func (*Holder) Warning

func (h *Holder) Warning() string

Warning is what a restart or a fix of config.json would change: the load failure of a file that broke, else that a changed file needs a restart; "" when the running config matches the file.

type HolderOptions

type HolderOptions struct {
	// Path is the config file to watch; "" watches nothing.
	Path string
	// Load reads the config; nil disables reloads.
	Load func() (Config, error)
	// Stat is os.Stat when nil.
	Stat func(string) (os.FileInfo, error)
	// Every is the stat interval; StatEvery when zero.
	Every time.Duration
	// Now is the clock; time.Now when nil.
	Now func() time.Time
	// OnProfileChange runs, outside the lock, after the profile setting changed to profile.
	OnProfileChange func(profile string)
	// OnWarningChange runs, outside the lock, after a reload changed what Warning answers.
	OnWarningChange func()
}

HolderOptions are the collaborators of a Holder.

type Items

type Items struct {
	Heat ItemsHeat `json:"heat"`
}

Items holds the items ledger's settings.

type ItemsHeat

type ItemsHeat struct {
	// WarmFor is how long a unit stays warm after its last item resolved; zero is the heat reader's default.
	WarmFor Days `json:"warm_for,omitempty"`
}

type MCP

type MCP struct {
	Port int `json:"port"`
}

MCP is the daemon's MCP endpoint, which agent homes register by URL.

func (MCP) URL

func (m MCP) URL() string

URL is the endpoint agent homes register.

type Notifications

type Notifications struct {
	DigestAt string `json:"digest_at"`
}

Notifications: DigestAt is the local "HH:MM" of the daily digest, "" for none.

type Nudge

type Nudge struct {
	SilentDays int `json:"silent_days"` // calendar days
}

type PlacementRule

type PlacementRule struct {
	Match    string `json:"match"`
	Repo     string `json:"repo,omitempty"`
	Checkout string `json:"checkout,omitempty"`
	Role     string `json:"role,omitempty"`
	Shared   bool   `json:"shared,omitempty"`
}

PlacementRule is one rule of the placement map.

type Plugin

type Plugin struct {
	Enabled *bool `json:"enabled,omitempty"`
}

Plugin is one plugin's switch; a nil Enabled means enabled.

type Project

type Project struct {
	Match       string `json:"match"`
	ProjectsDir string `json:"projects_dir"`
	// Agent is the agent the project's sessions run.
	Agent     string `json:"agent"`
	AgentHome string `json:"agent_home"`
	// WorkspaceManagers orders the managers a new worktree of the project picks from.
	WorkspaceManagers []string `json:"workspace_managers"`

	TrustedAuthors            []string `json:"trusted_authors"`
	FollowupsWithoutWorkspace *bool    `json:"followups_without_workspace"`
	AddressWithoutWorkspace   *bool    `json:"address_without_workspace"`
}

Project matches repositories by an owner/repo pattern such as "acme/*" or "acme/infra". Empty fields keep the top-level value.

func (Project) Matches

func (p Project) Matches(owner, repo string) bool

type ProposalApproval

type ProposalApproval struct {
	Mode   string `json:"mode"`
	Window Days   `json:"window,omitempty"`
}

type ProposalRule

type ProposalRule struct {
	Approval *ProposalApproval `json:"approval,omitempty"`
}

type Proposals

type Proposals struct {
	RenudgeAfter Days
	Rules        map[string]ProposalRule
}

Proposals holds the settings of the rules that propose drafts on their own: how long a nudged, discarded, sent or observed proposal keeps its rule from proposing it again, and each rule's approval by rule id ("stalled-nudge", "closure", "ask-owner", "github-nudge"). In JSON the rules sit beside "renudge_after".

func (Proposals) Approval

func (p Proposals) Approval(rule string) draft.Approval

Approval is rule's configured approval, always when the config sets none.

func (Proposals) MarshalJSON

func (p Proposals) MarshalJSON() ([]byte, error)

func (*Proposals) UnmarshalJSON

func (p *Proposals) UnmarshalJSON(b []byte) error

type Rounds

type Rounds struct {
	PerPRPerDay int `json:"per_pr_per_day"`
}

Rounds caps the automatic rounds: PerPRPerDay stops a runaway loop on one pull request, counted per local day.

type Scope

type Scope struct {
	People []string `json:"people"`
	Teams  []string `json:"teams"`
	Repos  []string `json:"repos"`
	Watch  []string `json:"watch"`
}

type SinkConfig

type SinkConfig struct {
	// Columns maps a semantic status (working, working-fallback, needs-me, reviewed, ready, in-progress, in-review, completed) to the sink's column.
	Columns map[string]string `json:"columns"`
}

SinkConfig is one view sink's own settings.

type Slack

type Slack struct {
	// ClientID is the Slack app's client id; empty leaves Slack unconfigured.
	ClientID     string `json:"client_id"`
	RedirectPort int    `json:"redirect_port"`
	// KeychainService names the Keychain items; empty is brand.StateDir()+"-slack".
	KeychainService string `json:"keychain_service"`
	// PostAllowlist, when not empty, holds the only channel ids, or user ids naming
	// the DM with that user, a post may go to.
	PostAllowlist []string `json:"post_allowlist"`
	// RequestLog logs one line per Slack call: method and HTTP status.
	RequestLog bool            `json:"request_log"`
	Ingest     SlackIngest     `json:"ingest"`
	Extraction SlackExtraction `json:"extraction"`
	Turns      SlackTurns      `json:"turns"`
}

Slack holds the Slack source's settings; no secret lives here.

func (Slack) Configured

func (s Slack) Configured() bool

func (Slack) Port

func (s Slack) Port() int

func (Slack) Service

func (s Slack) Service() string

type SlackExtraction

type SlackExtraction struct {
	// Enabled nil is on.
	Enabled *bool `json:"enabled,omitempty"`
	// Tier is fast, balanced or frontier; empty is fast.
	Tier     string  `json:"tier,omitempty"`
	Language string  `json:"language,omitempty"`
	MaxCall  float64 `json:"max_call_usd,omitempty"`
	MaxDay   float64 `json:"max_day_usd,omitempty"`
	MaxCalls int     `json:"max_day_calls,omitempty"`
	// Quiet is how long a unit stays unchanged before it runs; MaxWait bounds the delay of its oldest change.
	Quiet       Days `json:"quiet,omitempty"`
	MaxWait     Days `json:"max_wait,omitempty"`
	WindowChars int  `json:"window_chars,omitempty"`
	// MaxFailures failed calls in a row make the job give up on a unit until its next change.
	MaxFailures int `json:"max_failures,omitempty"`
	// ContextMessages and ContextChars bound the read-only messages shown before a DM's window; -1 turns either off.
	ContextMessages int `json:"context_messages,omitempty"`
	ContextChars    int `json:"context_chars,omitempty"`
	// EscalateOverChars sends a unit whose rendered conversation is longer to the frontier tier; 0 or -1 is off.
	EscalateOverChars int `json:"escalate_over_chars,omitempty"`
}

SlackExtraction sets the extraction job; a zero value keeps its default.

func (SlackExtraction) ContextBudget

func (e SlackExtraction) ContextBudget() int

func (SlackExtraction) ContextN

func (e SlackExtraction) ContextN() int

func (SlackExtraction) EscalateOver

func (e SlackExtraction) EscalateOver() int

func (SlackExtraction) GiveUpAfter

func (e SlackExtraction) GiveUpAfter() int

func (SlackExtraction) LanguageName

func (e SlackExtraction) LanguageName() string

func (SlackExtraction) MaxCallUSD

func (e SlackExtraction) MaxCallUSD() float64

func (SlackExtraction) MaxDayCalls

func (e SlackExtraction) MaxDayCalls() int

func (SlackExtraction) MaxDayUSD

func (e SlackExtraction) MaxDayUSD() float64

func (SlackExtraction) MaxWaitFor

func (e SlackExtraction) MaxWaitFor() time.Duration

func (SlackExtraction) On

func (e SlackExtraction) On() bool

func (SlackExtraction) QuietFor

func (e SlackExtraction) QuietFor() time.Duration

func (SlackExtraction) TierName

func (e SlackExtraction) TierName() string

func (SlackExtraction) Window

func (e SlackExtraction) Window() int

type SlackIngest

type SlackIngest struct {
	// Terms admit a message that holds one of them as a word, in any case.
	Terms []string `json:"terms"`
	// AllowApps and DenyApps hold bot ids (B...) or app ids (A...).
	AllowApps []string `json:"allow_apps"`
	DenyApps  []string `json:"deny_apps"`
	// Socket nil is on.
	Socket *bool `json:"socket"`
	// Since is the first start's backfill date, YYYY-MM-DD; empty is 7 days back.
	Since string `json:"since"`
}

SlackIngest is what the Slack source admits and how it listens.

func (SlackIngest) SocketOn

func (i SlackIngest) SocketOn() bool

type SlackTurns

type SlackTurns struct {
	// MaxChars bounds the unit's messages rendered into the instructions; zero is 30000, and less than MinSlackTurnChars reads as it.
	MaxChars int `json:"max_chars,omitempty"`
}

SlackTurns sets what a turn on a Slack unit reads.

func (SlackTurns) Chars

func (t SlackTurns) Chars() int

type Stalled

type Stalled struct {
	Review Days `json:"review"`
	Reply  Days `json:"reply"`
	Merge  Days `json:"merge"`
}

type Sweep

type Sweep struct {
	Fast              Days    `json:"fast"`
	Slow              Days    `json:"slow"`
	RateLimitFraction float64 `json:"rate_limit_fraction"`
}

type UnknownKeysError

type UnknownKeysError struct {
	File string
	Keys []string // paths such as "sweep.fsat" or "projects[0].agent_hom"
}

UnknownKeysError names the keys of a config file that no setting reads.

func (*UnknownKeysError) Error

func (e *UnknownKeysError) Error() string

type WorkflowConfig

type WorkflowConfig struct {
	Mode     string          `json:"mode,omitempty"`
	Enabled  *bool           `json:"enabled,omitempty"`
	Approval *ApprovalConfig `json:"approval,omitempty"`
	// OnlyWhen is a predicate over the workflow's facts that must hold
	// besides its manifest's when; "" adds none.
	OnlyWhen string `json:"only_when,omitempty"`
}

Jump to

Keyboard shortcuts

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