dsh-cc/dsh-cc--packages-context-context-crusher ↗★ 1
@dsh-cc/context-crusher
CCR reversible tool-output compression: compress large grep/log tool results, cache the original, retrieve it via context_retrieve 适合需压缩 grep 或日志输出又保留原文可取的开发者。
インストール
検証済み bundle がないか、互換性チェックに失敗しています。先にリポジトリの説明を読んでください。 README 全文を読む ↗
ドキュメント
README 全文を読む ↗@dsh-cc/context-crusher
English | 中文
CCR (Compress-Cache-Retrieve) reversible tool-output compression. A tools/post-execute listener compresses large grep/log-shaped tool results, caches the original in a content-addressed store, and appends a ccr:// marker; the context_retrieve({ hash }) tool restores the original verbatim. Compression is risk-free because the original is always one call away.
Gated flow
tools/post-executefires; the crusher is the OUTERMOST listener ({ prepend: true }, mounted before the hooks bridge) and composes post-next().- A non-
acceptdownstream decision passes through untouched. - Gates, in order: disabled → protected tool (replace-semantics list) → short error (]
— appended to every replaced result. Thecontext_retrievetool description references the sameccr://spelling; a test pins the pairing.hashissha256(original utf8)` hex, first 16 chars.
Store
$DSH_HOME/ccr/ /, projectKey = sha256(session cwd) first 16 hex (the worktree-path divergence from the TUI project-root convention is accepted: the store is self-consistent). Atomic temp+rename writes, plain UTF-8 envelope files, LRU 200 entries, TTL 3600 s, sweep-on-write (fire-and-forget). Corrupt/expired entries fail closed (corrupt / expired / unknown_hash).
Config
Namespace cc-context-compression (settings overlay re-read on every use; config defaults under it). protected-tools REPLACES the default list when explicitly set — not a union.
| Key | Default | Meaning |
|---|---|---|
enabled | false | Master flag; the feature is opt-in. |
mode | dry-run | dry-run measures only; on replaces. |
min-bytes | 8192 | Minimum size before eligibility (token-meter tokens; the key keeps its legacy name). |
min-savings-ratio | 0.4 | Minimum token saving fraction. |
protected-tools | over-inclusive default list | Tools never crushed. |
Caveats
- The transcript keeps the COMPRESSED form forever: TUI replay and
command-exportshow the compressed blob (the original lives only in the store + ledger). final-resultdispatches and tool-definitionfinalizeContentbypass or follow the waterfall and may rewrite crushed content — residual bypass classes, best-effort coverage.- The marker is inert text; there is no auto-restore and no model-summarization.