config

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config resolves SpecScore configuration from layered sources.

Configuration is read from three layers, in decreasing specificity:

specscore.local.yaml  (repo root, uncommitted)  -- most specific
specscore.yaml        (repo root, committed)
~/.specscore.yaml     (user home)               -- least specific

The most specific layer wins per key; mapping nodes are deep-merged, while scalars and sequences are replaced wholesale. An explicit null in a more specific layer clears a value set by a less specific one.

Index

Constants

View Source
const (
	ProjectFile = "specscore.yaml"
	LocalFile   = "specscore.local.yaml"
	HomeFile    = ".specscore.yaml"
)

Layer file names.

Variables

View Source
var UserScopedKeys = []string{
	"recaps.repo",
	"recaps.user",
	"journal.repo",
	"journal.stream",
}

UserScopedKeys are dotted config keys that carry per-user or per-machine values (filesystem paths, identities). They MUST NOT appear in the committed project file (specscore.yaml); they are accepted only from specscore.local.yaml or ~/.specscore.yaml. Owning Features register their keys here.

Functions

func EnsureLocalGitignored

func EnsureLocalGitignored(repoRoot string) (added bool, warning string, err error)

EnsureLocalGitignored makes sure specscore.local.yaml is git-ignored in repoRoot, appending it to .gitignore when absent. It returns whether the entry was added and a non-empty warning when the file is already git-tracked (which defeats its per-user purpose).

func EnsureLocalGitignoredMsg

func EnsureLocalGitignoredMsg(repoRoot string) string

EnsureLocalGitignoredMsg ensures the ignore entry and returns a single advisory message for callers to surface (empty when there is nothing to report). It never returns an error — a failure is folded into the message — so callers need only check for a non-empty string.

Types

type CommittedScopeViolation

type CommittedScopeViolation struct {
	Key string
}

CommittedScopeViolation reports a user-scoped key found in the committed project file where it is not allowed.

func CheckCommittedScope

func CheckCommittedScope(repoRoot string) ([]CommittedScopeViolation, error)

CheckCommittedScope reads the committed project layer (specscore.yaml) at repoRoot and returns a violation for each user-scoped key present in it. The local and home layers are not inspected — user-scoped keys are allowed there. A missing project file yields no violations; a malformed one errors.

type Resolved

type Resolved struct {
	// Values is the deep-merged configuration tree.
	Values map[string]any
	// Origin maps a dotted leaf key path to the layer it resolved from:
	// one of "local", "project", or "home".
	Origin map[string]string
}

Resolved is the merged configuration plus the per-key source layer.

func ResolveDir

func ResolveDir(repoRoot, homeDir string) (Resolved, error)

ResolveDir resolves layered config for a repo root and a home directory. Missing layer files are treated as empty layers (not errors); a malformed layer file is a hard error.

Jump to

Keyboard shortcuts

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