Documentation
¶
Overview ¶
Package config resolves baum settings from flags, the environment, the XDG config file and defaults, in that order of precedence.
Local review commands contact no baum server and send no telemetry; the file holds the backend choice, optional tokens and generation budgets, nothing else.
Index ¶
- Constants
- Variables
- func CapNames() []string
- func DeviceOrganizations(ctx context.Context, c Config, refresh bool) (githubauth.OrganizationAccess, error)
- func ParseEffort(s string) (*string, error)
- func Path() (string, error)
- func Save(path string, cfg Config) error
- func ValidEffort(effort string) bool
- func ValidateAgentEnv(env map[string]string) error
- type Backend
- type Budgets
- type Config
- func (c Config) AgentEnviron() []string
- func (c Config) EffectiveCaps() (map[string]int, error)
- func (c Config) ExplicitGitHubTokenSource(host string) (string, string)
- func (c Config) ResolveGitHubToken(ctx context.Context, host string) (string, error)
- func (c Config) ResolveGitHubTokenSource(ctx context.Context, host string) (string, string, error)
- type Duration
- type Overrides
Constants ¶
const ( EnvGitHubToken = "GITHUB_TOKEN" EnvGHToken = "GH_TOKEN" EnvAnthropicAPIKey = "ANTHROPIC_API_KEY" EnvBackend = "BAUM_BACKEND" EnvModel = "BAUM_MODEL" )
Environment variables read by Load.
const ( DefaultReviewTimeout = 10 * time.Minute DefaultRunTimeout = 30 * time.Minute )
Default time limits (Budgets).
const GitHubHost = "github.com"
GitHubHost is github.com, the host GITHUB_TOKEN, GH_TOKEN and github_token belong to.
const MaxAgentEnv = 32
MaxAgentEnv bounds how many variables AgentEnv may set.
const SourceBaum = "baum credential store"
const SourceConfigFile = "config file"
SourceConfigFile is the GitHubTokenSource of github_token in the config file.
Variables ¶
var Backends = []Backend{BackendAuto, BackendAnthropic, BackendClaude, BackendCodex, BackendCursorAgent}
Backends lists every accepted backend name, Auto first.
var CapDefaults = map[string]int{
"max_sessions": 12,
"max_prompts_per_session": 2,
"max_command_events_per_session": 20,
"max_comments": 40,
"max_hunk_patch_lines": 200,
"max_bytes": 262144,
"max_diff_files": 3000,
"max_diff_patch_bytes": 100 << 20,
"max_diff_index_bytes": 512 << 10,
"max_images": 20,
"max_image_bytes": 10 << 20,
"max_image_alt_bytes": 512,
"checkout_max_file_bytes": 1 << 20,
"checkout_max_total_bytes": 200 << 20,
"checkout_max_total_files": 20000,
}
CapDefaults are the generation bundle caps by name, which the [caps] table of the config file overrides. The values are the hosted service's defaults, so the same pull request is trimmed the same way in both places. Byte caps are bytes; the rest are counts or line counts.
var Efforts = []string{"low", "medium", "high", "xhigh", "max", "ultra"}
Efforts are the reasoning efforts the app offers, passed to Claude Code as --effort, to Codex as model_reasoning_effort and to the Anthropic API as output_config.effort; cursor-agent has none.
var ErrNoGitHubToken = errors.New("no GitHub token")
var GitHubAuth = githubauth.New(githubauth.ProcessStore{})
GitHubAuth is shared by every token consumer and the local authentication API.
var PathBackends = []Backend{BackendClaude, BackendCodex, BackendCursorAgent}
PathBackends are the backends whose executable BackendPaths can name.
Functions ¶
func DeviceOrganizations ¶ added in v0.2.0
func DeviceOrganizations(ctx context.Context, c Config, refresh bool) (githubauth.OrganizationAccess, error)
DeviceOrganizations names the organizations the saved device sign-in cannot reach (githubauth.Manager.Organizations). An explicit token is not asked: a fine-grained one lists no organizations at all, which would read as every membership being hidden.
func ParseEffort ¶
ParseEffort reads a chosen effort case-insensitively: nil for an empty one, which is the harness's own and no choice.
func Path ¶
Path returns the config file location: $XDG_CONFIG_HOME/baum/config.toml, defaulting to ~/.config/baum/config.toml.
func Save ¶
Save writes cfg to path, creating the directory 0700 and the file 0600 so a stored token is readable by the user only.
func ValidEffort ¶
ValidEffort reports whether effort is empty (the harness's own) or one of Efforts.
func ValidateAgentEnv ¶
ValidateAgentEnv rejects a name that is not a portable variable name, a value with a NUL byte or longer than 4 KiB, and more than MaxAgentEnv variables.
Types ¶
type Backend ¶
type Backend string
Backend names a model backend. Auto picks one at run time: claude, then codex, each when installed and passing its checks, then, in the command line only, anthropic when ANTHROPIC_API_KEY is set. cursor-agent runs only when named. The desktop app and its daemon run auto, claude and codex only (Backend.Desktop).
func ParseBackend ¶
ParseBackend accepts a backend name case-insensitively.
type Budgets ¶
type Budgets struct {
PassTimeout Duration `toml:"pass_timeout"`
ReviewTimeout Duration `toml:"review_timeout"`
RunTimeout Duration `toml:"run_timeout"`
MaxCalls int `toml:"max_calls,omitempty"`
MaxTokens int `toml:"max_tokens,omitempty"`
}
Budgets bound agent runs. Exceeding one fails the run naming it. ReviewTimeout is a review's time limit and RunTimeout that of every other agent run (a fix, a question to a review's agent, a feature build); PassTimeout bounds each model call. MaxCalls and MaxTokens bound each run when set; zero, the default, is no limit, so only the time limit ends a run.
type Config ¶
type Config struct {
Backend Backend `toml:"backend"`
Model string `toml:"model,omitempty"`
// Effort is the reasoning effort the app chose (Efforts); empty leaves
// it to the harness. It is never read from or written to the file.
Effort string `toml:"-"`
GitHubToken string `toml:"github_token,omitempty"`
// GitHubTokenSource names where GitHubToken came from: GITHUB_TOKEN,
// GH_TOKEN or the config file. It is empty when there is no token and is
// never written to the file.
GitHubTokenSource string `toml:"-"`
// AnthropicAPIKey comes from the environment only and is never written to
// the file.
AnthropicAPIKey string `toml:"-"`
Budgets Budgets `toml:"budgets"`
// Caps override the generation bundle caps by name; unnamed caps keep their
// defaults. Names are defined by the bundle assembler.
Caps map[string]int `toml:"caps,omitempty"`
// BackendPaths names the executable of a backend by absolute path. A named
// path is used instead of a PATH lookup, never in addition to one, so apps
// started without the shell's PATH still find their backends. Only claude,
// codex and cursor-agent are accepted; per-repository settings do not
// override it.
BackendPaths map[Backend]string `toml:"backend_paths,omitempty"`
// AgentEnv are variables set for every agent baum runs on this computer
// and for the git commands that commit and push a fix, over the inherited
// environment: for example GIT_CONFIG_GLOBAL, to sign an agent's commits
// with another key. The app's own choice replaces it (repos.Preferences).
AgentEnv map[string]string `toml:"agent_env,omitempty"`
}
Config is the resolved configuration. Its TOML form is the on-disk file.
func Load ¶
Load resolves the configuration with the precedence flags, environment, file, defaults. A missing file is not an error.
func ReadFile ¶
ReadFile parses the config file at path over the defaults. ok is false when the file does not exist.
func (Config) AgentEnviron ¶
AgentEnviron is AgentEnv as "NAME=value" entries sorted by name, each value with a leading ~ and $NAME or ${NAME} expanded from this process's environment, as a shell would.
func (Config) EffectiveCaps ¶
EffectiveCaps returns every cap: the defaults with the configured overrides applied. An unknown name or a negative value is an error, so a misspelt override is not silently ignored.
func (Config) ExplicitGitHubTokenSource ¶
ExplicitGitHubTokenSource resolves overrides without opening the keyring. Enterprise credentials apply only to the explicitly selected GH_HOST.
func (Config) ResolveGitHubToken ¶
type Duration ¶
Duration is a time.Duration written in TOML as a string such as "10m".
func (Duration) MarshalText ¶
MarshalText renders d with time.Duration's String.
func (*Duration) UnmarshalText ¶
UnmarshalText parses d with time.ParseDuration.