Documentation
¶
Overview ¶
Package prompts provides template-based prompt management for agent configurations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Prompt ¶
type Prompt string
Prompt represents a text prompt with support for templating and composition.
type TemplateSet ¶
type TemplateSet struct {
// contains filtered or unexported fields
}
TemplateSet manages named template partials, validates their dependency graph via DAG cycle detection, and renders a composed prompt from a designated entry point.
Components (system prompt, agent prompt, mode prompt, autoloaded files, workspace instructions) are registered as named templates. The entry point template controls the composition order via {{ template "X" . }} for static references and {{ include "name" $ }} for dynamic (variable) references.
func NewTemplateSet ¶
func NewTemplateSet(entryPoint string) *TemplateSet
NewTemplateSet creates a TemplateSet with the given entry point name. The entry point must be registered via Register before Render is called.
func (*TemplateSet) Register ¶
func (ts *TemplateSet) Register(name, source string)
Register adds a named template partial to the set. Duplicate names overwrite the previous registration.
func (*TemplateSet) Render ¶
func (ts *TemplateSet) Render(data any) (string, error)
Render validates the dependency graph, assembles the Go template with all partials as named templates, and executes the entry point with the given data.
func (*TemplateSet) Validate ¶
func (ts *TemplateSet) Validate() error
Validate parses all partials, extracts static {{ template "X" }} and {{ include "literal" }} references, builds a DAG, and returns an error if cycles or missing references exist.
Dynamic {{ include .Variable $ }} references cannot be validated statically; they are caught at render time if the template does not exist.