DeepSeek Harness Plugin

LoveDoLove/dsh-token-saver

Stars ★ 3 Category Usage & Billing Added 2026-10-20

DeepSeek Harness plugin that trims tool output (head/tail plus grep folding), adds optional prompt shaping (Caveman and Ponytail), instant local responses, RTK command-output compaction, context-pressure handling, optional LLM-summary compaction, stable prompt-cache layout, a Web settings UI, and persisted savings telemetry.

Install

# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)

dsh plugin --profile web add github:LoveDoLove/dsh-token-saver

Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).

README

Keep more of your context window for the model. A DeepSeek Harness plugin that trims oversized tool output, folds grep results, and makes prompt shaping and local answers optional.

简体中文 · Documentation · Releases · Issues

Why

Tool output fills a context window faster than anything else. One file read, one grep, or one build log can add tens of thousands of bytes the model never needed, and those bytes stay in the conversation for every later turn.

Token Saver works at the DSH tool-execution boundary. It keeps the head and tail of long results, folds search output down to its matches, and can apply shape-aware RTK filters. It never touches user messages, assistant messages, or errors, and it fails open: a compaction error returns the original result.

Features

Feature What it does Default
Tool-output trimming Keeps the head and tail of oversized results On
Grep folding Keeps matches plus context On
RTK filters Shape-aware compaction for diffs, logs, trees, tables Off
Caveman shaping Terse, direct answers with exact code and paths Off
Ponytail shaping Minimal-change, smallest-diff style Off
Local responses Answers quota, prefix, title, suggestion, filepath probes Off
Context pressure Triggers compaction above a threshold Off
Web panel Settings and savings in Settings → Token Saver On DSH Web

Every feature can be turned off. mode: off disables all tool-output compaction; prompt shaping and local responses have their own switches.

Quick start

dsh plugin --profile web add github:LoveDoLove/dsh-token-saver

Pin the current release:

dsh plugin --profile web add github:LoveDoLove/dsh-token-saver#v1.0.7

If DSH asks for build-script approval, follow the printed instructions and retry. The prebuilt dsh-token-saver-1.0.7.tgz on the v1.0.7 release installs without a local build.

Upgrading from v1.0.4 or older? v1.0.5 fixes a data-destruction bug in RTK autodetection that could collapse README-style prose. Upgrade if you read files through a tool.

Configuration

Configuration lives in the bundle row in your DSH profile. A typical setup:

- id: dsh-token-saver
  name: dsh-token-saver
  config:
    mode: conservative
    headBytes: 16384
    tailBytes: 8192
    rtkEnabled: false
    cavemanLevel: off
    ponytailLevel: off
    localResponsesEnabled: false
Mode Behavior
off No trimming, folding, or RTK
conservative Trim and fold only; never compacts the session
balanced Adds pressure-driven compaction when enabled
aggressive Same as balanced, with a lower bar for compaction

The Web panel writes live overrides to $DSH_HOME/token-saver/settings.json. See configuration for all 22 options.

How it works

  1. tools/post-execute — decide whether a result should be compacted. Errors and structured values pass through.
  2. Strategy — RTK filter, grep fold, or byte-budget truncation, whichever fits the tool and the result.
  3. ctx.systemPrompt.section() — add Caveman or Ponytail text as a prompt section. The frozen LLM request is never rewritten.
  4. llm/stream — answer a recognized probe locally with zero usage; otherwise pass through.

Safety

  • Errors are never compacted.
  • Output is accepted only when it is non-empty and strictly smaller.
  • Every strategy fails open.
  • Prompt text uses the supported section API, not the assembly waterfall.
  • The agent-loop LLM request is never mutated.
  • Invalid configuration fails activation instead of being silently coerced.

Benchmark

UTF-8 bytes on synthetic fixtures:

Fixture Before After Saved
Large diff 182,892 24,675 86.5%
Grep result 29,321 8,145 72.2%
Find result 29,321 12,321 58.0%
Build log 19,781 1,301 93.4%
Table 9,423 2,163 77.0%

Bytes are not tokens. Method: benchmark-methodology.

Documentation

Compatibility

Targets DSH >=0.2.0 <0.3.0 and Node >=22.19.0. Works alongside Billion Context, OmniRoute, and Our Free Model. Details: compatibility.

Development

pnpm install
pnpm prepack

pnpm prepack runs lint, typecheck, tests, build, and package verification. Agent guidance: AGENTS.md.

License

MIT

Content from the project README on GitHub ↗

Links

More in this category

View the whole category →

Community comments

Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.