config

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package config handles loading and validating the config.yaml configuration.

Index

Constants

View Source
const DefaultSentryBaseURL = "https://sentry.io/api/0"

Variables

View Source
var ValidClaudeEffortLevels = []string{"", "low", "medium", "high", "max"}

ValidClaudeEffortLevels lists the accepted values for ClaudeCodeConfig.Effort. An empty string means "defer to Claude's own default."

View Source
var ValidClaudeThinkingLevels = []string{"", "adaptive", "enabled", "disabled"}

ValidClaudeThinkingLevels lists the accepted values for ClaudeCodeConfig.Thinking. An empty string means "defer to Claude's own default."

View Source
var ValidCodexReasoningEfforts = []string{"", "none", "minimal", "low", "medium", "high", "xhigh"}

ValidCodexReasoningEfforts lists the accepted values for CodexConfig.ReasoningEffort. An empty string means "defer to the Codex model's own default."

View Source
var ValidThinkingLevels = []string{"", "off", "minimal", "low", "medium", "high", "xhigh"}

ValidThinkingLevels lists the accepted values for OhMyPiConfig.ThinkingLevel. An empty string means "defer to the oh-my-pi agent's own default."

Functions

func ConfigPath

func ConfigPath() (string, error)

ConfigPath returns the path to the configuration file.

func GitHubAuthConfigured

func GitHubAuthConfigured(cfg GithubConfig) bool

func GitHubAuthSource

func GitHubAuthSource(cfg GithubConfig) string

func GitLabAuthConfigured

func GitLabAuthConfigured(cfg GitlabConfig) bool

GitLabAuthConfigured reports whether GitLab authentication is available. It mirrors GitHubAuthConfigured: a token in config, a keychain reference, or the glab CLI on PATH is sufficient.

func GitLabAuthSource

func GitLabAuthSource(cfg GitlabConfig) string

GitLabAuthSource returns a human-readable label describing the active GitLab auth source ("config token", "glab cli", or "unset").

func GlobalDBPath

func GlobalDBPath() (string, error)

GlobalDBPath returns the path to the global SQLite database.

func GlobalDir

func GlobalDir() (string, error)

GlobalDir returns the path to the global Substrate directory. It respects the SUBSTRATE_HOME environment variable if set. Tilde (~) is expanded and relative paths are resolved to absolute.

func HarnessCredentialFields

func HarnessCredentialFields() map[string][]string

func HarnessFieldAllowed

func HarnessFieldAllowed(harness, key string) bool

func HasGitHubCLI

func HasGitHubCLI() bool

func HasGlabCLI

func HasGlabCLI() bool

HasGlabCLI reports whether the glab binary is on PATH.

func HasSentryCLI

func HasSentryCLI() bool

func InferGlabBaseURL

func InferGlabBaseURL() string

InferGlabBaseURL attempts to detect the GitLab instance URL from the glab CLI by running "glab auth status" and extracting the first authenticated host. Returns "https://gitlab.com" if glab is absent, not authenticated, or the output cannot be parsed.

func ListSentryCLIOrganizations

func ListSentryCLIOrganizations(cfg SentryConfig) []string

ListSentryCLIOrganizations returns the slugs of all Sentry organizations accessible via the authenticated sentry CLI. Returns nil when the CLI is not available or the call fails.

func LoadSecrets

func LoadSecrets(cfg *Config, store SecretStore) error

func NormalizeProjects

func NormalizeProjects(projects []string) []string

func NormalizeSentryBaseURL

func NormalizeSentryBaseURL(raw string) string

func SaveSecrets

func SaveSecrets(cfg *Config, store SecretStore) error

func SecretKeys

func SecretKeys() map[string]string

func SentryAuthConfigured

func SentryAuthConfigured(cfg SentryConfig) bool

func SentryAuthSource

func SentryAuthSource(cfg SentryConfig) string

func SentryCLIEnvironment

func SentryCLIEnvironment(baseURL string) []string

func SentryRootURL

func SentryRootURL(raw string) string

func SessionsDir

func SessionsDir() (string, error)

SessionsDir returns the path to the sessions directory.

func ValidateClaudeEffort

func ValidateClaudeEffort(level string) error

ValidateClaudeEffort returns an error if level is not a recognised value.

func ValidateClaudeThinking

func ValidateClaudeThinking(level string) error

ValidateClaudeThinking returns an error if level is not a recognised value.

func ValidateCodexReasoningEffort

func ValidateCodexReasoningEffort(level string) error

ValidateCodexReasoningEffort returns an error if level is not a recognised value.

func ValidateThinkingLevel

func ValidateThinkingLevel(level string) error

ValidateThinkingLevel returns an error if level is not a recognised value.

Types

type AdaptersConfig

type AdaptersConfig struct {
	OhMyPi     OhMyPiConfig     `yaml:"ohmypi"`
	ClaudeCode ClaudeCodeConfig `yaml:"claude_code"`
	Codex      CodexConfig      `yaml:"codex"`
	OpenCode   OpenCodeConfig   `yaml:"opencode"`
	Linear     LinearConfig     `yaml:"linear"`
	Glab       GlabConfig       `yaml:"glab"`
	GitLab     GitlabConfig     `yaml:"gitlab"`
	GitHub     GithubConfig     `yaml:"github"`
	Sentry     SentryConfig     `yaml:"sentry"`
}

AdaptersConfig contains per-adapter configuration.

type ClaudeCodeConfig

type ClaudeCodeConfig struct {
	// BunPath is the path to the bun executable.
	// Defaults to "bun" resolved via PATH.
	BunPath string `yaml:"bun_path"`

	// BridgePath overrides the default bridge script location.
	// Defaults to bridge/claude-agent-bridge.ts next to the substrate binary.
	BridgePath string `yaml:"bridge_path"`

	// Model is the Claude model name. Empty means use Claude's own default.
	Model string `yaml:"model"`

	// Thinking controls extended thinking mode. Empty uses Claude's default.
	Thinking string `yaml:"thinking"`

	// Effort controls reasoning depth and token spend. Empty uses Claude's default.
	Effort string `yaml:"effort"`
}

ClaudeCodeConfig configures the claude-agent bridge harness.

type CodexConfig

type CodexConfig struct {
	BinaryPath string `yaml:"binary_path"`
	// Model is the OpenAI model name passed via -m flag (e.g. "o4", "o4-mini", "o3").
	// Empty uses Codex's own default.
	Model string `yaml:"model"`
	// ReasoningEffort controls model reasoning depth via -c model_reasoning_effort.
	// Empty defers to the model's own default.
	ReasoningEffort string `yaml:"reasoning_effort"`
}

CodexConfig configures the OpenAI Codex CLI harness.

type CommitConfig

type CommitConfig struct {
	Strategy        CommitStrategy      `yaml:"strategy"`
	MessageFormat   CommitMessageFormat `yaml:"message_format"`
	MessageTemplate string              `yaml:"message_template"`
}

CommitConfig controls agent commit behavior.

type CommitMessageFormat

type CommitMessageFormat string

CommitMessageFormat controls the format of commit messages.

const (
	CommitMessageAIGenerated  CommitMessageFormat = "ai-generated"
	CommitMessageConventional CommitMessageFormat = "conventional"
	CommitMessageCustom       CommitMessageFormat = "custom"
)

type CommitStrategy

type CommitStrategy string

CommitStrategy controls how often agents commit during a session.

const (
	CommitStrategyGranular    CommitStrategy = "granular"
	CommitStrategySemiRegular CommitStrategy = "semi-regular"
	CommitStrategySingle      CommitStrategy = "single"
)

type Config

type Config struct {
	Commit   CommitConfig          `yaml:"commit"`
	Plan     PlanConfig            `yaml:"plan"`
	Review   ReviewConfig          `yaml:"review"`
	Harness  HarnessConfig         `yaml:"harness"`
	Adapters AdaptersConfig        `yaml:"adapters"`
	Foreman  ForemanConfig         `yaml:"foreman"`
	Repos    map[string]RepoConfig `yaml:"repos"`
	UI       UIConfig              `yaml:"ui"`
}

Config is the top-level configuration loaded from config.yaml.

func Load

func Load(path string) (*Config, error)

Load reads and validates a config.yaml configuration file. Missing fields are filled with defaults before validation.

func (*Config) IssueCommentContentForSource

func (c *Config) IssueCommentContentForSource(source string) IssueCommentContent

IssueCommentContentForSource returns the IssueCommentContent configured for the given work-item source adapter ("github" or "gitlab"). Falls back to IssueCommentSubPlan for unknown sources.

type ForemanConfig

type ForemanConfig struct {
	QuestionTimeout string `yaml:"question_timeout"`
}

ForemanConfig controls the foreman question-answering system.

type GithubConfig

type GithubConfig struct {
	TokenRef            string              `yaml:"token_ref"` // optional keychain reference; gh auth token remains fallback
	Token               string              `yaml:"-"`
	BaseURL             string              `yaml:"base_url"`      // default: https://api.github.com
	Assignee            string              `yaml:"assignee"`      // username filter for Watch; "me" resolves via /user
	PollInterval        string              `yaml:"poll_interval"` // default: 5m
	Reviewers           []string            `yaml:"reviewers"`
	Labels              []string            `yaml:"labels"`
	StateMappings       map[string]string   `yaml:"state_mappings"`
	IssueCommentContent IssueCommentContent `yaml:"issue_comment_content"`
	PostMergeCloseIssue bool                `yaml:"post_merge_close_issue"`
}

type GitlabConfig

type GitlabConfig struct {
	TokenRef            string              `yaml:"token_ref"` // keychain reference for GitLab REST API
	Token               string              `yaml:"-"`
	BaseURL             string              `yaml:"base_url"`      // default: https://gitlab.com
	Assignee            string              `yaml:"assignee"`      // username filter for Watch
	PollInterval        string              `yaml:"poll_interval"` // default: 5m
	StateMappings       map[string]string   `yaml:"state_mappings"`
	IssueCommentContent IssueCommentContent `yaml:"issue_comment_content"`
}

type GlabConfig

type GlabConfig struct {
	// Reviewers is a list of GitLab usernames added as reviewers to created MRs.
	Reviewers []string `yaml:"reviewers"`
	// Labels is a list of GitLab label names added to created MRs.
	Labels []string `yaml:"labels"`
	// PostMergeCloseIssue closes the linked GitLab issue when all MRs for a work item are merged.
	PostMergeCloseIssue bool `yaml:"post_merge_close_issue"`
}

GlabConfig configures the glab CLI adapter. All fields are optional; the adapter is always registered regardless.

type HarnessConfig

type HarnessConfig struct {
	// The harness used for all agent phases.
	Default HarnessName `yaml:"default"`
}

type HarnessName

type HarnessName string
const (
	HarnessOhMyPi     HarnessName = "ohmypi"
	HarnessClaudeCode HarnessName = "claude-code"
	HarnessCodex      HarnessName = "codex"
	HarnessOpenCode   HarnessName = "opencode"
)

type IssueCommentContent

type IssueCommentContent string

IssueCommentContent controls what plan content is posted as a comment on linked issues at plan approval.

const (
	// IssueCommentNone disables issue comments on plan approval.
	IssueCommentNone IssueCommentContent = "none"
	// IssueCommentOrchestratorPlan posts only the top-level orchestration narrative.
	IssueCommentOrchestratorPlan IssueCommentContent = "orchestrator_plan"
	// IssueCommentSubPlan posts only the per-repository sub-plan content (default).
	IssueCommentSubPlan IssueCommentContent = "sub_plan"
	// IssueCommentOrchestratorAndSubPlan posts the orchestration narrative followed by all sub-plans.
	IssueCommentOrchestratorAndSubPlan IssueCommentContent = "orchestrator_and_sub_plan"
	// IssueCommentFullPlan posts the full plan document including the execution-groups fence block.
	IssueCommentFullPlan IssueCommentContent = "full_plan"
)

type LinearConfig

type LinearConfig struct {
	APIKeyRef      string            `yaml:"api_key_ref"`
	APIKey         string            `yaml:"-"` //nolint:gosec // credential field name, not a hardcoded value
	TeamID         string            `yaml:"team_id"`
	AssigneeFilter string            `yaml:"assignee_filter"` // "me" or explicit user ID
	PollInterval   string            `yaml:"poll_interval"`   // e.g. "5m"; default "5m"
	StateMappings  map[string]string `yaml:"state_mappings"`  // TrackerState -> Linear workflow state UUID
}

LinearConfig configures the Linear GraphQL adapter.

type OSKeychainStore

type OSKeychainStore struct{}

func (OSKeychainStore) Delete

func (OSKeychainStore) Delete(key string) error

func (OSKeychainStore) Get

func (OSKeychainStore) Get(key string) (string, error)

func (OSKeychainStore) Set

func (OSKeychainStore) Set(key, value string) error

type OhMyPiConfig

type OhMyPiConfig struct {
	BunPath    string `yaml:"bun_path"`
	BridgePath string `yaml:"bridge_path"`
	// ThinkingLevel controls reasoning depth for the oh-my-pi agent.
	// Empty defers to the agent's own configured default.
	ThinkingLevel string `yaml:"thinking_level"`
	// Model is the model pattern for new sessions (e.g. "anthropic/claude-sonnet-4-20250514").
	// Empty means use oh-my-pi's own default.
	Model string `yaml:"model"`
}

OhMyPiConfig configures the oh-my-pi agent harness.

type OpenCodeConfig

type OpenCodeConfig struct {
	// BinaryPath is the path to the opencode binary.
	// Defaults to "opencode" resolved via PATH.
	BinaryPath string `yaml:"binary_path"`

	// Port is the HTTP port for opencode serve.
	// 0 means let the server pick an available port.
	Port int `yaml:"port"`

	// Hostname is the bind address for opencode serve.
	// Defaults to "127.0.0.1".
	Hostname string `yaml:"hostname"`

	// Model is the provider/model identifier (e.g. "anthropic/claude-sonnet-4-20250514").
	// Empty means use opencode's own default.
	Model string `yaml:"model"`

	// Agent selects the opencode agent type: "build" (full-access) or "plan" (read-only).
	// Defaults to "build".
	Agent string `yaml:"agent"`

	// Variant selects the model variant (reasoning effort) for prompts.
	// Empty defers to the model's own default.
	// Valid values depend on the provider and model:
	//   Anthropic: high, max (adaptive models also: low, medium)
	//   OpenAI: none, minimal, low, medium, high, xhigh
	//   Google: low, high (2.5 models: high, max)
	// Unsupported values are silently ignored by opencode.
	Variant string `yaml:"variant"`
}

OpenCodeConfig configures the opencode server harness.

type PassThreshold

type PassThreshold string

PassThreshold controls how strict the review pipeline is.

const (
	PassThresholdNitOnly     PassThreshold = "nit_only"
	PassThresholdMinorOK     PassThreshold = "minor_ok"
	PassThresholdNoCritiques PassThreshold = "no_critiques"
)

type PlanConfig

type PlanConfig struct {
	MaxParseRetries *int `yaml:"max_parse_retries"`
}

PlanConfig controls the planning pipeline.

type RepoConfig

type RepoConfig struct {
	// DocPaths are documentation paths to include in planning context.
	DocPaths []string `yaml:"doc_paths"`
}

RepoConfig contains per-repo overrides.

type ResolvedSentryAuth

type ResolvedSentryAuth struct {
	Token        string
	BaseURL      string
	Organization string
	Projects     []string
	Source       string
	UseCLI       bool
}

func ResolveSentryAuth

func ResolveSentryAuth(_ context.Context, cfg SentryConfig) (ResolvedSentryAuth, error)

type ResolvedSentryContext

type ResolvedSentryContext struct {
	BaseURL      string
	Organization string
	Projects     []string
}

func ResolveSentryContext

func ResolveSentryContext(cfg SentryConfig) ResolvedSentryContext

type ReviewConfig

type ReviewConfig struct {
	PassThreshold    PassThreshold `yaml:"pass_threshold"`
	MaxCycles        *int          `yaml:"max_cycles"`
	Timeout          *string       `yaml:"timeout"`
	AutoFeedbackLoop *bool         `yaml:"auto_feedback_loop"`
}

ReviewConfig controls the review pipeline.

func (ReviewConfig) ReviewTimeout

func (r ReviewConfig) ReviewTimeout() time.Duration

ReviewTimeout returns the parsed review session timeout duration. Falls back to 1 hour if parsing fails.

type SecretStore

type SecretStore interface {
	Get(key string) (string, error)
	Set(key, value string) error
	Delete(key string) error
}

type SentryConfig

type SentryConfig struct {
	TokenRef        string   `yaml:"token_ref"`
	Token           string   `yaml:"-"`
	BaseURL         string   `yaml:"base_url"`
	BaseURLExplicit bool     `yaml:"-"`
	Organization    string   `yaml:"organization"`
	Projects        []string `yaml:"projects"`
	PollInterval    string   `yaml:"poll_interval"` // default: 5m
}

func (*SentryConfig) UnmarshalYAML

func (c *SentryConfig) UnmarshalYAML(value *yaml.Node) error

type UIConfig added in v0.0.35

type UIConfig struct {
	// DefaultFilter sets the initial filter mode for the sessions list.
	// Valid values: "all", "active", "attention", "completed".
	DefaultFilter string `yaml:"default_filter"`
	// DefaultGroup sets the initial grouping dimension for the sessions list.
	// Valid values: "none", "state", "source", "created", "activity".
	DefaultGroup string `yaml:"default_group"`
}

UIConfig controls TUI presentation defaults.

Jump to

Keyboard shortcuts

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