DeepSeek Harness Plugin

vrvtvy/dsh-cache-hit-precision

Stars ★ 1 Downloads (30d) 1,504 Category Usage & Billing Added 2026-10-16 npm dsh-cache-hit-precision

Refines the built-in cache-hit percentage to three decimals in place across the composer stats row and the token-usage dialog.

Install

# from npm (prebuilt)

dsh plugin --profile web add dsh-cache-hit-precision

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

dsh plugin --profile web add github:vrvtvy/dsh-cache-hit-precision

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

English | 中文 | Changelog

CI

A DeepSeek Harness (DSH) Web plugin: it renders the built-in cache-hit reading of the composer statistics row with three-decimal precision in place (缓存命中 98% -> 缓存命中 98.460%), and keeps the same reading in the Token usage dialog and the status line in step.

Nothing is added to the UI. The plugin claims an invisible seat in the composer dock, reads the same tokenUsage projection the built-in pill reads, and refines only the cache-hit reading — turns, steps, throughput, totals, and the dialog's other buckets (uncached input, cache read, cache write, output) are untouched. No geometry is changed.

What it looks like

The cache-hit reading refined to 99.186% in the Token usage dialog and the status line

Both the cache hit row of the dialog and the status line (80.9M tok · 缓存命中 99.186%) are replaced in place with the three-decimal reading; everything else matches the built-in rendering exactly.

Why three decimals

The built-in formatter refuses to round a partial hit up to 100%: it prints an integer until that would collapse, then widens the precision until the miss is visible. This readout keeps that promise from a three-decimal base instead of an integer one, so day-to-day movements of the hit rate stay visible:

cache read / billed input built-in this plugin
123 / 1123 11% 10.953%
9995 / 10000 99.95% 99.950%
999999 / 1000000 99.9999% 99.9999%
9995 / 9995 100% 100.000%

The denominator is DSH's own — the sum of the three disjoint prompt-side billing buckets, uncachedInputTokens + cacheReadTokens + cacheWriteTokens — so the two readings can only differ in precision, never in meaning. Rounding is half-up in exact integer arithmetic, so a percentage never inherits float drift.

How it works

Refinement is immediate: the built-in dialog renders its first frame at integer precision, so the plugin re-refines inside the mutation observer's own microtask — after React's commit, before the browser paints — whenever an anchor mounts or React rewrites a reading in place. The low-precision first frame is never seen; anything else settles through one debounced rescan per mutation burst.

The plugin anchors on whichever pill holds the cache-hit reading — the data-composer-stats container that wrapped the whole statistics row up to 0.2.0, or the per-pill data-composer-stat entries that replaced it in 0.2.1 (only usage; activity carries turns and speed) — and on the data-session-stats-usage attribute of the session usage dialog's row list, so it keeps working across both statistics-row markups.

From 0.2.2 a pill whose label an ellipsis cuts also raises a full-reading tooltip (a portal onto document.body). The plugin refines that too, and only the cache-hit reading inside it: a tooltip carrying no such reading comes out byte-identical. Labels are matched in every locale the host ships (zh, en, ja, es, fr, de, ru, pt), and each locale's own colon and padding between the number and the percent sign are preserved verbatim — only the digits change.

Install

By package name (recommended) — the package is published to npm. In the desktop app, open Settings → Plugins, click Add plugin, and enter the package name dsh-cache-hit-precision; the command line equivalent is:

dsh plugin --profile web add dsh-cache-hit-precision

A freshly published version may lag a few minutes on the npmmirror mirror; both the install dialog and the CLI fall back between the official registry and the mirror automatically, and the CLI accepts --registry to pick one explicitly.

From a directory — you can also install from a source checkout. Clone the repository first:

git clone https://github.com/vrvtvy/dsh-cache-hit-precision.git

In the desktop app, Settings → Plugins → Add plugin with the absolute path of the cloned directory; from the command line:

dsh plugin --profile web add /absolute/path/to/dsh-cache-hit-precision

The path must be absolute; forward slashes work on every platform (D:/… on Windows, /home/you/… elsewhere). Restart DSH when the install finishes.

The desktop app manages its own profile exclusively, so it refuses --profile desktop from the CLI; use Settings → Plugins there instead.

Compatibility

Built for DSH 0.2.0-rc.*, 0.2.1-rc.*, 0.2.2-* and 0.2.3-*, cold-booted for real on 0.2.2-alpha.2 (a full turn each in zh and fr; pill, full-reading tooltip and usage dialog agreed) and on 0.2.1-rc.4 (one zh turn, still refining without a tooltip). 0.2.3-alpha.1 was audited at source level: the composer and dialog anchors, all eight locale strings, the tokenUsage projection and billing buckets, and the formatter's critical-width behaviour are unchanged, with core readings rechecked by in-process assertions; a cold-boot visual check on that version is still outstanding. The composer statistics row is rendered by @deepseek-ai/dsh-client-ui-chat's StatsPills; from 0.2.1 that row is one dock entry per pill, so the anchor moved from the row container to the single pill and the plugin reads both. 0.2.2 widened the copy to eight locales and added the clipped-label tooltip; both are covered here. An upstream rework of that markup or copy may require a plugin update.

The per-turn usage panel (data-turn-usage-details) is deliberately left alone: its cache-hit reading is a different aggregate — one turn rather than the whole session — so refining it to the pill's number would misreport it.

DSH 0.1.x exposed a different stats line and is not supported by this version.

Notes

  • Reads no network, uploads nothing.
  • Registers one slot entry and no styles; uninstalling leaves no residue.

Test

npm test

Credits & license

Continued from Cheng-cheng9669's dsh-cache-precision, adapted to DSH 0.2. Released under the MIT license.

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.