kusesad-1122/dsh-context-compactor
DSH 上下文压缩/总结插件:80% 自动全局详细总结压缩(保留核心任务/决策/待解决问题/重要文件位置,删除调试细节与已解决错误),压缩后验保证 totalTokens 必须真实下降,context-overflow 自动恢复,/compact + /context-status,输入框上方一键按钮
Project Overview项目介绍
This is a context compression plugin built natively for DeepSeek Harness (DSH). It automatically triggers detailed summary compression of full conversation history when token usage reaches 80% of the model’s context window. This prevents conversations from failing when the maximum context length is exceeded. The plugin integrates DSH’s official dsh-compaction-basic compression engine and tool result pruner, mounting them in an isolated scope for each agent, and runs before any default compression engine to prioritize detailed summary compression. To install it, you first run the build script bash scripts/build.sh, then add it as a dependency to your DSH profile. A hot install can be done to activate it immediately without a full DSH restart.
The plugin enforces mandatory token verification before and after every compression to guarantee that the post-compression token count is strictly lower than the pre-compression count. It never performs "fake compression" that does not reduce token count. It also adapts to third-party providers that incorrectly report large context window sizes, which is a common issue with some modlens providers that overreport their available context. When a context overflow error is explicitly thrown by a provider, the plugin automatically compresses and retries the current request up to a configurable maximum number of retries. It can also automatically reduce the retained conversation tail and summary budget if the first compression attempt does not meet the token reduction requirement.
The plugin adds a toolbar with two buttons above the DSH conversation input box. One button triggers a manual compression, and the other enhances the prompt in the input box using the active DSH model, then writes the enhanced prompt back to the input box. The toolbar also displays the current context usage percentage in real time, and highlights it when the 80% threshold is crossed to warn users. The plugin also provides three manual commands: /compact to trigger manual compression, /enhance-prompt for prompt enhancement, and /context-status to check current token usage and settings. The summary of each compressed session is also automatically saved to a Markdown file in your DSH storage directory, and this feature can be disabled in the plugin configuration if needed.
这是一款原生的DSH上下文压缩插件,用于在会话token用量达到模型上下文窗口的80%时自动压缩总结对话历史,解决超过最大上下文长度导致对话失败的问题。它集成了DSH官方的dsh-compaction-basic压缩引擎和工具结果裁剪器,挂载到agent作用域内独立运行,抢在所有默认压缩引擎之前执行,保证详细总结压缩优先处理。
本插件支持多项实用功能:压缩前后必须进行token校验,保证压缩后token数一定小于压缩前,绝不做“假压缩”;适配了上报错误上下文窗口的第三方provider,上下文溢出时会自动重试压缩;能裁剪超大工具结果但不粗暴截断对话历史。输入框上方还添加了手动压缩和提示增强两个按钮,同时提供了三条可用手动命令。
安装本插件需要先运行构建脚本,再将其作为依赖添加到你的DSH配置profile中,重启DSH即可激活。也可以使用热注入命令让它立即生效,无需重启。安装完成后,输入框上方会自动出现包含两个按钮的工具条,实时显示上下文用量百分比,你还可以运行/context-status查看当前token用量、阈值和总结保存路径等信息。
请帮我安装这个 DSH 插件。安装前先完成【兼容性检查 + 安全性检查】,检查通过再动手。
插件:dsh-context-compactor(kusesad-1122/dsh-context-compactor)
仓库:https://github.com/kusesad-1122/dsh-context-compactor
本站详情页:https://www.yhbd.top/plugins/kusesad-1122-dsh-context-compactor/
本站登记:类型 plugin · 归类 原生 DSH 插件 · 许可证未声明 · ⭐ 3 · 最近提交 2026-08-16 · 主语言 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 更稳。
- No license declared - all rights reserved by default; ask the author before commercial use or redistribution未声明开源许可证 —— 默认「保留所有权利」,商用或再分发前先问作者
- Only 3 stars - very few users, little community feedback星标只有 3,几乎没人在用,遇到问题缺少社区反馈
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:kusesad-1122/dsh-context-compactor
把 kusesad-1122/dsh-context-compactor 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-context-compactor
开箱即用的 上下文压缩 / 上下文总结 插件。它把 DSH 官方 dsh-compaction-basic
压缩引擎 + 工具结果裁剪器一次性装配进 profile,解决「对话满了不会自动压缩、模型
直接报 maximum context length 导致本轮失败」的问题。
功能
1. 80% 自动触发(总结最优先 + 压缩后验)
- 通过
ctx.tokenMeter估算当前会话 token 用量; - 达到模型窗口 80%(
thresholdRatio默认 0.8)时,下一步前自动先做详细总结: 把全部较早历史用 LLM 压缩成一份详尽中文 checkpoint,替换旧消息,只保留最近retainRatio(默认 16%)的原样尾巴; - 本引擎的监听器以 prepend 注册,会抢在任何 preset 默认压缩引擎之前执行, 保证“总结最优先”且用的是详细版总结;
- 压缩前后都有会话日志事件(
compaction/start、compaction/summary、compaction/end)。
1.5 硬性保证:压缩必须真的变小
- 每次压缩都会做 before/after 校验:压缩后
totalTokens必须严格小于压缩前; - 自动压缩:
- 目标 = 低于 80% 阈值(所以 80% → 必须 < 80%,不是“压完还是 80%”);
- overflow 恢复:目标 = 低于压缩前;
- 若第一次没达标,会自动逐级降保留尾巴(16% → 8% → 4% → 0%)并 逐级降总结预算(12288 → 6144 → 3072 → 1024)反复压缩全部较早历史;
- 手动
/compact(包括按钮):同样做 before/after 校验;若总结反而变大, 自动降低总结预算重试,最多 4 次;仍不能下降就明确报错,绝不“假压缩”; - 日志会打印
before → after tokens(xx% reduced),方便确认真的压缩了。
1.6 真实上下文窗口(modlens / 第三方 provider 适配)
- 部分 provider(如
modlens-qwen)会向 DSH 上报一个很大的contextWindow(例如 1,000,000),但真实可用窗口只有 256k。这会导致阈值算错、永远“不到 80%”。 - 插件现在的窗口解析顺序:
modelPolicies[].contextWindow(显式覆盖,最优先);- 会话请求头里 ≥100k 的
maxTokens(视为真实窗口兜底,如 256000); - 适配器上报的
contextWindow(最后回退)。
- 需要手动指定时,在 profile 的插件 config 里加:
modelPolicies:
- provider: modlens-qwen
model: DeepSeek-V4-Flash-0731
contextWindow: 262144 # 按真实窗口填
thresholdRatio: 0.8
2. 全局详细总结 + 双份保存
- 全局,不是只压一段:每次触发都把“全部较早历史”(从最早消息到保留尾巴之前) 一次性做成一个全局 checkpoint;若历史里已有旧 checkpoint,会与本次新消息 全局合并——仍然成立的事实保留,已解决/过时的删除,相同内容只保留一份。
- 总结严格按保留/删除策略执行:
- 必须保留:① 核心任务与当前进度 ② 关键决策及理由 ③ 待解决问题 ④ 重要文件或代码位置(精确路径/函数/类位置,必要时保留简短关键片段);
- 必须删除:详细调试过程(只留结论)、已解决的错误(不保留报错原文与排查过程)、 客套话与所有重复内容。
- 保存 1:会话日志持久化 checkpoint 节点(可回放);
- 保存 2:额外写 Markdown 到
~/.dsh/storages/dsh-context-compactor/summaries/<session-id>.md(默认开启, 可关saveSummaryFile: false); - 总结调用生成上限默认
maxTokens: 12288(详细预算,可调大)。
3. context-overflow 自动恢复(专治 context length 报错)
- provider 明确报上下文超限时,先详细总结压缩,再自动 retry 本轮请求;
- 默认最多连续恢复
maxOverflowRetries次。
4. 超大工具结果裁剪(辅助手段,不替代总结)
- 超过
pruneThresholdChars(默认 8192 字符)的工具输出,保留头 + 标记 + 尾; - 只裁剪工具结果文本,对话历史一律走详细总结,绝不粗暴截断。
Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →
vlln/dsh-task-status
yishengjun8/dsh-workspace-studio
esengine/DeepSeek-Reasonix
chuspeeism/dashi-taskboard
Aisland-SJL/dsh-worktable
gitroomhq/postiz-agent