bowenliang123/dsh-context
bowenliang123/dsh-contextDSH 上下文洞察面板:Context 仪表盘 + /context命令 + Context 浏览器,查看 Context的分类组成、内容详情、演进趋势、压缩/注入事件、统计等一站式 Context 全生命周期管理。
以寄存器阵列与反应堆芯历史盘面的形式,在 DSH 右侧栏实时显示当前会话的提示词缓存遥测。
Live prompt-cache telemetry for the current session, drawn as an instrument panel in the DSH right sidebar.
English · 中文说明
The plugin adds one tab to the DSH right sidebar. It reads the tokenUsage and
contextPressure session projections the Host already publishes and shows them
as four flat instrument faces:
| Face | Shows |
|---|---|
| Hit rate | Session cache-hit rate as a 5×7 dot-matrix percentage, plus the settled request count, the last request's rate, that request's age and a 28-lamp bar against the current prompt total. |
| Register bank | The four disjoint cache buckets — cache read, cache write, uncached input, output — with session totals and proportional lamp rows. |
| Reactor core | One cell per settled request, newest first. Ink is that request's cache-hit rate, diameter is its size against the heaviest request on the board, and the field fades with age. |
| Context pressure | Pressure tokens against the context window. |
The tab opens by itself once per page load, so the panel is on screen without hunting through the tab guide. It closes like any other tab.
hit rate = cache read / (cache read + cache write + uncached input)
Output tokens are deliberately excluded. Generated tokens are never cacheable, so counting them would flatter the number — a long generation would make a cold prompt look warm.
One cell is one request that settled while the panel was mounted, ordered newest-first from the top left. The board is one whole number of rows at all times, and it is never taller than the history it actually holds, so a young session shows a short row rather than a large empty lattice.
sqrt(request tokens / heaviest request on the board), which
keeps small requests visible next to a cold burst.Each cell carries a title with its exact read / write / uncached / output
split, so the picture can be audited rather than trusted.
dsh plugin --profile web add github:Billwu18/dsh-cache-hit-monitor
Or install it through the Plugin Manager in the Web UI.
git clone https://github.com/Billwu18/dsh-cache-hit-monitor
dsh plugin --profile web add /absolute/path/to/dsh-cache-hit-monitor
Then reload the page. The Host re-reads plugin artifacts by modification time,
so edits to client.js are picked up by a refresh — no dsh web restart.
>=0.1.7-rc.1 <0.2.0-0>=20 (only for the test harnesses; the plugin itself runs in the browser)No dependencies, no build step, no install scripts.
The Host half is deliberately inert (index.js exports an empty apply). It
exists so the bundle has a Loader row and can be enabled, disabled and inspected
like any other plugin.
Everything the panel shows is already computed on the Host:
@deepseek-ai/dsh-token-meter
folds the durable session log into the tokenUsage and contextPressure
projections. The Client half reads them from its slot props via useProjection
and renders.
The client bundle is a single file (client.js) in the DSH browser-module
format. It uses only React and standard browser APIs:
getComputedStyle plus a ResizeObserver, and re-renders once before paint.
If the measurement is unavailable the board simply grows with the data instead
of being capped.keepMounted: true, which prevents that remount in the first place.The panel reads local session projections. It makes no network requests, sends no telemetry, and stores nothing outside the browser tab. Clearing history touches only in-memory state.
| DSH | >=0.1.7-rc.1 <0.2.0-0 |
| Platform | web (dsh.client.platform) |
| React | 18 or newer (provided by the host) |
| Themes | Both. The instrument faces are intentionally dark in both themes; the surrounding chrome follows the --dsw-* theme tokens. |
| Locales | English and Chinese. Other locales fall back to English. |
| Hosts | Any host that provides the sidebarRightTabs service. |
No dependencies are required to work on this plugin — the tests run on plain
Node against the real client.js.
node test/run-all.mjs # all four suites
node test/preview.mjs # writes HTML that can be screenshotted
dsh-cache-hit-monitor/
├── client.js the entire browser half (React, DSH module format)
├── index.js the host half (intentionally inert)
├── cordis.patch.yml the Loader row that installs the plugin
├── package.json manifest: dsh.bundle + dsh.client
├── icon.svg plugin card artwork
├── screenshots.json storefront screenshots, relative to this file
├── locale/
│ ├── en.json plugin card title and description
│ └── zh.json
├── assets/ screenshots referenced by the READMEs
└── test/
├── run-all.mjs runs every suite below
├── preview.mjs renders the panel to standalone HTML
├── wiring.test.mjs bundle identity, effects, tab and slot registration
├── render.test.mjs the rendered tree: shapes, counts, no NaN, key coverage
├── persist.test.mjs history and depth survive a remount
└── robust.test.mjs adversarial inputs and locale coverage
There is no DOM and no test framework. Each harness stubs
window.__ModuleLoader__ to capture the bundle, stubs react, applies the real
apply(ctx) against a stub context, then drives the registered component with a
small renderer.
That is enough to assert real behaviour: which services the plugin injects, what
it registers into which slot, how many cells and lamps the tree contains, that
history survives a remount, and that no reachable input produces a thrown
exception or leaks undefined/NaN into a style string.
| Suite | Asserts |
|---|---|
wiring | Module id, declared injects, ctx.effect registrations, the tab definition (including keepMounted), both keyed slot registrations, and that the body is a component. |
render | Rendered tree shape: dot-matrix dots, reactor cells and cell dots, bar lamps, register rows, exactly one red element, no undefined/NaN in any style, and that every element in an array has a React key. |
persist | A real per-instance hook runtime: record a request, change the depth, unmount, remount — history, depth and keepMounted all confirmed. |
robust | 16 adversarial scenarios (missing or throwing projection, NaN/Infinity/negative/string token counts, no session id, no translate seat, empty to 10 000 events) must all render, and every locale key must exist in both dictionaries. |
MIT © 2026 Billwu18