rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:cp990207/dsh-usage-ledger
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
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 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.
* 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.
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.
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.
All data is computed locally from session logs. The HTTP endpoint listens on the loopback interface only and rejects cross-site requests.
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.
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.$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.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.MIT © 2026 白白酱 (cp990207)
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。