Skip to main content

Crate oxicode_snapcompact

Crate oxicode_snapcompact 

Source
Expand description

Snapcompact — bitmap-frame context compression for vision-capable LLMs.

Ported from omp (MIT) — packages/snapcompact/src/snapcompact.ts. See docs/ref-porter/xai-org-grok-build.md section E2 for design rationale.

§How it works

Instead of asking an LLM to summarize discarded history, snapcompact renders discarded text as dense bitmap frames that vision-capable models read back directly. Local and deterministic — no LLM call, no API key, no latency beyond rendering.

§Scope of this crate

Shape system, conversation serialization, shape selection, and the full text→PNG rasterizer (ported from omp’s pi-natives/src/snapcompact.rs — see the renderer submodule). The renderer uses bundled BDF/HEX bitmap fonts plus the bundled Silver TrueType font for non-Latin glyphs, all under permissive licenses (see NOTICE.md).

compact() always returns real PNG-encoded bytes — there is no “no-op renderer” path. When a frame fails to render, the error is logged via tracing and that frame’s bytes are empty; the caller can decide whether to drop or surface partial results.

Modules§

renderer
Renderer submodule — pi-natives ported text→PNG rasterizer.

Structs§

BoundedSource
The minimal envelope returned by compact when no renderer is available — shape chosen, text chunked into per-frame source ranges, but frame bytes are empty.
CompactOptions
Options for compact.
CompactPreparation
Inputs to a compaction pass.
CompactResult
Outcome of a compaction pass.
FrameRange
Per-frame source range.
FrameRef
A reference to a rendered frame.
Shape
One eval-validated frame shape.

Enums§

Font
Bundled font name.
Variant
Ink variant.

Constants§

SHAPES
Eval-validated shape table. Names match omp’s SHAPE_VARIANTS keys exactly so the Rust and TS registries stay in sync.

Functions§

compact
Run a compaction pass — render each frame slice through the pi-natives ported renderer (render_snapcompact_png) so the returned bytes are real PNG-encoded image data.
normalize
Normalize conversation text for rasterization.
prepare
Render the conversation text into a serializable compact envelope.
resolve_shape
Pick the eval-validated shape for model_id.
serialize_conversation
Compact conversation text to one line per turn.