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

v0.1.5

Published

Token cost tracking for DeepSeek Harness: per-session and per-message cost projection with a web summary surface. Official DeepSeek prices are synced automatically by a daily script.

Downloads

349

Readme

dsh-token-cost

English | 中文

为 DeepSeek Harness 开发的 Token 费用统计插件。

  • 会话总费用:会话头部显示 💰 ¥1.48(悬停提示"估算费用,以官方账单为准")
  • 每条消息费用:每条 assistant 消息的动作行上,与"用时 · 首 token · tok/s"统计信息一样,鼠标悬停才显示
  • 设置 → 费用统计:跨会话总费用 + 按模型分列
  • 价格按每百万 token 计价,来自 DeepSeek 官方价格,由每日脚本自动同步

安装

一条命令(推荐,无需 pnpm)

npx dsh-token-cost setup

这条命令会自动:把插件安装到你的 web profile(缺 pnpm 时通过 corepack 自动启用)、写入 cordis.patch.yml 配置、创建价格目录。重复执行安全(幂等)。

安装到其他 profile(例如 tui):

npx dsh-token-cost setup --profile tui

通过 dsh(需要 pnpm)

# 在 dsh profile 目录(例如 ~/.dsh/profiles/web)
cd ~/.dsh/profiles/web
dsh plugin --profile web add dsh-token-cost

然后在 profile 的 cordis.patch.yml 中添加:

- insert:
    - id: token-cost
      name: 'dsh-token-cost'
      config:
        currency: CNY

重启 dsh web 并强制刷新浏览器(Ctrl+Shift+R)。

价格更新

只有两个价格来源,都是 ~/.dsh/prices/(或 $DSH_HOME/prices/)下的纯 JSON 文件:

| 文件 | 谁维护 | 优先级 | |---|---|---| | official-prices.json | 每日脚本自动维护 — 请勿手改 | 低 | | local-prices.json | 你自己 — 可选覆盖 | 高 |

每个模型的生效价格:local-prices.json > official-prices.json > 内置默认值。修改后重启 dsh web 生效(投影会用新价格重放日志)。

每日自动同步(推荐)

dsh-token-cost-update 脚本会抓取 DeepSeek 官方定价页、解析当前价格并重写 official-prices.json:

# 手动执行一次
npx dsh-token-cost-update

# 或直接调用安装的命令
dsh-token-cost-update

通过 Windows 任务计划程序每天执行一次:

$action = New-ScheduledTaskAction -Execute (Get-Command node).Source -Argument "`"$(npm root -g)/dsh-token-cost/update-prices.mjs`""
$trigger = New-ScheduledTaskTrigger -Daily -At '09:30'
Register-ScheduledTask -TaskName 'DSH-TokenCost-UpdatePrices' -Action $action -Trigger $trigger -Force

脚本可以随时安全运行:抓取或解析失败时不会改动现有文件(以非零码退出),因此临时网络问题绝不会破坏上一次的好价格表。它会打印 prices changed: true/false,方便你从日志中发现官方调价。

手动本地覆盖

创建 ~/.dsh/prices/local-prices.json:

{
  "prices": {
    "deepseek-v4-flash": { "inputPerM": 1.5, "outputPerM": 3, "cacheReadPerM": 0.03 }
  }
}

格式为 { "prices": { "<模型id>": { "inputPerM", "outputPerM", "cacheReadPerM?", "cacheWritePerM?" } } }。未配置的模型按 0 计价,但仍会累计 token 数量。

工作原理

  • 一个 host 侧投影单元(tokenCost)折叠持久化会话日志:request/header 事件跟踪路由(provider/model),assistant/message 的用量按模型计价,并按消息 id 记录每条消息的费用。
  • 投影走标准的 session-projection 通道(注册表快照、变更推送、session.list 基线),因此浏览器端渲染全部数据无需任何额外 RPC。
  • 内置默认价格让插件在零配置下即可使用;已包含 DeepSeek 当前官方价格(2026-08)。

许可证

MIT