Documentation
¶
Overview ¶
Package prompts builds the default coding-agent system prompt.
It mirrors upstream core/system-prompt.js as of Pi 0.87.1: an untagged preamble, then tagged sections in upstream order (tools, rules, docs, addendum, project_context, skills, cwd). The model receives this text, so it matches upstream byte for byte apart from the product name and the documentation location (divergence D22). BuildDefaultPrompt's callers pass the same inputs upstream's agent session collects: selected tools, their prompt snippets and guidelines, context files, and skills.
Index ¶
- func ApplyCustomSystemPromptSections(base, custom ai.OrderedSections) (ai.OrderedSections, error)
- func BuildDefaultPrompt(o Options) string
- func BuildSystemPromptSections(o Options) ai.OrderedSections
- func BuildSystemPromptState(o Options) ai.SystemMessage
- func DefaultToolSnippets() map[string]string
- func DiffSystemPromptSections(previous, current ai.OrderedSections) ai.OrderedSections
- type Options
- type Skill
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyCustomSystemPromptSections ¶
func ApplyCustomSystemPromptSections(base, custom ai.OrderedSections) (ai.OrderedSections, error)
ApplyCustomSystemPromptSections overlays extension-authored sections on the base prompt in insertion order. Empty values leave the base unchanged; preamble and invalid tag names are rejected. Ports packages/coding-agent/src/core/system-prompt.ts:121-186.
func BuildDefaultPrompt ¶
BuildDefaultPrompt renders the structured prompt or returns an exact forced replacement.
func BuildSystemPromptSections ¶
func BuildSystemPromptSections(o Options) ai.OrderedSections
BuildSystemPromptSections retains the ordered, independently replaceable prompt sections.
func BuildSystemPromptState ¶
func BuildSystemPromptState(o Options) ai.SystemMessage
BuildSystemPromptState returns opaque content for a forced prompt, or empty content with structured sections otherwise.
func DefaultToolSnippets ¶
DefaultToolSnippets are the built-in tool summaries used in the system prompt.
func DiffSystemPromptSections ¶
func DiffSystemPromptSections(previous, current ai.OrderedSections) ai.OrderedSections
DiffSystemPromptSections returns replacements in current order, followed by removals in previous order. A nil value removes a section from the transcript.
Types ¶
type Options ¶
type Options struct {
// Cwd is the working directory shown to the model.
Cwd string
// Tools are the selected tool names in the order the model sees them. Nil selects read, bash, edit, and write; an empty slice selects none.
Tools []string
// ToolHints maps a tool name to its prompt snippet. Upstream lists only
// tools that have a snippet.
ToolHints map[string]string
// ToolGuidelines maps a tool name to its prompt guidelines. Guidelines of
// selected tools become rules, deduplicated in tool order.
ToolGuidelines map[string][]string
// PromptGuidelines are rules that do not belong to one tool.
PromptGuidelines []string
// Skills lists discovered skills.
Skills []Skill
// CustomPrompt is an agent definition's body. AppendMode decides its role.
CustomPrompt string
// ForceSystemPrompt replaces the full prompt without sections, including when it points to an empty string.
ForceSystemPrompt *string
// AppendSystemPrompt is appended as an addendum after the configured preamble.
AppendSystemPrompt string
// ContextFiles are the loaded AGENTS.md and CLAUDE.md files.
ContextFiles []struct{ Path, Content string }
// PigDocsPath is the local documentation bundle synced by pigdocs. Empty
// uses the standard config-root location.
PigDocsPath string
// AppendMode is "append" (default: CustomPrompt becomes the addendum
// section) or "replace" (CustomPrompt replaces the preamble, and the tools,
// rules, and docs sections are omitted, as upstream does for a custom
// system prompt).
AppendMode string
}
Options configures BuildDefaultPrompt.
func FromExtensionOptions ¶
func FromExtensionOptions(input extension.BuildSystemPromptOptions) Options
FromExtensionOptions converts the resource and tool inputs exposed to extensions into prompt-builder inputs.
func WithToolDefinitions ¶
func WithToolDefinitions(options Options, definitions []extension.RegisteredTool) Options
WithToolDefinitions applies registered definitions over built-in prompt metadata. An override with no snippet or guidelines removes the built-in contribution. Ports packages/coding-agent/src/core/agent-session.ts