Shaw529/dsh-token-saver
dsh-token-saver 通过挂载三个扩展点节约 token:tools/post-execute(无损头尾裁剪 / grep 折叠)、agent/pre-step(委托官方 ctx.compaction)、以及可选的 prompt-cache 段稳定排序。所有改写都走 dsh 的事件流,不会触发"model-visible 与 logged 不一致"不变式。
catalog descriptioncatalog 简介 / catalog description:DeepSeek Harness plugin: aggressive token savings, no task-quality loss
Project Overview项目介绍
dsh-token-saver is a native Cordis plugin built exclusively for DeepSeek Harness (DSH), with the core goal of cutting down LLM token usage without sacrificing task performance. It integrates with DSH via three official extension points: post-execute tool hook for lossless head-tail truncation and grep result folding, pre-agent step hook that calls DSH’s built-in compaction API, and an optional utility that sorts prompt cache segments to boost cache hit rates. It follows all DSH’s core rules to ensure the consistency between model-visible context and session logs, avoiding unexpected integration inconsistencies.
The plugin offers four user-configurable compression modes ranging from completely disabled to full aggressive compression. The default setting is conservative mode out of the box, which only applies lossless folding to tool outputs without altering DSH’s native processing flow, so it carries almost zero risk of degrading or breaking overall task outcomes. Users who need significantly higher compression ratios for common long-running agent tasks can switch to balanced or aggressive modes, which add extra automatic threshold-triggered compaction and an optional LLM-powered summary engine that can replace DSH’s default basic built-in compaction.
After you have installed and set up DSH on your local machine, you can install this plugin using DSH’s built-in plugin command, and it supports four different installation sources: npm registry, GitHub Release tarball, local development tarball, and directly from the source code repository. For local development work on the plugin, you need Node.js version 22.19 or newer and pnpm version 10 or newer installed on your system. It is open-sourced under the permissive MIT license, and strictly adheres to DSH’s core invariants to keep session state consistent across session replays and snapshots.
dsh-token-saver 是专门为 DeepSeek Harness (DSH) 设计的原生 Cordis 插件,核心功能是在不影响任务效果的前提下激进节省 LLM 调用的 Token 消耗。它通过挂载三个 DSH 扩展点实现 Token 压缩:工具执行后扩展点做无损头尾裁剪和 grep 结果折叠,代理前置步骤扩展点调用官方压缩接口,还可选对 prompt 缓存段做稳定排序提升缓存命中率。
它提供了从关闭到激进四种压缩模式,默认启用保守模式,仅对工具输出做无损折叠,不改动 DSH 原生链路,对任务效果几乎没有损失风险。平衡和激进模式在此基础上增加了自动触发压缩,还可接入自定义大语言摘要引擎替换原生基础压缩,满足追求更高 Token 压缩率用户的需求。
可通过 DSH 自带的插件命令安装,支持从 npm 注册表、GitHub 发布包、本地压缩包或源码仓库四种渠道获取。它严格遵循 DSH 核心不变式保证模型可见内容与会话日志一致,采用 MIT 许可证开源,本地开发要求 Node.js 不低于 22.19 版本、pnpm 不低于 10 版本。
请帮我安装这个 DSH 插件。安装前先完成【兼容性检查 + 安全性检查】,检查通过再动手。
插件:dsh-token-saver(Shaw529/dsh-token-saver)
仓库:https://github.com/Shaw529/dsh-token-saver
本站详情页:https://www.yhbd.top/plugins/shaw529-dsh-token-saver/
本站登记:类型 plugin · 归类 原生 DSH 插件 · 许可证 MIT · ⭐ 4 · 最近提交 2026-09-07 · 主语言 TypeScript
按下面顺序执行,每步先把结论告诉我,再进入下一步:
【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 更稳。
- Only 4 stars - very few users, little community feedback星标只有 4,几乎没人在用,遇到问题缺少社区反馈
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:Shaw529/dsh-token-saver
把 Shaw529/dsh-token-saver 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-token-saver
一个为 DeepSeek Harness (dsh) 设计的 Cordis 插件。激进节省 token、绝不破坏任务效果。
dsh-token-saver 通过挂载三个扩展点节约 token:tools/post-execute(无损头尾裁剪 / grep 折叠)、agent/pre-step(委托官方 ctx.compaction)、以及可选的 prompt-cache 段稳定排序。所有改写都走 dsh 的事件流,不会触发"model-visible 与 logged 不一致"不变式。
目录
为什么需要它
DeepSeek 这类 agent 在长任务里 80%+ 的 prompt tokens 来自两类内容:
- 被读出来的大文件 —— 一次性 read 一个 1MB 的迁移 SQL 就要吃掉 250k tokens。
- 被反复搜索出来的命中结果 —— grep 几十个文件,回填全部 grep 结果,模型根本没读完。
dsh-token-saver 默认 conservative 档只做一件事:完整保留头/尾,中间的部分用一行 metadata 替换。这是一种"lossless"折叠 —— 模型仍然知道"中间被截断了",但实际送进 model 的字符数降到几千。
更激进的 balanced/aggressive 档再叠加:
- delegate 给 dsh 官方
ctx.compaction.compactIfNeeded()在压力阈值被触发时自动滑窗 - 替换
dsh-compaction-basic为我们自己的 LLM-summary engine(用户接入 LLM 调用函数即可)
详见 测试效果 章节的真实数据。
四种模式
| 模式 | tools/post-execute 头尾裁剪 |
grep 折叠 | agent/pre-step 触发 ctx.compaction |
替换 dsh-compaction-basic |
LLM-summary engine |
|---|---|---|---|---|---|
off |
❌ | ❌ | ❌ | ❌ | ❌ |
conservative (默认) |
✅ | ✅ | ❌(保留 dsh 默认行为) | ❌ | 可选 |
balanced |
✅(更紧的 budget) | ✅ | ✅ | ❌ | 推荐 |
aggressive |
✅(更紧的 budget) | ✅ | ✅ | ✅ | 推荐 |
默认 conservative:完全不替换 dsh 原生链路,只对读出来的工具结果做无损头尾折叠,任务效果零损失风险。
安装
dsh 安装好后,在你的 harness home 里执行:
dsh plugin --profile web install dsh-token-saver
要锁定版本:
dsh plugin --profile web install dsh-token-saver@0.1.0
安装方式(按发布状态)
| 来源 | 命令 | 说明 |
|---|---|---|
| npm registry(推荐) | dsh plugin --profile web install dsh-token-saver@0.1.0 |
待 npm publish 后可用;目前走 GitHub tarball 或本地 pack |
| GitHub Release tarball | dsh plugin --profile web install https://github.com/Shaw529/dsh-token-saver/releases/download/v0.1.0/dsh-token-saver-0.1.0.tgz |
预构建 tarball,16.8KB,跳过 allowBuilds |
| 本地 tarball(开发中版本) | pnpm run build && pnpm pack → dsh plugin --profile web install ./dsh-token-saver-0.1.0.tgz |
本地 build 后打包 |
| 源码仓库(不推荐) | dsh plugin --profile web install https://github.com/Shaw529/dsh-token-saver |
走源码构建,需要 allowBuilds 授权 |
Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →
GanyuanRan/Aegis
wecode-ai/Wegent
shengsheng90/DSH-taskboard
Nwflower/dsh-chat-import
shanliuling/skills-link
pengyue-polaron/deepseek-harness-genui
Jayden-X-L/forkprobe