distill

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanCarriageReturns

func CleanCarriageReturns(s string) string

CleanCarriageReturns resolves in-place line overwrites caused by terminal progress bars (\r). Standard CRLF (\r\n) is normalized to \n. Standalone \r keeps only the last segment before \n.

func ComputeFastHash

func ComputeFastHash(s string) uint64

ComputeFastHash calculates a 64-bit FNV-1a hash of a string.

func ComputeRef

func ComputeRef(s string) string

ComputeRef creates a 12-char SHA-256 ref for a string.

func DeduplicateHistoricalReads

func DeduplicateHistoricalReads(blocks []BlockRecord) ([]string, bool)

DeduplicateHistoricalReads detects identical large blocks (>512 bytes) across turns. The LATEST occurrence of each block is kept 100% intact (active working memory). EARLIER redundant occurrences are replaced with a concise backwards reference.

func DistillDiff

func DistillDiff(s string) (string, bool)

DistillDiff processes git unified diffs: 1. Collapses massive lockfile and minified asset diffs into 1-line semantic summaries. 2. Compacts excessive unchanged context lines (>8 lines) in application code diffs down to 3 lines. 3. Real code modifications are preserved 100% verbatim.

func DistillJSON

func DistillJSON(s string) (string, bool)

DistillJSON applies structural pruning and tabular schema-lifting to JSON strings: 1. Drops null fields, empty arrays/objects, and envelope telemetry. 2. Lifts homogeneous arrays of objects into compact, token-efficient Markdown tables. 3. Emits dense, unindented JSON for non-tabular structures.

func FoldRepeatedLines

func FoldRepeatedLines(s string) string

FoldRepeatedLines folds consecutive identical lines repeated >3 times into a single line with count.

func IsLockfileOrGenerated

func IsLockfileOrGenerated(path string) bool

IsLockfileOrGenerated reports whether a path matches generated files, dependency lockfiles, or minified assets that pollute agent context.

func IsUnifiedDiff

func IsUnifiedDiff(s string) bool

IsUnifiedDiff reports whether text appears to be a unified git diff.

func SanitizeTerminal

func SanitizeTerminal(s string) (string, bool)

SanitizeTerminal runs the full terminal hygiene pipeline: ANSI stripping, progress overwrite resolution, and line folding.

func StripANSI

func StripANSI(s string) string

StripANSI removes ANSI escape codes (CSI, OSC) from a string. Fast path: if no ESC byte (0x1b) is found, returns the input untouched without allocations.

Types

type BlockRecord

type BlockRecord struct {
	TurnIndex int
	Content   string
	Hash      uint64
	Ref       string
}

BlockRecord tracks a large tool content block across conversation turns.

Jump to

Keyboard shortcuts

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