config

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseDirOf added in v0.5.0

func BaseDirOf(cfg types.Config) string

BaseDirOf resolves the plugins/skills root that a loaded config points at.

types.Config.BaseDir holds the RAW OVERRIDE, empty for standalone nib, so it is not a directory and must never be joined onto a path: filepath.Join("", "plugins") silently yields a relative path under the process working directory. Use this helper wherever a resolved directory is wanted. Handing the raw field to something that documents its parameter as an override (manage.NewIn, setup.Save) is the other correct use and needs no wrapping.

This cannot be a method on types.Config: plugin already imports types, so types importing plugin would be an import cycle.

func Load

func Load() types.Config

Load loads the configuration from YAML file and environment variables. Environment variables take precedence over YAML config.

func LoadWith added in v0.5.0

func LoadWith(o LoadOptions) types.Config

LoadWith is Load with injectable roots and behavior switches.

func WritablePath

func WritablePath() string

WritablePath returns the config file self-configuration should write to: the first existing config path (so additions are visible to Load), else the preferred default ~/.config/nib/config.yaml.

func WritablePathIn added in v0.5.0

func WritablePathIn(root string) string

WritablePathIn returns the config file to write to for the given root.

Types

type AgentTypeConfig

type AgentTypeConfig = types.AgentTypeConfig

AgentTypeConfig is re-exported for ergonomic use within the config package.

func MergeAgentTypes

func MergeAgentTypes(user []AgentTypeConfig) []AgentTypeConfig

MergeAgentTypes returns the built-in types with any user entries merged in: an entry whose Name matches a default overrides it field-for-field; a new Name is appended. Defaults not mentioned by the user are preserved.

type LoadOptions added in v0.5.0

type LoadOptions struct {
	// BaseDir overrides the config/plugins/skills root. Empty means the
	// default XDG resolution.
	BaseDir string
	// Defaults seed fields the config file leaves empty. They sit beneath the
	// file so a user edit always wins. Every field of types.Config is seedable,
	// not a hand-picked subset, with ONE carve-out: Defaults.BaseDir is ignored.
	// The root has exactly one knob, LoadOptions.BaseDir above, and a seeded
	// BaseDir is overwritten by it (including when it is empty, which is what
	// selects standalone nib's XDG resolution). See applySeeds for exactly what
	// "empty" means for maps, slices and booleans.
	Defaults types.Config
	// Overrides are Defaults' mirror image: they sit ABOVE the config file and
	// above the environment block, so whatever an embedder sets here is the
	// final word for that field. This is the channel for a value the embedder
	// resolved on the user's behalf and that a config file must not silently
	// undo, a CLI flag above all: `--endpoint` seeded through Defaults is
	// accepted and then ignored the moment the file carries a base_url, which
	// is the default state once anything has written one.
	//
	// The same reflective merge as Defaults, so every field of types.Config is
	// overridable, with the SAME single carve-out: Overrides.BaseDir is ignored,
	// because LoadOptions.BaseDir remains the one knob for the root.
	//
	// The zero-value merge cuts the other way here, and it is the one thing an
	// embedder has to plan around. A zero value is indistinguishable from
	// "unset", so an override only ever raises a field: an override of "" cannot
	// blank a model the file sets, an override of 0 cannot zero an iteration
	// count, and an override of FALSE CANNOT BEAT A `true:` IN THE FILE. There
	// is no exception, Browser.AllowPrivateURLs included, so an embedder that
	// must force a bool off cannot do it through this channel; it has to own the
	// file, or point BaseDir at a root it controls. Presence tracking would need
	// a decoder that records which keys were written, which is not what a
	// types.Config-typed field can express.
	Overrides types.Config
	// SkipBareEnv suppresses the bare MODEL / API_KEY / BASE_URL environment
	// variables. Embedders that expose their own prefixed variables set this so
	// a MODEL meant for some other tool cannot retarget the agent.
	SkipBareEnv bool
}

LoadOptions configures LoadWith. The zero value is what standalone nib uses.

Jump to

Keyboard shortcuts

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