dsh-cc/dsh-cc--packages-context-context-crusher ↗★ 1

@dsh-cc/context-crusher

可逆压缩大型工具输出,缓存原文并通过 context_retrieve 还原。 适合需压缩 grep 或日志输出又保留原文可取的开发者。

包名
@dsh-cc/context-crusher
兼容性
待验证
Harness 依赖范围
>=0.1.5-rc.1
Cordis 依赖范围
>=0.1.5-rc.1
版本
0.7.1
许可证
Apache-2.0
最近更新
2026年9月16日

安装

此插件尚未提供可验证的 bundle,或兼容性检查未通过。请先阅读仓库说明。 阅读完整 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

  1. tools/post-execute fires; the crusher is the OUTERMOST listener ({ prepend: true }, mounted before the hooks bridge) and composes post-next().
  2. A non-accept downstream decision passes through untouched.
  3. 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.

KeyDefaultMeaning
enabledfalseMaster flag; the feature is opt-in.
modedry-rundry-run measures only; on replaces.
min-bytes8192Minimum size before eligibility (token-meter tokens; the key keeps its legacy name).
min-savings-ratio0.4Minimum token saving fraction.
protected-toolsover-inclusive default listTools never crushed.

Caveats

  • The transcript keeps the COMPRESSED form forever: TUI replay and command-export show the compressed blob (the original lives only in the store + ledger).
  • final-result dispatches and tool-definition finalizeContent bypass 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.