Documentation
¶
Overview ¶
* Copyright © 2025 Carlos Mendez <carlos@hadaelectronics.com> | https://cjairm.me/
- Copyright © 2025 Carlos Mendez <carlos@hadaelectronics.com> | https://cjairm.me/
* Copyright © 2025 Carlos Mendez <carlos@hadaelectronics.com> | https://cjairm.me/
* Copyright © 2025 Carlos Mendez <carlos@hadaelectronics.com> | https://cjairm.me/
* Copyright © 2025 Carlos Mendez <carlos@hadaelectronics.com> | https://cjairm.me/
* Copyright © 2025 Carlos Mendez <carlos@hadaelectronics.com> | https://cjairm.me/
Copyright © 2025 Carlos Mendez <carlos@hadaelectronics.com> | https://cjairm.me/
Copyright © 2025 Carlos Mendez <carlos@hadaelectronics.com> | https://cjairm.me/
Copyright © 2025 Carlos Mendez <carlos@hadaelectronics.com> | https://cjairm.me/
* Copyright © 2025 Carlos Mendez <carlos@hadaelectronics.com> | https://cjairm.me/
- Copyright © 2025 Carlos Mendez <carlos@hadaelectronics.com> | https://cjairm.me/
* Copyright © 2025 Carlos Mendez <carlos@hadaelectronics.com> | https://cjairm.me/
* Copyright © 2025 Carlos Mendez <carlos@hadaelectronics.com> | https://cjairm.me/
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Version is set during build via ldflags Version = "dev" // Commit is set during build via ldflags Commit = "unknown" // BuildDate is set during build via ldflags BuildDate = "unknown" )
var Settings = []Setting{ { Key: "worktree.default_ai", Description: "Default AI coder for `dg ws` create when no --layout/--ai/default_layout applies", Kind: "string", Default: resolvedAIFallbackName, Get: func(gc *config.GlobalConfig) (string, bool) { return gc.Worktree.DefaultAI, gc.Worktree.DefaultAI != "" }, Set: func(gc *config.GlobalConfig, raw []string) error { value, err := requireExactlyOne("worktree.default_ai", raw) if err != nil { return err } if _, err := worktree.ResolveAICoder(value); err != nil { return err } gc.Worktree.DefaultAI = value return nil }, Unset: func(gc *config.GlobalConfig) { gc.Worktree.DefaultAI = "" }, }, { Key: "worktree.search_paths", Description: "Directories to scan for git repos in the `dg ws` repo picker; empty disables scanning", Kind: "stringlist", Default: func() string { return "" }, Get: func(gc *config.GlobalConfig) (string, bool) { return strings.Join(gc.Worktree.SearchPaths, ", "), len(gc.Worktree.SearchPaths) > 0 }, Set: func(gc *config.GlobalConfig, raw []string) error { if len(raw) == 0 { return errors.New( "worktree.search_paths requires at least one path; " + "use `dg config unset worktree.search_paths` to clear it", ) } paths := make([]string, len(raw)) copy(paths, raw) gc.Worktree.SearchPaths = paths return nil }, Unset: func(gc *config.GlobalConfig) { gc.Worktree.SearchPaths = nil }, }, { Key: "worktree.scan_depth", Description: "Max directory depth for the `dg ws` repo scan; 0 (or unset) uses the default", Kind: "int", Default: func() string { return strconv.Itoa(worktree.DefaultScanDepth()) }, Get: func(gc *config.GlobalConfig) (string, bool) { return strconv.Itoa(gc.Worktree.ScanDepth), gc.Worktree.ScanDepth != 0 }, Set: func(gc *config.GlobalConfig, raw []string) error { value, err := requireExactlyOne("worktree.scan_depth", raw) if err != nil { return err } depth, err := strconv.Atoi(value) if err != nil { return fmt.Errorf("worktree.scan_depth must be an integer, got %q: %w", value, err) } if depth < 0 { return fmt.Errorf("worktree.scan_depth must be non-negative, got %d", depth) } gc.Worktree.ScanDepth = depth return nil }, Unset: func(gc *config.GlobalConfig) { gc.Worktree.ScanDepth = 0 }, }, { Key: "worktree.default_layout", Description: "Default tmux window layout for `dg ws` create when no --layout/--ai applies", Kind: "string", Default: resolvedAIFallbackName, Get: func(gc *config.GlobalConfig) (string, bool) { return gc.Worktree.DefaultLayout, gc.Worktree.DefaultLayout != "" }, Set: func(gc *config.GlobalConfig, raw []string) error { value, err := requireExactlyOne("worktree.default_layout", raw) if err != nil { return err } if _, err := worktree.ResolveLayout(value, "", gc); err != nil { return err } gc.Worktree.DefaultLayout = value return nil }, Unset: func(gc *config.GlobalConfig) { gc.Worktree.DefaultLayout = "" }, Effective: func(gc *config.GlobalConfig) string { layout, err := worktree.ResolveLayout("", "", gc) if err != nil { return resolvedAIFallbackName() } return layout.Name }, }, { Key: "worktree.attach_after_create", Description: "Whether `dg ws` create's n/N attaches into the new window (true) or stays in the dashboard (false)", Kind: "bool", Default: func() string { return strconv.FormatBool((*config.GlobalConfig)(nil).ShouldAttachAfterCreate()) }, Get: func(gc *config.GlobalConfig) (string, bool) { if gc.Worktree.AttachAfterCreate == nil { return "", false } return strconv.FormatBool(*gc.Worktree.AttachAfterCreate), true }, Set: func(gc *config.GlobalConfig, raw []string) error { value, err := requireExactlyOne("worktree.attach_after_create", raw) if err != nil { return err } parsed, err := strconv.ParseBool(value) if err != nil { return fmt.Errorf( "worktree.attach_after_create must be a boolean (true/false), got %q: %w", value, err, ) } gc.Worktree.AttachAfterCreate = &parsed return nil }, Unset: func(gc *config.GlobalConfig) { gc.Worktree.AttachAfterCreate = nil }, }, { Key: "worktree.notify_sound", Description: "Whether an agent pane finishing/blocking/erroring plays a sound while its window is unattended (ADR-0009)", Kind: "bool", Default: func() string { return strconv.FormatBool(false) }, Get: func(gc *config.GlobalConfig) (string, bool) { return strconv.FormatBool(gc.Worktree.NotifySound), gc.Worktree.NotifySound }, Set: func(gc *config.GlobalConfig, raw []string) error { value, err := requireExactlyOne("worktree.notify_sound", raw) if err != nil { return err } parsed, err := strconv.ParseBool(value) if err != nil { return fmt.Errorf( "worktree.notify_sound must be a boolean (true/false), got %q: %w", value, err, ) } gc.Worktree.NotifySound = parsed return nil }, Unset: func(gc *config.GlobalConfig) { gc.Worktree.NotifySound = false }, }, { Key: "worktree.location", Description: "Where worktrees are created, and looked for by remove/repair/state checks: " + "`shared` (default) or `in-repo`", Kind: "string", Default: func() string { return config.WorktreeLocationShared }, Get: func(gc *config.GlobalConfig) (string, bool) { return gc.Worktree.Location, gc.Worktree.Location != "" }, Set: func(gc *config.GlobalConfig, raw []string) error { value, err := requireExactlyOne("worktree.location", raw) if err != nil { return err } switch value { case config.WorktreeLocationShared, config.WorktreeLocationInRepo: gc.Worktree.Location = value return nil default: return fmt.Errorf( "unknown worktree.location %q. Valid values: %s, %s", value, config.WorktreeLocationShared, config.WorktreeLocationInRepo, ) } }, Unset: func(gc *config.GlobalConfig) { gc.Worktree.Location = "" }, }, }
Settings is the registry of every user-settable devgeta configuration key.
Functions ¶
Types ¶
type Setting ¶ added in v1.6.0
type Setting struct {
Key string // dotted path, e.g. "worktree.attach_after_create"
Description string
Kind string // "bool" | "int" | "string" | "stringlist"
// Default returns the live default by calling whatever owns it, so the
// registry cannot drift from the runtime behavior it describes. It must
// never restate a default as a literal.
Default func() string
// Get reads the setting's current value off gc. isSet is false when
// nothing has been configured (the zero value) - callers should show
// Default() in that case rather than value, which is meaningless then.
Get func(gc *config.GlobalConfig) (value string, isSet bool)
// Set parses and validates raw, then assigns it on gc. Validation
// delegates to the same resolver the rest of devgeta uses for this
// value, so an invalid value produces the identical error a user would
// hit elsewhere (e.g. `dg wt create --ai <bad-alias>`).
Set func(gc *config.GlobalConfig, raw []string) error
// Unset clears the setting back to its zero value, letting Default()
// govern again.
Unset func(gc *config.GlobalConfig)
// Effective, when non-nil, resolves this setting's real effective value
// against the actual loaded gc when it's unset - for the one kind of
// setting whose "what applies when unset" answer depends on another live
// setting, not just this entry's own context-free Default() (e.g.
// worktree.default_layout falling back through worktree.default_ai before
// falling back to "opencode"). EffectiveDefault is the single place
// list/get/set/unset all read this through, so they can never disagree
// about it the way list's DEFAULT column once did with get/unset. Nil for
// every setting whose effective-when-unset value is simply Default().
Effective func(gc *config.GlobalConfig) string
}
Setting describes one user-settable devgeta configuration key: how to read its live default, read/write it on a loaded config, and validate a new value before assigning it.
func FindSetting ¶ added in v1.6.0
FindSetting looks up a registered setting by its dotted key.
func (*Setting) EffectiveDefault ¶ added in v1.6.0
func (s *Setting) EffectiveDefault(gc *config.GlobalConfig) string
EffectiveDefault returns what s resolves to when unset: s.Effective(gc) if the registry entry supplies cross-setting resolution, otherwise s's context-free Default(). This is the one code path `dg config list`'s DEFAULT column and get/set/unset's "value in effect when unset" logic both go through.