prompttemplate

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package prompttemplate loads reusable, file-backed prompt macros.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsExplicitInvocationText

func IsExplicitInvocationText(text string) bool

func Load

func Load(opts LoadOptions) (*Registry, []Diagnostic)

Load discovers Markdown files directly inside the configured roots. Project templates replace user templates with the same filename-derived name.

func LoadFor

func LoadFor(workspace string) (*Registry, []Diagnostic)

func ParseArguments

func ParseArguments(value string) []string

ParseArguments splits a command tail while preserving whitespace inside matching single or double quotes, matching Pi's prompt-template behavior.

func ParseExplicitInvocationText

func ParseExplicitInvocationText(text string) (invocation.Record, bool)

ParseExplicitInvocationText returns metadata only from the hidden block the backend created after resolving and expanding a template. User-authored slash text lives in the first content block and is never parsed here.

func Roots

func Roots(workspace string) (userDir, projectDir string)

Roots returns the user-level and workspace-level prompt directories.

func Substitute

func Substitute(content string, args []string) string

Substitute expands Pi-compatible positional, all-argument, default, and slicing placeholders in one pass so values are never recursively expanded.

Types

type Diagnostic

type Diagnostic struct {
	Path    string
	Message string
}

Diagnostic reports a template file that could not be loaded.

type LoadOptions

type LoadOptions struct {
	UserDir    string
	ProjectDir string
}

type Registry

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

func NewRegistry

func NewRegistry(templates []Template) *Registry

func (*Registry) ExpandExplicitInvocation

func (r *Registry) ExpandExplicitInvocation(text string) (string, bool)

ExpandExplicitInvocation recognizes /name followed by optional arguments. Unknown slash commands remain ordinary user text.

func (*Registry) List

func (r *Registry) List() []Template

func (*Registry) Lookup

func (r *Registry) Lookup(name string) (Template, bool)

type Source

type Source string

Source identifies where a prompt template was loaded from.

const (
	SourceUser    Source = "user"
	SourceProject Source = "project"
)

type Template

type Template struct {
	Name          string
	Description   string
	Descriptions  map[string]string
	ArgumentHint  string
	ArgumentHints map[string]string
	Content       string
	Path          string
	Source        Source
}

Template is one Markdown prompt template and its discovery metadata.

Jump to

Keyboard shortcuts

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