config

package
v0.5.2-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config is the configuration layer: project config files, the SENIOR_DEV_* environment surface and their merge.

Index

Constants

This section is empty.

Variables

View Source
var VariableNames = []string{
	"SENIOR_DEV_CLIENT",
	"SENIOR_DEV_CONFIG",
	"SENIOR_DEV_CONFIG_CONTENT",
	"SENIOR_DEV_CONFIG_DIR",
	"SENIOR_DEV_DISABLE_AUTOCOMPACT",
	"SENIOR_DEV_DISABLE_MODELS_FETCH",
	"SENIOR_DEV_DISABLE_PROJECT_CONFIG",
	"SENIOR_DEV_DISABLE_PRUNE",
	"SENIOR_DEV_EAGER_COMMIT",
	"SENIOR_DEV_ENABLE_EXA",
	"SENIOR_DEV_ENABLE_PARALLEL",
	"SENIOR_DEV_ENABLE_QUESTION_TOOL",
	"SENIOR_DEV_ENV_SIGNALS",
	"SENIOR_DEV_EXPERIMENTAL",
	"SENIOR_DEV_EXPERIMENTAL_EXA",
	"SENIOR_DEV_EXPERIMENTAL_OXFMT",
	"SENIOR_DEV_EXPERIMENTAL_PARALLEL",
	"SENIOR_DEV_MODELS_PATH",
	"SENIOR_DEV_MODELS_URL",
	"SENIOR_DEV_OUTPUT_TOKEN_MAX",
	"SENIOR_DEV_PERMISSION",
	"SENIOR_DEV_SCRATCH_MAX_GB",
	"SENIOR_DEV_SCRATCH_ROOT",
	"SENIOR_DEV_SCRATCH_TTL_H",
	"SENIOR_DEV_SHARED_BUILD_CACHE",
	"SENIOR_DEV_WEBSEARCH_PROVIDER",
	"SENIOR_DEV_MAX_COST_USD",
	"SENIOR_DEV_MAX_WALL_H",
}

VariableNames is the environment surface the config layer snapshots. A variable not listed here is invisible to Env.Get.

Functions

func FileInDirectory

func FileInDirectory(dir, name string) []string

FileInDirectory returns the candidate paths for name, JSON before JSONC.

func ParseBoolean

func ParseBoolean(mode BoolMode, raw *string) bool

ParseBoolean applies one of the exact boolean comparisons. raw=nil represents an absent environment entry.

func ParseJSONC

func ParseJSONC(text, source string) (any, error)

ParseJSONC parses comments and trailing commas while preserving the source path in errors.

func ProjectFiles

func ProjectFiles(name, directory, worktree string) []string

ProjectFiles finds config files from the project boundary inward.

func Substitute

func Substitute(input SubstituteInput) (string, error)

Substitute applies {env:VAR} and {file:path} substitutions. A file reference on a line that starts with // is left alone; a missing file is an error.

Types

type BoolMode

type BoolMode string

BoolMode identifies how a boolean environment variable is spelled. The spellings are deliberately asymmetric (an opt-out reads "0", an opt-in reads "1", a truthy flag reads "true"/"1"), so they are not replaced with strconv.ParseBool.

const (
	RawValue   BoolMode = "raw"
	OptInOne   BoolMode = "opt-in-1"
	OptOutZero BoolMode = "opt-out-0"
	Truthy     BoolMode = "truthy"
)

func Mode

func Mode(name string) BoolMode

Mode returns the parsing mode for name. Non-boolean variables retain their raw string value.

type Env

type Env struct {
	// contains filtered or unexported fields
}

Env snapshots an environment without mutating the process-global map.

func NewEnv

func NewEnv(lookup Lookup) Env

NewEnv snapshots lookup for the declared variables.

func (Env) All

func (e Env) All() map[string]string

All returns a defensive copy.

func (Env) Enabled

func (e Env) Enabled(name string) bool

Enabled parses name according to its declared mode.

func (Env) Get

func (e Env) Get(name string) (string, bool)

Get returns a raw value and preserves absent versus explicitly empty.

type Info

type Info map[string]any

Info is the deliberately open config object. The known fields sit next to several extensible record surfaces; retaining JSON values avoids lossy re-encoding during merges.

func LoadText

func LoadText(text string, input SubstituteInput) (Info, error)

LoadText expands substitutions, parses JSONC, and applies schema-level normalizations used by the pipeline.

func Merge

func Merge(target, source Info) Info

Merge deep-merges source over target; the instructions array is the one field that is concatenated (deduplicated) instead of replaced.

type InvalidError

type InvalidError struct {
	Path    string
	Message string
}

func (*InvalidError) Error

func (e *InvalidError) Error() string

type Loader

type Loader struct {
	GlobalDir string
	Env       Env
}

Loader reads and merges the config sources for one directory.

func (Loader) Load

func (l Loader) Load(directory, worktree string) (Info, error)

Load merges the config sources, lowest precedence first: global files, SENIOR_DEV_CONFIG, project files, SENIOR_DEV_CONFIG_CONTENT, SENIOR_DEV_PERMISSION.

type Lookup

type Lookup func(string) (string, bool)

Lookup is the minimal environment read boundary used by Config.

type OrderedEntry

type OrderedEntry struct {
	Key   string
	Value any
}

OrderedEntry is one insertion-ordered JSON object field.

type OrderedObject

type OrderedObject struct {
	// contains filtered or unexported fields
}

OrderedObject preserves source key order for the precedence-sensitive permission and tools objects.

func NewOrderedObject

func NewOrderedObject() *OrderedObject

func NormalizePermission

func NormalizePermission(value any) (*OrderedObject, bool)

NormalizePermission expands the action shorthand to the "*" rule.

func (*OrderedObject) Entries

func (o *OrderedObject) Entries() []OrderedEntry

func (*OrderedObject) Get

func (o *OrderedObject) Get(key string) (any, bool)

func (*OrderedObject) MarshalJSON

func (o *OrderedObject) MarshalJSON() ([]byte, error)

func (*OrderedObject) Set

func (o *OrderedObject) Set(key string, value any)

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service caches per-directory config and supports explicit invalidation.

func NewService

func NewService(loader Loader) *Service

func (*Service) Get

func (s *Service) Get(directory, worktree string) (Info, error)

func (*Service) Invalidate

func (s *Service) Invalidate(directory string)

func (*Service) Update

func (s *Service) Update(directory string, info Info) error

type SubstituteInput

type SubstituteInput struct {
	Text   string
	Path   string
	Dir    string
	Source string
	Lookup Lookup
}

SubstituteInput is the input to Substitute: the config text plus where it came from, which anchors relative {file:...} references.

Jump to

Keyboard shortcuts

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