Versions in this module Expand all Collapse all v1 v1.5.0 Apr 2, 2026 Changes in this version + func DefaultGoals() map[GoalType]Goal + func RegisterAdvancedLayers(registry *LayerRegistry) + func RegisterDefaultLayers(registry *LayerRegistry) + func RegisterFinalLayers(registry *LayerRegistry) + type AnalyzeResult struct + FilteredItems int + Items []ContextItem + RelevanceAvg float64 + TotalItems int + type AttentionSinkLayer struct + func NewAttentionSinkLayer() *AttentionSinkLayer + func (l *AttentionSinkLayer) Apply(content string) (string, int) + func (l *AttentionSinkLayer) Name() string + func (l *AttentionSinkLayer) ShouldApply(contentType string) bool + type AttributionLayer struct + func NewAttributionLayer() *AttributionLayer + func (l *AttributionLayer) Apply(content string) (string, int) + func (l *AttributionLayer) Name() string + func (l *AttributionLayer) ShouldApply(contentType string) bool + type BudgetConfig struct + MaxTokens int + Mode BudgetMode + PreserveRatio float64 + func DefaultBudgetConfig() BudgetConfig + type BudgetEnforcer struct + func NewBudgetEnforcer(config BudgetConfig) *BudgetEnforcer + func (be *BudgetEnforcer) Check(content string) BudgetStatus + func (be *BudgetEnforcer) Enforce(content string) (string, EnforceResult) + type BudgetLayer struct + func NewBudgetLayer(maxTokens int) *BudgetLayer + func (l *BudgetLayer) Apply(content string) (string, int) + func (l *BudgetLayer) Name() string + func (l *BudgetLayer) ShouldApply(contentType string) bool + type BudgetMode int + const BudgetModeAdaptive + const BudgetModeSoft + const BudgetModeStrict + type BudgetStatus struct + CurrentTokens int + Exceeded bool + MaxTokens int + PercentUsed float64 + RemainingTokens int + type CodeFoldLayer struct + func NewCodeFoldLayer() *CodeFoldLayer + func (l *CodeFoldLayer) Apply(content string) (string, int) + func (l *CodeFoldLayer) Name() string + func (l *CodeFoldLayer) ShouldApply(contentType string) bool + type CodeFoldLayer22 struct + func NewCodeFoldLayer22() *CodeFoldLayer22 + func (l *CodeFoldLayer22) Apply(content string) (string, int) + func (l *CodeFoldLayer22) Name() string + func (l *CodeFoldLayer22) ShouldApply(contentType string) bool + type CommentRemovalLayer struct + func NewCommentRemovalLayer() *CommentRemovalLayer + func (l *CommentRemovalLayer) Apply(content string) (string, int) + func (l *CommentRemovalLayer) Name() string + func (l *CommentRemovalLayer) ShouldApply(contentType string) bool + type CommentRemovalLayer24 struct + func NewCommentRemovalLayer24() *CommentRemovalLayer24 + func (l *CommentRemovalLayer24) Apply(content string) (string, int) + func (l *CommentRemovalLayer24) Name() string + func (l *CommentRemovalLayer24) ShouldApply(contentType string) bool + type CompressionInfo struct + CompressedSize int + OriginalSize int + Regions int + Saved int + type ContextItem struct + Content string + LineNum int + Priority float64 + Relevance float64 + Source string + type ContrastiveLayer struct + func NewContrastiveLayer() *ContrastiveLayer + func (l *ContrastiveLayer) Apply(content string) (string, int) + func (l *ContrastiveLayer) Name() string + func (l *ContrastiveLayer) ShouldApply(contentType string) bool + type CostTracker struct + func NewCostTracker() *CostTracker + func (t *CostTracker) GetCostByModel() map[string]float64 + func (t *CostTracker) GetCostByProvider() map[string]float64 + func (t *CostTracker) GetTotalCost() float64 + func (t *CostTracker) GetTurns(limit int) []TurnRecord + func (t *CostTracker) RecordTurn(cmd string, inputTokens, outputTokens int, cost float64, ...) + type DupDetector struct + func NewDupDetector(window time.Duration) *DupDetector + func (d *DupDetector) Cleanup() + func (d *DupDetector) GetDuplicates() []*DupEntry + func (d *DupDetector) Record(command string, tokens int) *DupEntry + type DupEntry struct + Command string + Count int + FirstSeen time.Time + LastSeen time.Time + TotalTokens int + type EnforceResult struct + FinalTokens int + OriginalTokens int + ReductionMethod string + StagesApplied []string + Warning string + WasEnforced bool + func (er EnforceResult) ReductionPercent() float64 + func (er EnforceResult) TokensSaved() int + type EntropyConfig struct + HighEntropyThresh float64 + LowEntropyThresh float64 + MinRepeat int + WindowSize int + func DefaultEntropyConfig() EntropyConfig + type EntropyFilter struct + func NewEntropyFilter(config EntropyConfig) *EntropyFilter + func (f *EntropyFilter) Analyze(content string) []Region + func (f *EntropyFilter) Compress(content string) (string, CompressionInfo) + func (f *EntropyFilter) FindDuplicates(content string) map[string][]int + func (f *EntropyFilter) GetStats(content string) EntropyStats + type EntropyStats struct + AvgEntropy float64 + DuplicateHashes int + HighEntropyPct float64 + LowEntropyPct float64 + type EntropyType int + const HighEntropy + const LowEntropy + const MediumEntropy + type FilterInfo struct + FilteredSize int + HighEntropyLines int + OriginalSize int + Perplexity float64 + func (f FilterInfo) ReductionPercent() float64 + type FinalPassLayer struct + func NewFinalPassLayer() *FinalPassLayer + func (l *FinalPassLayer) Apply(content string) (string, int) + func (l *FinalPassLayer) Name() string + func (l *FinalPassLayer) ShouldApply(contentType string) bool + type Goal struct + Keywords []string + PriorityMap map[string]float64 + Type GoalType + type GoalAnalyzer struct + func NewGoalAnalyzer(goal Goal) *GoalAnalyzer + func (a *GoalAnalyzer) Analyze(content string, source string) AnalyzeResult + func (a *GoalAnalyzer) ExtractRelevant(content string, source string) string + func (a *GoalAnalyzer) RankFiles(files map[string]string) []RankedFile + type GoalType int + const GoalDebug + const GoalDocument + const GoalOptimize + const GoalRefactor + const GoalReview + const GoalSearch + const GoalTest + const GoalUnderstand + func GetGoalFromQuery(query string) GoalType + type HeavyHitterLayer struct + func NewHeavyHitterLayer() *HeavyHitterLayer + func (l *HeavyHitterLayer) Apply(content string) (string, int) + func (l *HeavyHitterLayer) Name() string + func (l *HeavyHitterLayer) ShouldApply(contentType string) bool + type ImportCollapseLayer struct + func NewImportCollapseLayer() *ImportCollapseLayer + func (l *ImportCollapseLayer) Apply(content string) (string, int) + func (l *ImportCollapseLayer) Name() string + func (l *ImportCollapseLayer) ShouldApply(contentType string) bool + type ImportCollapseLayer23 struct + func NewImportCollapseLayer23() *ImportCollapseLayer23 + func (l *ImportCollapseLayer23) Apply(content string) (string, int) + func (l *ImportCollapseLayer23) Name() string + func (l *ImportCollapseLayer23) ShouldApply(contentType string) bool + type KGNode struct + Content string + ID string + Related []string + Type string + type KnowledgeGraphLayer struct + func NewKnowledgeGraphLayer() *KnowledgeGraphLayer + func (l *KnowledgeGraphLayer) Apply(content string) (string, int) + func (l *KnowledgeGraphLayer) Name() string + func (l *KnowledgeGraphLayer) ShouldApply(contentType string) bool + type LLMCompactionLayer struct + func NewLLMCompactionLayer() *LLMCompactionLayer + func (l *LLMCompactionLayer) Apply(content string) (string, int) + func (l *LLMCompactionLayer) Name() string + func (l *LLMCompactionLayer) ShouldApply(contentType string) bool + type Layer interface + Apply func(content string) (string, int) + Name func() string + ShouldApply func(contentType string) bool + type LayerRegistry struct + func NewLayerRegistry() *LayerRegistry + func (r *LayerRegistry) Apply(content string, contentType string) (string, int) + func (r *LayerRegistry) GetLayers() []Layer + func (r *LayerRegistry) Register(layer Layer) + type LazyPrunerLayer struct + func NewLazyPrunerLayer() *LazyPrunerLayer + func (l *LazyPrunerLayer) Apply(content string) (string, int) + func (l *LazyPrunerLayer) Name() string + func (l *LazyPrunerLayer) ShouldApply(contentType string) bool + type LineScore struct + Entropy EntropyType + Line int + Perplexity float64 + Text string + type LiveCommand struct + Command string + InputTokens int + OutputTokens int + PID int + SavedTokens int + StartedAt time.Time + Status string + type LiveMonitor struct + func NewLiveMonitor() *LiveMonitor + func (m *LiveMonitor) Cleanup(maxAge time.Duration) + func (m *LiveMonitor) EndCommand(pid int, inputTokens, outputTokens int) + func (m *LiveMonitor) GetActive() []*LiveCommand + func (m *LiveMonitor) GetRecent(n int) []*LiveCommand + func (m *LiveMonitor) StartCommand(pid int, cmd string) + type MetaTokenLZ77Layer struct + func NewMetaTokenLZ77Layer() *MetaTokenLZ77Layer + func (l *MetaTokenLZ77Layer) Apply(content string) (string, int) + func (l *MetaTokenLZ77Layer) Name() string + func (l *MetaTokenLZ77Layer) ShouldApply(contentType string) bool + type NGramModel struct + func NewNGramModel() *NGramModel + func PretrainedModel() *NGramModel + func (m *NGramModel) Perplexity(text string) float64 + func (m *NGramModel) Train(text string) + type NgramDeduplicationLayer struct + func NewNgramDeduplicationLayer() *NgramDeduplicationLayer + func (l *NgramDeduplicationLayer) Apply(content string) (string, int) + func (l *NgramDeduplicationLayer) Name() string + func (l *NgramDeduplicationLayer) ShouldApply(contentType string) bool + type PerplexityConfig struct + MaxNgram int + MinLength int + Threshold float64 + UseGPU bool + func DefaultPerplexityConfig() PerplexityConfig + type PerplexityFilter struct + func NewPerplexityFilter(config PerplexityConfig) *PerplexityFilter + func (f *PerplexityFilter) AnalyzeLines(content string) []LineScore + func (f *PerplexityFilter) BatchProcess(documents []string) []FilterInfo + func (f *PerplexityFilter) Filter(content string) (string, FilterInfo) + func (f *PerplexityFilter) Score(content string) ScoreResult + func (f *PerplexityFilter) TrainOnCorpus(samples []string) + type PrecisionLayer struct + func NewPrecisionLayer() *PrecisionLayer + func (l *PrecisionLayer) Apply(content string) (string, int) + func (l *PrecisionLayer) Name() string + func (l *PrecisionLayer) ShouldApply(contentType string) bool + type PromptDebugger struct + func NewPromptDebugger(dir string) *PromptDebugger + func (d *PromptDebugger) CompressionRatio(record PromptRecord) float64 + func (d *PromptDebugger) List(limit int) ([]PromptRecord, error) + func (d *PromptDebugger) Save(record PromptRecord) error + type PromptRecord struct + Command string + CompressedPrompt string + Duration time.Duration + InputTokens int + Model string + OutputTokens int + RawPrompt string + Timestamp time.Time + type RankedFile struct + Content string + Path string + Relevance float64 + Score float64 + type Region struct + Content string + End int + Entropy float64 + EntropyType EntropyType + Start int + type RepetitionLayer struct + func NewRepetitionLayer() *RepetitionLayer + func (l *RepetitionLayer) Apply(content string) (string, int) + func (l *RepetitionLayer) Name() string + func (l *RepetitionLayer) ShouldApply(contentType string) bool + type ScoreResult struct + Confidence float64 + EntropyType EntropyType + Perplexity float64 + ShouldKeep bool + type SemanticAnchorLayer struct + func NewSemanticAnchorLayer() *SemanticAnchorLayer + func (l *SemanticAnchorLayer) Apply(content string) (string, int) + func (l *SemanticAnchorLayer) Name() string + func (l *SemanticAnchorLayer) ShouldApply(contentType string) bool + type SemanticChunkLayer struct + func NewSemanticChunkLayer() *SemanticChunkLayer + func (l *SemanticChunkLayer) Apply(content string) (string, int) + func (l *SemanticChunkLayer) Name() string + func (l *SemanticChunkLayer) ShouldApply(contentType string) bool + type SemanticSimilarityLayer struct + func NewSemanticSimilarityLayer() *SemanticSimilarityLayer + func (l *SemanticSimilarityLayer) Apply(content string) (string, int) + func (l *SemanticSimilarityLayer) Name() string + func (l *SemanticSimilarityLayer) ShouldApply(contentType string) bool + type SessionInfo struct + Agent string + CommandCount int + ID string + LastActive time.Time + StartedAt time.Time + TokensSaved int + type SessionTracker struct + func NewSessionTracker() *SessionTracker + func (s *SessionTracker) GetActiveSessions() []*SessionInfo + func (s *SessionTracker) GetAdoptionRate() float64 + func (s *SessionTracker) GetAllSessions() []*SessionInfo + func (s *SessionTracker) RecordCommand(id string, tokensSaved int) + func (s *SessionTracker) StartSession(id, agent string) + type Sketch struct + FullHash string + Key string + Summary string + type SketchStoreLayer struct + func NewSketchStoreLayer() *SketchStoreLayer + func (l *SketchStoreLayer) Apply(content string) (string, int) + func (l *SketchStoreLayer) Name() string + func (l *SketchStoreLayer) ShouldApply(contentType string) bool + type StringInternLayer struct + func NewStringInternLayer() *StringInternLayer + func (l *StringInternLayer) Apply(content string) (string, int) + func (l *StringInternLayer) Name() string + func (l *StringInternLayer) ShouldApply(contentType string) bool + type TruncateLayer struct + func NewTruncateLayer() *TruncateLayer + func (l *TruncateLayer) Apply(content string) (string, int) + func (l *TruncateLayer) Name() string + func (l *TruncateLayer) ShouldApply(contentType string) bool + type TurnRecord struct + Command string + Cost float64 + InputTokens int + Model string + OutputTokens int + Provider string + Timestamp time.Time + type URLLayer struct + func NewURLLayer() *URLLayer + func (l *URLLayer) Apply(content string) (string, int) + func (l *URLLayer) Name() string + func (l *URLLayer) ShouldApply(contentType string) bool + type WhitespaceLayer struct + func NewWhitespaceLayer() *WhitespaceLayer + func (l *WhitespaceLayer) Apply(content string) (string, int) + func (l *WhitespaceLayer) Name() string + func (l *WhitespaceLayer) ShouldApply(contentType string) bool v0 v0.28.0 Apr 16, 2026 Changes in this version + func EstimateTokensFast(text string) int v0.1.0 Apr 6, 2026 Changes in this version + var CommonModelPricing = map[string]ModelPricing + func CalculateSavings(tokensSaved int, model string) float64 + func CalculateTokensSaved(original, filtered string) int + func EstimateTokens(text string) int + func RegisterModelPricing(model string, input, output float64) + func WarmupBPETokenizer() + type BPETokenizer struct + func (b *BPETokenizer) Count(text string) int + type CommandRunner interface + LookPath func(name string) (string, error) + Run func(ctx context.Context, args []string) (output string, exitCode int, err error) + type DiscoverAnalyzer struct + func NewDiscoverAnalyzer() *DiscoverAnalyzer + func (d *DiscoverAnalyzer) Analyze(command string) []MissedSaving + func (d *DiscoverAnalyzer) AnalyzeBatch(commands []string) []MissedSaving + type MissedSaving struct + Command string + EstSavings int + EstTokens int + Reason string + Suggestion string + type ModelPricing struct + InputPerMillion float64 + Model string + OutputPerMillion float64 + func GetModelPricing(model string) ModelPricing + type OSCommandRunner struct + Env []string + func NewOSCommandRunner() *OSCommandRunner + func (r *OSCommandRunner) LookPath(name string) (string, error) + func (r *OSCommandRunner) Run(ctx context.Context, args []string) (string, int, error)