Documentation
¶
Overview ¶
Package skills provides activation-context prompt templates for Synapses. Prompts are Markdown files with YAML frontmatter that Synapses auto-injects into agent context when declared patterns (file, entity, module) match. They are pure text injection — no code execution — and are always safe to load regardless of origin (builtin, user-scoped, or project-scoped).
Index ¶
- type PromptTemplate
- func AutoLoadPrompts(templates []PromptTemplate) []PromptTemplate
- func BuiltinPrompts() []PromptTemplate
- func DeduplicatePrompts(templates []PromptTemplate) []PromptTemplate
- func LoadPromptDir(dir, source string) ([]PromptTemplate, error)
- func MatchPrompts(templates []PromptTemplate, file, entity, pkg string) []PromptTemplate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PromptTemplate ¶
type PromptTemplate struct {
ID string // unique identifier (from frontmatter "id" field)
Description string // one-line summary for prompts/list
FilePattern string // glob: match when entity file path matches (e.g. "**/*.go")
EntityPattern string // regex: match when entity name matches (e.g. ".*Service")
ModulePattern string // glob: match when entity package path matches (e.g. "internal/*")
AutoLoad bool // if true, include in session_init for project-wide conventions
Body string // full Markdown body — the activation context text
Source string // "builtin" | "user" | "project"
}
PromptTemplate is a named activation-context snippet that Synapses injects into agent context when its declared patterns match the queried entity.
func AutoLoadPrompts ¶
func AutoLoadPrompts(templates []PromptTemplate) []PromptTemplate
AutoLoadPrompts returns templates marked auto_load: true. These are project-wide conventions surfaced in session_init.
func BuiltinPrompts ¶
func BuiltinPrompts() []PromptTemplate
BuiltinPrompts returns the prompt templates compiled into the binary. These cover common Go conventions and Synapses internals.
func DeduplicatePrompts ¶
func DeduplicatePrompts(templates []PromptTemplate) []PromptTemplate
DeduplicatePrompts removes duplicate IDs, keeping the last occurrence per ID. However, project-scoped prompts (Source == "project") cannot shadow user or builtin prompts — an untrusted project repo must not override user-defined IDs.
func LoadPromptDir ¶
func LoadPromptDir(dir, source string) ([]PromptTemplate, error)
LoadPromptDir reads all .md files from dir and parses them as PromptTemplates. source should be "user" or "project". Non-existent directories are silently skipped (returns nil, nil) so startup never fails on missing directories.
func MatchPrompts ¶
func MatchPrompts(templates []PromptTemplate, file, entity, pkg string) []PromptTemplate
MatchPrompts returns templates whose patterns match the given entity context. A template matches if ALL of its non-empty patterns match the inputs (AND semantics). A template with file_pattern AND entity_pattern only fires when both the file glob and the entity regex both match — not when just one does. Templates with no patterns set (only auto_load) are not returned by this function — use AutoLoadPrompts to retrieve those.