config

package
v0.54.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var YamlOnlyKeys = map[string]bool{

	"no-db":             true,
	"no-daemon":         true,
	"no-auto-flush":     true,
	"no-auto-import":    true,
	"json":              true,
	"auto-start-daemon": true,

	"db":       true,
	"actor":    true,
	"identity": true,

	"flush-debounce":       true,
	"lock-timeout":         true,
	"remote-sync-interval": true,

	"git.author":      true,
	"git.no-gpg-sign": true,
	"no-push":         true,
	"no-git-ops":      true,

	"sync-branch": true,
	"sync.branch": true,
	"sync.require_confirmation_on_mass_delete": true,

	"daemon.auto_commit": true,
	"daemon.auto_push":   true,
	"daemon.auto_pull":   true,

	"routing.mode":        true,
	"routing.default":     true,
	"routing.maintainer":  true,
	"routing.contributor": true,

	"create.require-description": true,

	"validation.on-create": true,
	"validation.on-sync":   true,

	"devlog.enforce-on-commit": true,
	"devlog.dir":               true,
	"devlog.author":            true,
	"devlog.branch-tracking":   true,

	"last-seen-changelog-version": true,
	"last-remote-version-check":   true,

	"hierarchy.max-depth": true,
}

YamlOnlyKeys are configuration keys that must be stored in config.yaml rather than the SQLite database. These are "startup" settings that are read before the database is opened.

This fixes GH#536: users were confused when `bd config set no-db true` appeared to succeed but had no effect (because no-db is read from yaml at startup, not from SQLite).

Functions

func AddRepo

func AddRepo(configPath, repoPath string) error

AddRepo adds a repository to the repos.additional list in config.yaml If primary is not set, it defaults to "."

func AllSettings

func AllSettings() map[string]interface{}

AllSettings returns all configuration settings as a map

func FindConfigYAMLPath

func FindConfigYAMLPath() (string, error)

FindConfigYAMLPath finds the config.yaml file in .beads directory Walks up from CWD to find .beads/config.yaml

func GetBool

func GetBool(key string) bool

GetBool retrieves a boolean configuration value

func GetConfigFileUsed

func GetConfigFileUsed() string

GetConfigFileUsed returns the path to the config file used by viper. Returns empty string if no config file was found.

func GetDevlogDir

func GetDevlogDir() string

GetDevlogDir retrieves the devlog.dir configuration value

func GetDevlogEnforceOnCommit

func GetDevlogEnforceOnCommit() bool

GetDevlogEnforceOnCommit retrieves the devlog.enforce-on-commit configuration value

func GetDirectoryLabels

func GetDirectoryLabels() []string

GetDirectoryLabels returns labels for the current working directory based on config. It checks directory.labels config for matching patterns. Returns nil if no labels are configured for the current directory.

func GetDuration

func GetDuration(key string) time.Duration

GetDuration retrieves a duration configuration value

func GetExternalProjects

func GetExternalProjects() map[string]string

GetExternalProjects returns the external_projects configuration. Maps project names to paths for cross-project dependency resolution. Example config.yaml:

external_projects:
  beads: ../beads
  gastown: /absolute/path/to/gastown

func GetIdentity

func GetIdentity(flagValue string) string

GetIdentity resolves the user's identity for messaging. Priority chain:

  1. flagValue (if non-empty, from --identity flag)
  2. BEADS_IDENTITY env var / config.yaml identity field (via viper)
  3. git config user.name
  4. hostname

This is used as the sender field in bd mail commands.

func GetInt

func GetInt(key string) int

GetInt retrieves an integer configuration value

func GetString

func GetString(key string) string

GetString retrieves a string configuration value

func GetStringMapString

func GetStringMapString(key string) map[string]string

GetStringMapString retrieves a map[string]string configuration value

func GetStringSlice

func GetStringSlice(key string) []string

GetStringSlice retrieves a string slice configuration value

func GetYamlConfig

func GetYamlConfig(key string) string

GetYamlConfig gets a configuration value from config.yaml. Returns empty string if key is not found or is commented out. Keys are normalized to their canonical yaml format (e.g., sync.branch -> sync-branch).

func Initialize

func Initialize() error

Initialize sets up the viper configuration singleton Should be called once at application startup

func IsYamlOnlyKey

func IsYamlOnlyKey(key string) bool

IsYamlOnlyKey returns true if the given key should be stored in config.yaml rather than the SQLite database.

func LogOverride

func LogOverride(override ConfigOverride)

LogOverride logs a message about a configuration override in verbose mode.

func RemoveRepo

func RemoveRepo(configPath, repoPath string) error

RemoveRepo removes a repository from the repos.additional list in config.yaml

func ResolveExternalProjectPath

func ResolveExternalProjectPath(projectName string) string

ResolveExternalProjectPath resolves a project name to its absolute path. Returns empty string if project not configured or path doesn't exist.

func Set

func Set(key string, value interface{})

Set sets a configuration value

func SetReposInYAML

func SetReposInYAML(configPath string, repos *ReposConfig) error

SetReposInYAML writes the repos configuration to config.yaml It preserves other config sections and comments where possible

func SetYamlConfig

func SetYamlConfig(key, value string) error

SetYamlConfig sets a configuration value in the project's config.yaml file. It handles both adding new keys and updating existing (possibly commented) keys. Keys are normalized to their canonical yaml format (e.g., sync.branch -> sync-branch).

Types

type ConfigOverride

type ConfigOverride struct {
	Key            string
	EffectiveValue interface{}
	OverriddenBy   ConfigSource
	OriginalSource ConfigSource
	OriginalValue  interface{}
}

ConfigOverride represents a detected configuration override

func CheckOverrides

func CheckOverrides(flagOverrides map[string]struct {
	Value  interface{}
	WasSet bool
}) []ConfigOverride

CheckOverrides checks for configuration overrides and returns a list of detected overrides. This is useful for informing users when env vars or flags override config file values. flagOverrides is a map of key -> (flagValue, flagWasSet) for flags that were explicitly set.

type ConfigSource

type ConfigSource string

ConfigSource represents where a configuration value came from

const (
	SourceDefault    ConfigSource = "default"
	SourceConfigFile ConfigSource = "config_file"
	SourceEnvVar     ConfigSource = "env_var"
	SourceFlag       ConfigSource = "flag"
)

func GetValueSource

func GetValueSource(key string) ConfigSource

GetValueSource returns the source of a configuration value. Priority (highest to lowest): env var > config file > default Note: Flag overrides are handled separately in main.go since viper doesn't know about cobra flags.

type MultiRepoConfig

type MultiRepoConfig struct {
	Primary    string   // Primary repo path (where canonical issues live)
	Additional []string // Additional repos to hydrate from
}

MultiRepoConfig contains configuration for multi-repo support

func GetMultiRepoConfig

func GetMultiRepoConfig() *MultiRepoConfig

GetMultiRepoConfig retrieves multi-repo configuration Returns nil if multi-repo is not configured (single-repo mode)

type ReposConfig

type ReposConfig struct {
	Primary    string   `yaml:"primary,omitempty"`
	Additional []string `yaml:"additional,omitempty,flow"`
}

ReposConfig represents the repos section of config.yaml

func GetReposFromYAML

func GetReposFromYAML(configPath string) (*ReposConfig, error)

GetReposFromYAML reads the repos configuration from config.yaml Returns an empty ReposConfig if repos section doesn't exist

func ListRepos

func ListRepos(configPath string) (*ReposConfig, error)

ListRepos returns the current repos configuration from YAML

Jump to

Keyboard shortcuts

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