zstdcli

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package zstdcli recovers metadata from zstd-compressed Codex rollout files by shelling out to the `zstd` CLI (https://github.com/facebook/zstd). Like the git and age integrations, cct stays a single, dependency-free binary and reuses a well-known external tool when it is available. Codex writes `.jsonl.zst` files as standard zstd frames, so the stock `zstd -d` reads them.

This package only ever *reads* (decompresses) compressed sessions to recover their session_meta — it never recompresses, rewrites, or modifies them. When `zstd` is not installed, callers fall back to treating compressed sessions as metadata-unknown, exactly as before.

Index

Constants

View Source
const DefaultHeadBytes = 1 << 20 // 1 MiB

DefaultHeadBytes is how many decompressed bytes are enough to recover the session_meta line (the first JSONL record) plus the first user message, without inflating a whole large rollout into memory.

View Source
const MaxDecompressedBytes = 256 << 20

MaxDecompressedBytes caps a full decompression so a small compressed input cannot inflate without bound (a decompression bomb). 256 MiB is far larger than any real session yet keeps memory bounded. See docs/security/audit.md (SEC-2).

Variables

This section is empty.

Functions

func Available

func Available() bool

Available reports whether the `zstd` binary is on PATH.

func Compress

func Compress(plain []byte) ([]byte, error)

Compress compresses plaintext bytes (read from stdin) into a standard zstd frame and returns the compressed bytes. Used to re-pack a compressed session after its metadata was rewritten on import.

func Decompress

func Decompress(compressed []byte) ([]byte, error)

Decompress fully decompresses zstd-compressed bytes (read from stdin) and returns the complete plaintext, up to MaxDecompressedBytes. It is suitable for rewriting a whole compressed session. Output beyond the cap is treated as a decompression bomb and returns an error; a truncated or corrupt frame is also surfaced as an error.

func DecompressHead

func DecompressHead(path string, maxBytes int64) ([]byte, error)

DecompressHead returns up to maxBytes of decompressed output from a zstd-compressed file. It streams `zstd -dc <path>` and stops once it has read enough, so a large rollout is never fully inflated. Truncating the stream early is expected and not treated as an error; an error is returned only when nothing could be decompressed (e.g. the file is not valid zstd).

Types

This section is empty.

Jump to

Keyboard shortcuts

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