config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Version is the schema version of this .layerx.yaml. Currently only 1
	// is accepted. Unset (zero) is treated as 1. Future schema breakage
	// will rev this — readers that see a version they don't understand
	// must error rather than guess.
	Version int `yaml:"version,omitempty"`

	Rules RulesConfig `yaml:"rules"`

	// PathRules is populated by the loader's normalize() pass. It is NOT
	// directly unmarshalled from YAML — see normalizePathRules() — because
	// the YAML can be either a mapping (flat form) or a sequence (list
	// form). Tagged "-" so yaml.Strict() doesn't barf on a missing key.
	PathRules []PathRuleSpec `yaml:"-"`

	// Keybindings is a placeholder for the M12 keybinding-override feature
	// documented in CLAUDE.md. Declared here so yaml.Strict() accepts the
	// documented top-level key without rejecting the whole config; semantics
	// are wired up in M12.
	Keybindings map[string]string `yaml:"keybindings,omitempty"`
}

Config holds all user-configurable settings.

func Default

func Default() *Config

Default returns the config with hardcoded default values.

func Load

func Load() (*Config, error)

Load reads .layerx.yaml from the current directory. Returns default config if the file does not exist.

func LoadFrom

func LoadFrom(path string) (*Config, error)

LoadFrom reads config from the specified path. Returns default config if the file does not exist, is empty, or contains only whitespace/comments.

type PathRuleSpec added in v1.3.0

type PathRuleSpec struct {
	ID        string
	Type      PathRuleType
	Paths     []string
	Threshold int
}

PathRuleSpec is the canonical, post-normalize representation of one path rule. Both YAML forms (flat map and list-of-rules) collapse to a slice of these — downstream code never needs to know which form the user wrote.

For Block / DenyWaste: Paths is populated, Threshold is 0. For MaxLayerCount: Threshold is populated, Paths is nil.

ID is the rule identifier used for log-grep and future --rule-id filters. In flat form, ID is the rule type name itself ("block", "deny-waste", "max-layer-count"). In list form, ID is user-supplied and must be unique.

type PathRuleType added in v1.3.0

type PathRuleType string

PathRuleType identifies one of the three supported path-rule kinds. Unknown values are rejected at load time.

const (
	PathRuleBlock         PathRuleType = "block"
	PathRuleDenyWaste     PathRuleType = "deny-waste"
	PathRuleMaxLayerCount PathRuleType = "max-layer-count"
)

type RulesConfig

type RulesConfig struct {
	LowestEfficiency         float64 `yaml:"lowest-efficiency"`
	HighestWastedBytes       int64   `yaml:"highest-wasted-bytes"`
	HighestUserWastedPercent float64 `yaml:"highest-user-wasted-percent"`
}

RulesConfig holds CI rule thresholds.

Jump to

Keyboard shortcuts

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