feat: add custom prime template config option#82
Conversation
- Add templates.prime config option to .beans.yml for overriding
the built-in prime document with a custom Go template file
- Add TemplatesConfig struct with Prime field, resolved relative
to the config file directory (same as beans.path)
- Custom templates have access to all built-in variables plus
{{.OriginalPrime}} which contains the fully-rendered built-in
prime output
- When custom template file is missing or has parse errors, fall
back to built-in prime with a warning on stderr
- Add prime template existence check to beans check command
- Extract renderPrime() for testability; add comprehensive tests
for rendering, fallback behavior, and config round-trips
|
Follow-up consideration: user-global config We discussed adding support for a user-global config (e.g., Rough shape:
This is out of scope for this PR but the |
|
I need to think about this some more. One important property of Please allow me some time to ponder this some more. |
|
@hmans Just weighing in that the general feature request is important given how opinionated the current For example:
This could contradict workflows where the user wants beans to be more orderly and mostly read instead of an ephemeral scratch pad for session context.
This contradicts workflows where the user wants beans to be a more ephemeral and local-only memory/context tool. |
Relates to #65
Summary
templates.primeconfig option to.beans.ymlfor overriding the built-in prime document with a custom Go template file{{.OriginalPrime}}(the fully-rendered built-in prime output)beans primewarns on stderr and outputs the built-in prime instead of failingbeans checkvalidates that the custom prime template file exists when configuredThis allows users to add project-specific or agent-specific instructions (like those suggested in #65) without forking the built-in prime template. Users can wrap the original prime with their own additions via
{{.OriginalPrime}}, or replace it entirely.Configuration
Template Variables
Custom templates have access to:
{{.GraphQLSchema}}- The GraphQL schema{{.Types}}- Type configs (name, color, description){{.Statuses}}- Status configs{{.Priorities}}- Priority configs{{.OriginalPrime}}- The fully-rendered built-in prime outputExample
Changes
internal/config/config.go: AddTemplatesConfigstruct,Templatesfield onConfig,ResolvePrimeTemplatePath()methodcmd/prime.go: ExtractrenderPrime()function, load config, handle custom template with fallbackcmd/check.go: Validate custom prime template file existscmd/prime_test.go: New test file covering rendering, fallback, all template variablesinternal/config/config_test.go: Tests for path resolution, config loading, save/load round-tripDesign Notes
The
templatessection is a new top-level config key (separate frombeans) to allow future extensibility: