sysprompt

package
v0.3.29-beta Latest Latest
Warning

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

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

Documentation

Overview

Package sysprompt renders system prompts from embedded templates.

Index

Constants

View Source
const (
	// ProductName is the name of the product used in prompts and documentation.
	ProductName = "kodelet"

	// AgentsMd is the filename for agent-specific documentation.
	AgentsMd = "AGENTS.md"
	// ReadmeMd is the filename for README documentation.
	ReadmeMd = "README.md"

	// SystemTemplate is the path to the main system prompt template.
	SystemTemplate = "templates/system.tmpl"
	// CodexTemplate is the path to the Codex-specific system prompt template.
	CodexTemplate = "templates/codex.tmpl"
)

Variables

View Source
var TemplateFS embed.FS

TemplateFS contains the embedded template files for system prompts.

Functions

func RenderRuntimeSections

func RenderRuntimeSections(ctx *PromptContext, renderer *Renderer) []string

RenderRuntimeSections renders system-info, loaded-contexts, and MCP-server sections.

func SystemPrompt

func SystemPrompt(model string, llmConfig llmtypes.Config, contexts map[string]string) string

SystemPrompt generates a system prompt for the given model

Types

type PromptContext

type PromptContext struct {
	WorkingDirectory string
	IsGitRepo        bool
	Platform         string
	OSVersion        string
	Date             string

	// Content contexts (README, AGENTS.md)
	ContextFiles map[string]string

	// Active context file name (resolved from configured patterns)
	ActiveContextFile    string
	Args                 map[string]string
	DisableFSSearchTools bool

	// MCP tools information
	MCPExecutionMode string
	MCPWorkspaceDir  string
	MCPServers       []string // List of available MCP server names
}

PromptContext holds all variables for template rendering

func BuildRuntimeContext

func BuildRuntimeContext(llmConfig llmtypes.Config, contexts map[string]string) *PromptContext

BuildRuntimeContext creates prompt context configured for runtime section rendering.

func (*PromptContext) WithMCPConfig

func (ctx *PromptContext) WithMCPConfig(executionMode, workspaceDir string) *PromptContext

WithMCPConfig adds MCP configuration to the prompt context

type Renderer

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

Renderer provides prompt template rendering capabilities

func NewRenderer

func NewRenderer(fs fs.FS) *Renderer

NewRenderer creates a new template renderer

func NewRendererWithTemplateOverride

func NewRendererWithTemplateOverride(fs fs.FS, overrides map[string]string) *Renderer

NewRendererWithTemplateOverride creates a renderer with custom template overrides. Overrides are keyed by template path (e.g., templates/system.tmpl).

func ResolveRendererForConfig

func ResolveRendererForConfig(llmConfig llmtypes.Config) (*Renderer, error)

ResolveRendererForConfig resolves the sysprompt renderer from config.

func (*Renderer) RenderPrompt

func (r *Renderer) RenderPrompt(name string, ctx *PromptContext) (string, error)

RenderPrompt renders a named template with the provided context

func (*Renderer) RenderSystemPrompt

func (r *Renderer) RenderSystemPrompt(ctx *PromptContext) (string, error)

RenderSystemPrompt renders the system prompt

func (*Renderer) RenderTemplate

func (r *Renderer) RenderTemplate(templatePath string, ctx *PromptContext) (string, error)

RenderTemplate renders an arbitrary template with the provided context.

Jump to

Keyboard shortcuts

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