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 ¶
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.
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 Compress ¶
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 ¶
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 ¶
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.