Codex-authored docs covering primitives, commands, messaging, lifecycle, subsystems, and getting started — all using the current DTO/Options/Result API with concrete usage examples. Co-Authored-By: Virgil <virgil@lethean.io>
2 KiB
2 KiB
| title | description |
|---|---|
| Configuration | Constructor options, runtime settings, and feature flags. |
Configuration
CoreGO uses two different configuration layers:
- constructor-time
core.Options - runtime
c.Config()
Constructor-Time Options
c := core.New(core.Options{
{Key: "name", Value: "agent-workbench"},
})
Current Behavior
Newacceptsopts ...Options- the current implementation copies only the first
Optionsslice - the
namekey is applied toc.App().Name
If you need more constructor data, put it in the first core.Options slice.
Runtime Settings with Config
Use c.Config() for mutable process settings.
c.Config().Set("workspace.root", "/srv/workspaces")
c.Config().Set("max_agents", 8)
c.Config().Set("debug", true)
Read them back with:
root := c.Config().String("workspace.root")
maxAgents := c.Config().Int("max_agents")
debug := c.Config().Bool("debug")
raw := c.Config().Get("workspace.root")
Important Details
- missing keys return zero values
- typed accessors do not coerce strings into ints or bools
Getreturnscore.Result
Feature Flags
Config also tracks named feature flags.
c.Config().Enable("workspace.templates")
c.Config().Enable("agent.review")
c.Config().Disable("agent.review")
Read them with:
enabled := c.Config().Enabled("workspace.templates")
features := c.Config().EnabledFeatures()
Feature names are case-sensitive.
ConfigVar[T]
Use ConfigVar[T] when you need a typed value that can also represent “set versus unset”.
theme := core.NewConfigVar("amber")
if theme.IsSet() {
fmt.Println(theme.Get())
}
theme.Unset()
This is useful for package-local state where zero values are not enough to describe configuration presence.
Recommended Pattern
Use the two layers for different jobs:
- put startup identity such as
nameintocore.Options - put mutable runtime values and feature switches into
c.Config()
That keeps constructor intent separate from live process state.