prompt

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SessionIDKey = sessionIDKey{}

SessionIDKey is the exported context key for storing the session ID in context.

Functions

func BuildPrompt added in v0.26.2

func BuildPrompt(ctx context.Context, agentName config.AgentName, provider models.ModelProvider, luaMgr *luaengine.FilterManager, opts ...BuildOption) (string, error)

BuildPrompt constructs a system prompt using the template-based builder. This is the new entry point that uses the template infrastructure while keeping GetAgentPrompt available for backward compatibility.

func CoderPrompt

func CoderPrompt(provider models.ModelProvider) string

func GetAgentPrompt

func GetAgentPrompt(agentName config.AgentName, provider models.ModelProvider, luaMgr *luaengine.FilterManager) string

func InjectSkillInstructions

func InjectSkillInstructions(name string, instructions string) string

func InjectSkillsMetadata

func InjectSkillsMetadata(availableSkills []skills.SkillMetadata) string

func NewPromptLuaFunctions added in v0.26.2

func NewPromptLuaFunctions() *luaengine.PromptFunctionOptions

NewPromptLuaFunctions creates PromptFunctionOptions with implementations that bridge the prompt system to Lua scripts.

func SetGlobalEvaluator added in v0.26.2

func SetGlobalEvaluator(e PromptEvaluator)

SetGlobalEvaluator sets the evaluator used by BuildPrompt for template selection and skill injection. Pass nil to disable.

func SummarizerPrompt

func SummarizerPrompt(_ models.ModelProvider) string

func TaskPrompt

func TaskPrompt(_ models.ModelProvider) string

func TitlePrompt

func TitlePrompt(_ models.ModelProvider) string

Types

type BuildOption added in v0.26.2

type BuildOption func(*buildOptions)

BuildOption is a functional option for configuring BuildPrompt.

func WithContextFiles added in v0.26.2

func WithContextFiles(files []ContextFile) BuildOption

WithContextFiles sets additional context files for the prompt.

func WithEnvironment added in v0.26.2

func WithEnvironment(workingDir string, isGitRepo bool, platform, date string) BuildOption

WithEnvironment sets environment information for the prompt.

func WithGitInfo added in v0.26.2

func WithGitInfo(branch, status, recentCommits string) BuildOption

WithGitInfo sets git-related information for the prompt.

func WithLSPInfo added in v0.26.2

func WithLSPInfo(info string) BuildOption

WithLSPInfo sets LSP information for the prompt.

func WithMCPInstructions added in v0.26.2

func WithMCPInstructions(instructions string) BuildOption

WithMCPInstructions sets MCP instructions for the prompt.

func WithMCPServers added in v0.26.2

func WithMCPServers(servers []string) BuildOption

WithMCPServers sets the list of MCP server names for capability detection.

func WithModel added in v0.26.2

func WithModel(model string) BuildOption

WithModel sets the model name for the prompt.

func WithProjectListing added in v0.26.2

func WithProjectListing(listing string) BuildOption

WithProjectListing sets the project directory listing for the prompt.

func WithSkills added in v0.26.2

func WithSkills(metadata string, activeSkills []string) BuildOption

WithSkills sets skills metadata and active skills for the prompt.

func WithTools added in v0.26.2

func WithTools(tools []string) BuildOption

WithTools sets the list of available tool names for capability detection.

func WithVersion added in v0.26.2

func WithVersion(version string) BuildOption

WithVersion sets the application version for the prompt.

type CapabilityDetector added in v0.26.2

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

CapabilityDetector detects available capabilities based on configuration, MCP server names, and available tool names.

func NewCapabilityDetector added in v0.26.2

func NewCapabilityDetector(cfg *config.Config, mcpServers []string, tools []string) *CapabilityDetector

NewCapabilityDetector creates a new CapabilityDetector.

func (*CapabilityDetector) Detect added in v0.26.2

func (d *CapabilityDetector) Detect() map[string]bool

Detect returns a map of capability names to their availability.

func (*CapabilityDetector) DetectWebSearchDetails added in v0.26.2

func (d *CapabilityDetector) DetectWebSearchDetails() (google, brave, perplexity bool)

DetectWebSearchDetails returns detailed web search provider availability.

type ContextFile added in v0.26.2

type ContextFile struct {
	Path    string
	Content string
}

ContextFile represents a loaded project context file.

type PromptBuilder added in v0.26.2

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

PromptBuilder composes a final system prompt from template sections.

func NewPromptBuilder added in v0.26.2

func NewPromptBuilder(agentName string, provider string, data *PromptData, luaMgr *luaengine.FilterManager) *PromptBuilder

NewPromptBuilder creates a new PromptBuilder.

func (*PromptBuilder) Build added in v0.26.2

func (b *PromptBuilder) Build(ctx context.Context) (string, error)

Build composes the final system prompt by rendering all applicable template sections and joining them together.

func (*PromptBuilder) SetEvaluator added in v0.26.2

func (b *PromptBuilder) SetEvaluator(e promptEvaluator)

SetEvaluator wires an evaluator into the builder for UCB template selection and skill injection. If e is nil the builder falls back to its default behaviour.

type PromptData added in v0.26.2

type PromptData struct {
	// Identity
	AgentName string
	AgentRole string
	Version   string

	// Environment
	WorkingDir       string
	IsGitRepo        bool
	Platform         string
	Date             string
	GitBranch        string
	GitStatus        string
	GitRecentCommits string
	ProjectListing   string

	// Provider
	Provider string
	Model    string

	// Capabilities (conditional section flags)
	HasRemembrances  bool
	HasOrchestration bool // mesnada sub-agents
	HasWebSearch     bool
	HasCodeIndexing  bool
	HasLSP           bool
	HasSkills        bool

	// Web search detail flags (for template conditionals)
	HasGoogleSearch bool
	HasBraveSearch  bool
	HasPerplexity   bool

	// Context
	ContextFiles    []ContextFile
	SkillsMetadata  string
	ActiveSkills    []string
	LSPInfo         string
	MCPInstructions string

	// Config reference
	Config *config.Config
}

PromptData contains all data available for template rendering.

type PromptEvaluator added in v0.26.2

type PromptEvaluator interface {
	SelectTemplate(ctx context.Context, sectionName string) (*PromptEvaluatorTemplate, error)
	GetActiveSkills(ctx context.Context, taskType string) ([]PromptEvaluatorSkill, error)
	RecordTemplateSelection(ctx context.Context, sessionID, templateID string)
}

PromptEvaluator is the interface used by PromptBuilder for UCB template selection and skill injection. It is exported so app.go can implement an adapter without creating an import cycle.

type PromptEvaluatorSkill added in v0.26.2

type PromptEvaluatorSkill struct {
	Content string
}

PromptEvaluatorSkill mirrors evaluator.Skill to avoid import cycles.

type PromptEvaluatorTemplate added in v0.26.2

type PromptEvaluatorTemplate struct {
	ID      string
	Content string
	Version int
}

PromptEvaluatorTemplate mirrors evaluator.PromptTemplate to avoid import cycles.

type PromptSection added in v0.26.2

type PromptSection struct {
	Name    string
	Content string
}

PromptSection represents a rendered template section.

type TemplateRegistry added in v0.26.2

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

TemplateRegistry manages template loading, caching, and rendering. It supports embedded templates with external override from project or user configuration directories.

func NewTemplateRegistry added in v0.26.2

func NewTemplateRegistry(overrideDirs ...string) *TemplateRegistry

NewTemplateRegistry creates a new TemplateRegistry. overrideDirs are directories checked (in order) for template overrides. Typically: [".pando/templates", "~/.config/pando/templates"]

func (*TemplateRegistry) Exists added in v0.26.2

func (r *TemplateRegistry) Exists(name string) bool

Exists checks whether a template exists (either embedded or overridden).

func (*TemplateRegistry) Get added in v0.26.2

func (r *TemplateRegistry) Get(name string) (*template.Template, error)

Get returns a parsed template by name. The name is a relative path without the .md.tpl extension, e.g. "base/identity", "agents/coder". External templates override embedded ones.

func (*TemplateRegistry) RegisterCustomFuncs added in v0.26.2

func (r *TemplateRegistry) RegisterCustomFuncs(funcs template.FuncMap)

RegisterCustomFuncs adds custom template functions that will be available in all templates. Must be called before any Get/Render calls.

func (*TemplateRegistry) Render added in v0.26.2

func (r *TemplateRegistry) Render(name string, data *PromptData) (string, error)

Render renders a template by name with the given data and returns the output.

Jump to

Keyboard shortcuts

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