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-glm-usage

v0.1.1

Published

DSH sidebar widget for GLM Coding Plan usage: 5h/weekly window progress bars + refresh countdown (Zhipu API) / DSH 侧边栏 GLM 用量监控

Readme

dsh-glm-usage

DSH(DeepSeek Harness)侧边栏 GLM Coding Plan 用量监控插件:在侧边栏底部、Cordis Plugin 按钮上方显示一条带双进度条的用量行。

GLM 5h 42% 周 18%        2h13m后刷新
████████████░░░░░░░░░░░░░░░░░░░░░░   ← 5h 滚动窗口 (绿/橙/红)
█████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░   ← 周窗口
[🔌 Cordis Plugin ▾]
[⚙ 设置]
  • 5h 滚动窗口 + 周窗口用量百分比,按 TOKENS_LIMIT 的 unit 3/6 区分
  • 颜色分级:<30% 绿、30–70% 常色、70–90% 橙、≥90% 红
  • 右对齐 刷新倒计时(XhYm后刷新),本地每 30s 重算
  • 每 3 分钟向智谱 API 拉取一次;窄轨(图标模式)不渲染
  • 出错时整行变红显示 GLM ⚠ <原因>,悬停看详情

安装

从 npm 安装(名称 dsh-glm-usage):

dsh plugin --profile web add dsh-glm-usage

或直接从 GitHub 安装:

dsh plugin --profile web add github:caimaoy/dsh-glm-usage

或本地路径(开发模式,link: 链接,改代码重启即生效):

dsh plugin --profile web add /path/to/dsh-glm-usage

安装后重启 DSH(dsh web)。dsh plugin 是 pnpm 转发器:声明了 dsh.bundle 的包会自动加入 profile 的组合层栈,本包的 cordis.patch.yml 随之组合进宿主 composition——重启持久,不再像动态插件那样进程重启即失。

配置

需要一个智谱 API Key(与 GLM Coding Plan 同账号):

# 方式一: DSH 凭据 (~/.dsh/.env)
echo 'ZHIPU_API_KEY=你的key' >> ~/.dsh/.env

# 方式二: 环境变量 (启动 dsh 的 shell 里)
export ZHIPU_API_KEY=你的key

Key 只在宿主进程内使用,经 HTTPS 直发 open.bigmodel.cn,不进命令行、不落日志。

结构

| 文件 | 作用 | |------|------| | lib/index.js | host 半:glmUsage Typert Remote 服务(SRC 模式),原生 fetch 直连智谱配额端点 | | lib/client.js | client 半:window.__ModuleLoader__ CJS 工厂,经 connection.rpc.call('/api','glmUsage/usage') 拉数,渲染进度条 | | cordis.patch.yml | 组合行:- insert: [{id: glm-usage, name: dsh-glm-usage}] | | package.json | dsh.bundle.patch 声明(进层栈)+ dsh.client(web 平台 client 面) |

技术要点(踩坑沉淀)

  • Remote 方法标记:Node 22 无原生装饰器,lib/index.js 手工复刻 TS 编译产物 __esDecorate 的效果——调用 Remote('usage') 返回的装饰器,喂入等价 decorator context,在构造函数里以实例为 this 重放其 initializer,把方法标记进 typert-protocol 的模块私有 markers 表(SRC 发现的唯一来源)。
  • client 面免代码生成:不走生成式 strict 描述符,直接 ctx.get('connection').rpc.call('/api', 'glmUsage/usage', {args:{}}),信封 {ok,value|error} 自己解。
  • 独占一行:槽容器是横向 flex 不换行,badge 自身 width:100%;自有类 .glmu-row(flex:0 0 100% !important + 不可压缩)是关键,inline 样式的 flex-basis:100% 会被容器 shrink 挤断行。
  • host 结果必须 lossless JSON(缺失字段用 null,不能 undefined)。

卸载

dsh plugin --profile web remove dsh-glm-usage

仓库内容与 npm 包内容

npm 包(files 字段控制)只含运行所需:lib/cordis.patch.ymlREADME.mdLICENSE

GitHub 仓库额外保留开发史料:packages/v3packages/v7(本插件的动态 Cordis 插件演进史,会话内 define/run、进程重启即失)、SPEC.md(最初实现规格)、reference/pi-glm-usage.ts(参考实现)。它们不随 npm 分发。

License

MIT — 与 pi-glm-usage 一致