Documentation
¶
Index ¶
- func AdaptiveSizes(messages []WindowMessage, budget int) (head, tail int)
- func FormatAnnotations(annotations []*Annotation) string
- func FormatWindow(result *WindowResult) string
- func ShouldApply(messages []WindowMessage, maxTokens int) bool
- func StripAnnotations(content string) string
- type AliasSuggestion
- type Annotation
- type AnnotationManager
- func (am *AnnotationManager) Add(file string, line int, content, annotationType, author string) *Annotation
- func (am *AnnotationManager) BuildContextFromAnnotations(file string) string
- func (am *AnnotationManager) GetAll() []*Annotation
- func (am *AnnotationManager) GetForFile(file string) []*Annotation
- func (am *AnnotationManager) GetUnresolved() []*Annotation
- func (am *AnnotationManager) InjectAnnotations(file, content string) string
- func (am *AnnotationManager) Remove(id string)
- func (am *AnnotationManager) Resolve(id string)
- func (am *AnnotationManager) Summary() string
- type CommandFrequency
- type CommandHistory
- func (ch *CommandHistory) Clear()
- func (ch *CommandHistory) DetectPatterns() []string
- func (ch *CommandHistory) FormatSummary() string
- func (ch *CommandHistory) GetFailing() []CommandRecord
- func (ch *CommandHistory) GetFrequent(limit int) []CommandFrequency
- func (ch *CommandHistory) GetSlow(threshold time.Duration) []CommandRecord
- func (ch *CommandHistory) Record(cmd string, exitCode int, duration time.Duration, output string)
- func (ch *CommandHistory) SearchCommands(query string) []CommandRecord
- func (ch *CommandHistory) SuggestAlias(minCount int) []AliasSuggestion
- type CommandRecord
- type ConversationSummarizer
- func (cs *ConversationSummarizer) CompareMessages(before, after []SumMessage) string
- func (cs *ConversationSummarizer) Detailed(messages []SumMessage) string
- func (cs *ConversationSummarizer) ExtractDecisions(messages []SumMessage) []string
- func (cs *ConversationSummarizer) ExtractFilesDiscussed(messages []SumMessage) []string
- func (cs *ConversationSummarizer) ExtractTopics(messages []SumMessage) []string
- func (cs *ConversationSummarizer) FormatSummary(summary *Summary) string
- func (cs *ConversationSummarizer) GenerateTitle(messages []SumMessage) string
- func (cs *ConversationSummarizer) OneLine(messages []SumMessage) string
- func (cs *ConversationSummarizer) Paragraph(messages []SumMessage) string
- func (cs *ConversationSummarizer) Structured(messages []SumMessage) *Summary
- func (cs *ConversationSummarizer) Summarize(messages []SumMessage, level SummaryLevel) *Summary
- type DistillExample
- type DistillStats
- type DistillationPipeline
- func (dp *DistillationPipeline) Capture(system, user, assistant string, toolCalls []string, quality float64, ...)
- func (dp *DistillationPipeline) Deduplicate()
- func (dp *DistillationPipeline) ExportAnthropicFormat(path string) error
- func (dp *DistillationPipeline) ExportJSONL(path string) error
- func (dp *DistillationPipeline) ExportOpenAI(path string) error
- func (dp *DistillationPipeline) Filter(minQuality float64, tags []string) []DistillExample
- func (dp *DistillationPipeline) FormatStats() string
- func (dp *DistillationPipeline) Load() error
- func (dp *DistillationPipeline) Prune(maxExamples int)
- func (dp *DistillationPipeline) Save() error
- func (dp *DistillationPipeline) Stats() DistillStats
- type FileMentionDetector
- func (d *FileMentionDetector) BuildSuggestion(newFiles []string) string
- func (d *FileMentionDetector) DetectMentions(text string) []string
- func (d *FileMentionDetector) FilterNew(paths []string, alreadyInContext map[string]bool) []string
- func (d *FileMentionDetector) InjectFileMentionContext(text string, messages []types.EyrieMessage) string
- type HeadTailWindow
- type SumMessage
- type Summary
- type SummaryLevel
- type WindowMessage
- type WindowResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdaptiveSizes ¶
func AdaptiveSizes(messages []WindowMessage, budget int) (head, tail int)
AdaptiveSizes dynamically determines head and tail sizes based on token budget. More budget yields a larger tail (recent context matters more). Always returns at least 2 head + 4 tail.
func FormatAnnotations ¶
func FormatAnnotations(annotations []*Annotation) string
FormatAnnotations formats annotations for display.
func FormatWindow ¶
func FormatWindow(result *WindowResult) string
FormatWindow returns a human-readable representation of the window result.
func ShouldApply ¶
func ShouldApply(messages []WindowMessage, maxTokens int) bool
ShouldApply returns true if the total token count of messages exceeds maxTokens, indicating the window strategy should be applied.
func StripAnnotations ¶
StripAnnotations removes all [hawk:*] comment lines from content. Used before commit/save to keep annotations agent-only.
Types ¶
type AliasSuggestion ¶
type AliasSuggestion struct {
Command string `json:"command"`
Alias string `json:"alias"`
Count int `json:"count"`
Reason string `json:"reason"`
}
AliasSuggestion proposes an alias for a frequently used command.
type Annotation ¶
type Annotation struct {
ID string
File string
Line int
Content string
Type string // "note", "todo", "question", "warning", "context"
Author string // "agent", "user"
CreatedAt time.Time
Resolved bool
}
Annotation represents a temporary inline annotation added to a file during agent work.
func DetectAnnotations ¶
func DetectAnnotations(content string) []*Annotation
DetectAnnotations finds existing hawk annotations in file content and parses them.
type AnnotationManager ¶
type AnnotationManager struct {
Annotations map[string][]*Annotation // file → annotations
// contains filtered or unexported fields
}
AnnotationManager manages temporary annotations across files.
func NewAnnotationManager ¶
func NewAnnotationManager() *AnnotationManager
NewAnnotationManager creates a new AnnotationManager.
func (*AnnotationManager) Add ¶
func (am *AnnotationManager) Add(file string, line int, content, annotationType, author string) *Annotation
Add creates a new annotation for the given file and line.
func (*AnnotationManager) BuildContextFromAnnotations ¶
func (am *AnnotationManager) BuildContextFromAnnotations(file string) string
BuildContextFromAnnotations formats annotations for a file for injection into agent context.
func (*AnnotationManager) GetAll ¶
func (am *AnnotationManager) GetAll() []*Annotation
GetAll returns all annotations across all files.
func (*AnnotationManager) GetForFile ¶
func (am *AnnotationManager) GetForFile(file string) []*Annotation
GetForFile returns all annotations for a given file.
func (*AnnotationManager) GetUnresolved ¶
func (am *AnnotationManager) GetUnresolved() []*Annotation
GetUnresolved returns all unresolved annotations.
func (*AnnotationManager) InjectAnnotations ¶
func (am *AnnotationManager) InjectAnnotations(file, content string) string
InjectAnnotations inserts annotation comments into file content at appropriate lines. Annotations are inserted ABOVE the target line using the correct comment syntax based on file extension.
func (*AnnotationManager) Remove ¶
func (am *AnnotationManager) Remove(id string)
Remove deletes an annotation by ID.
func (*AnnotationManager) Resolve ¶
func (am *AnnotationManager) Resolve(id string)
Resolve marks an annotation as resolved.
func (*AnnotationManager) Summary ¶
func (am *AnnotationManager) Summary() string
Summary returns a brief summary of all annotations.
type CommandFrequency ¶
type CommandFrequency struct {
Command string `json:"command"`
Count int `json:"count"`
AvgDuration time.Duration `json:"avg_duration"`
FailRate float64 `json:"fail_rate"`
}
CommandFrequency tracks usage statistics for a command.
type CommandHistory ¶
type CommandHistory struct {
Commands []CommandRecord `json:"commands"`
Patterns map[string]int `json:"patterns"`
Failures map[string]int `json:"failures"`
// contains filtered or unexported fields
}
CommandHistory tracks shell commands executed during sessions and provides insights.
func NewCommandHistory ¶
func NewCommandHistory() *CommandHistory
NewCommandHistory creates a new CommandHistory instance.
func (*CommandHistory) DetectPatterns ¶
func (ch *CommandHistory) DetectPatterns() []string
DetectPatterns analyzes command history for notable patterns and returns insights.
func (*CommandHistory) FormatSummary ¶
func (ch *CommandHistory) FormatSummary() string
FormatSummary returns a formatted string summary of command history.
func (*CommandHistory) GetFailing ¶
func (ch *CommandHistory) GetFailing() []CommandRecord
GetFailing returns commands that frequently fail (exit code != 0).
func (*CommandHistory) GetFrequent ¶
func (ch *CommandHistory) GetFrequent(limit int) []CommandFrequency
GetFrequent returns the most frequently used commands up to limit.
func (*CommandHistory) GetSlow ¶
func (ch *CommandHistory) GetSlow(threshold time.Duration) []CommandRecord
GetSlow returns commands that took longer than the given threshold.
func (*CommandHistory) SearchCommands ¶
func (ch *CommandHistory) SearchCommands(query string) []CommandRecord
SearchCommands returns commands matching the query string.
func (*CommandHistory) SuggestAlias ¶
func (ch *CommandHistory) SuggestAlias(minCount int) []AliasSuggestion
SuggestAlias returns alias suggestions for commands used more than minCount times.
type CommandRecord ¶
type CommandRecord struct {
Command string `json:"command"`
ExitCode int `json:"exit_code"`
Duration time.Duration `json:"duration"`
Output string `json:"output"`
Timestamp time.Time `json:"timestamp"`
SessionID string `json:"session_id"`
WorkDir string `json:"work_dir"`
}
CommandRecord represents a single command execution with metadata.
type ConversationSummarizer ¶
type ConversationSummarizer struct {
// contains filtered or unexported fields
}
ConversationSummarizer produces concise summaries of conversation messages at different granularities for compaction, session titles, and cross-session context.
func NewConversationSummarizer ¶
func NewConversationSummarizer() *ConversationSummarizer
NewConversationSummarizer creates a new ConversationSummarizer.
func (*ConversationSummarizer) CompareMessages ¶
func (cs *ConversationSummarizer) CompareMessages(before, after []SumMessage) string
CompareMessages describes what changed between two message states.
func (*ConversationSummarizer) Detailed ¶
func (cs *ConversationSummarizer) Detailed(messages []SumMessage) string
Detailed produces a full multi-section summary.
func (*ConversationSummarizer) ExtractDecisions ¶
func (cs *ConversationSummarizer) ExtractDecisions(messages []SumMessage) []string
ExtractDecisions identifies key decisions made during the conversation.
func (*ConversationSummarizer) ExtractFilesDiscussed ¶
func (cs *ConversationSummarizer) ExtractFilesDiscussed(messages []SumMessage) []string
ExtractFilesDiscussed identifies files mentioned or modified in the conversation.
func (*ConversationSummarizer) ExtractTopics ¶
func (cs *ConversationSummarizer) ExtractTopics(messages []SumMessage) []string
ExtractTopics identifies what was discussed in the conversation.
func (*ConversationSummarizer) FormatSummary ¶
func (cs *ConversationSummarizer) FormatSummary(summary *Summary) string
FormatSummary formats a Summary into a human-readable string.
func (*ConversationSummarizer) GenerateTitle ¶
func (cs *ConversationSummarizer) GenerateTitle(messages []SumMessage) string
GenerateTitle produces a short title suitable for labeling a session.
func (*ConversationSummarizer) OneLine ¶
func (cs *ConversationSummarizer) OneLine(messages []SumMessage) string
OneLine produces a single concise sentence summarizing the conversation.
func (*ConversationSummarizer) Paragraph ¶
func (cs *ConversationSummarizer) Paragraph(messages []SumMessage) string
Paragraph produces a 3-5 sentence summary covering what happened.
func (*ConversationSummarizer) Structured ¶
func (cs *ConversationSummarizer) Structured(messages []SumMessage) *Summary
Structured produces a Summary with all fields populated.
func (*ConversationSummarizer) Summarize ¶
func (cs *ConversationSummarizer) Summarize(messages []SumMessage, level SummaryLevel) *Summary
Summarize produces a Summary at the requested level from the given messages.
type DistillExample ¶
type DistillExample struct {
ID string `json:"id"`
SystemPrompt string `json:"system_prompt"`
UserMessage string `json:"user_message"`
AssistantResponse string `json:"assistant_response"`
ToolCalls []string `json:"tool_calls,omitempty"`
Quality float64 `json:"quality"`
Model string `json:"model"`
Tokens int `json:"tokens"`
CreatedAt time.Time `json:"created_at"`
Tags []string `json:"tags,omitempty"`
}
DistillExample represents a single successful interaction captured for fine-tuning distillation.
type DistillStats ¶
type DistillStats struct {
TotalExamples int `json:"total_examples"`
AvgQuality float64 `json:"avg_quality"`
ByModel map[string]int `json:"by_model"`
ByTag map[string]int `json:"by_tag"`
TotalTokens int `json:"total_tokens"`
EstimatedCost float64 `json:"estimated_cost"`
}
DistillStats holds aggregate statistics about the distillation pipeline.
type DistillationPipeline ¶
type DistillationPipeline struct {
Examples []DistillExample `json:"examples"`
Dir string `json:"dir"`
TargetModel string `json:"target_model"`
SourceModel string `json:"source_model"`
MinQuality float64 `json:"min_quality"`
// contains filtered or unexported fields
}
DistillationPipeline collects successful interactions as fine-tuning examples to distill expensive model behavior into cheaper models.
func NewDistillationPipeline ¶
func NewDistillationPipeline(dir string) *DistillationPipeline
NewDistillationPipeline creates a new distillation pipeline that stores data in dir.
func (*DistillationPipeline) Capture ¶
func (dp *DistillationPipeline) Capture(system, user, assistant string, toolCalls []string, quality float64, model string)
Capture records a successful interaction as a training example. Only keeps the example if quality >= MinQuality.
func (*DistillationPipeline) Deduplicate ¶
func (dp *DistillationPipeline) Deduplicate()
Deduplicate removes near-duplicate examples (>0.9 similarity based on content hashing and overlap).
func (*DistillationPipeline) ExportAnthropicFormat ¶
func (dp *DistillationPipeline) ExportAnthropicFormat(path string) error
ExportAnthropicFormat exports examples in Anthropic fine-tuning format. Format: {"system":"...","messages":[{"role":"user","content":"..."},{"role":"assistant","content":"..."}]}
func (*DistillationPipeline) ExportJSONL ¶
func (dp *DistillationPipeline) ExportJSONL(path string) error
ExportJSONL exports examples as JSONL format suitable for fine-tuning. Each line: {"messages":[{"role":"system","content":"..."},{"role":"user","content":"..."},{"role":"assistant","content":"..."}]}
func (*DistillationPipeline) ExportOpenAI ¶
func (dp *DistillationPipeline) ExportOpenAI(path string) error
ExportOpenAI exports examples in OpenAI fine-tuning format. Format: {"messages":[{"role":"system","content":"..."},{"role":"user","content":"..."},{"role":"assistant","content":"..."}]}
func (*DistillationPipeline) Filter ¶
func (dp *DistillationPipeline) Filter(minQuality float64, tags []string) []DistillExample
Filter returns examples matching the given minimum quality and any of the specified tags. If tags is empty, only quality filtering is applied.
func (*DistillationPipeline) FormatStats ¶
func (dp *DistillationPipeline) FormatStats() string
FormatStats returns a human-readable summary of the distillation pipeline.
func (*DistillationPipeline) Load ¶
func (dp *DistillationPipeline) Load() error
Load restores the pipeline state from disk.
func (*DistillationPipeline) Prune ¶
func (dp *DistillationPipeline) Prune(maxExamples int)
Prune keeps only the top N examples by quality, discarding the rest.
func (*DistillationPipeline) Save ¶
func (dp *DistillationPipeline) Save() error
Save persists the pipeline state to disk.
func (*DistillationPipeline) Stats ¶
func (dp *DistillationPipeline) Stats() DistillStats
Stats computes aggregate statistics about the distillation pipeline.
type FileMentionDetector ¶
type FileMentionDetector struct {
// contains filtered or unexported fields
}
FileMentionDetector scans LLM response text for file path mentions, validates them against the filesystem, and suggests additions to context.
func NewFileMentionDetector ¶
func NewFileMentionDetector(projectRoot string) *FileMentionDetector
NewFileMentionDetector creates a new detector rooted at the given project directory.
func (*FileMentionDetector) BuildSuggestion ¶
func (d *FileMentionDetector) BuildSuggestion(newFiles []string) string
BuildSuggestion formats a human-readable suggestion message listing the given files that are mentioned but not yet in context.
func (*FileMentionDetector) DetectMentions ¶
func (d *FileMentionDetector) DetectMentions(text string) []string
DetectMentions scans the given text for file paths, validates them on disk (relative to projectRoot), and returns a deduplicated list of valid paths.
func (*FileMentionDetector) FilterNew ¶
func (d *FileMentionDetector) FilterNew(paths []string, alreadyInContext map[string]bool) []string
FilterNew removes paths that are already present in the context map.
func (*FileMentionDetector) InjectFileMentionContext ¶
func (d *FileMentionDetector) InjectFileMentionContext(text string, messages []types.EyrieMessage) string
InjectFileMentionContext detects file mentions in the given text, filters out files already discussed in the message history, and returns a system context string if new files are found. Returns "" if none.
type HeadTailWindow ¶
type HeadTailWindow struct {
HeadSize int
TailSize int
MaxTokens int
IncludeSummary bool
// contains filtered or unexported fields
}
HeadTailWindow implements a context window strategy that keeps the first N and last M messages, dropping the middle. Inspired by autogen's HeadAndTailChatCompletionContext.
func NewHeadTailWindow ¶
func NewHeadTailWindow(headSize, tailSize, maxTokens int) *HeadTailWindow
NewHeadTailWindow creates a new HeadTailWindow with the given sizes. If headSize <= 0, defaults to 4. If tailSize <= 0, defaults to 12. maxTokens sets the token budget; if <= 0, no token limit is enforced.
func (*HeadTailWindow) Apply ¶
func (w *HeadTailWindow) Apply(messages []WindowMessage) *WindowResult
Apply keeps the first HeadSize messages and last TailSize messages, dropping the middle. If IncludeSummary is true, a brief summary of dropped messages is generated. The result is verified to fit within MaxTokens.
type SumMessage ¶
SumMessage represents a single message in the conversation for summarization.
type Summary ¶
type Summary struct {
Level string
Content string
Topics []string
Decisions []string
FilesDiscussed []string
ToolsUsed map[string]int
TokensSaved int
}
Summary holds a structured summary of a conversation at the requested level.
type SummaryLevel ¶
type SummaryLevel string
SummaryLevel defines the granularity of a conversation summary.
const ( // SummaryOneLine produces a single concise sentence. SummaryOneLine SummaryLevel = "one_line" // SummaryParagraph produces a 3-5 sentence overview. SummaryParagraph SummaryLevel = "paragraph" // SummaryDetailed produces a full multi-section summary. SummaryDetailed SummaryLevel = "detailed" // SummaryStructured populates all fields of a Summary struct. SummaryStructured SummaryLevel = "structured" )
type WindowMessage ¶
WindowMessage represents a single message in the context window.
func PreserveToolPairs ¶
func PreserveToolPairs(messages []WindowMessage, head, tail int) ([]WindowMessage, int)
PreserveToolPairs ensures tool_use and tool_result messages stay together by adjusting window boundaries so pairs are not split. Returns the adjusted messages and number of extra messages included to preserve pairs.
type WindowResult ¶
type WindowResult struct {
Head []WindowMessage
Tail []WindowMessage
Dropped int
Summary string
TotalTokens int
}
WindowResult holds the result of applying the head-tail window strategy.