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

@kongjianguan/dsh-opencode-usage

v0.2.8

Published

Persistent opencode.ai usage widget: header progress + settings page + webServer API routes.

Readme

dsh-opencode-usage

DeepSeek Harness(dsh web)持久化插件:在输入框工具行右侧显示 opencode.ai 额度用量同心圆(5 小时 / 本周 / 本月),hover 弹出详情面板,实时重置倒计时。

English version: README-en.md

安装

  1. 发布版(npm):

    dsh plugin --profile web add @kongjianguan/dsh-opencode-usage

    本地开发(link 安装,热重载友好):

    dsh plugin --profile web add link:/path/to/dsh-opencode-usage
  2. 重启 dsh web(客户端模块扫描需重启生效;之后插件支持热重载)。

功能

  • 输入框同心圆(可选,默认开启):在输入框工具行右侧(模型名左侧)显示三层同心圆——最内层月、中间层周、最外层 5 小时额度;圆环按真实百分比绘制(0% 不画弧、100% 无端帽凸起、低百分比保持比例)
  • hover 详情面板:鼠标悬停同心圆即弹出 5h / 周 / 月 三行详情(进度条 + 百分比 + 重置倒计时,每秒实时跳动);移开 180ms 自动收起;键盘 Enter/Space 可切换、Esc 关闭
  • 面板右上角刷新按钮:点击强制刷新用量(绕过缓存)
  • 最顶层显示:面板 position: fixed + 最大 z-index,不被任何侧边栏遮挡
  • 不覆盖侧边栏:面板自动探测聊天区可用范围(左右侧边栏之间),优先贴输入框右缘展开;聊天区变窄时右移避让左侧栏
  • 宽度自适应:聊天区 ≥264px 时面板 264px 正常显示;264–200px 时收缩至聊天区宽−16px(紧凑模式:压缩 label、隐藏重置倒计时);<200px 时隐藏面板,降级为原生 tooltip(按钮 title 三行摘要)
  • 按钮自动隐藏:窄布局下用量按钮与左侧元素(权限按钮等)重叠时自动隐藏按钮本身,空间恢复后自动显示(带滞回防抖动)
  • 配色对齐官方 ContextMeter(0 硬编码色值,全部使用 dsh web 设计令牌,随主题自动切换):
    • 弹窗:背景 --dsw-specific-menu、边框 --dsw-alias-border-inverted(hairline)、阴影 --dsw-shadow-lv3、圆角 12px、正文 label-secondary、数字 label-primary
    • 按钮/圆环:图标 label-secondary、hover 背景 interactive-bg-hover、圆环轨道 border-l3、圆环填充 label-tertiary
    • 进度条:轨道 interactive-bg-hover、填充与色块 label-tertiary、百分比数字 label-primary
    • 设置页:状态消息成功 state-success-primary / 失败 state-error-primary,其余控件随 dsh 默认令牌
  • 原生 tooltip 协调:弹窗打开时清空按钮原生 tooltip,避免双重提示;弹窗隐藏(空间不足)时原生 tooltip 兜底
  • 设置页(设置 → OpenCode 用量):Workspace ID、完整 Auth Cookie、刷新间隔、输入框同心圆开关;配置持久化到 ~/.dsh/ocu-config.json(0600),重启不丢

使用

设置 → OpenCode 用量:填入 Workspace ID 和完整 Auth Cookie(浏览器打开 opencode.ai,从开发者工具复制 auth cookie),点"测试连接"。

工作原理

  • 双端结构:lib/index.js 是 Host 插件(Cordis plugin),lib/client.js 是浏览器 bundle(window.__ModuleLoader__.load(...),由 package.json 的 dsh.client 声明发现)。
  • RPC:Client 通过同源 fetch 调用 Host 注册的 webServer 路由:GET/POST /ocu/api/config、POST /ocu/api/usage。
  • 数据源:Host 用 subprocess 跑 curl 抓取 https://opencode.ai/workspace/{workspaceId}/go,解析页面内嵌的 lite.subscription.get 数据(rollingUsage / weeklyUsage / monthlyUsage,含 usagePercent 与 resetInSec)。
  • 面板定位:Client 每帧(requestAnimationFrame)按视口坐标钳制面板位置——固定在最顶层、约束在聊天区范围内、跟随按钮移动;布局变化(侧边栏开关/拖动、窗口缩放)自动纠正。

安全

  • 切勿把 auth cookie 或 workspace ID 提交到仓库。源码默认值为空,实际值只存在于 ~/.dsh/ocu-config.json(0600)。
  • API 路由仅监听本机 dsh 服务,请勿在不可信环境暴露。

许可证

MIT — see LICENSE