Documentation
¶
Overview ¶
Package config handles configuration loading and validation.
Index ¶
- Variables
- func ApplyArgOverrides(ctx context.Context, cfg *Config, sources *FieldSources, command string, ...) error
- func ApplyGlobalOverrides(cfg *Config, global globalconfig.GlobalConfig, proj LayeredProjectOverrides)
- func ApplyOneSetOverride(ctx context.Context, cfg *Config, sources *FieldSources, key, value string) error
- func ApplySetOverrides(ctx context.Context, cfg *Config, sources *FieldSources, command string, ...) error
- func MergeEnv(globalEnv, projectEnv map[string]string) map[string]string
- func ValidateModelArg(ctx context.Context, model string) error
- type Backend
- type Backends
- type BitbucketConfig
- type Config
- func (c Config) EffectiveHideGit() bool
- func (c Config) HealthcheckEnabledValue() bool
- func (c Config) ParsedHealthcheckInterval() time.Duration
- func (c Config) ParsedIdleLogInterval() time.Duration
- func (c Config) ParsedMaxPromptDuration() time.Duration
- func (c Config) ParsedPreflightInterval() time.Duration
- func (c Config) ParsedQueueInterval() time.Duration
- func (c Config) ParsedSweepInterval() time.Duration
- func (c Config) ResolvedBitbucketToken() string
- func (c Config) ResolvedClaudeDir() string
- func (c Config) ResolvedDiscordWebhook() string
- func (c Config) ResolvedGitHubToken() string
- func (c Config) ResolvedProjectOverride() string
- func (c Config) ResolvedTelegramBotToken() string
- func (c Config) ResolvedTelegramChatID() string
- func (c Config) Validate(ctx context.Context) error
- type DiscordConfig
- type ExtraMount
- type FieldSources
- type GitHubConfig
- type LayeredProjectOverrides
- type LoadResult
- type Loader
- type NotificationsConfig
- type PromptsConfig
- type Provider
- type Providers
- type SpecsConfig
- type TelegramConfig
- type Workflow
- type Workflows
Constants ¶
This section is empty.
Variables ¶
var AvailableBackends = Backends{BackendDocker, BackendLocal}
AvailableBackends contains the two valid backend values.
var AvailableProviders = Providers{ProviderGitHub, ProviderBitbucketServer}
AvailableProviders contains all valid provider values.
var AvailableWorkflows = Workflows{WorkflowDirect, WorkflowBranch, WorkflowWorktree, WorkflowClone}
AvailableWorkflows contains the four valid workflow values for new configs. WorkflowPR ("pr") is intentionally excluded — it is legacy and mapped at load time.
var SupportedSetKeys = []string{
"hideGit",
"autoRelease",
"dirtyFileThreshold",
"model",
"maxContainers",
"backend",
"workflow",
"pr",
"autoMerge",
"autoGeneratePrompts",
}
SupportedSetKeys is the authoritative list of yaml-backed user-pref keys accepted by --set. Adding a new yaml field requires a new entry here.
Functions ¶
func ApplyArgOverrides ¶ added in v0.184.0
func ApplyArgOverrides( ctx context.Context, cfg *Config, sources *FieldSources, command string, model string, ) error
ApplyArgOverrides validates command-gate rules and applies --model CLI flag override to cfg and sources. model is the extracted flag value from ParseArgs (empty = not set).
func ApplyGlobalOverrides ¶ added in v0.184.0
func ApplyGlobalOverrides( cfg *Config, global globalconfig.GlobalConfig, proj LayeredProjectOverrides, )
ApplyGlobalOverrides applies global config values for the layered user-pref fields into cfg, but only where the project config did not explicitly set the field. Fields the project explicitly set (non-nil pointer in proj) are left untouched.
func ApplyOneSetOverride ¶ added in v0.184.0
func ApplyOneSetOverride( ctx context.Context, cfg *Config, sources *FieldSources, key, value string, ) error
applyOneSetOverride applies a single --set key=value entry with type coercion and validation.
func ApplySetOverrides ¶ added in v0.184.0
func ApplySetOverrides( ctx context.Context, cfg *Config, sources *FieldSources, command string, setOverrides map[string]string, ) error
ApplySetOverrides validates command-gate rules and applies --set key=value overrides to cfg and sources. Valid only for "run" and "daemon" commands.
Types ¶
type Backend ¶ added in v0.192.0
type Backend string
Backend selects how LLM steps (prompt execution and generation) are launched.
type Backends ¶ added in v0.192.0
type Backends []Backend
Backends is a collection of Backend values.
type BitbucketConfig ¶ added in v0.45.0
BitbucketConfig holds Bitbucket Server-specific configuration.
type Config ¶
type Config struct {
ProjectName string `yaml:"projectName"`
Project *string `yaml:"project,omitempty"`
Workflow Workflow `yaml:"workflow"`
PR bool `yaml:"pr,omitempty"`
Worktree bool `yaml:"worktree,omitempty"`
HideGit bool `yaml:"hideGit,omitempty"`
DefaultBranch string `yaml:"defaultBranch"`
Prompts PromptsConfig `yaml:"prompts"`
Specs SpecsConfig `yaml:"specs"`
ContainerImage string `yaml:"containerImage"`
NetrcFile string `yaml:"netrcFile"`
GitconfigFile string `yaml:"gitconfigFile"`
Model string `yaml:"model"`
ValidationCommand string `yaml:"validationCommand"`
ValidationPrompt string `yaml:"validationPrompt"`
TestCommand string `yaml:"testCommand"`
DebounceMs int `yaml:"debounceMs"`
ServerPort int `yaml:"serverPort"`
AutoMerge bool `yaml:"autoMerge"`
AutoRelease bool `yaml:"autoRelease"`
VerificationGate bool `yaml:"verificationGate"`
GitHub GitHubConfig `yaml:"github"`
Provider Provider `yaml:"provider"`
Bitbucket BitbucketConfig `yaml:"bitbucket"`
Notifications NotificationsConfig `yaml:"notifications"`
Env map[string]string `yaml:"env,omitempty"`
ExtraMounts []ExtraMount `yaml:"extraMounts,omitempty"`
ClaudeDir string `yaml:"claudeDir"`
GenerateCommand string `yaml:"generateCommand"`
AdditionalInstructions string `yaml:"additionalInstructions,omitempty"`
MaxContainers int `yaml:"maxContainers,omitempty"`
DirtyFileThreshold int `yaml:"dirtyFileThreshold,omitempty"`
AutoApprovePrompts bool `yaml:"autoApprovePrompts,omitempty"`
AutoGeneratePrompts bool `yaml:"autoGeneratePrompts,omitempty"`
MaxPromptDuration string `yaml:"maxPromptDuration"`
AutoRetryLimit int `yaml:"autoRetryLimit"`
PreflightCommand string `yaml:"preflightCommand"`
PreflightInterval string `yaml:"preflightInterval"`
HealthcheckEnabled *bool `yaml:"healthcheckEnabled,omitempty"`
HealthcheckInterval string `yaml:"healthcheckInterval"`
QueueInterval string `yaml:"queueInterval"`
SweepInterval string `yaml:"sweepInterval"`
IdleLogInterval string `yaml:"idleLogInterval"`
Backend Backend `yaml:"backend,omitempty"`
}
Config holds the dark-factory configuration.
func (Config) EffectiveHideGit ¶ added in v0.187.7
EffectiveHideGit reports whether the container should hide the project's `.git` directory. The container can't follow a worktree's `.git` pointer file, so worktree workflows ALWAYS hide git; explicit HideGit also hides it regardless of workflow.
Use this method at every site that builds a launchpolicy.Policy or passes a hideGit flag downstream — never inline `cfg.Workflow == config.WorkflowWorktree || cfg.HideGit`. The `scripts/hotpath-hidegit-check.sh` gate (run by `make precommit`) rejects the inline formula in pkg/ to prevent the regression class that caused the 2026-06-26 silent minimax healthcheck failure (helper existed, was applied at 1 of 3 sites; the inline copies drifted silently).
func (Config) HealthcheckEnabledValue ¶ added in v0.181.0
HealthcheckEnabledValue reports whether the healthcheck startup gate is enabled. nil HealthcheckEnabled means enabled (the default); only an explicit false disables it.
func (Config) ParsedHealthcheckInterval ¶ added in v0.181.0
ParsedHealthcheckInterval returns the parsed duration from HealthcheckInterval. Returns 0 when HealthcheckInterval is empty (disables interval-based caching). Safe to call at any time — returns 0 on error, never panics.
func (Config) ParsedIdleLogInterval ¶ added in v0.150.5
ParsedIdleLogInterval returns the parsed duration from IdleLogInterval. Returns time.Minute when IdleLogInterval is empty or unparseable (preserves default behaviour). Returns 0 when IdleLogInterval is "0" (heartbeat disabled). Safe to call at any time — never panics.
func (Config) ParsedMaxPromptDuration ¶ added in v0.98.0
ParsedMaxPromptDuration returns the parsed duration from MaxPromptDuration. Returns 0 when MaxPromptDuration is empty or unparseable (disables timeout). Safe to call at any time — returns 0 on error, never panics.
func (Config) ParsedPreflightInterval ¶ added in v0.126.0
ParsedPreflightInterval returns the parsed duration from PreflightInterval. Returns 0 when PreflightInterval is empty (disables interval-based caching). Safe to call at any time — returns 0 on error, never panics.
func (Config) ParsedQueueInterval ¶ added in v0.135.4
ParsedQueueInterval returns the parsed duration from QueueInterval. Returns 5 * time.Second when QueueInterval is empty or unparseable (preserves default behaviour). Safe to call at any time — never panics.
func (Config) ParsedSweepInterval ¶ added in v0.135.4
ParsedSweepInterval returns the parsed duration from SweepInterval. Returns 60 * time.Second when SweepInterval is empty or unparseable (preserves default behaviour). Safe to call at any time — never panics.
func (Config) ResolvedBitbucketToken ¶ added in v0.45.0
ResolvedBitbucketToken reads the Bitbucket token from the env var named in TokenEnv. Returns empty string when not configured or env var is empty. Uses os.Getenv directly (not resolveEnvVar) because tokenEnv holds the env var name (e.g. "BITBUCKET_TOKEN"), not a ${VAR} reference that resolveEnvVar expects.
func (Config) ResolvedClaudeDir ¶ added in v0.71.0
ResolvedClaudeDir returns the claude-yolo config directory with ~ expanded.
func (Config) ResolvedDiscordWebhook ¶ added in v0.47.0
ResolvedDiscordWebhook reads the Discord webhook URL from the env var named in WebhookEnv. Returns empty string when not configured or env var is empty.
func (Config) ResolvedGitHubToken ¶ added in v0.15.0
ResolvedGitHubToken returns the GitHub token with environment variables resolved. Returns empty string when not configured, letting gh use its own auth.
func (Config) ResolvedProjectOverride ¶ added in v0.159.0
ResolvedProjectOverride returns the effective project name override string for project.Resolve(). The explicit `project:` field takes precedence over the legacy `projectName:` field. Returns an empty string when neither is set; project.Resolve() handles the git-root fallback.
func (Config) ResolvedTelegramBotToken ¶ added in v0.47.0
ResolvedTelegramBotToken reads the Telegram bot token from the env var named in BotTokenEnv. Returns empty string when not configured or env var is empty.
func (Config) ResolvedTelegramChatID ¶ added in v0.47.0
ResolvedTelegramChatID reads the Telegram chat ID from the env var named in ChatIDEnv. Returns empty string when not configured or env var is empty.
type DiscordConfig ¶ added in v0.47.0
type DiscordConfig struct {
WebhookEnv string `yaml:"webhookEnv"`
}
DiscordConfig holds Discord notification configuration.
type ExtraMount ¶ added in v0.87.0
type ExtraMount struct {
Src string `yaml:"src"`
Dst string `yaml:"dst"`
ReadOnly *bool `yaml:"readOnly,omitempty"` // nil defaults to false (read-write)
}
ExtraMount describes an additional volume mount to inject into the YOLO container.
func (ExtraMount) IsReadonly ¶ added in v0.87.0
func (m ExtraMount) IsReadonly() bool
IsReadonly returns true if the mount is read-only (default when ReadOnly is nil is false = read-write).
type FieldSources ¶ added in v0.140.0
type FieldSources struct {
HideGit string
AutoRelease string
DirtyFileThreshold string
Model string
MaxContainers string
Workflow string
PR string
AutoMerge string
AutoApprovePrompts string
AutoGeneratePrompts string
HealthcheckEnabled string
HealthcheckInterval string
Backend string
}
FieldSources records which config layer provided each of the layered user-pref fields. Valid values for each field are: "default", "global", "project", "arg". Zero value (empty string) is treated the same as "default" by callers.
func ComputeFieldSources ¶ added in v0.184.0
func ComputeFieldSources( global globalconfig.GlobalConfig, proj LayeredProjectOverrides, ) FieldSources
ComputeFieldSources determines which config layer provided each of the layered user-pref fields. Rules: global wins over default; project wins over global. "arg" source is not set here — it is set via ApplyArgOverrides / ApplySetOverrides when CLI flags override.
type GitHubConfig ¶ added in v0.15.0
type GitHubConfig struct {
Token string `yaml:"token"`
}
GitHubConfig holds GitHub-specific configuration.
type LayeredProjectOverrides ¶ added in v0.140.0
type LayeredProjectOverrides struct {
HideGit *bool
AutoRelease *bool
DirtyFileThreshold *int
Model *string
MaxContainers *int // included for completeness; maxContainers uses its own precedence path
Workflow *Workflow // non-nil when .dark-factory.yaml explicitly sets workflow
PR *bool // non-nil when .dark-factory.yaml explicitly sets pr
AutoMerge *bool // non-nil when .dark-factory.yaml explicitly sets autoMerge
AutoApprovePrompts *bool // non-nil when .dark-factory.yaml explicitly sets autoApprovePrompts
AutoGeneratePrompts *bool // non-nil when .dark-factory.yaml explicitly sets autoGeneratePrompts
HealthcheckEnabled *bool // non-nil when .dark-factory.yaml explicitly sets healthcheckEnabled
HealthcheckInterval *string // non-nil when .dark-factory.yaml explicitly sets healthcheckInterval
Backend *Backend // non-nil when .dark-factory.yaml explicitly sets backend
}
LayeredProjectOverrides reports which of the 4 layered user-pref fields were explicitly set in .dark-factory.yaml. nil means the field was absent from the file (so the default or global value applies). Non-nil means project explicitly set it.
type LoadResult ¶ added in v0.140.0
type LoadResult struct {
Config Config
Overrides LayeredProjectOverrides
}
LoadResult bundles the merged project config with information about which of the 4 layered user-pref fields the project explicitly set.
func LoadWithOverrides ¶ added in v0.140.0
func LoadWithOverrides(ctx context.Context) (LoadResult, error)
LoadWithOverrides reads .dark-factory.yaml, merges with defaults, validates, and returns the merged config plus project override detection data. Use this when global-config layering is needed (e.g. in main.run()). Existing callers that use NewLoader().Load() are unaffected.
type NotificationsConfig ¶ added in v0.47.0
type NotificationsConfig struct {
Telegram TelegramConfig `yaml:"telegram"`
Discord DiscordConfig `yaml:"discord"`
}
NotificationsConfig holds notification channel configuration.
type PromptsConfig ¶ added in v0.20.3
type PromptsConfig struct {
InboxDir string `yaml:"inboxDir"`
InProgressDir string `yaml:"inProgressDir"`
CompletedDir string `yaml:"completedDir"`
RejectedDir string `yaml:"rejectedDir"`
CancelledDir string `yaml:"cancelledDir"`
LogDir string `yaml:"logDir"`
}
PromptsConfig holds directories for the prompt lifecycle.
type Provider ¶ added in v0.45.0
type Provider string
Provider is a string-based enum for git provider types.
Provider selects the git hosting provider for PR operations.
type Providers ¶ added in v0.45.0
type Providers []Provider
Providers is a collection of Provider values.
type SpecsConfig ¶ added in v0.20.3
type SpecsConfig struct {
InboxDir string `yaml:"inboxDir"`
InProgressDir string `yaml:"inProgressDir"`
CompletedDir string `yaml:"completedDir"`
RejectedDir string `yaml:"rejectedDir"`
LogDir string `yaml:"logDir"`
}
SpecsConfig holds directories for the spec lifecycle.
type TelegramConfig ¶ added in v0.47.0
type TelegramConfig struct {
BotTokenEnv string `yaml:"botTokenEnv"`
ChatIDEnv string `yaml:"chatIDEnv"`
}
TelegramConfig holds Telegram notification configuration.
type Workflow ¶
type Workflow string
Workflow is a string-based enum for workflow types.
const ( WorkflowDirect Workflow = "direct" WorkflowBranch Workflow = "branch" WorkflowWorktree Workflow = "worktree" WorkflowClone Workflow = "clone" // WorkflowPR is the legacy enum value kept for parsing only. // The loader maps it to WorkflowClone + pr: true before validation. // Do not use this constant in new code. WorkflowPR Workflow = "pr" )
Workflow defines how prompts are processed.