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-usage-stats-alhabor

v0.2.17

Published

Usage statistics for DeepSeek Harness: aggregated token and cost metering per session, per day, per week, per month and over custom date ranges, with per-model breakdown, peak-hour pricing, durable daily history, a Settings usage panel and the /usage comm

Readme

📊 dsh-usage-stats

DeepSeek Harness 的 API 开支监控:逐请求明细、上期对比与历史图表,一个面板全览。

让每一分 token 开支都看得见。

License DSH plugin Node

English · 简体中文 · Español · Português · हिन्दी


兼容性

| 方面 | 状态 | |---|---| | Harness | DeepSeek Harness 0.1.0-rc.8 | | Node | ^22.19.0 \|\| >=24.0.0 | | 界面 | Host + Web 客户端(设置页「用量统计」页签);/usage 命令 |

你能得到什么

dsh-usage-stats 把会话事件流变成完整的 API 开支监控面板:

  • 汇总卡片 —— 今日 / 本周 / 本月 / 累计四张卡片,每张带较上期(昨日 / 上周 / 上月)的百分比增减角标。
  • 当前对话逐请求明细 —— 每条模型请求的请求时刻、轮次/步骤、模型、输入 / 输出 / 缓存读 / 缓存写 tokens、按请求时价格核算的费用与峰时标记;基于会话投影持久化,重启后依然完整(有界环形缓冲,requestLog 配置)。
  • 日 / 周 / 月视图 —— 本期 vs 上期对比面板(费用、tokens、调用数、峰时调用数 + 增减百分比)与期内逐日明细。
  • 历史面板 —— 逐日费用柱状图(峰时柱着色区分,悬停显示明细)+ 逐日表格(费用 / tokens / 调用 / 峰时,逐模型下钻),默认保留 90 天(持久层按会话保留约一年)。
  • 自定义区间 —— 任选起止日期查询:区间合计、逐日图表、逐周明细、模型明细。
  • 计价 —— 内置 USD 价目表与 config.prices 合并;峰谷计价按请求开始时间生效(peak.hours 窗口 × multiplier 或显式 peak.prices),日历分桶跟随 peak.timezone
  • 碳足迹与延迟 —— token→碳桥接(tokens × kWh/token × PUE × 区域电网强度)与按模型延迟百分位。

快速开始

# 1. 把 bundle 装进你的 profile(tarball 通道)
pnpm pack
dsh plugin --profile web add ./dsh-usage-stats-<version>.tgz

# 2. 重启并核实行
dsh web --restart
dsh --profile web --dump-config | grep -A2 'id: usage'

然后在会话里输入 /usage,并在设置页查看「用量统计」页签。

安装与卸载

  • npm 通道(已发布版本):dsh plugin --profile web add dsh-usage-stats-alhabor —— npm registry,由 tag 触发发布。
  • git 通道(最新 main):dsh plugin --profile web add "github:PerryLink/dsh-budget#main" —— prepare 脚本仅用生产依赖构建。
  • tarball 通道:在本仓库执行 pnpm pack,然后 dsh plugin --profile web add ./dsh-usage-stats-<version>.tgz
  • 卸载dsh plugin --profile web remove dsh-usage-stats

配置

所有字段都是 Schemastery 校验的 cordis 配置(默认值见 cordis.patch.yml)。

| 键 | 默认值 | 含义 | |---|---|---| | prices | {} | 每模型每 1M token 单价,合并覆盖内置 USD 价目表 | | defaultPrice | {input: 1.0, output: 3.0} | 两表均无该模型时的回退价格 | | peak.enabled / timezone / hours / weekendOffpeak / multiplier / prices | true / Asia/Shanghai / [[9,12],[14,18]] / true / {input:2, output:2, cacheRead:2, cacheWrite:2} / {} | 峰谷计价:请求开始时间落在高峰窗口内时按 peak.prices 计价(缺失时按 peak.multiplier 放大基础价);仅周一至周五算峰时,周末全天按低谷价(DeepSeek 2026-08-23 新规);日/月分桶也按 peak.timezone 划分 | | modelAliases | {} | 模型 id 别名:带日期后缀/旧 id 映射到规范定价 id | | currency | {code: CNY, rate: 1.0, decimals: 2} | 展示货币(金额 = 核算值 × rate;直接人民币计价时设 rate: 1.0 并在 prices 填人民币单价) | | outputLanguage | zh | /usage 输出语言:en / zh | | historyDays | 90 | 面板快照保留的按天历史天数(1..365;投影持久层每会话保留约一年) | | requestLog.enabled / size | true / 200 | 当前对话逐请求明细的开关与每会话环形缓冲容量(10..2000) | | carbon.enabled / region / pue / energyKwhPerToken | true / global / 1.58 / 0.000007 | 碳桥接(区域:global, us, eu, china, india, uk, france, iceland) | | latency.enabled / windowSize | true / 200 | 按模型延迟百分位与其窗口 | | refreshIntervalMs | 5000 | 设置页签轮询间隔(保留字段) |

工具与界面

| 界面 | 类型 | 说明 | |---|---|---| | /usage | 命令 | 总览(会话/今日/昨日/本周/上周/本月/上月/累计) | | /usage models \| days \| sessions \| week <周一> \| range <起> <止> | 命令 | 模型明细 / 每日历史 / 会话列表 / 某周 / 自定义区间 | | 设置 → 插件 → 用量统计 | 设置页签 | 汇总卡片、当前对话明细、日/周/月对比、自定义区间、历史图表 | | usage/statususage/range | Typert Remote | 客户端通道(页签消费这两个方法) |

权限与数据

  • 权限session:append(仅命令审计)、native-code:none;无出站网络。
  • 数据:展示内容全部来自会话事件流的只读聚合;插件不向会话日志写入任何自定义事件(rc.8 读取路径会拒绝未知事件类型),持久化状态全部走会话投影(projection)机制。
  • 失败大声:非法价格、时区、比例、区域与边界在挂载时即失败。

已知限制

  • 逐请求明细按会话有界保留(默认最近 200 条);更早的请求只进入聚合计量。
  • 汇总卡片的上期对比在持久历史不足一个完整周期时显示「新增/持平」。
  • 内置价目会漂移;用 config.prices 覆盖条目。

开发

pnpm install        # node ^22.19 || >=24
pnpm run typecheck  # tsc:src + tests,对照本地 harness checkout
pnpm run typecheck:ci  # tsc:对照已发布的 0.1.0-rc.8 类型(无 paths)
pnpm test           # vitest:80 个测试
pnpm run build      # tsc 声明 + tsdown bundles(lib/)
pnpm run verify:self-contained  # 依赖声明全部来自 registry
pnpm run verify:artifacts       # 构建产物 ESM 面 + typert manifest + 客户端 bundle
pnpm pack           # 发布用 tarball

Topics

dsh, dsh-plugin, deepseek-harness, deepseek, cordis, budget, cost-tracking, carbon-footprint, latency-benchmark, token-usage

Contributors

  • @PerryLink —— 创建者与维护者:聚合、预算治理、碳足迹与延迟移植、设置页签与五语文档。

PerryLink DSH Plugin Family

本项目是由 PerryLink 维护的 29 个 DeepSeek Harness 插件之一。如果这个对你有用,其他插件很可能也会:

| Plugin | One-liner | |---|---| | dsh-auto-review | 审批链上的第二模型自动审查,默认失败关闭 | | dsh-background-agents | 持久化后台子代理,带 Web UI 侧边栏、消息与打断 | | dsh-budget | DeepSeek Harness 的成本治理:预算、碳排与延迟一屏呈现。 | | dsh-checkpoint-rewind | Claude Code /rewind 等价物:快照、会话分叉、一次性恢复 | | dsh-claude-move | 将 Claude Code 会话、记忆、技能与 CLAUDE.md 迁入 DSH | | dsh-click | 跨平台原生桌面控制(DeepSeek Harness),Windows 优先。 | | dsh-composer-history | Web 输入框的终端式输入历史:方向键、Ctrl+R 搜索 | | dsh-defend | DeepSeek Harness 的提示注入、越狱与密钥泄露防护。 | | dsh-doublecheck | 工程纪律门禁:需求质询、测试门禁、对抗式审查 | | dsh-draw | DeepSeek Harness 的统一静态图像生成路由。 | | dsh-fast | DeepSeek Harness 的只读性能诊断。 | | dsh-github | DSH 的 GitHub PR/issue 集成,每次写入都经审批门 | | dsh-library | DeepSeek Harness 的本地文档知识库。 | | dsh-local-ai | DeepSeek Harness 的本地模型(Ollama)接入。 | | dsh-lsp-actions | 经语言服务器的 LSP 诊断、格式化、补全、代码操作与重命名 | | dsh-mask | DeepSeek Harness 的 PII 脱敏中间件——数据到模型前匿名化,展示层还原。 | | dsh-mcp-panel | 只读 MCP 运行时面板:/mcp 命令 + 带状态、工具与错误的设置页 | | dsh-memento | 带审批门的跨会话记忆:ctx.memory 接缝 + SQLite + memory 工具 | | dsh-observe | DeepSeek Harness 的 OpenTelemetry 与 Langfuse 可观测导出器。 | | dsh-output-styles | Claude Code outputStyles 等价的运行时样式切换 | | dsh-permission-rules | Claude Code 风格声明式 allow/deny/ask 权限规则,带审计 | | dsh-plugin-guide | 按需 agent 技能形式的插件开发知识库 | | dsh-score | DeepSeek Harness 插件的多指标质量评分。 | | dsh-session-pin | 在 Web 侧边栏置顶会话,顺序持久化 | | dsh-session-sync | DeepSeek Harness 的跨设备会话同步——会话存储的专用 git 镜像。 | | dsh-skill-pack-security | 安全审计技能包:密钥扫描、依赖与供应链审查 | | dsh-talk | DeepSeek Harness 的语音优先会话闭环:对它说,听它答。 | | dsh-test-drive | DeepSeek Harness 插件的隔离式安装冒烟实测。 | | dsh-translate | DeepSeek Harness 的厂商参数翻译与确定性 JSON 修复。 |

License

Apache License 2.0 © 2026 dsh-budget contributors