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-plugin-model-usage-meter

v0.2.0

Published

Model usage meter: a context-occupancy ring rendered left of the composer model name

Readme

dsh-plugin-model-usage-meter

DeepSeek Harness(DSH)Web 客户端插件:在消息输入框的模型名左侧显示一枚额度用量环,点击弹出悬浮面板展示今日 / 本周 / 本月的用量与限额;当会话选用 ModelScope(魔豆)站点时,自动切换为魔豆余额环

演示

功能

  • 用量环:显示最紧预算周期(今日 → 本周 → 本月)的已用百分比,跟随当前会话选中的模型自动切换提供方。
  • 魔豆余额环:当 provider 指向 modelscope.cn 站点时,宿主端改调 openapi/v1/magicubes/balance,圆环显示「可用余额 / 每日 250 豆」的占用比——250 豆/人/天 即进度条的总长度。面板列出可用 / 冻结 / 总余额三行。
  • 状态色:用量 < 80% 为绿色(额度充足),≥ 80% 为棕黄色(额度快满);魔豆余额 ≤ 20%(≤ 50 豆)时同样转棕黄提醒。
  • 悬浮面板:点击圆环弹出,样式与官方上下文仪表一致——头部百分比 + 右对齐金额、条形进度、各周期图例行。桌面端从圆环右上角展开,移动端为底部浮层。
  • 安全:API key 只存在于服务器端。浏览器只请求本插件的宿主代理路由,由宿主端读取 provider 的 baseURL 与凭据后调用 {baseURL}/usage(ModelScope 站点则调用其余额接口),key 永不下发到浏览器。

安装

方式一:npm(推荐)

dsh plugin --profile web add dsh-plugin-model-usage-meter

包自带 dsh.bundle 声明,安装即自动注册为 profile layer,无需手动编辑任何配置。重启生效:

pkill -f "dsh web"; sleep 2; nohup dsh web --no-open > /tmp/dsh-web.log 2>&1 &

方式二:GitHub

dsh plugin --profile web add git+https://github.com/iamyours/dsh-plugin-model-usage-meter.git

同样重启生效。

方式三:本地开发(file: 依赖)

把仓库克隆到 $DSH_HOME/profiles/plugins/ 下,然后:

dsh plugin --profile web add file:../plugins/dsh-plugin-model-usage-meter

开发期间修改 lib/client.js 经 HMR 热更新,刷新浏览器即可;修改 lib/index.js(宿主半)需重启。

更新

dsh plugin --profile web update dsh-plugin-model-usage-meter
# 若 pnpm 缓存导致未升级,显式指定版本:
dsh plugin --profile web add dsh-plugin-model-usage-meter@<版本号>

前置条件

宿主端代理路由需要从 llm-pi-ai settings 段读取 provider 配置:

{
  "providers": {
    "zuco": {
      "baseURL": "https://api.zuco.ai/",
      "apiKeyEnv": "ZUCO_API_KEY"
    }
  }
}

其中 apiKeyEnv 指向的凭据需已在 DSH 凭据服务中配置(如环境变量)。provider 的 /usage 端点需返回形如:

{
  "subscription": {
    "daily_usage_usd": 95.4, "daily_limit_usd": 100,
    "weekly_usage_usd": 125.68, "weekly_limit_usd": 700,
    "monthly_usage_usd": 513.92, "monthly_limit_usd": 3000
  }
}

ModelScope(魔豆)站点

provider 的 key 为 modelscope,或 baseURL 指向 modelscope.cn / *.modelscope.cn 时,宿主端不走 {baseURL}/usage,而是改调其余额接口(固定地址,与 baseURL 无关):

GET https://modelscope.cn/openapi/v1/magicubes/balance
Authorization: Bearer <apiKeyEnv 解析出的凭据>

接口需返回形如:

{
  "success": true,
  "request_id": "022161e1-e8e5-498c-9d0b-a327e2839607",
  "data": { "total_balance": 140, "available_balance": 140, "frozen_amount": 0 }
}

宿主端将其归一化为 { magicubes: { daily_max: 250, total_balance, available_balance, frozen_amount } } 下发。其中 daily_max = 250 是「每人每天最多 250 豆」的配额,即魔豆进度条的总长度;圆环与条形进度展示 available_balance / 250 的占用比,面板头部显示百分比与 可用 / 250 豆,图例行展示可用 / 冻结 / 总余额。

未配置或端点不可用时,用量环自动隐藏,不影响其他功能。

包结构

| 文件 | 作用 | |---|---| | package.json | 插件清单;dsh.bundle 声明使其成为 profile layer,dsh.client 声明浏览器插件 | | cordis.patch.yml | bundle 层自带的 Loader insert 条目(id: model-usage-meter) | | lib/index.js | 宿主半——注册 /plugins/model-usage-meter/quota 代理路由(读 settings + 凭据,调 provider /usage;ModelScope 站点改调 magicubes/balance 并归一化,带 30s 缓存) | | lib/client.js | 客户端——用量环 / 魔豆余额环组件,注册到 conversation.input.right 槽位,轮询宿主路由 |

许可

MIT