DeepSeek Harness Plugin Hub

Publish and manage complete Harness Profiles. Discover Plugins for your next setup.

Explore

PluginsPresetsDocsNews

Community

Publish a pluginContactReport an issue

Resources

Plugin Hub on GitHubDeepSeek HarnessSystem statusPrivacy notice
© 2026 DeepSeek Harness Plugin HubPowered byPaxTech

Independent and unofficial. Not affiliated with, authorized by, or endorsed by DeepSeek.

Tokensqueezer — DSH Plugin for DeepSeek Harness
DeepSeek Harness Plugin Hub
ProfilesPluginsCategoriesNewsDocsSign inManage Profiles
ProfilesPluginsCategoriesNewsDocsSign in
← Plugins
T

@local/tokensqueezer

Tokensqueezer

TokenSqueezer: cuts token use on the model's own output — caps generation before the call, folds verbose answers and reasoning after it, and keeps fenced code byte-identical.

The plugin will be installed here. Keep web if you are unsure.

npx -y @deepseek-ai/dsh plugin --profile web add github:boxiaolanya2008/tokensqueezer#6be121164612952b4e031faadf1a7da0faeda58c
READMECompatibilityVersions

Compatibility and provenance

Tokensqueezer is published as @local/tokensqueezer and currently resolves to version 0.1.0. The Hub verifies its manifest and preserves the exact installation source for reproducible installs.

DSH compatibility
*
Runtime surfaces
web
Release source
github
Registry updated
9/30/2026

Versions

0.1.0stable
9/30/2026

Related plugins

Loading related plugins…

Latest
0.1.0
DSH
*
HMR
Process restart
Tree shaking
Safe tree shaking not declared
Unpacked size
Unavailable
Files
Unavailable
Surface
web
License
MIT
Source
github
GitHub
★ 0
Weekly downloads
0
Last push
9/30/2026
View source ↗
README badge

Click the badge to copy Markdown for your README.

Do you maintain this Plugin?Claim benefit · Priority security scan

Verify the GitHub repository declared in package.json to manage this listing. After you claim it, Hub will prioritize a security scan of the current version and publish the result when it passes.

Claim this Plugin →
Report an issue

Related plugins

More verified plugins in models-usage.

Usage@linxin666/dsh-usageUsage statistics plugin for the dsh web GUI: per-provider balance and coding-plan quota detection plus a live token usage ledger, with a compact price glance card above the sidebar's Settings rowClient Ui Model Capabilities@linxin666/dsh-client-ui-model-capabilitiesPer-model capability declarations (image input and reasoning efforts) for custom pi-ai providers, edited in place on the Models settings cards; writes the official llm-pi-ai settings namespace, no DSH source changes.Codex Subscriptiondsh-codex-subscriptionUse ChatGPT and Codex subscriptions in DeepSeek Harness with OAuth, quota, safe resets, web search, images, and Fast modeCommandcode Provider@mars-sea/dsh-commandcode-providerUnofficial DeepSeek Harness LLM provider plugin for Command Code, ported from pi-commandcode-provider (MIT). Registers the 'commandcode' provider route with a Models-page card and live model catalog.

README

TokenSqueezer

A DeepSeek Harness plugin that reduces what an agent costs to run. It works on the model's own output — not on the input it is fed.

English | 中文


Read this first: what actually saves tokens

Two mechanisms with completely different economics live in this plugin, and conflating them is the easiest way to be disappointed.

MechanismSavesWhy
PreventionbrevityInstructionoutputThe model writes less. The answer stays complete.
reasoningBrevityInstructionoutputReasoning is ~87% of everything a model emits; asking it to think in a straight line is the largest lever here.
outputTokenCapoutputA ceiling set through agent/request before the call. Tokens never generated are never billed.
reasoningEffortoutputPins the reasoning tier. Applied only when the model advertises it.
Compressionllm/stream rewritereplay onlyBy the time a chunk arrives, those tokens are generated and paid for.
session/event backstopreplay onlySame.
answer / reasoning / per-kind foldsreplay onlySame.

Compression cannot make the current answer cheaper. That money is spent. What it does is shorten the transcript, so every later request in the turn carries fewer bytes — a saving that compounds and is invisible at the moment it is made.

The plugin never touches usage, so reported token counts stay truthful.


Install

# 1. Put this repository somewhere permanent, then link it into a profile.
#    The profile manages its own node_modules; a link: install keeps the plugin editable.
cd <your DSH profile directory>
pnpm add link:<path-to-this-repository>

# 2. Enable it. The bundle ships cordis.patch.yml, which inserts the row for you.
#    In <DSH_HOME>\profiles\<profile>\cordis.patch.yml:
- id: tokensqueezer
  disabled: false

Restart the application. The two halves reload by different mechanisms, and the asymmetry is worth knowing before it wastes an afternoon:

How it loadsEditing it while DSH runs
Host half (index.js, lib/)a loader entry, read once at application startdoes nothing until a full restart
Client half (client.js)a module artifact whose revision is derived from mtimeMs/ctimeMs/sizehot-reloads immediately

So a UI that updates while behaviour does not is the normal symptom of a stale Host. status prints the file the Host was loaded from, which makes the question a comparison rather than a guess:

Host code: <path>\index.js @ 2026-09-30T04:26:12.732Z.

How it works

Host half — five surfaces, each installed independently

SurfaceHookRole
Stream rewritellm/stream (waterfall)Buffers each text/reasoning block to its block-end, compresses, re-emits. This is the only leg that runs before the text is displayed, and because the loop builds its assistant/message from the chunks it receives, it also decides what is committed.
Durable backstopsession/eventReplaces an over-budget assistant/message that reached the log by another route, using the replay-safe compaction/prune + surfaceOp: replace protocol. A no-op in the normal path.
Output budgetagent/request (waterfall)The prevention half: sets maxTokens, optionally pins reasoningEffort, before prepareCall.
Tool resultstools/post-execute (waterfall)Compresses a tool result before the model reads it — with the code guarantee below.
Status routewebServer.registerA read-only GET /api/tokensqueezer/status so the UI can show a number. GET only; anything else gets 405. The payload is this plugin's own counters: no session content, no paths, no credentials.

Each is its own installation step, so a failure names itself in status (Installed: …) and does not take the other four down with it.

Client half — two seats

  • conversation.composer.dock — a readout below the composer. It polls the status route every 3s and shows the session's saving. When no number is available it says so instead of showing a placeholder.
  • settings.section — a settings page built from the shipped primitives (Tag, Switch, SegmentedControl, Input, CodeBlock, Button), grouped by what each setting actually saves, localized through the shipped locale service.

The pipeline

lib/engine/output.js splits a payload into fenced-code and prose segments first, so no code block ever reaches the semantic layer. Everything else flows through:

  1. L1 lossless — ANSI and control removal, carriage-return redraws, trailing whitespace, blank-line runs, repeated line/block folding.
  2. L2 normalisation — path relativisation against the session cwd, optional symbol interning. Both skipped for executable kinds.
  3. L3 semantic — one compressor per detected kind: json, yaml, diff, stacktrace, log, terminal, testreport, filetree, searchresults, deptree, markdown, html, code, prose, plus answer and reasoning, which fold at answer scale.

Reversibility

Everything the lossy layers remove is interned into a content-addressed store (8 hex characters of sha1) and replaced by a bare ⟦TS:id⟧ marker, with a legend line at the end of the payload. The same text always yields the same id, so a second pass over compressed output is a no-op. The model retrieves originals through the tokensqueezer tool's expand action.


The code guarantee

A tool result that is file content or a patch is not compressed semantically. This is enforced in three places, and the reason there are three is a mistake worth recording:

The first implementation called engine.compress(text, { lossy: false }) and assumed that was enough. Measured on a 40-line repeated body, it returned three lines. The repeat-line folding that damages code runs in the lossless stage, so switching the lossy layer off happens upstream of the damage.

So:

  1. The tool name decides the kind. toolContentKind() pins read/read_file/view/cat/write/ edit/str_replace → code, and diff/patch → diff. Heuristics are the wrong instrument here: a source file that detectKind happens to read as log would have its repeated lines folded.
  2. Those kinds skip the pipeline entirely and receive losslessCleanup only. EXECUTABLE_KINDS is not the guard — it only protects L2, while compressCode/compressDiff do fold code bodies.
  3. The result must be net-shorter. A payload whose final text — marker and legend included — is not shorter is discarded unchanged. This is what makes "compress everything" safe rather than self-defeating, because a 13-character marker plus a ~100-character legend would otherwise grow small payloads.

Measured on the shipped engine:

read_file, 40 repeated code lines   1079 → 1079   40/40 lines survive
patch, 30 added lines               1231 → 1231   30/30 lines survive
code with ANSI escapes and blanks    1122 → 1111   41/41 lines survive, escapes stripped

Configuration

Every key has a default; nothing needs configuring. The floors default to 0, so an ordinary payload always enters the compressor — and the net-shorter rule above decides whether the result is kept.

KeyDefaultMeaning
compressOutputtrueMaster switch for output compression.
compressStreamOutputtrueThe llm/stream leg — the only one that runs before display.
compressDurableOutputtrueThe session/event backstop.
compressReasoningtrueFold reasoning blocks. false skips them before any compressor runs.
compressToolResultstrueCompress tool results, behind the code guarantee.
outputMinChars0Floor for a visible text block.
reasoningMinChars0Floor for a reasoning block.
toolMinChars0Floor for a tool result.
minSavedChars0Worth-it floor. Safe at 0 because of the net-shorter rule.
segmentMinChars200Floor for one prose segment when an answer is split around code.
reasoningElideMinChars0Compressor-internal floor for reasoning.
reasoningFoldMinChars0Compressor-internal fold floor for reasoning.
answerElideMinChars0Compressor-internal floor for answers.
answerFoldFloor0Compressor-internal fold floor for answers.
outputTokenCapunsetHard ceiling on generated tokens. Too low truncates the answer (finish: max-tokens). Never raises an existing stricter limit.

outputTokenCap and reasoningEffort apply to every agent, subagents included — deliberately, so a delegation cannot quietly outspend the budget it was given.


Tooling

The plugin ships its own verification, because the engine layer was never the part that broke:

$node = '<node executable>'
& $node scripts\linkcheck.mjs      # every relative import resolves to a real export
& $node scripts\selftest.mjs       # engine, 9 sample kinds: 122537 → 32812 chars (73.2%)
& $node scripts\hosttest.mjs       # Host half, fake ctx and a session as strict as the real one
& $node scripts\clienttest.mjs     # Client half, fake loader plus a real render
& $node scripts\reasontest.mjs     # skeleton folding: skeleton kept, references reversible
& $node scripts\archtest.mjs       # architecture digest

Three diagnostics exist for the questions the UI cannot answer:

ScriptQuestion it answers
scripts/audit.mjsDid the plugin actually rewrite committed output? It reads the durable session logs and counts, per session, how many assistant/message rows carry a marker — split into answers and reasoning. The UI is a derived view; this is the log.
scripts/sessionrepair.mjsWhich rows would format-v4 admission refuse, and offers to fix two shapes of them. Previews by default; --write backs up first. Its second rule only applies to v4 logs, so v3 sessions in other projects are never touched.
scripts/asar-find.mjs · asar-extract.mjsWhat the shipping Harness actually does. Both read the application archive's header and extract named entries, which is how the contracts below were read instead of guessed.

hosttest.mjs uses a fake session that enforces the real rules — an assistant/message replacement must not carry sourceEventSeqs, must carry turn/step while that step is open, and surfaceOp must be exactly {op, startSeq, endSeq}.


Platform constraints

These were all found the hard way, and each one cost at least one restart. They are properties of the Harness, not of this plugin.

  • A profile-installed bundle cannot import @deepseek-ai/*. The packages live inside the application archive; Node's resolution never reaches it, and the entry fails with a bare failed to import. So the Host half is a functional plugin with no framework imports, and the two helpers it needs are vendored.

  • cordis resolves a service on a context only when that context injects it. An undeclared service is not merely unavailable — reading it as a property throws. That throw is what silently killed one installation step here. inject is a gate, and both halves declare what they need (['tools', 'webServer'] and ['slots', 'locale', 'configForms']).

  • A plugin Config is two different protocols. cordis activation validates through Standard Schema (Config['~standard'].validate, synchronous); DSH's settings projection wants a schemastery brand (Symbol.for('schemastery'), type, meta). Supplying only the brand satisfies the inspect provider — which reports a healthy status: "schema" — while the entry goes to fiberPhase: "failed". An inspect provider is a read-only projection, not a validator.

  • A client-visible projection needs compile-time declaration merging into SessionProjectionMap plus a wire codec, and a typert Remote namespace needs generated code. Neither is available to a plain-JS plugin, which is why the UI reads a read-only HTTP route instead.

  • SessionReference documents behaviour, not a content API. It has paging, minima and lifetime semantics, but no public way to read the loaded messages.

  • agent/request, llm/stream and tools/post-execute are waterfalls and can legitimately replace what they return. agent/assistant-stream is emit only and can never be rewritten.


Honest limitations

  • Short content does not compress, and should not. With every floor at zero the compressor is still reached; it simply finds nothing to remove. A 46-character answer has no foldable middle, and an 11-character tool result has no redundancy. Pushing further would be deleting information, not saving it.
  • Measured savings on real sessions are modest — single-digit to low-double-digit percent of the blocks that qualify, with roughly half of all blocks having no redundancy at all. The large numbers are in the prevention knobs, and two of those (outputTokenCap, reasoningEffort) default to off because they change what the model produces.
  • The settings page's write path is unverified end to end. The controls call the settings service's set(key, value) and report the outcome — including the failure text — but that signature was read from documentation, not exercised against a live profile.
  • The dock readout depends on the status route. If the route is not reachable it says so; it never renders a number it does not have.
  • The reference store is per session and bounded. expand resolves within the session that produced a marker, and the LRU keeps 32 sessions warm. Originals always remain in the durable log.

Layout

index.js            Host half: five surfaces, the tool, the prompt sections, the status route
client.js           Client half: the composer dock and the settings page
cordis.patch.yml    bundle patch: inserts the tokensqueezer row
package.json        bundle and client declarations
lib/config.js       the plugin Config (Standard Schema + schemastery brand)
lib/session-message.js  the v4 producer-source rule still relied on
lib/arch.js         architecture digest
lib/engine/
  compress.js       orchestrator
  output.js         fenced-code split, code protection, answer-scale wiring
  detect.js         content-type detection
  textsafe.js       L1 lossless
  refs.js           content-addressed reference store
  dedupe.js         line and block folding
  normalize.js      path and symbol normalisation
  tokens.js         token estimation
  kinds/            one compressor per content kind
locale/             i18n: en.json, zh.json
scripts/            the six suites and the three diagnostics

License

MIT.

reasoningEffort
unset
Reasoning tier to force. Quality tradeoff; applied only when the model advertises the value.
brevityInstructiontrueAsk for lean answers. The one writing-style change the plugin makes.
reasoningBrevityInstructiontrueAsk for lean reasoning.
level10 lossless only, 1 balanced, 2 aggressive.
relativizePathstrueRelativise repeated absolute paths. Never on code or diffs.
internSymbolsfalseIntern long repeated identifiers. Never on code or diffs.
protectCodeFencestrueKeep fenced code out of the semantic layer.
toolSkip[]Tool names whose results are never compressed.
archMaxChars / archMaxDepth1200 / 3Bounds for the architecture digest.