dsh-context-usage-guard

DSH PLUGINUI 与外观

仓库 icrefin/dsh-context-usage-guard

UI 与外观 未标注验证等级 安全审查:未标注 可信度:未标注 可安装插件

修复 DeepSeek Harness 输入框上下文用量环的两处缺陷:重试期间空用量样本不再把读数压成 0%,百分比字号也与同行数字一致。

一句话选型结论

按资料字段整理

dsh-context-usage-guard 是UI 与外观类的 DSH 可安装插件,未做沙盒验证,暂无安全审查结论,列出 4 项功能,没有现成安装命令,需要按仓库 README 接入。验证通过不等于安全:插件会读写文件、执行命令或联网,装前先到仓库确认它做了什么;涉及密钥或系统权限的,建议先在隔离环境试装。

分类UI 与外观 收录类型可安装插件 验证等级未标注验证等级 安全审查未标注
验证等级 UNKNOWN 未标注验证等级
GitHub 星标 0 复刻 0 · 未关闭 issue 0
最近更新 2026-10-11 创建于 2026-10-11
README 16.0 KB 正文体量,越大说明说明书写得越细

安装

可安装插件
在 DSH 里执行,装完用 dsh plugin list 确认已挂上;标了 L4 / L5 的命令已在沙盒里真实跑通
  1. 1
    确认版本与运行环境

    仓库没有标注兼容版本与 Node.js 要求,先确认你的 DSH 版本能装,再继续。

  2. 2
    执行安装命令

    在 DSH 里执行上面的命令;多包仓库要注意区分具体子包名,别装错包。

  3. 3
    确认已挂载

    用 dsh plugin list 查看列表里是否出现这个插件,出现即挂载成功。

  4. 4
    试跑并检查权限

    加载后跑一个最小用例,确认它能正常工作;同时看它申请了哪些文件、命令或网络权限。

兼容 DSH 版本未标注版本不匹配时安装会报错
Node.js 要求未标注来自仓库 package.json 的 engines 字段
前置依赖无需要同时安装的同级依赖
npm 包名未发布到 npm可用 npm view 查看包信息

能做什么

4 项功能
字段来自项目仓库与公开索引,中文说明由本站标注

dsh-context-usage-guard:让 DeepSeek Harness 的上下文用量环读数与排版回归真实

  • 重试期间保持真实上下文读数
  • 空用量样本不再归零
  • 百分比字号与同行数字一致
  • 含 40 项测试覆盖两处修复

上游标签

context-windowcordis-plugindeepseek-harnessdshdsh-plugintypescriptusage-meter

验证等级与安全审查

未标注验证等级
自动化流程结论,不是人工审核
验证等级未标注验证等级上游未给出验证结论,安装前请自行确认
安全审查未标注静态分析结论,未标注不代表已通过审查
仓库健康度未标注按仓库活跃度与最近更新时间给出
可信度未标注综合仓库活跃度与验证结果

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 列出了 4 项功能,能直接看出它解决什么问题。

先想清楚的地方

  • 安全审查还没结论,装之前先看仓库改了什么、要什么权限。
  • 没有现成安装命令,要按仓库 README 手动接入。
  • 验证通过不等于安全:插件会读写文件、执行命令或联网,装前先到仓库确认它做了什么。

更适合

  • 需要在UI 与外观场景里给 DSH 补能力的人。
  • 能接受在本地装依赖、愿意自己确认权限的人。

不太适合

  • 只使用 DSH 官方内置能力、不接受第三方插件的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
插件验证等级安全审查星标兼容版本安装命令
dsh-context-usage-guard当前 未做沙盒验证 未标注 0 未标注 无
awesome-dsh-plugin L4 · 沙盒安装通过 低风险 1.8 万 0.1.1-rc.2 有
deepseek-balance-whale-widget L4 · 沙盒安装通过 低风险 4,492 0.1.7-rc.2 等 2 个 有
dsh-better-sidebar L4 · 沙盒安装通过 低风险 4,112 0.1.7-rc.2 等 10 个 有
dsh-deep-whale L4 · 沙盒安装通过 低风险 2,470 未标注 有
deepseek-design L4 · 沙盒安装通过 低风险 1,438 未标注 有

仓库档案

UI 与外观
字段来自项目仓库与公开索引,中文说明由本站标注
作者 / 维护方icrefin仓库 dsh-context-usage-guard · 默认分支 main
分类UI 与外观interface
收录类型可安装插件声明了 dsh.bundle、可用 dsh plugin add 安装的条目
开发语言TypeScript仓库主语言
许可证MIT商用或二次分发前请确认条款原文
星标 / 复刻 / issue0 / 0 / 0收录时的数值,非实时
创建 / 更新2026-10-11 · 2026-10-11最后推送 2026-10-11
本站收录2026-10-11首次进入本站目录的时间

README 全文

16.0 KB
作者原文,中文版优先;只做安全转义,不改内容

dsh-context-usage-guard

Keeps the DeepSeek Harness composer's context-usage ring honest: an empty usage
sample during a retry no longer collapses it to 0%, and its percentage is
typeset at the size of the figures beside it.
English | 简体中文








A DeepSeek Harness (dsh)
plugin that repairs two defects in the composer's context-usage ring — one in
the value it shows, one in how large that value is drawn:

  1. the ring stops dropping to 0% while a model request is being retried — the
    host half; and
  2. the ring's percentage renders at the size of every other figure on its own
    line — the browser half, one stylesheet rule.

The two bugs it repairs

One line, in the composer footer:

182 steps · 238 tok/s      33.4M tok · Cache hit 94%      ◯ 30%
↑
the ring's 30% was one pixel larger than every other figure

Mid-retry, the same ring read 0% instead of holding the last real reading:

◯ 0%   →   ◯ 6%

The ring collapses to 0% while a request is being retried

The ring renders the session projection contextPressure. That projection takes
the newest usage sample as the current prompt size and publishes:

pressureTokens  = usage.inputTokens + cacheReadTokens + cacheWriteTokens
projectedTokens = max(0, pressureTokens + surfaceTokens - sampledSurfaceTokens)

A model call that fails before the provider reports anything — a 429, a rate
limit, a timeout, a transport error, or a user cancellation — still ends its
stream with a usage chunk:

[ { "type": "chunk", "chunk": { "type": "usage",  "usage": { "inputTokens": 0, "outputTokens": 0, "totalTokens": 0 } } },
{ "type": "chunk", "chunk": { "type": "finish", "reason": { "kind": "error",
"failure": { "code": "RATE_LIMIT", "message": "429: token_capacity_exceeded" } } } } ]

The adapter's accumulator starts at zero and nothing ever overwrote it, so this
sample is empty, not a measurement. But it is the newest sample, so
pressureTokens becomes 0, and because the sample is stamped at the current
surface total the projection publishes projectedTokens: 0. @deepseek-ai/dsh-llm-retry
then retries the same step — six times in the session this plugin was written
from — and the ring reads 0% for the whole storm, misreporting a context that
never changed.

Measured against the shipped contextPressure fold, replaying that session's
real events (test/fold.spec.ts):

Replay pressureTokens projectedTokens Ring
after the last successful call, before the retry 64 389 64 389 6%
the failed attempt, unguarded 0 0 0% ← the symptom
the failed attempt, guarded 64 389 64 389 6%
the retried step finally succeeds 64 575 64 575 6%

The percentage is one pixel larger than the figures beside it

The same footer band holds the session statistics and the ring, and the two
shipped stylesheets disagree by one pixel about how big a figure is:

/* @deepseek-ai/dsh-client-ui-chat — StatsPills.module.css, the pills */
.bOPqQW_root    { font-size: calc(var(--dsh-content-font-size-secondary,13px) - 1px) }

/* @deepseek-ai/dsh-client-ui-conversation — ContextMeter.module.css, the ring */
.JObwrW_trigger { font-size: var(--dsh-content-font-size-secondary,13px) }

Both prefixes are content-hashed per build — the pair above is what the
0.2.1-rc.3 packages installed here carry; the declarations are what matters,
and test/meter-typography.spec.ts re-reads them from the installed packages
rather than trusting this block.

So 30% renders about 8% larger than the 182 steps, 238 tok/s, 33.4M tok
and Cache hit 94% beside it, which reads as a different typeface. Measured on a
screenshot of that line: every other figure has a 12 px cap height, the ring's
has 13–14 px — a ratio of 1.08, exactly 13 ÷ 12. The meter's own breakdown
panel is already 12px, so the trigger is the outlier.

What the plugin does

Half Surface What it does
Host llm/stream waterfall one listener that withholds an empty usage sample belonging to a failed attempt, so the projection keeps its last real reading
Browser the document head one self-tagged stylesheet rule that puts the meter's percentage at the statistics pills' figure size

Neither half adds a page, a route, a settings section or a stored file. The host
half declares inject: ['llm'], so the LLM service must exist first, and it
registers inside ctx.effect: cordis runs the disposer on unload, when the
profile patch disables the row, or at shutdown — a bare ctx.on would leak the
listener past unload.

One rule, applied to the chunk stream of every model call:

> A usage sample whose every reported count is zero measures nothing. When it
> belongs to an attempt that ended in error or aborted, it is dropped, so the
> previous real reading stands.

Everything else passes through untouched:

  • a successful completion, whatever it reports — stop, tool-calls and
    max-tokens are authoritative provider answers, so a zero there is left for
    the consumer to judge;
  • a failed attempt that did report something — a partial call can carry real
    input counts, so no billed counter is ever discarded;
  • stream shape, order and timing — the withheld sample is the only chunk that
    moves; visible deltas keep their order and the terminal finish the retry
    executor reads is preserved.

How the fix works

Host half: the sample that decides the reading never lands

The wrapper holds at most one usage chunk and releases it immediately
before the next chunk, so the only chunk whose position can change is the sample
that decides the outcome. A stream that ends without its terminal finish still
releases a held sample — the guard never swallows information it did not
positively decide to drop. Withholding the chunk is legal in the stream protocol:
usage may appear at most once and is never required, BlockAssembler.usage
stays undefined without it, and the agent loop already omits the durable
event's usage field rather than failing. Token accounting is unaffected — the
projection's usage fold adds an empty sample's buckets as zero anyway, which
test/fold.spec.ts pins directly.

Browser half: one stylesheet rule

The browser half adds one stylesheet rule that repeats the statistics
declaration verbatim:

button[aria-haspopup="dialog"]:has(> svg > circle) {
font-size: calc(var(--dsh-content-font-size-secondary,13px) - 1px);
}
  • Structural selector, not a class name. The meter's button is the only
    dialog-opening control whose icon is the ring — an inline with children — while the statistics pills draw ` icons. A build that re-hashes every class name cannot break the rule, and the pills can never match it. Specificity(0,1,3)beats the shipped(0,1,0), so there is no!important`.
  • One declaration. Nothing is hidden, moved, recolored or replaced; the line
    box is unchanged, because both shipped rules already share line-height.
  • Self-limiting. test/meter-typography.spec.ts reads both declarations out
    of the installed packages and fails when they converge, so a release that fixes
    the trigger upstream says so instead of leaving a silent workaround behind.

Screenshot

The footer band as tools/preview.mjs renders it outside the GUI: the pills'
26 turns 182 steps · 238 tok/s and 33.4M tok · Cache hit 94%, and the ring's
30%, now share one figure size — all of it drawn from the installed
dsh-client-ui-chat and dsh-client-ui-conversation stylesheets. The figures
are a replay of plausible session projections, not a capture: the harness never
reads a session log, a profile or the network.

Requirements

Requirement Version Notes
DeepSeek Harness 0.2.1-rc.3 the dsh version this build is pinned to; peers are @deepseek-ai/cordis ^4.0.5, @deepseek-ai/dsh-llm 0.2.1-rc.3 and @deepseek-ai/schemastery ^3.18.5
Node.js >=22.17.0 engines.node in package.json
pnpm 11.8.0 only for developing this repository: pnpm check and pnpm build
Google Chrome, Chromium or Edge any recent only for tools/preview.mjs, the screenshot harness

The built halves are committed in lib/, so installing the plugin needs no build
step and no toolchain beyond the harness you install it into.

Install

git clone https://github.com/icrefin/dsh-context-usage-guard.git
cd dsh-context-usage-guard
sh scripts/install.sh

scripts/install.sh packs dist/dsh-context-usage-guard-0.2.1.tgz and prints the
path to give the app. The desktop profile is owned by the Electron application,
so dsh plugin add refuses it: install the tarball from Settings → Plugins
(or with the plugin-manager tool), then restart. A bundle added to a running
profile cannot be imported by that process — its module path is not in the
resolution the harness computed at boot — and the browser half additionally needs
the page reloaded.

To run the suite before or after installing:

pnpm install
pnpm check     # tsc over both halves, then 40 tests in five suites

Two operational notes:

  • Reinstalling the same version is a no-op. pnpm sees an unchanged spec and
    leaves the extracted copy in node_modules alone, so a rebuilt tarball at the
    same version does not reach the profile. Remove the bundle first, then install
    it again — or bump the version.
  • A host-side change reaches the running app only on the next start. On the
    first install the host listener activates and the browser half registers as
    soon as the install finishes. After that the two halves diverge: the browser
    bundle is re-imported when its revision changes, but the host half is a
    boot-time ESM import and keeps serving the code the process started with.
    This is upstream behaviour; client-side changes never need a restart.

Uninstall

Remove the bundle from Settings → Plugins (or with the plugin-manager tool)
and restart. Nothing else is written: no route, no file, no stored state. The
stylesheet goes with the bundle — the client module system evicts any ``
tagged for this package, and the plugin's own effect removes it even earlier.

Configuration

The row's Config is the settings namespace, so the values live in the row's
config in /cordis.patch.yml:

- id: dsh-context-usage-guard
config:
enabled: true
logHeldSamples: false
Field Type Default Meaning
enabled boolean true While off, every stream is passed through untouched.
logHeldSamples boolean false Log one host line per withheld sample: route and failure code.

Both fields are volatile, so a change applies to the next request with no reload.
The defaults change nothing except the repair itself: a fresh install behaves
like a stock one that keeps its context reading honest.

[dsh-context-usage-guard] held an empty usage sample from a failed request
(example-provider/example-model-v1, RATE_LIMIT); the context reading stays at its last value

What this plugin deliberately does not do

  • It does not touch the projection registry. dsh-token-meter registers
    contextPressure internally and the registry shares a key rather than
    replacing it, so a second registration cannot override the fold, and
    re-registering the same key first would hijack a package this plugin does not
    own. Repairing the fold's input is the narrow fix; the fold itself is left to
    its owners.
  • It does not replace or restyle the ring's component. The meter is rendered
    inside dsh-client-ui-conversation's input bar with no extension seat. The one
    thing the browser half does is add a font-size declaration to the trigger the
    statistics already prove is wrong; the ring, its icon, its colors, its hover
    state and its dialog are the shipped ones.
  • It does not invent a number. When nothing measurable has ever been
    reported, the projection stays absent and the ring stays hidden — the shipped
    behavior — rather than showing a value nobody measured.
  • It does not freeze the reading. The next successful attempt reports real
    usage and the ring advances, which the suite asserts.

Limits

  • The repair is about failed attempts. A successful completion reports what
    the provider sent, zeros included, because a stop/tool-calls/max-tokens
    answer with zero counts is still an answer. The plugin never overrides a
    provider's own numbers.
  • The browser half is a workaround with a built-in expiry. It exists because
    the two shipped declarations differ; the moment they converge the suite fails
    and the rule should be deleted rather than kept.
  • Its pixels are checked outside the GUI, not inside a live session.
    tools/preview.mjs renders the real bundle and the real stylesheets in headless
    Chrome and fails unless the meter matches the pills; what the running app paints
    with a user's own theme and font settings is not asserted automatically.
  • The host half only sees calls that use the LLM service. It sits on the
    llm/stream waterfall, which is where the harness routes model calls; a
    provider reached around that service is neither guarded nor broken by this
    plugin.

Troubleshooting

The ring still reads 0%. Check that enabled is true. If it is, the
reading came from a call that completed successfully: the guard withholds empty
samples only from attempts that ended in error or aborted, and a successful
answer reporting zero is left for the consumer to judge. Once a retried step
succeeds, the next real usage sample takes the reading over again.

The percentage still looks larger than the figures beside it. The rule is
installed when the browser half registers, so a plugin installed into a running
app needs the restart described in Install and then a page reload.
After that, test/meter-typography.spec.ts is the authority: it fails when the
shipped declarations converge, which is the signal to delete the rule.

No held an empty usage sample line appears in the log. That line is behind
logHeldSamples, which defaults to false; the repair itself does not depend on
it. Turn it on and the next withheld sample prints the route and the failure code.

License

MIT — see LICENSE.

> If this plugin keeps your context reading honest, a ⭐ star helps other DSH
> users find it.


Built for DeepSeek Harness 0.2.1-rc.3 · MIT · issues and pull requests are welcome.

常见问题

7 问
答案由本站依据条目字段整理,不引用上游原文
dsh-context-usage-guard 怎么安装?

本站没有抓到该条目的安装命令,请到仓库主页确认安装方式;这类条目多数是生态应用或尚未发布安装包的项目。

dsh-context-usage-guard 的验证等级是什么意思?

未标注验证等级。上游未给出验证结论,安装前请自行确认

dsh-context-usage-guard 安全吗?

未标注。

dsh-context-usage-guard 装之前要先确认什么?

先看它会读写哪些文件、执行哪些命令、连接哪些网络地址;验证等级只说明装得上、跑得起来,不等于安全。涉及密钥或系统权限的,建议先在隔离环境试装。

dsh-context-usage-guard 用的是什么许可证?

上游标注为 MIT。商用或二次分发前请到仓库确认许可证原文。

dsh-context-usage-guard 有哪些功能?

重试期间保持真实上下文读数、空用量样本不再归零、百分比字号与同行数字一致、含 40 项测试覆盖两处修复。

这条记录的数据可靠吗?

本站按仓库名去重后合并整理,字段以作者仓库与 npm 元数据为准;安装命令、仓库地址与 README 保持原文,带 L4 / L5 标记的安装命令已在隔离沙盒里真实跑通。

UI 与外观
按星标排序,可作替代方案

awesome-dsh-plugin

awesome-dsh-plugin

A curated list of plugins for DeepSeek Harness (dsh) · DeepSeek Harnes

L4 · 沙盒安装通过 1.8 万 星

deepseek-balance-whale-widget

DeepSeek-Balance-Whale-Widget

DSH 界面右下角的常驻小鲸鱼余额挂件,实时显示 DeepSeek 账户余额、今日已用与每轮对话消耗,支持拖拽吸附、Q 弹动画与音效,开箱即

L4 · 沙盒安装通过 4,492 星

dsh-better-sidebar

DSH-better-sidebar

面向 DeepSeek Harness 的服务化侧边栏工作台插件,把文件编辑、终端、Git 变更、子代理任务与侧边对话整合进右侧栏与底部面板

L4 · 沙盒安装通过 4,112 星

dsh-deep-whale

dsh-deep-whale

DSH Web 鲸鱼娘皮肤系列(深海女仆工坊 maid-atelier)。

L4 · 沙盒安装通过 2,470 星

deepseek-design

deepseek-design

可视化设计工作室,支持网站、App 原型、海报、信息卡、报告和杂志的模板创建、元素编辑、选区级 AI 草稿衔接与导出。

L4 · 沙盒安装通过 1,438 星

superdesign-skill

superdesign-skill

Superdesign为DeepSeek Harness等编码代理提供设计判断力,将AI生成的平庸UI转化为可交付的精致前端,支持设计系统、

L3 · 安装规范通过 647 星

icrefin 的其它插件

6 个

插件的元信息来自作者仓库;分类、验证等级与安全结论的中文说明为中文整理,最近核验 —。