rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:xq25478/dsh-usage-statistics
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English | 中文
A community plugin for DeepSeek Harness that adds a 用量统计 / Usage statistics page to the left rail: per-day and per-hour token usage, the cache hit rate, and a live request log that updates the moment a reply settles.
It is not an official DeepSeek package. It is a profile bundle: one directory, plain JavaScript, no build step, no dependencies, no network calls.
930,435,062 reads as 9.3亿) and keep the exact number on hover. A row that arrives while
you watch pops in with a flashing border.git clone https://github.com/xq25478/dsh-usage-statistics.git ~/dsh-plugins/dsh-usage-statistics
Then in DeepSeek Harness open Plugins → Add plugin and pick that directory, or install the path directly:
plugin_manager install_bundle target=~/dsh-plugins/dsh-usage-statistics
The plugin appears in the left rail as a bar-chart icon below the session list. It needs DeepSeek
Harness 0.2.2-rc.3 or newer; it reads ~/.dsh/sessions and nothing else.
Every token count prints in 万 (ten thousand) and 亿 (a hundred million), one system in every language:
930,435,062 reads as 9.3亿, 4,562,325 as 456.2万, and anything under ten thousand stays exact.
The exact value stays in the hover text, the tooltip, and the accessible name.
There is no polling. On open, the page holds one NDJSON stream to the Host
(/api/usage-statistics/stream); the Host pushes a fresh snapshot whenever a reply settles,
coalescing bursts into one push per 400 ms and sending a heartbeat every 20 s. A quiet stream is
reopened after 1.5 s, a stream that has delivered nothing for 45 s is treated as dead, and returning
to the tab asks for a fresh snapshot. The log header shows the time of the last push, so a stalled
channel is visible instead of silent.
Every number comes from one place: the usage block that the model call itself reports, written by
the agent loop into the durable session log. Nothing is estimated, sampled, or inferred from message
text.
| Layer | What it provides | Where it comes from |
|---|---|---|
| Usage counts | inputTokens (uncached prompt), cacheReadTokens, cacheWriteTokens, outputTokens, and the provider's own total |
The provider response, mapped by the active LLM adapter into the harness TokenUsage shape, whose counts are documented as disjoint |
| Event time | The instant the reply settled, in epoch milliseconds | The session event envelope (event.time) |
| Corpus | Which sessions exist | ctx.sessionQuery.listSessions() |
| Log bodies | Every committed event of one session, including fork seed metadata | ctx.sessionQuery.readSession(id): the Host reads and replay-validates the JSONL, zstd frames included; this plugin never parses or decompresses a log itself |
| Live increments | New replies while the page is open | The session/event feed, fanned out to open streams as a snapshot push |
| Day boundary | Which day a sample belongs to | The Host process's local calendar date (Intl zone) |
| Range | Which days are in view | from/to local day keys, or a days count; the Host caps a range at 366 days and reads a reversed pair the way it was meant |
totalTokens; the
four-count sum equals totalTokens in every one of them (absolute difference 0). The only aggregate
gap was exactly the five older records that report no totalTokens at all.llm/retry-started reopens the slot so a retried attempt
counts on its own.inheritedEventCount), so a fork never re-adds its parent's history.assistant/message.usage fields.outputTokens / (last output chunk − first output chunk).first output chunk − step start.Both read the timestamps the stream recorder stamps on every chunk, so they share the session clock
rather than a second one. A reply with no output chunk, or a decode window shorter than 200 ms, shows
— instead of a meaningless rate.
| File | Role |
|---|---|
index.js |
Host entry: owns the ledger, the live event feed, the snapshot route, and the stream route |
ledger.js |
The fold itself: pure event-to-day/hour/request aggregation, no Harness imports |
client.js |
Browser module: the rail icon and the page |
cordis.patch.yml |
The one Loader row this bundle inserts |
locale/ |
Plugin title, description, and detail document path per language |
docs/ |
Feature image and the detail documents |
tests/ |
Node checks: fold rules, the Host entry against a real corpus, and the page's render path |
node tests/ledger.test.mjs # replacement, retry, fork seed, midnight, ranges, hourly buckets
node tests/client.test.mjs # registrations, dictionaries, theme tokens, render path
node tests/host.test.mjs # the Host entry mounted on this machine's sessions (needs `zstd`)
The Host test reads the local session corpus; it prints the figures the page would show and asserts the routes, the push stream, and the row limit.
MIT. See LICENSE.
A community plugin, not an official DeepSeek package. Built and verified with DeepSeek Harness.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。