config

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package config is the public authoring surface for a plums user config. An external ~/.config/plums/config/config.go imports this package and provides a func Config() config.Config that returns its Opts and the plugins it wants.

config builds on github.com/Ceinl/plums/capabilities (the plugin floor).

Index

Constants

View Source
const Dynamic = dynamicSentinel

Dynamic marks a Pref field as runtime-remembered. When no stored value exists, it behaves as "use the default value".

Variables

View Source
var DynamicCount = Count{/* contains filtered or unexported fields */}

DynamicCount marks a Count field as runtime-remembered: it counts as set (so it survives Merge), but resolves to the default until the dynamic-prefs store supplies a remembered value.

Functions

func Registered

func Registered() (func() Config, bool)

Registered returns the config-producing function previously registered by Use, and whether one was registered.

func Use

func Use(fn func() Config)

Use registers the config-producing function selected by a compiled user build. The generated cmd/plums/main.go calls config.Use(userconfig.Config).

Types

type Bool

type Bool int8

Bool is a tri-state boolean: Unset (zero value — inherit the default), True, or False. This removes the ambiguity of a plain bool whose zero value (false) is indistinguishable from "not set".

const (
	Unset Bool = iota // inherit the default
	True
	False
)

func (Bool) Set

func (b Bool) Set() bool

Set reports whether the Bool was explicitly assigned True or False.

func (Bool) Value

func (b Bool) Value(def bool) bool

Value resolves the tri-state to a concrete bool, returning def when unset.

type Config

type Config struct {
	Opts    Opts
	Plugins []Plugin
}

Config is the root returned by a user config's func Config() config.Config and by the built-in Default Config. Opts are the non-plugin settings; Plugins are the units of behavior to activate (in slice order, last-wins over defaults).

func Merge

func Merge(base, over Config) Config

Merge overlays the external Config over the base (Default Config): Opts merge field-by-field (MergeOpts) and Plugins concatenate base-then-external so the external plugins load later and win on name collisions (last-wins).

type Count

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

Count is a tri-state integer for fields whose zero value (0) is a meaningful setting and so cannot double as "unset". The zero Count is unset; wrap a real value with Int (including Int(0)). A Count can also be Dynamic (runtime- remembered) via DynamicCount.

func Int

func Int(v int) Count

Int constructs a set Count from v (Int(0) is "explicitly zero", distinct from the zero-value Count which is unset).

func (Count) IsDynamic

func (c Count) IsDynamic() bool

IsDynamic reports whether the Count is the Dynamic sentinel.

func (Count) Set

func (c Count) Set() bool

Set reports whether the Count was assigned (including Dynamic).

func (Count) Value

func (c Count) Value(def int) int

Value resolves the Count, returning def when unset or Dynamic.

type Keybind

type Keybind = capabilities.Keybind

Keybind maps a key chord to a command name.

type Opts

type Opts struct {
	// Active selection — typical Dynamic candidates (remembered at runtime).
	Backend       Pref // backend plugin name, or Dynamic
	Model         Pref // model id, or Dynamic
	DefaultLayout Pref // layout name, or Dynamic
	Mode          Pref // agent mode, or Dynamic

	// Appearance.
	Theme Theme

	// Input.
	Keybinds         []Keybind
	ClipboardCommand string

	// Conversation visibility.
	HideThinking       Bool // tri-state: True / False / unset
	ThinkingVisibility int
	ToolCallVisibility int

	// Split sizing.
	SplitLeftWidth Count // tri-state int: unset inherits
	OutputPercent  Count

	// Sessions.
	ClearHistory Bool

	// Registry.
	Disable []RegistryKey

	// Advanced timeouts (milliseconds; unset/0 inherits the default).
	HealthTimeoutMS        int
	QuestionReplyTimeoutMS int
	RecentModelTimeoutMS   int
	ListTimeoutMS          int
	SpinnerIntervalMS      int
}

Opts is the long, typed list of everything that is NOT a plugin: active selection, appearance, input, conversation visibility, split sizing, sessions, registry disables, and advanced timeouts. Fields left at their zero value inherit the Default Config's value when merged (see Merge); use the sentinel tri-state / Dynamic helpers below to express "set" unambiguously for fields whose zero value is otherwise meaningful.

func MergeOpts

func MergeOpts(base, over Opts) Opts

MergeOpts overlays the external Opts over the base (Default Config) Opts, last-wins, field by field. A field counts as "set" only when its sentinel tri-state says so (Pref.Set, Bool.Set, Count.Set) or, for plain slices/ints, when it is non-empty/non-zero. Unset fields fall through to the base.

The result is itself an Opts (still expressed in sentinel types) so the resolved value of every field is unambiguous and callers can re-merge.

func (Opts) ToSettings

func (o Opts) ToSettings(def SettingsDefaults) capabilities.Settings

ToSettings projects resolved Opts into the kernel/runtime-facing capabilities.Settings. Tri-state fields resolve through def; Pref fields use their pinned value. Dynamic Pref fields should be seeded from the app-managed state.toml store before this projection.

type Plugin

type Plugin struct {
	Self any
	Opts any
}

Plugin pairs a plugin value (Self) with its typed options (Opts). The loader activates Self's capabilities and calls Self.Init(host, Opts).

type Pref

type Pref string

Pref is a string-valued option that distinguishes three states: unset (zero value — inherit the default), Dynamic (remembered at runtime by the app-managed state.toml store), and a pinned literal value. An untyped string constant assigns directly: Backend: "opencode".

func (Pref) IsDynamic

func (p Pref) IsDynamic() bool

IsDynamic reports whether the Pref is the Dynamic sentinel.

func (Pref) Set

func (p Pref) Set() bool

Set reports whether the Pref was assigned (any non-zero value, including Dynamic).

func (Pref) Value

func (p Pref) Value() string

Value returns the pinned string, or "" for unset or Dynamic (both of which fall through to the default during settings projection).

type RegistryKey

type RegistryKey = capabilities.RegistryKey

RegistryKey qualifies a registry entry for Opts.Disable.

type SettingsDefaults

type SettingsDefaults struct {
	HideThinking   bool
	SplitLeftWidth int
	OutputPercent  int
	ClearHistory   bool
}

SettingsDefaults supplies concrete fallbacks for tri-state Opts fields whose "unset" must resolve to a meaningful value when projecting to capabilities.Settings. These mirror today's hardcoded runtime defaults.

type Theme

type Theme = capabilities.Theme

Theme is the appearance token set (an Opt, not a plugin).

Jump to

Keyboard shortcuts

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