Documentation
¶
Overview ¶
Package promptfacts is the registry of short, labeled facts injected into an agent's system prompt under a "Current environment" heading. It is the Go counterpart of lib/tasks/prompt_facts.rb.
Each fact is toggled with a `prompt.<name> = on|off` config key; presentation order follows Registry, not map iteration, because the block is a rendered document and two runs that listed the facts in different orders would be two different system prompts.
A provider that fails or returns blank is omitted silently, so a flaky future source (weather, a calendar, …) can never abort an agent run.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var FactName = regexp.MustCompile(`\A[a-z][a-z0-9_-]*\z`)
FactName is PromptFacts::FACT_NAME — what a `prompt.<name>` key may spell.
var Registry = []Fact{ { Name: "datetime", Default: true, Render: func(s Sources) (string, error) { return FormatDatetime(s.clock()), nil }, }, { Name: "hostname", Default: true, Render: func(s Sources) (string, error) { return s.hostname() }, }, }
Registry is PromptFacts::REGISTRY, in its order.
Functions ¶
func Defaults ¶
Defaults is the name → default-state map, derived from Registry so the two cannot drift. internal/config carries its own copy for the resolution it owns; TestConfigAndRegistryAgreeOnTheFactSet pins them together.
func FormatDatetime ¶
FormatDatetime is `time.strftime("%Y-%m-%d %a %H:%M %Z")`. The zone abbreviation is the last field, so an agent reading "09:00" knows which 09:00 it is without a second question.
func ParseToggle ¶
ParseToggle is PromptFacts.parse_toggle: a strict three-way answer. The second result is false for a value that names neither state, which the config parser treats as "say nothing" rather than as off — a typo must not silently disable a fact the user meant to enable.
func Render ¶
Render builds the "Current environment" block, or "" when nothing is enabled or every provider failed. `enabled` is the resolved name → bool map; a nil map means "nothing was resolved", which resolves to the registry defaults the way `paths.prompt_facts || PromptFacts.resolve` does in Ruby.
Types ¶
type Fact ¶
type Fact struct {
Name string
Default bool
// Render answers the fact's value. An error omits this line only — never
// the block, and never the run.
Render func(Sources) (string, error)
}
Fact is one registry entry: its config name, whether it is on when nothing says otherwise, and how it renders.
type Sources ¶
Sources are the injectable providers a fact renders from. Production uses time.Now and os.Hostname, which is what lib/tasks/prompt_facts.rb defaults to (Time.now / Socket.gethostname).
Deliberately NOT wired to internal/determinism: Ruby's `tasks -p` builds the context with the defaults and never passes a harness pin, so pinning here would make the Go system prompt differ from the Ruby one on exactly the runs a conformance harness performs. The block never reaches stdout, so there is nothing to gain and a difference to lose.