Help us shape the future of Go! Take the 2026 Go Developer Survey

prompt

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package prompt provides prompt template loading and management.

Core types:

  • Loader: Loads prompt templates from files or embedded resources
  • Template: A loaded prompt template with variable substitution

Example usage:

loader := prompt.NewLoader(prompt.Config{
    TemplateDir: ".devflow/prompts",
    EmbedFS:     embeddedPrompts,
})
tmpl, err := loader.Load("generate-spec")
result := tmpl.Execute(map[string]string{
    "ticket": "TK-421",
    "title":  "Add authentication",
})

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 helps construct prompts programmatically.

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new prompt builder.

func (*Builder) Add

func (b *Builder) Add(text string) *Builder

Add adds text to the prompt.

func (*Builder) AddFile

func (b *Builder) AddFile(path, content string) *Builder

AddFile adds file content with XML-style tags.

func (*Builder) AddList

func (b *Builder) AddList(header string, items []string) *Builder

AddList adds a bulleted list.

func (*Builder) AddSection

func (b *Builder) AddSection(header, content string) *Builder

AddSection adds a markdown section with header.

func (*Builder) Build

func (b *Builder) Build() string

Build returns the constructed prompt.

func (*Builder) Clear

func (b *Builder) Clear()

Clear resets the builder.

type Loader

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

Loader loads and renders prompt templates.

func NewLoader

func NewLoader(projectDir string) *Loader

NewLoader creates a prompt loader for the given project directory. It searches for prompts in the following order: 1. .devflow/prompts/ in project 2. prompts/ in project 3. Embedded prompts in devflow binary

func (*Loader) AddFunc

func (l *Loader) AddFunc(name string, fn any)

AddFunc adds a custom template function.

func (*Loader) AddSearchDir

func (l *Loader) AddSearchDir(dir string)

AddSearchDir adds a directory to search for prompts.

func (*Loader) ClearCache

func (l *Loader) ClearCache()

ClearCache clears the template cache.

func (*Loader) Exists

func (l *Loader) Exists(name string) bool

Exists checks if a prompt exists.

func (*Loader) List

func (l *Loader) List() ([]string, error)

List returns all available prompt names.

func (*Loader) Load

func (l *Loader) Load(name string) (string, error)

Load loads a prompt by name without variable substitution.

func (*Loader) LoadWithVars

func (l *Loader) LoadWithVars(name string, vars map[string]any) (string, error)

LoadWithVars loads and renders a prompt with variable substitution.

Jump to

Keyboard shortcuts

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