npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dsh-context-reminder

v0.6.1

Published

Shows a persistent, color-coded context reminder above the composer as the model context fills up, with a button that asks the assistant for a starter prompt.

Readme

Context Guard

上下文预算提醒(DSH 插件,Host 空壳 + 客户端实现)。会话上下文接近收尾线时, 在输入框上方常驻一行按占用变色的提醒(灰 → 黄 → 红),旁边一个「生成开工提示词」按钮; 点击才把请求发给模型。不碰系统提示词、不自动改动草稿。

安装

已发布到 npm([email protected]):

dsh plugin --profile desktop add dsh-context-reminder

也可以直接从本仓的 Git 地址安装(不经过 npm):

dsh plugin --profile desktop add "git+https://gitee.com/DeyaoCai/dsh-context-guard.git"

Git 安装保存的是 git spec;updateBundle 只接受 pin 到完整 40 位 commit 的 spec,想用更新功能就装成 git+https://gitee.com/DeyaoCai/dsh-context-guard.git#<commit>。装完重启 Desktop(客户端 bundle 通常由 HMR 热替换,没生效就刷新页面)。

本地开发时,把本仓目录作为 bundle 安装(Plugins → Add plugin 选本目录),或在 profile 的 package.json 里用 "dsh-context-reminder": "link:<本仓路径>" 指向检出目录。Host 插件在 DSH 启动时装载。

它做什么

client.js 注册一个 conversation.input.dock 条目(输入框上方的整行区域):

  • 读 contextPressure 投影(和输入框下方的上下文圆环同源),优先用 projectedTokens, 缺省回退 pressureTokens;
  • 收尾线取两条线里更早的那个:
    • 绝对 20 万 tokens——1M 窗口按 50% 算要 50 万,太晚;实测 20 万后细节召回开始变差;
    • 窗口的 80%——32K / 64K 小窗口永远够不到 20 万,用比例兜底;
  • 用到收尾线 70% 就出现,之后常驻(手动关掉或换会话才消失;清掉阈值只是回到自动线,不会收起), 颜色随接近程度变化:
    • 灰(收尾线 70%–80%):观察;
    • 黄(80%–100%):接近,文案带「接近收尾线(还差 X)」;
    • 红(≥100%):到线,文案变「建议收尾换会话」;
  • 出现时渲染一行带底色和小图标的提醒: 上下文 258K / 收尾线 200K · 已超 58K · 建议收尾换会话 [生成开工提示词] 阈值 [200]K 自动 [×]; 分母用收尾线而不是窗口:窗口占比交给输入框下方的 ContextMeter,这里只回答“离收尾还有多远”;
  • 按钮旁的「阈值」可以直接改(单位 K):回车或失焦生效,存 localStorage;留空或点「恢复自动」 回到 min(200K, 窗口 × 80%)(没改过阈值时这里是灰色「自动」标签,改过才变成可点的「恢复自动」)。 「恢复自动」只重置阈值,不会自动发送消息或切换会话。自动线的实际值:窗口 ≥250K 时是 200K, 更小的窗口取 80%(32K → 26.2K,64K → 52.4K)。填的值达到或超过当前窗口时直接回到自动, 避免显示值与实际判定不一致;没改动就离开输入框也不会把「自动」变成手动。只要手动阈值还在, 行就一直显示(即使还没到 70%),文案按与自动线的比较写「阈值已调高 / 已调低」,且不提供 ×; 本会话在红档点过 × 后不再出现。这样把阈值填大后刷新也不会找不到改回自动的入口。 换会话或重启后按新阈值判断;
  • 点按钮 → 先显示「发送中…」,Host 接收(进入队列)后显示「已排队」2 秒,再变回「再次生成」; 提醒行不自动收起(这正是「常驻」的意思),由用户决定何时换会话。queue 模式只保证请求 入队,当前轮次结束后才会生成;conversation.send() 发的仍是一条“要交接”的请求,让模型给出 3–6 行「下轮开工提示词」,复制到新会话即可。若 Host 拒收或 15 秒未接收,按钮变「发送失败,重试」, 提醒保留;
  • 点 × 记下关掉时的档位:灰档关掉后,升到黄/红会再提醒一次;黄档同理;红档关掉后本会话 不再提醒(tooltip 会写明),设置行也一起收起,要改阈值可换会话或开新标签页。标记存在 sessionStorage,键里带真实的 session.sessionId,每个标签页每会话独立。

不自动写草稿、不自动发送、不额外消耗请求——一切由用户点击决定。

为什么不再注入提示词

旧版用 system-prompt section 注入提醒,文案里的百分比每步都变。system prompt 在整段 prompt 最前面,一变就把后面所有 token 的前缀缓存打掉(本机实测缓存命中的是整段 prompt, 前缀一变就是全量重新 prefill)。改走客户端后,提示词逐字节稳定,缓存不受影响。

限制

  • 默认收尾线写在 client.js:THRESHOLD_TOKENS = 200_000、WINDOW_RATIO = 0.8、 WATCH_RATIO = 0.7、NEAR_RATIO = 0.8;用户在提醒行里改的阈值存 localStorage, 换浏览器或清站点数据会回到自动。
  • 界面文案目前只有中文;locale/zh.json / locale/en.json 只用于插件管理页的标题和描述。
  • 判定用的是上一次请求的实测 / 投影占用;输入框里刚打的长文要等 contextPressure 更新后才计入。
  • 按钮在当前会话里发消息:模型在旧会话产出提示词,你复制到新会话;DSH 没有跨会话写草稿的接口。
  • 提醒行出现后常驻,压缩导致占用回落也不会自动消失(可手动关);关掉的只是当前档位, 档位升高会再提醒一次。手动阈值还在时行会一直显示(红档关掉或换会话例外);点「恢复自动」 只把判定改回自动线,行仍常驻,直到手动关掉或换会话。
  • 提醒状态在 sessionStorage:每个标签页每会话独立,应用重启后清空,可能再提醒一次。
  • 依赖客户端 bundle 加载:package.json 的 dsh.client 与 ./client 导出缺一不可。

本地验证

node --check client.js
npm pack --dry-run   # 确认发布包含 index.js / client.js / patch / locale / icon / README / LICENSE

# 想立刻看到:DevTools 里把阈值改小,例如
# localStorage.setItem('dsh-context-reminder:thresholdTokens', '20000')
# 刷新后,占用到 14K(20K 的 70%)就会出现;再点「恢复自动」恢复自动线。
# 颜色:占用/阈值 < 0.7 不显示;0.7–0.8 灰;0.8–1 黄;≥1 红。

发布

npm login --registry=https://registry.npmjs.org/
npm publish --registry=https://registry.npmjs.org/ --access public

npm 的默认 registry 若是镜像(如 npmmirror),必须显式带 --registry。首次发布会走 npm 的 staged publishing:先出现 0.0.0-stage 占位版本,正式版本处理完(或维护者批准)后 latest 才指过去。

License

MIT,见 LICENSE。