giter00/dsh-headroom
工具输出在进入模型之前先被压缩:JSON、搜索、日志、表格与长文本各自走专用压缩器; 所有有损压缩都会把原文存入本地 CCR store,并在压缩结果里注入一个短 marker, 模型需要精确原文时调用 headroomretrieve(id=…) 即可逐字节取回。
catalog descriptioncatalog 简介 / catalog description:deepSeek harness上下文压缩工具
Project Overview项目介绍
This is a native DeepSeek Harness plugin that automatically compresses tool output context before it is saved to the agent's session history. It hooks into DSH's tools/post-execute event, runs after tool execution completes and before results are finalized. It sorts output into different content types and routes each to a dedicated compressor. All lossy compression saves the full original output to a local CCR store and injects a marker into the compressed result. When the agent needs the full original content, it can call the headroom_retrieve tool with the provided ID to get the exact original bytes back.
It includes custom compression strategies for JSON, search output, logs, tables, long text, code, and file tools. By default, it skips compression for code and file tool outputs to preserve patchability and line number accuracy. For long text, it uses a Kompress-style word-level scoring pipeline that forces retention of semantically critical tokens like paths, numbers, and flags. Users can configure it to use a head-tail truncation fallback for text, or enable the official ONNX-formatted Kompress-v2-base model for ML-powered scoring. It also ships three extra tools for manual use.
The plugin runs entirely on JavaScript and Node.js built-in modules by default, so it has no native compilation dependencies and works across Windows, macOS, and Linux. To use the official ONNX model, you need to install two optional dependencies: onnxruntime-node and @huggingface/transformers. If the dependencies or model are missing, the plugin automatically falls back to a deterministic heuristic scorer and issues a warning. DSH users can install it directly via the DSH plugin manager with no extra build steps. It is released under the open-source Apache-2.0 license.
这是专为 DeepSeek Harness 开发的原生上下文自动压缩插件,设计思路参考开源 Headroom 项目。插件挂载到 DSH 的 tools/post-execute 钩子,在工具执行完成后、结果存入会话上下文之前,对工具输出分类路由并调用专用压缩器处理。所有有损压缩都会将原文存入本地 CCR 存储,并在压缩结果中注入标记,模型需要完整原文时可调用 headroom_retrieve 工具逐字节取回。
它针对 JSON、搜索结果、日志、表格、长文本、代码等不同内容类型提供了定制压缩策略,默认对代码和文件工具输出不压缩。长文本默认采用 Kompress 风格逐词评分压缩,语义关键内容强制保留,支持切换为头尾截断策略,也可启用真实的 ONNX 格式 Kompress-v2-base 模型做评分。还提供了 headroom_stats 查看压缩统计、headroom_compress 压缩任意自定义文本。
默认配置下仅依赖纯 JavaScript 和 Node 内置模块,无原生编译依赖,跨 Windows、macOS、Linux 全平台可用。启用真实 ONNX 模型压缩需要额外安装 onnxruntime-node 和 @huggingface/transformers,未安装或模型缺失时自动回退到启发式压缩。项目采用 Apache-2.0 许可证开源,是 Headroom 的衍生合规项目。
请帮我安装这个 DSH 插件。安装前先完成【兼容性检查 + 安全性检查】,检查通过再动手。
插件:dsh-headroom(giter00/dsh-headroom)
仓库:https://github.com/giter00/dsh-headroom
本站详情页:https://www.yhbd.top/plugins/giter00-dsh-headroom/
本站登记:类型 plugin · 归类 原生 DSH 插件 · 许可证 Apache-2.0 · ⭐ 16 · 最近提交 2026-08-23 · 主语言 JavaScript
按下面顺序执行,每步先把结论告诉我,再进入下一步:
【1 兼容性检查】
① 我这边:DSH 版本、Node 版本、操作系统、当前 profile(web / desktop)。
② 读它的 README、package.json、插件 manifest,列出它要求的 DSH 版本 / Node 版本 / 操作系统 / 外部依赖 / 需要另外先装的运行时。
③ 逐条比对,结论只写「满足 / 不满足 / 未知」三种;不满足的给出可行替代方案。
④ 检查是否和我已装的插件冲突:命令名重复、skill / tool 重名、端口占用、重复注册的 MCP server。
【2 安全性检查】
① 仓库可信度:和上面「本站登记」是否一致;star / fork 数、创建时间、最近提交,是否归档或长期停更。
② 安装脚本:逐行看 package.json 的 preinstall / install / postinstall,以及 install.sh、setup.ps1 之类脚本。出现 curl|bash、下载后直接执行、混淆代码、访问与插件功能无关的域名,立刻停下来告诉我,不要继续装。
③ 依赖:列出新增依赖,标出无人维护、或与知名包拼写近似的可疑包(typosquatting)。
④ 权限与副作用:它会读写哪些目录、访问哪些域名、需要哪些 DSH 权限(filesystem / network / shell / clipboard 等),以及怎么卸载和回滚。
⑤ 如果它要求 sudo / 管理员权限,或权限明显超出功能所需,先停下来问我。
【3 安装】
上面两步没有「不满足」和「高危项」时才执行;用官方推荐方式安装,不要自行提权。
【4 汇报】
用表格输出:检查项 / 结论 / 依据 / 是否需要我决策。拿不准的一律写「未知」并说明要我怎么确认——不要猜,也不要替我决定。
Send this message to DSH in your current session: it verifies compatibility and security first (answering met / not met / unknown item by item) and only installs once everything checks out — it will stop and ask you if it finds a high-risk item. The box scrolls; the copy is the full prompt. CLI install commands may not be accurate across systems, so DSH is the safer route.把上面这条消息直接发给当前会话里的 DSH:它会先核对兼容性与安全性(逐条给「满足 / 不满足 / 未知」),确认没问题再安装,有高危项会停下来问你。框内可滚动,复制到的是完整提示词;安装命令不一定准确,发给 DSH 更稳。
- 16 stars - an early-stage project星标 16,属于早期项目
DSH walks through these 9 checksDSH 会逐条核对这 9 项
Compatibility兼容性
- DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
- External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
- Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册
Security安全性
- Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
- Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
- curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
- Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
- Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
- Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式
Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。
Or use CLI install (for developers)或使用命令行安装(适合开发者)
CLI Install命令行安装
dsh plugin --profile web add github:giter00/dsh-headroom
把 giter00/dsh-headroom 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-headroom
适配 DeepSeek Harness (dsh) 的上下文自动压缩插件,思路参考 Headroom。
工具输出在进入模型之前先被压缩:JSON、搜索、日志、表格与长文本各自走专用压缩器;
所有有损压缩都会把原文存入本地 CCR store,并在压缩结果里注入一个短 marker,
模型需要精确原文时调用 headroom_retrieve(id=…) 即可逐字节取回。
tool body settles
│
▼
tools/post-execute ← dsh-headroom 在此压缩
│
▼
tool/result 进入 session log / 模型历史(压缩后内容 + CCR marker)
│
▼
模型需要原文时调用 headroom_retrieve(id=…)
特性
自动压缩工具输出:挂载
tools/post-execute,在工具结果物化之前替换文本内容。内容路由,专用压缩器:
内容类型 压缩策略 JSON 数组/对象 SmartCrusher 风格透视: _keys+_rows+_common,长单元格截断grep/ripgrep 结果 按文件折叠: file (N matches)+line[:col]: rest构建/测试/日志 连续重复行折叠 + 保留 error/fail/exception/assert上下文CSV/TSV/markdown 表格 保留表头与首尾行,中间行 offload 长文本 Kompress 风格 ML 压缩(默认):逐词打分 + must-keep 保护 + CCR 可逆取回; textStrategy: 'head-tail'可切回首尾截断代码 默认不压缩(JS 端口不做 AST 压缩,避免破坏可补丁字节; read/str_replace_editor的行号前缀会先剥离再识别)文件工具 默认不压缩( read/str_replace_editor/edit/write及其匹配*.js/*.ts/*.json/*.yml的路径)
Kompress 文本压缩(参考 Headroom 的 Kompress-v2-base ML 模型): 文本按词切分 → 每词打分(
score = keep概率 × (0.5 + 0.5 × span分数),模拟模型的 token 分类头 + span CNN 双头)→score > 0.5保留(或targetRatio取 top-k)→ 数字 / hex / 全大写标识符 / 路径 / 扩展名 / CLI flag / CamelCase 等语义脆弱词强制保留 → 保留词重组。默认评分器是确定性纯 JS 启发式;也可启用真实 Kompress-v2-base ONNX 模型打分(kompress.scorer: 'onnx',见下文「真实模型压缩」)。
- 可逆压缩(CCR):所有有损压缩都保存原文,
headroom_retrieve按 id 精确取回;headroom_stats查看节省量;headroom_compress压缩任意文本。 - 持久化:CCR store 默认写入
<DSH_HOME>/storages/dsh-headroom-ccr.json(1 秒去抖、原子替换、TTL + 最大条目数可配)。 - 无害跳过:短文本、代码、错误输出、
excludeTools命中的工具、本插件自身工具 都不会被压缩。 - 跨平台:纯 JavaScript + Node 内置模块,无原生编译依赖;路径全部通过
node:path处理,DSH_HOME支持环境变量覆盖,Windows / macOS / Linux 行为一致。 CI 矩阵见.github/workflows/ci.yml。
实现方式
flowchart LR
A[ToolRuntime 工具执行完成] --> B[tools/post-execute]
B --> C{文本块总长 >= minChars?}
C -- 否 --> Z[原样返回]
C -- 是 --> D[ContentRouter 类型检测]
D --> E[json] --> E1[SmartCrusher 透视]
D --> F[search] --> F1[按文件折叠]
D --> G[log] --> G1[重复折叠 + 错误保留]
D --> H[tabular] --> H1[首尾行保留]
D --> I[text] --> I1[Kompress 逐词打分 + must-keep 保护]
I1 -. 无收益 .-> I2[回退首尾截断]
D --> J[code] --> Z
E1 & F1 & G1 & H1 & I1 & I2 --> K{压缩后 + marker 更小?}
K -- 否 --> Z
K -- 是 --> L[写入 CCR store]
L --> M[替换 decision.content]
M --> N[模型看到压缩内容 + headroom_retrieve marker]
Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →
extracurricular-ai/dsh-filesnap
SenmuuuuW/dsh-whale-report
SnowCrescenter-tech/dsh-milestone
PerryLink/dsh-checkpoint-rewind
XieZongChen/dsh-md-notes
TencentCloud/tencentcloud-agentobs-sdk-dsh
linyp/dsh-plugin-langfuse