DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

cp990207 /

cp990207/dsh-usage-ledger

Verified

DeepSeek Harness plugin: a local usage ledger for tokens, cache hit rate and estimated cost per day, per model and per workspace.

★ 1 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHub
READMESource: main@5012b5d1

Usage Ledger(用量账本)

A local-first usage ledger for DeepSeek Harness: mines the session logs on this machine and reports per-day / per-model / per-workspace token consumption, cache hit rate, tool-vs-chat split, and an estimated cost.

本地用量账本插件:从本机会话日志统计每日 / 每模型 / 每工作区的 token 消耗、缓存命中率、工具请求占比,并按配置单价估算开销。

Install

Install it as a DeepSeek Harness plugin from this repository — in the desktop app open the plugin market (插件市场) install field and paste:

github:cp990207/dsh-usage-ledger

Or from a local clone, point the same field at the absolute path of the checkout. The bundle patch registers the usage-ledger entry with the ledger dashboard in the header; no extra configuration is needed.

When you install from a local directory by hand, keep the installed package.json name equal to the specifier the profile loads (for example @local/usage-ledger). The host validates that the icon resolved through <specifier>/icon stays inside a package with that exact name; a mismatch only surfaces as a "Plugin metadata … icon must remain inside its package directory" diagnostic.

Features

  • Daily token & cost overview with today / 7d / 30d / all-time range filters
  • Per-model table: requests, uncached input, cache read/write, output, hit rate, cost
  • Share pies (tokens & cost), daily cost bar chart
  • Workspace breakdown (sessions merged by cwd) and tool-call ranking
  • Instant startup after the first run: folded sessions are cached on disk, so only logs that changed are re-read (see Fold cache)
  • Price configuration: a ⚙ Prices button in the header opens a per-model price editor (input / output / cache read / cache write, per 1M tokens)

How pricing works

  1. Built-in catalog — the plugin ships with USD list prices for the models it knows (Kimi, GLM, MiniMax, DeepSeek coding-plan models, verified against official pricing pages). Catalog prices follow plugin updates.
  2. Observed models — model names come from your own session logs, so the editor always lists exactly the models you actually used.
  3. Custom overrides — any row edited in the ⚙ dialog is persisted into your user profile patch (via the host's config editor) and takes precedence over the built-in catalog. Untouched rows keep following the catalog.
  4. Fallback — models without any price are estimated at the * fallback row (default $0.50 in / $2.00 out per 1M tokens) and flagged in the UI.

Saving restates every historical day instantly: the plugin stores token totals and derives cost at read time, so a price edit needs neither a refold nor a cache rewrite.

Fold cache

A cold start replays every session log (decompressing the zstd JSONL and folding each event), which takes seconds once a machine has a few hundred sessions and is repeated on every plugin activation — including the reload that follows each price save.

index.js therefore persists the fold to $DSH_HOME/cache/usage-ledger/fold-cache.json (default ~/.dsh/cache/..., DSH_HOME respected). Each entry stores the folded token/request totals plus the session log's persistence revision (dev:ino:size:mtimeNs:ctimeNs). On activation the plugin takes one sessionPersistence.list() snapshot, adopts a cached entry only when the revision still matches, and re-reads just the sessions that changed. Live sessions are always refolded from the event stream.

The cache stores no cost, only measurable counters, so it is safe to delete: the next activation simply folds everything again. Writes are atomic (temp file + rename), coalesced, and skipped when nothing changed; a run writes the cache once after its startup fold and once on shutdown, so serving the dashboard does no extra I/O and a corrupt or partial file is ignored.

Serving is pure aggregation over the folded states: display metadata (model, title, first prompt) is folded from the log's own events, so opening the panel never re-reads a session log. In particular, titles come from session/title events rather than sessionQuery.readTitleSnapshots, which would reload every session corpus on each request.

Configuration

The plugin's config is { currency: string, prices: Record<string, {input, output, cacheRead, cacheWrite}> }. Prefer the ⚙ dialog; hand-editing the usage-ledger row of your profile's cordis.patch.yml works too:

- insert:
    - id: usage-ledger
      name: 'dsh-usage-ledger'
      config:
        currency: CNY            # display currency label (USD default)
        prices:
          glm-5.3-flash: { input: 0.15, output: 0.5, cacheRead: 0.03, cacheWrite: 0 }

If the host environment has no config editor, the ⚙ button is hidden and the dashboard explains how to edit the patch instead.

Privacy

All data is computed locally from session logs. The HTTP endpoint listens on the loopback interface only and rejects cross-site requests.

Host requirements

The ⚙ Prices editor needs a host that mounts the configEditor service (DeepSeek Harness desktop and web both do). On hosts without it the plugin still folds the session log and serves the dashboard — read-only, priced from the built-in catalog.

Changelog

  • 1.3.1 — The dashboard no longer reloads the session corpus per request: titles are folded from their session/title events (and cached) instead of calling sessionQuery.readTitleSnapshots, which re-read every session log on each GET (~8 s for 127 sessions). Serving is now pure aggregation. Fold-cache version bumped to 2.
  • 1.3.0 — Fold cache: per-session folded totals are persisted to $DSH_HOME/cache/usage-ledger/fold-cache.json and invalidated by the session log's persistence revision, so activation only re-reads logs that changed (cold start ~4.5 s on 126 sessions / 76 MB of logs, warm start ~10 ms). Cost is now derived from stored token totals at rollup time, which makes a cached start bit-identical to a cold fold and lets price edits apply without a refold. Live events that arrive during the first backfill are now parked instead of dropped, and one unreadable log no longer aborts the whole fold.
  • 1.1.1 — Resolve the host config editor through ctx.fiber.entry and ctx.get('configEditor') instead of injected service access, so the price editor is offered wherever the host provides one (and never crashes the save route when it does not). The config schema returns the user's own rows only, so resolved config no longer folds the built-in catalog into the profile patch. Entry lookup accepts any package name ending in usage-ledger.

License

MIT © 2026 白白酱 (cp990207)

—/ 5

No ratings yet

Verified DSH bundle

Commit 5012b5d137e8

Community comments

No comments yet. Be the first to write one.

DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout