Libraries/squeeze
squeezeCompress

97% smaller.
100% reversible.

Shrink verbose context without throwing anything away. Content-aware, deterministic compression for JSON, logs, code, and prose — no LLM, no network — and every original restores byte-for-byte from its handle.

$ pip install cendor-squeezeCompress a log live ↓
ingest.pydeterministic · target never exceeded
from cendor.squeeze import compress

small, handle = compress(huge_logs, kind="auto", target_tokens=400)
# ~97% smaller on repetitive logs — detect() routed it to the log compressor

original = handle.expand()      # byte-for-byte, anytime — even next process
assert original == huge_logs    # the original lives in a content-addressed store
How it compresses

Four compressors, routed by content.

compress() looks at the shape of what you hand it and routes it to a specialized compressor — deterministic, no LLM, no network.

Kind
What it does
json
minify + drop nulls; under a budget, shrinks the structure so output stays valid JSON
logs
normalize timestamps/UUIDs/IPs/ids, dedup repeats into "(×N)", chronological order kept
code
strip comments — string-aware, so a // or # inside a literal survives; keeps shebangs and preprocessor lines
prose
extractive sentence ranking (length-normalized), abbreviation-aware splitting

detect() auto-routes by content shape; kind= overrides. target_tokens is a hard ceiling — a final safety pass guarantees it's never exceeded. fidelity = lossless | balanced | aggressive trades structure for size.

Try it

Compress it. Expand it. Diff it.

A repetitive app log, squeezed by the log compressor: timestamps and UUIDs normalized, repeats deduped into (×N), the ERROR kept verbatim — then restored byte-for-byte.

▸ press compress to squeeze the excerpt · then expand to get every byte back

app.log70.4 KB · 3,412 tokens

The original never left — it's in a content-addressed store (in-memory LRU or SQLite), deduped by hash. Persist handle.to_dict() and expand in a different process.

Composes

Plugs into contextkit — without an import.

SqueezeCompressor satisfies core's Compressor protocol by shape, so contextkit's evict="compress" uses it with zero coupling — the contextkit[squeeze] extra. The handle rides the assembly receipt, so a compressed block can always be expanded later.

Honest limits

Where the edges are — by design.

It trades storage for tokens.

squeeze cuts the tokens sent to the model while keeping the full original for byte-exact restore — it does not reduce total storage.

Deterministic, not semantic.

No LLM: the prose compressor is extractive ranking, useful as a rough filter. For meaning-aware summarization, plug your own summarizer into contextkit.

detect() is a heuristic.

Ambiguous content (a bare JSON scalar, colon-heavy prose) can misroute; pass kind= when you know the content type.

Compressed output is for the model, not your parser.

Under a tight budget the compressed form is optimized for token count; parse the original (via expand()), not the squeezed text.

Get started

Send less. Keep everything.

$ pip install cendor-squeeze

squeeze docs → · log-compression cookbook → · composes with the Cendor stack