globalconfig

package
v0.198.21 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: BSD-2-Clause Imports: 8 Imported by: 1 module, 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 globalconfig loads and validates the user-level dark-factory configuration from ~/.config/dark-factory/config.yaml (XDG) with fallback to ~/.dark-factory/config.yaml (legacy).

Index

Constants

View Source
const DefaultMaxContainers = 3

DefaultMaxContainers is the system-wide container limit when no config is set.

View Source
const ModelPattern = `^[a-zA-Z0-9._:/[\]-]{1,256}$`

ModelPattern is the regex source string. Exported so callers can include it in error messages.

Square brackets are allowed for provider-side variant suffixes (e.g. `claude-sonnet-4-5[1m]` for the 1M context window variant, `deepseek-v4-flash[1m]`). They are NOT shell metacharacters in the docker-run context — model flows as a single argv element via `exec.Command(name, args...)`, never through `sh -c`, so the shell glob meaning never applies.

Variables

ModelRegex validates model identifiers at every config layer (global, project, CLI arg). Permits Anthropic IDs (claude-opus-4-7), variant suffixes (claude-sonnet-4-5[1m]), other-provider IDs (qwen3.6:35b-a3b, deepseek-v4-flash[1m]), namespaced paths (local/qwen3.6:35b-a3b), and Docker image refs (docker.io/bborbe/claude-yolo:v0.6.1). Blocks true shell metacharacters (`;`, `&`, `|`, `$`, backticks, quotes, etc.). EXPORTED so pkg/config and main.go reuse the SAME compiled regex — do not duplicate the pattern.

Functions

func FileExists added in v0.111.0

func FileExists(ctx context.Context) (bool, error)

FileExists reports whether the global config file exists. Callers use this only to distinguish "global file present" from "using built-in defaults" in diagnostic logs. - Config file missing → (false, nil) - Config dir lookup fails → (false, wrapped error) - Any other stat error → (false, wrapped error) - File present (any size) → (true, nil)

func FindConfigDir added in v0.191.0

func FindConfigDir(ctx context.Context, toolName string) (string, error)

FindConfigDir returns the absolute path to the configuration directory for the given tool name, following the XDG Base Directory Specification with legacy fallback.

Resolution order:

  • If ~/.config/<tool>/ exists (stat success) → returns ~/.config/<tool/>
  • If ~/.<tool>/ exists (stat success) → returns ~/.<tool>/ (legacy path)
  • Neither exists → returns ~/.config/<tool>/ (XDG default; not created)

Returns an error only if the home directory lookup fails. Stat failures on missing directories are swallowed (they trigger fallthrough, not error).

Types

type GlobalConfig

type GlobalConfig struct {
	MaxContainers       int               `yaml:"maxContainers"`
	HideGit             *bool             `yaml:"hideGit,omitempty"`
	AutoRelease         *bool             `yaml:"autoRelease,omitempty"`
	DirtyFileThreshold  *int              `yaml:"dirtyFileThreshold,omitempty"`
	Model               *string           `yaml:"model,omitempty"`
	AutoApprovePrompts  *bool             `yaml:"autoApprovePrompts,omitempty"`
	AutoGeneratePrompts *bool             `yaml:"autoGeneratePrompts,omitempty"`
	Backend             *string           `yaml:"backend,omitempty"`
	Env                 map[string]string `yaml:"env,omitempty"`
}

GlobalConfig holds the user-level dark-factory configuration. It is loaded from ~/.config/dark-factory/config.yaml (XDG) with fallback to ~/.dark-factory/config.yaml (legacy) once at daemon startup. When the file does not exist or the field is omitted, defaults apply.

func (GlobalConfig) Validate

func (g GlobalConfig) Validate(ctx context.Context) error

Validate validates the GlobalConfig fields.

type Loader

type Loader interface {
	Load(ctx context.Context) (GlobalConfig, error)
}

Loader loads the global dark-factory configuration.

func NewLoader

func NewLoader() Loader

NewLoader creates a Loader that reads from the XDG-first global config path (see FindConfigDir for the exact semantics).

Jump to

Keyboard shortcuts

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