Documentation
¶
Index ¶
- func BaseDirOf(cfg types.Config) string
- func FileSettings(path string) (types.Config, map[string]bool, error)
- func FormatSettingValue(v any) string
- func Load() types.Config
- func LoadWith(o LoadOptions) types.Config
- func UnsetSetting(path, key string) (bool, error)
- func WritablePath() string
- func WritablePathIn(root string) string
- func WriteSetting(path, key string, v any) error
- type AgentTypeConfig
- type LoadOptions
- type Setting
- type SettingType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BaseDirOf ¶ added in v0.5.0
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 FileSettings ¶ added in v0.9.1
FileSettings reads the config file at path and returns what it resolves to once nib's defaults fill its gaps, plus the settable keys it sets explicitly. It is how /settings tells "from the file" apart from "default". A missing file resolves to pure defaults with nothing present.
func FormatSettingValue ¶ added in v0.9.1
FormatSettingValue renders a typed setting value the way Format does.
func Load ¶
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 UnsetSetting ¶ added in v0.9.1
UnsetSetting removes key from the config file at path, so its default applies again, and removes any parent mapping the removal left empty. It reports whether the key was there. A missing file has nothing to unset.
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
WritablePathIn returns the config file to write to for the given root.
func WriteSetting ¶ added in v0.9.1
WriteSetting sets key to v (a value as Setting.Parse returns it) in the config file at path, creating the file and any missing parent mappings.
It edits the yaml node tree rather than round-tripping through a struct or a map, so comments, key order and keys nib does not know about survive. A file that does not parse is refused rather than replaced: it is the user's, and whatever is wrong with it is theirs to see.
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.
type Setting ¶ added in v0.9.1
type Setting struct {
Key string
Type SettingType
// Doc is a one-line description, empty for keys with no entry in
// settingDocs.
Doc string
// Values are the values offered for completion: on/off for every bool, the
// modes for an enum-like string. Empty for free-form keys.
Values []string
// contains filtered or unexported fields
}
Setting is one scalar key of the config file that /settings can read and write, addressed by its dotted yaml path ("compaction.threshold").
The set is REFLECTED from types.Config's yaml tags rather than listed by hand, so a scalar field added to the config later is settable, listed and completed the moment it exists, with no second list to forget. Only the descriptions and the value hints live in hand-written tables below, and a key missing from those still works, it just shows its type instead of a sentence.
func LookupSetting ¶ added in v0.9.1
LookupSetting finds a settable key. An unknown key gets the closest real one suggested, and a secret gets told where it belongs instead.
func Settings ¶ added in v0.9.1
func Settings() []Setting
Settings returns every settable key, sorted by key.
func (Setting) Format ¶ added in v0.9.1
Format renders the key's value in cfg for display: on/off for bools, and quotes around an empty string so "" reads as a value rather than a gap. Multi-line values (a custom prompt) are cut to their first line.
type SettingType ¶ added in v0.9.1
type SettingType string
SettingType is the value kind of a settable config key.
const ( SettingBool SettingType = "bool" SettingInt SettingType = "int" SettingFloat SettingType = "float" SettingString SettingType = "string" )