config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config loads and merges acd-ctx configuration (spec §18).

Precedence, lowest to highest (§18.5): defaults, global file, matching "projects" override in the global file, local <root>/.acd-ctx/config.yaml, ACD_CTX_* environment variables, explicit flags. Each key resolves on its own. Effective reports which layer supplied each key.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultGlobalPath

func DefaultGlobalPath() (string, error)

DefaultGlobalPath returns the global config path for this OS (§18.1).

func EnvName

func EnvName(key string) string

EnvName returns the environment variable that sets key, e.g. "trigger.step_base" -> "ACD_CTX_TRIGGER_STEP_BASE".

func Validate

func Validate(c Config) error

Validate checks a merged configuration and returns one error listing every violated rule. It does not know which layer a value came from. Load reports sources.

Types

type Config

type Config struct {
	// trigger.* (§8.1, §8.4)
	UFloor         apd.Decimal // trigger.u_floor
	UHigh          apd.Decimal // trigger.u_high
	UEmerg         apd.Decimal // trigger.u_emerg
	StepBase       int         // trigger.step_base
	StepMin        int         // trigger.step_min
	StepMax        int         // trigger.step_max
	StepReadGain   apd.Decimal // trigger.step_read_gain
	MinGrowthFloor int         // trigger.min_growth_floor
	MaxRefusals    int         // trigger.max_refusals
	TiersEnabled   bool        // trigger.tiers_enabled

	// cache.* (§9). Global only: TTL and prices depend on the provider.
	CacheTTL      time.Duration // cache.ttl
	CacheMargin   apd.Decimal   // cache.margin
	PriceUncached apd.Decimal   // cache.price_uncached
	PriceCached   apd.Decimal   // cache.price_cached

	// compress.* (§10, §11)
	PreserveRecentMessages int      // compress.preserve_recent_messages
	PreserveRecentTokens   int      // compress.preserve_recent_tokens
	MinCompressRange       int      // compress.min_compress_range
	MinSummaryChars        int      // compress.min_summary_chars
	MaxSummaryChars        int      // compress.max_summary_chars
	ProtectedTools         []string // compress.protected_tools
	FramingCheck           bool     // compress.framing_check
	UserTurnAfterSummaries bool     // compress.user_turn_after_summaries
	IntentLedger           bool     // compress.intent_ledger

	// ccr.* (§14)
	CCRThresholdTokens int  // ccr.threshold_tokens
	CrushEnabled       bool // ccr.crush

	// recall.* (§13)
	RecallAssist        bool        // recall.assist
	RecallMinAcceptRate apd.Decimal // recall.min_accept_rate

	// window.* (§8.1, §4): the context window the trigger measures against.
	WindowLimit  int            // window.context_limit: 0 derives the window from the model
	WindowModels map[string]int // window.models: model prefix (lower case) -> tokens

	// compaction.* (docs/compaction-commands.md). Global only: the setting decides
	// which requests are passed through unchanged, so a project file must not change it.
	// strong (default): the fixed prompt markers of the clients whose compaction
	// prompt is a full sentence; all: also the weak prefixes of OpenCode v2;
	// off: text rules are not used. Header and item signals are always on.
	CompactionTextRules string // compaction.text_rules

	// storage: "global" (default) or "local" (§18.1, §18.3).
	Storage string // storage
}

Config is the merged, typed configuration. Field comments give the YAML key.

func Defaults

func Defaults() Config

Defaults returns the built-in values (spec §18.8 and §8.1).

func (Config) Kernel

func (c Config) Kernel() kernel.Config

Kernel maps the trigger settings onto kernel.Config. The kernel package does not import this one.

type Entry

type Entry struct {
	Key    string
	Value  string
	Source string // "default", "global:<path>", "global:projects[<pattern>]", "local:<path>", "env:<VAR>", "flag"
}

Entry is one key in the effective configuration.

type Options

type Options struct {
	// GlobalPath is the global config file. Empty means DefaultGlobalPath().
	GlobalPath string
	// Root is the project root (the directory that holds .acd-ctx/, or the
	// repository root). Empty disables local config and project overrides.
	Root string
	// Flags maps dotted keys (e.g. "trigger.step_base") to raw values. This is
	// the highest-precedence layer.
	Flags map[string]string
	// LookupEnv reads environment variables. Nil means os.LookupEnv.
	LookupEnv func(string) (string, bool)
}

Options selects the inputs for Load. Zero values mean "not provided".

type Result

type Result struct {
	Config   Config
	Warnings []string
	// contains filtered or unexported fields
}

Result is the outcome of Load.

func Load

func Load(opts Options) (Result, error)

Load merges all layers, validates the result, and records the source of each key.

func (Result) Effective

func (r Result) Effective() []Entry

Effective returns every known key with its final value and the layer that supplied it, in spec-table order.

Jump to

Keyboard shortcuts

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