compression

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package compression implements the file-read compression pipeline that produces a token-optimized rendering of a file given Grove's symbols and the current session state.

Index

Constants

View Source
const MaxTokensPerFile = 50000

MaxTokensPerFile caps the size of any single compressed file response.

Variables

This section is empty.

Functions

func Hash

func Hash(content string) string

Hash returns the SHA-256 hex of content. Used as the cache key.

Types

type Options

type Options struct {
	Task            string
	Symbols         []grove.SymbolRecord // symbols in this file (from Grove)
	Session         *session.Tracker
	Ledger          *session.Ledger
	TokenLedgerName string // tool name to bill ledger ("prism_read")
	Confidence      session.Confidence
	Embeddings      ranking.SemanticBackend // optional; nil → no semantic signal
}

CompressFileRead produces a fidelity-appropriate rendering of a file based on the symbols Grove has indexed for it, the current task, and the session state.

The "task" is optional context for ranking; if empty, all symbols are treated as equally relevant.

type Result

type Result struct {
	FilePath        string
	Content         string
	Strategy        string // "full-fresh" | "compressed-fresh" | "session-reference" | "session-signature" | "escalated-full"
	OriginalTokens  int
	DeliveredTokens int
	SavingsPercent  float64
}

Result is the output of CompressFileRead.

func CompressFileRead

func CompressFileRead(filePath, content string, opts Options) Result

CompressFileRead returns the rendered output and ledger metadata.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL