prompts

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 7 Imported by: 0

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.

func (*Prompt) Append

func (p *Prompt) Append(content string)

Append adds content to the prompt with a newline separator.

func (Prompt) Render

func (p Prompt) Render(data any) (Prompt, error)

Render executes the prompt as a Go template with the given data.

func (Prompt) String

func (p Prompt) String() string

String returns the prompt as a trimmed string.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL