Documentation
¶
Overview ¶
Package prompts manages workspace context for hawk sessions. This file implements auto-accumulation of learnings into Hawk user state.
Index ¶
- func BuildSubAgentPrompt(ctx PromptContext) (string, error)
- func BuildSystemPrompt(ctx PromptContext) (string, error)
- func ExtractPattern(toolName string, filePath string, diff string) string
- func ListTemplates() []string
- func LoadTemplate(name string) (string, error)
- type AgentsAccumulator
- type Learning
- type PromptContext
- type WorkspaceContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildSubAgentPrompt ¶
func BuildSubAgentPrompt(ctx PromptContext) (string, error)
BuildSubAgentPrompt assembles the sub-agent variant of the system prompt.
func BuildSystemPrompt ¶
func BuildSystemPrompt(ctx PromptContext) (string, error)
BuildSystemPrompt assembles the main template sections into a complete system prompt. It checks Hawk user config first for user overrides, then falls back to embedded templates.
func ExtractPattern ¶
ExtractPattern analyzes a successful edit and extracts a reusable pattern. This is a simple heuristic - in practice, the LLM would generate this.
func ListTemplates ¶
func ListTemplates() []string
ListTemplates returns all available template names from the embedded templates.
func LoadTemplate ¶
LoadTemplate loads a single template by name. It checks Hawk user config prompts first, then falls back to embedded.
Types ¶
type AgentsAccumulator ¶
type AgentsAccumulator struct {
// contains filtered or unexported fields
}
AgentsAccumulator captures learnings from successful edits and appends them to user state for future sessions to benefit from.
func NewAgentsAccumulator ¶
func NewAgentsAccumulator(projectDir string) *AgentsAccumulator
NewAgentsAccumulator creates an accumulator for the given project directory.
func (*AgentsAccumulator) Flush ¶
func (a *AgentsAccumulator) Flush() error
Flush writes all buffered learnings to Hawk user state.
func (*AgentsAccumulator) ForPrompt ¶
func (a *AgentsAccumulator) ForPrompt(maxEntries int) string
ForPrompt returns the accumulated learnings formatted for injection into the system prompt. Returns empty string if no learnings exist.
type Learning ¶
type Learning struct {
Timestamp time.Time
Context string // what was being done
Pattern string // what was learned
Files []string // files involved
}
Learning represents a captured insight from the current session.
type PromptContext ¶
type PromptContext struct {
Date string
WorkDir string
OS string
Shell string
Model string
Provider string
GitBranch string
GitStatus string
RecentCommits string
TopFiles string
MaxTurns int
Task string
}
PromptContext holds the variables available to prompt templates.
func DefaultContext ¶
func DefaultContext() PromptContext
DefaultContext builds a PromptContext from the current environment.
type WorkspaceContext ¶
type WorkspaceContext struct {
GitBranch string
GitStatus string // short status (modified files)
RecentCommits []string // last 5 commit onelines
TopFiles []string // top-level files/dirs
Language string // detected primary language
ChangedFiles []string // files with uncommitted changes (for change-set context)
}
WorkspaceContext gathers git and project info for prompt injection.
func GatherWorkspaceContext ¶
func GatherWorkspaceContext(dir string) *WorkspaceContext
GatherWorkspaceContext collects workspace info from the given directory. It uses the filesystem for top-level files and detects language from extensions. It uses git commands for branch, status, and recent commits.
func (*WorkspaceContext) Format ¶
func (w *WorkspaceContext) Format() string
Format returns the workspace context as a prompt section.