giter00/dsh-headroom0

dsh-headroom

Headroom-inspired automatic context compression plugin for DeepSeek Harness (dsh): compresses tool outputs before they reach the model and keeps every lossy compression reversible via CCR retrieval tools.

包名
dsh-headroom
版本
0.1.0
许可证
MIT
最近更新
2026年8月16日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:giter00/dsh-headroom

压力测试配置(更激进,用于验证压缩器上限)

node scripts/verify-compress.mjsminChars=120, maxRows=40, maxCellChars=80, maxTextChars=400 下的结果:

样本类型压缩前(字符)压缩后(字符)节省
JSON 数组 200 行json62 4919 30285.1%
grep 结果 270 条search10 7724 60357.3%
日志 180 行log3 9091 12571.2%
CSV 201 行tabular19 8143 02984.7%
长文本 400 段text29 50654698.1%
代码code4934930%(故意不压)
短文本text19190%(未达阈值)

token 估算:脚本按 chars / 4 粗估,实际 token 与模型 tokenizer 相关。 所有有损压缩均保存原文,headroom_retrieve 可精确取回。

默认配置

默认配置更保守(minChars=600, maxRows=80, maxCellChars=200, maxTextChars=2400):

样本类型节省
JSON 数组 200 行json65.6%
grep 结果 90 条search41.3%
日志 180 行log56.8%
CSV 201 行tabular59.8%
长文本 400 段text94.7%

配置

在 profile 的 cordis.patch.yml(或 --patch 覆盖层)中可覆盖默认配置:

- id: dsh-headroom
  config:
    enabled: true
    minChars: 600
    maxRows: 80
    maxCellChars: 200
    maxSearchMatchesPerFile: 60
    maxLogLines: 80
    maxTextChars: 2400
    maxTabularLines: 80
    excludeTools: []
    includeErrors: false
    ccr:
      enabled: true
      persist: true
      ttlMs: 86400000
      maxEntries: 2000
字段默认值说明
enabledtrue总开关
minChars600文本块至少多少字符才考虑压缩
maxRows80JSON 透视保留的最大行数
maxCellChars200JSON/search 单元格字符串截断长度
maxSearchMatchesPerFile60每个文件保留的搜索命中数
maxLogLines80日志保留的首尾行数
maxTextChars2400长文本首尾保留字符数
maxTabularLines80表格保留的首尾行数
excludeTools[]* 通配符;命中的工具不压缩
includeErrorsfalse是否压缩工具错误输出
ccr.enabledtrue关闭后不进行有损压缩
ccr.persisttrue是否持久化 CCR store
ccr.ttlMs86400000原始内容保留时长(毫秒)
ccr.maxEntries2000内存/持久化 store 最大条目数