Shaw529/dsh-token-saver

Plugin插件 Native原生 ⭐ 4 MIT Productivity & Tasks效率与任务

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 版本。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • 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 来自两类内容:

  1. 被读出来的大文件 —— 一次性 read 一个 1MB 的迁移 SQL 就要吃掉 250k tokens。
  2. 被反复搜索出来的命中结果 —— 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 →

← 上一个 Prev dsh-archive-viewer 下一个 Next dsh-hindsight-plugins →