prompt

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder assembles prompt sections into a single system prompt string.

func DefaultBuilder

func DefaultBuilder() *Builder

DefaultBuilder returns a Builder pre-loaded with the four built-in sections.

func LoadAgentFromDir

func LoadAgentFromDir(base *Builder, dir string, logger *zap.SugaredLogger) *Builder

LoadAgentFromDir overlays per-agent prompt overrides on top of a shared base builder. The directory should be <promptsDir>/agents/<agentName>/. If the directory does not exist, the base builder is returned unmodified.

func LoadFromDir

func LoadFromDir(dir string, logger *zap.SugaredLogger) *Builder

LoadFromDir loads .md files from the given directory and overrides matching default sections. Unknown .md files are added as custom sections with priority 900+.

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates an empty Builder.

func (*Builder) Add

func (b *Builder) Add(s PromptSection) *Builder

Add appends a section. If a section with the same ID already exists, it is replaced (last-writer-wins).

func (*Builder) Build

func (b *Builder) Build() string

Build sorts sections by priority and joins their rendered content.

func (*Builder) Clone

func (b *Builder) Clone() *Builder

Clone returns a deep copy of the builder so the caller can diverge independently (e.g. per sub-agent customization).

func (*Builder) Has

func (b *Builder) Has(id SectionID) bool

Has returns true if a section with the given ID is registered.

func (*Builder) Remove

func (b *Builder) Remove(id SectionID) *Builder

Remove removes a section by ID.

type PromptSection

type PromptSection interface {
	ID() SectionID
	Priority() int  // Lower = first. Identity=100, Safety=200, ...
	Render() string // Empty string = omitted
}

PromptSection produces a titled block of text for the system prompt.

type SectionID

type SectionID string

SectionID identifies a prompt section.

const (
	SectionIdentity          SectionID = "identity"
	SectionAgentIdentity     SectionID = "agent_identity"
	SectionSafety            SectionID = "safety"
	SectionConversationRules SectionID = "conversation_rules"
	SectionToolUsage         SectionID = "tool_usage"
	SectionCustom            SectionID = "custom"
	SectionAutomation        SectionID = "automation"
)

func (SectionID) Valid

func (s SectionID) Valid() bool

Valid reports whether s is a known section ID.

func (SectionID) Values

func (s SectionID) Values() []SectionID

Values returns all known section IDs.

type StaticSection

type StaticSection struct {
	// contains filtered or unexported fields
}

StaticSection is a simple prompt section with fixed content.

func NewStaticSection

func NewStaticSection(id SectionID, priority int, title, content string) *StaticSection

NewStaticSection creates a new static prompt section.

func (*StaticSection) ID

func (s *StaticSection) ID() SectionID

func (*StaticSection) Priority

func (s *StaticSection) Priority() int

func (*StaticSection) Render

func (s *StaticSection) Render() string

Render returns the section content with an optional title header.

Jump to

Keyboard shortcuts

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