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-bailian-token-plan

v0.1.4

Published

阿里云百炼 Token Plan 用量统计插件:5小时/周/月滚动窗口、订阅 Credits 与重置倒计时、额度横条、点击立即刷新、峰/谷切换弹窗与系统通知提醒。Alibaba Cloud Bailian (Model Studio) Token Plan usage meter for DeepSeek Harness: rolling 5h/week/month windows, subscription credits & resets, quota strip, click-to-refresh,

Readme

dsh-bailian-token-plan

阿里云百炼 Token Plan 用量统计插件(DeepSeek Harness,深浅色自适应、中英双语界面)

统计百炼 Token Plan 订阅用量:滚动 5 小时 / 本周(个人版)、订阅 Credits 总额/剩余/到期(团队版),并提供峰值/谷值时段展示与切换前的弹窗、系统通知提醒。

本插件 UI 交互参考 dsh-cost-meter(额度横条、点击刷新、峰谷提醒弹窗/图解),宿主通道参考 dsh-token-stats 的已验证模式;百炼接口形态参考 CodexBar 的 Qwen Cloud provider。

功能

  • Token Plan 用量统计(侧边栏卡片 + 设置页):个人版滚动 5 小时/本周窗口的已用%、重置倒计时;团队版 Credits 总额/剩余/已用/到期;可挂载额度上限(来自 quota-config)与本地历史采样曲线缓存。
  • 点击立即刷新:点击侧边栏卡片任意处、卡片头部 ⟳ 或输入框上方横条 chip,立即触发一次真实拉取;刷新中按钮呼吸动画;失败保留上次数据并给出错误原因。
  • 额度横条:输入框上方一条横排 chips(短标签 + 迷你进度条 + %),≥80% 橙色预警、≥100% 红色超支;悬停显示重置时刻;点击 chip 即刷新;可开关。
  • 峰/谷切换提醒图解:docs/peak-alert.md 完整的触发时序、配置项与提醒矩阵图解。
  • 峰/谷切换弹窗提醒:进入峰/谷前按提前量(默认 2 分钟,1–30 可配)弹出全局色条徽标(进峰橙/进谷蓝),位置可选右下角/屏幕中心,提醒类型可选(仅进峰/仅进谷/峰和谷),同一切换点只提醒一次;可选同步发送浏览器系统通知(页面最小化仍可收到);设置页可一键预览真实弹窗。

为什么不能直接用 dsh-cost-meter

dsh-cost-meter 与百炼 Token Plan 的需求不匹配:

| 需求 | dsh-cost-meter 现状 | 差距 | |---|---|---| | 多窗口用量(5h/周/月) | 自定义 Provider 余额只有单值余额(remaining/max/spend + JSON path extract) | 表达不了窗口百分比×3、各窗口重置时刻 | | 订阅 Credits(团队版) | 无百炼 provider(内置 9 家 Coding Plan 无阿里云) | 需要专用客户端与归一化 | | 控制台会话(Cookie + sec_token) | 自定义余额只支持"GET + Authorization 头",无会话解析/表单网关流程 | 需要专用客户端 | | 峰谷提醒 | 时段表是 DeepSeek 官方峰谷(UTC 01:00–04:00/06:00–10:00),且不可针对百炼套餐复用 | 需要可配置时段表 + 预设 |

因此本插件在 UI 交互上借鉴它(横条/点击刷新/弹窗/图解),数据链路则全部针对百炼重新实现。

安装

需求:Node.js ≥ 20 + DeepSeek Harness(带 dsh plugin 命令,npm i -g @deepseek-ai/dsh)。

# 本地目录安装(开发)
git clone <本仓库URL> && cd dsh-bailian-token-plan
dsh plugin --profile web add link:.

# 安装后重启 web
dsh web

快速配置

  1. 浏览器登录百炼控制台:
  2. 打开浏览器 DevTools → Network,刷新用量页,找到请求(过滤 tokenplan / sfm_bailian / usage),复制其 Cookie 请求头。
  3. 打开插件右上角 ⚙ 设置 → 连接:选择站点与套餐类型,粘贴 Cookie 头,点测试连接;返回配额 JSON 即成功。
  4. 可选:设置 → 峰谷 → 载入预设(Qwen 国际站参考 / 周末全谷)或手动编辑时段表;设置 → 提醒 → 打开弹窗提醒与系统通知。

国内站两条通道

  • bl CLI 通道(推荐):安装并登录官方 CLI bl(npm i -g bailian-cli && bl auth login),在设置中勾选「优先使用官方 bl CLI 通道」。插件直接调用 bl usage token-plan --output json,鉴权与网关由官方 CLI 负责,国内站最稳。
  • Cookie 直连:国内站控制台网关地址非公开文档,请在"Gateway 覆盖"粘贴抓包到的真实网关 URL/action(步骤见 docs/api-capture.md)。

数据与安全

  • 配置与缓存放 $DSH_HOME/storages/bailian-token-plan/state.json(POSIX 下 0600,原子写入)。
  • Cookie 只存本地、只发给所配置的网关域名;前端界面始终以 ●●●● 掩码显示,回存掩码值不会覆盖真实凭据(宿主端保护)。
  • 前端仅轮询同源 /bailian-token-plan/state(默认 15s,纯内存读取,不产生外部请求);真实拉取只在缓存过期或点击刷新时发生(默认 15 分钟自动过期)。
  • 插件不向任何第三方上报数据。

架构

┌─ 浏览器(注入 shell.overlay)────────────────────────┐
│  SideCard(用量卡片) · StripRow(额度横条)          │
│  AlertPopup(峰/谷弹窗 + 系统通知) · SettingsModal   │
└───────────▲──────────────────────────────────────────┘
            │ fetch /bailian-token-plan/state|action(同源)
┌─ 宿主(cordis 插件)──────────────────────────────────┐
│  lib/index.js  路由注册、异步刷新调度、配置校验        │
│  lib/bailian.js 三通道客户端+容错归一化               │
│  lib/peak.js   峰谷时钟纯函数                        │
│  lib/store.js  持久化(cookie 掩码保护)              │
└───────────────────────────────────────────────────────┘

开发与验证

corepack pnpm install   # 无运行时依赖,仅开发工具,可跳过
npm run check           # node --check 全部模块
npm run test            # node --test test/

注意:当前沙箱环境下 node --test 的默认子进程隔离不可用,可用 node --experimental-test-isolation=none --test test/(用户机器上无需该参数)。

已知限制

  • 百炼控制台接口为非公开契约,字段可能随控制台改版变动;归一化已做多形态容错,无法识别时保留原始响应(设置 → 测试连接可见)供校准。
  • 个人版国际站默认网关/action(home.qwencloud.com/sfm_bailian、IntlBroadScopeAspnGateway)有第三方实现背书;国内站网关请以抓包为准。
  • 峰谷时段表以阿里云官方套餐说明为准:插件内置两个参考预设 + 完全自定义,不替用户断言官方时段(不同套餐/区域的峰谷可能不同)。
  • Cookie 会过期;会话失效时隔天点击刷新会给出明确错误提示,重新粘贴即可。
  • 与 dsh-cost-meter 无冲突:两者通道、存储路径、UI 前缀均独立。

License

MIT