prompts

package
v0.0.0-...-608921b Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package prompts manages system prompt templates for each agent mode. Templates are markdown files embedded into the binary or loaded from a directory configured under YAML key prompts (config.Prompts in internal/config/prompts.go). They use Go text/template for variable substitution.

Template variables available in .md files:

{{.CWD}}      - session working directory
{{.Tools}}    - readable list of tools available in the current mode (markdown)
{{.Skills}}   - active skills/rules (markdown), built by the agent
{{.Memory}}   - session agent memory notes (may be empty)
{{.TodoList}} - current session todo checklist rendered as markdown (empty until plan tools populate state)
{{.UTCNow}}   - current date and time in UTC (RFC3339), set each time the system prompt renders

Use {{if .Skills}}...{{end}} (and similarly for .Tools, .Memory, .TodoList) when sections should be omitted when empty. The ReAct runner refreshes the rendered system prompt before each LLM call while handling one session prompt.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultSource

func DefaultSource(mode string) string

DefaultSource returns the built-in template source for a mode. Useful for displaying to the user so they can customize it.

func Render

func Render(mode, promptsDir, agentFile, planFile string, data TemplateData) (string, error)

Render renders the prompt template for the given mode with the provided data. promptsDir must be empty to use built-in templates; otherwise it is a directory that contains the files named agentFile and planFile (for example agent.md and plan.md). mode must be "agent" or "plan". Unknown modes use the agent template file.

func RenderWithFallback

func RenderWithFallback(mode, promptsDir, agentFile, planFile string, data TemplateData) string

RenderWithFallback renders the prompt and returns a safe default on error.

Types

type TemplateData

type TemplateData struct {
	// CWD is the session working directory.
	CWD string

	// Skills is preformatted markdown for active skills and rules (may be empty).
	Skills string

	// Tools is a human-readable markdown list of tools for the current mode (may be empty).
	Tools string

	// Memory is session-scoped notes injected into the prompt (may be empty).
	Memory string

	// TodoList is the current session checklist as markdown lines (may be empty).
	TodoList string

	// UTCNow is the wall-clock instant in RFC3339 (UTC) at render time for model grounding.
	UTCNow string
}

TemplateData holds values injected into prompt templates.

Jump to

Keyboard shortcuts

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