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-cost-ledger

v0.1.4

Published

DeepSeek Harness 详细用量/费用插件:每段对话、每个提问的 token 与花费台账(含峰谷计价、官方余额轮询、预算提醒、历史回放、可拖拽悬浮面板)。

Readme

💸 dsh-cost-ledger

DeepSeek Harness 详细用量 / 费用插件:每一段对话、每一个提问、每一步模型调用的 Token 与花费明细台账,叠加 DeepSeek 官方余额轮询(覆盖「她用自己的电脑用同一 个 API Key」的场景)与 峰谷计价、预算超支提醒。

  • 📋 回放全部历史会话日志(~/.dsh/sessions/*/session.jsonl.zstd),自动补全装插件之前的账目
  • ⚡ 运行中实时订阅 session/event,每次请求落账,刷新即见
  • 💰 DeepSeek 官方峰谷定价:工作日高峰 = 低谷 ×2,周末低谷;价格表可在面板里改
  • 👥 账户级余额:轮询官方 GET api.deepseek.com/user/balance,你在女友机器上看不到的消耗,会以余额跌幅体现
  • 🖥️ 双界面:可拖拽悬浮面板(默认左下角,拖到哪停哪、位置自动记忆)+ 每条回复底部一行小字费用
  • 🚨 每日 / 每周预算提醒(超过变红闪烁)

效果预览

右下角胶囊可按住拖到任意位置并自动记忆。图为实际使用效果画质,具体数据视你的会话而定。


安装

# npm(已发布)
dsh plugin --profile web add dsh-cost-ledger

# 或 GitHub
dsh plugin --profile web add github:Kilganon725/dsh-cost-ledger

# 或本地 tgz
dsh plugin --profile web add /path/to/dsh-cost-ledger-0.1.4.tgz

# 重启 dsh web 并刷新页面
dsh web

也可以手动安装(与 dsh-sysmon 同款布局):解包到 ~/.dsh/profiles/web/node_modules/dsh-cost-ledger,把补丁追加进 ~/.dsh/profiles/web/cordis.patch.yml:

- insert:
    - id: cost-ledger
      name: dsh-cost-ledger

装好后刷新页面:左下角出现 💸 今日 ¥x · 余额 ¥y 悬浮胶囊(可按住拖到任意位置,位置自动记住);每条回复下方出现 💸 ¥0.0123 · ↑14.1k ☁384 ↓200 · deepseek-v4-flash。


用法

悬浮面板

| 页签 | 内容 | | --- | --- | | 概览 | 今日 / 近7天 / 本月 / 累计花费;账户余额与「账户日消耗(估)」(余额跌幅推算);模型分布 | | 账户 | 账户级总览(余额跌幅,含所有用同一 Key 的机器)+ 每日消耗估算 + 与本机明细的偏差提示 | | 会话 | 每段对话一行(标题 / 工作目录 / 主机 / 花费 / 次数),点击展开该会话按提问汇总的逐条明细 | | 明细 | 最近 300 条逐请求明细:时间、模型、提问、输入↑ / 缓存☁ / 输出↓ Token、费用(悬停看完整提问) | | 设置 | 价格表(每百万 tokens 输入/缓存/输出)、峰谷时段与倍率、每日/每周预算、余额轮询开关与接口、重新扫描历史、导出 JSON |

数据从哪来

  • 本机明细:DSH 会话日志里的 assistant/message.usage(provider 上报的真实 token), 事件 request/header 提供模型名,user/message 提供提问文本(跳过系统注入的上下文)。
  • 账户总消耗:官方余额接口,60 秒轮询一次;两次快照之间的余额下降记为该日「账户消耗估算」。 你女朋友在她自己电脑上用同一个 Key 产生的消耗,会反映在这里(但她那台机器上的逐条明细 只有在她那台也装这个插件才能看到,或用「导出 JSON」合并)。

计价(对齐 DeepSeek 官方 2026-08-17 峰谷定价)

时区:默认 Asia/Shanghai(东八区),高峰判定、日/周/月边界、消息时间显示全部按东八区换算,不再受机器时区影响——这是修复「内部消费与官方对不上」的核心。

高峰时段(东八区,工作日):9:00–12:00、14:00–18:00,其余为空闲(低谷);周末全天按低谷。可在「设置」页改,或点「恢复官方默认」。

价格表(单位:元 / 每百万 tokens;高峰自动 ×2):

| 模型 | 空闲输入 | 缓存命中 | 输出(含推理) | 高峰输入 | 高峰输出 | | --- | --- | --- | --- | --- | --- | | deepseek-v4-flash(及 vision、deepseek-chat 别名) | 1.5 | 0.05 | 4.5 | 3 | 9 | | deepseek-v4-pro(及 deepseek-reasoner 别名) | 4.5 | 0.1* | 13.5 | 9 | 27 | | 其他模型(兜底 *) | 2.25 | 0.1 | 9 | 4.5 | 18 |

  • deepseek-v4-pro 的缓存命中价官方公告未给出确切值,暂按 0.1 元/百万(可改)。 数据来源:DeepSeek 官方公告(api-docs.deepseek.com/zh-cn/quick_start/pricing)。 面板「设置」页可改价格/峰谷;改完后点「按当前价格重算历史」可把历史台账按新价格重新计价,让历史明细也与官方对齐。

隐私与安全

  • API Key 从不落盘、不出本机:仅通过 DSH credentials 服务解析一次,用于官方余额接口。
  • 台账保存在本地 ~/.dsh/dsh-cost-ledger/ledger.jsonl,全部是本机数据。
  • HTTP 接口仅监听 dsh web 同源端口(/dsh-cost/*),无外发、无统计上报。

限制

  1. 口径差异:「明细 / 会话」页签是本机逐条账目;「账户」页签是账户级(余额跌幅,含女友那台机器)总消耗——两者本来就不相等,别拿来直接对比。
  2. 女友本机:她的逐条明细需要在她那台电脑也装本插件;想合并两份账,两台都点「导出 JSON」再自行合并。
  3. 账户消耗估算:余额跌幅是估算——充值当天会被冲抵,跨天边界按快照时间归属。
  4. 未计价模型:显示「兜底价格」标记,请到设置里补充价格。
  5. 只有 usage chunk(请求中断)的记录标记 final:false,同样入账。
  6. 时区:默认东八区;如你官网/系统用其它时区,到「设置」改 timezone 即可对齐。

HTTP API(调试用)

| 接口 | 说明 | | --- | --- | | GET /dsh-cost/overview | 概览(今日/周/月/累计、模型、会话、余额、预算) | | GET /dsh-cost/requests?sessionId=&model=&from=&to=&group=turn&limit=&offset= | 逐请求 / 按提问汇总 | | GET /dsh-cost/turn?sessionId=&turn= | 单条回复的费用(消息底部统计用) | | GET /dsh-cost/balance | 余额与日消耗估算 | | GET /dsh-cost/config / POST /dsh-cost/config | 读取 / 保存配置 | | POST /dsh-cost/refresh | 强制重新扫描全部历史日志 | | GET /dsh-cost/export | 导出本机台账 JSON |

数据目录:~/.dsh/dsh-cost-ledger/(config.json、ledger.jsonl、index.json)。


更新(自动检查 + 一键更新)

插件内置版本自检:启动时 + 每 6 小时请求 npm registry 比对 dsh-cost-ledger 最新版。 有新版本时,面板(概览页)顶部会出现黄色横幅:

⬆️ 有新版本 vX(当前 vY) · 一键更新 · 更新后需重启 dsh web

点「一键更新」会自动在 profile 里执行 pnpm update dsh-cost-ledger,然后你重启 dsh web 即可。

也可以手动:

dsh plugin --profile web update dsh-cost-ledger
dsh web   # 重启生效

⚠️ 只有从 npm 安装(dsh plugin --profile web add dsh-cost-ledger)的用户会被自动更新; 如果当初是从 GitHub 或 tgz 装的,请先切成 npm 源:dsh plugin --profile web add dsh-cost-ledger@latest。


卸载

dsh plugin --profile web remove dsh-cost-ledger
# 可选:删除数据
rm -rf ~/.dsh/dsh-cost-ledger

开发

npm test        # 计价引擎单测
npm run validate
npm pack        # 打 tgz 包