rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:Cottins-Vanilla/dsh-session-usage
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
A DeepSeek Harness plugin that answers one question for every conversation: what did it cost, in money and tokens?
It reads the committed session log, folds assistant/message usage plus
assistant/attempt stream usage into per-conversation and per-turn totals, and
presents them in the places where you already work: the sidebar, the
conversation's View tabs, the session header, and the end of every answer.
| Surface | Where | What it shows |
|---|---|---|
| Usage panel | Sidebar → 会话用量 / Session usage | The full dashboard: KPIs, daily and per-turn curves, conversation list |
| Usage tab | Conversation View tabs → 用量 / Usage | The same dashboard, scoped to the open conversation |
| Session header chip | Right side of the conversation header | Current conversation price and total tokens; click to open the panel |
| Turn price badge | After every completed answer | 本轮 ¥… · 当前对话 ¥… — this turn's price first, then the conversation total, with a white default and a configurable accent |
Sidebar
└─ 会话用量 ← full dashboard
Conversation header
├─ [Chat] [Trajectory] [用量] [Context] [Fleet]
└─ ¥0.1234 · 12.3k tokens ← header chip
End of a completed answer
└─ 本轮 ¥0.1234 · 当前对话 ¥1.2345 ← turn badge
In the Web UI, open Plugins → Add plugin, choose the GitHub source, and enter:
https://github.com/Cottins-Vanilla/dsh-session-usage
Or with the CLI, using the profile name that owns your Web UI:
dsh plugin --profile desktop add https://github.com/Cottins-Vanilla/dsh-session-usage
git clone https://github.com/Cottins-Vanilla/dsh-session-usage.git
dsh plugin --profile desktop add ./dsh-session-usage
The bundle has no build step and no runtime dependencies. Installation enables it by default; if your app is already running, refresh the page. If the Host half cannot reload through HMR, restart the app once.
Use Plugins → Session usage → Remove in the Web UI, or:
dsh plugin --profile desktop remove dsh-session-usage
Direct installation works now. Listing in the in-app market requires a pull
request to the curated awesome-dsh-plugin catalog; see
docs/marketplace.md for the ready-to-submit entry, the
required dsh-plugin topic, and the one-day repository-age gate.
The scope row is a labeled control, not a set of loose labels:
<title> — the conversation you last
opened in this page.<folder> — sessions whose recorded cwd
matches the current conversation's cwd. Hover the button for the full path.<n> — every live or persisted session
visible to sessionQuery.The current-conversation and current-project options are disabled until a conversation has been opened in this page.
The toggle at the top right of the chart card depends on the scope.
For the current conversation, in order:
chartDays calendar days, ending
today (Beijing date). It answers "when did I spend what?"For current project and all conversations, the toggle is Daily then By turn; the single-turn value view is intentionally limited to the current conversation. The cumulative view plots the eight most expensive conversations as colored lines plus a gray aggregate.
Every completed turn renders a small badge in the chat:
● 本轮 ¥0.1234 · 当前对话 ¥1.2345
localStorage under
dsh-session-usage.turnColor.Prices are estimates. The Harness records token usage per assistant message but does not record an invoice or a provider price.
The default table follows DeepSeek's published CNY list prices per 1M tokens:
| Model match | Cache hit | Cache miss (input) | Output |
|---|---|---|---|
deepseek-flash |
0.02 | 1 | 4 |
deepseek-v4-flash |
0.02 | 1 | 4 |
deepseek-v4-flash-vision-exp |
0.02 | 1 | 4 |
deepseek-v4-pro |
0.15 | 4.5 | 13.5 |
deepseek-pro |
0.15 | 4.5 | 13.5 |
| fallback | 0.02 | 1 | 4 |
For one message:
cost = (cacheRead × hit + input × miss + cacheWrite × miss + output × out) / 1,000,000
× (peak ? peakMultiplier : 1)
peakMultiplier defaults to 2.outputTokens already contains reasoningTokens in the Session contract, so
reasoning is not added twice.totalTokens is input + cacheRead + cacheWrite + output; the plugin honors
an explicit totalTokens when the provider supplies one.See docs/pricing.md for the full rules and caveats.
The bundle row accepts an optional config object. Values override the built-in
defaults; see docs/configuration.md for every field.
- id: session-usage
config:
chartDays: 14 # daily points, 2..60
maxSessions: 400 # newest N sessions to scan, 1..2000
pricing:
currency: CNY
peakMultiplier: 2
peakHours: [[9, 12], [14, 18]]
weekendValley: true
models:
deepseek-v4-pro: { hit: 0.15, miss: 4.5, out: 13.5 }
deepseek-flash: { hit: 0.02, miss: 1, out: 4 }
my-model: { hit: 0.1, miss: 2, out: 6 }
fallback: { hit: 0.02, miss: 1, out: 4 }
holidays: ['2026-10-01']
Model keys match case-insensitively as substrings of the model id, longest key
first. Each model row and fallback must contain non-negative numeric hit,
miss, and out; a malformed or partial row throws at plugin startup instead of
silently falling back. The first All conversations query reads every cold
session once and caches the folded index in memory; later queries only fold newly
committed live events.
sessionQuery.readSession(). The plugin never appends events and never writes
session data.POST /api/session-usage/query between this
bundle's Client and Host halves. The update check (once per Harness login or
the manual button) makes one Host-side request to api.github.com; the Host
caches the result for six hours. No data about you or your sessions is sent.maxSessions caps the scan; the query route is read-only;
failed sessions are isolated and reported as a warning count.See SECURITY.md for reporting a vulnerability.
Session log ──► Host fold (lib/stats.js + lib/pricing.js)
│
├── per-session totals (tokens, price, models, days, turns)
├── per-turn points (cost, tokens, seq)
└── POST /api/session-usage/query
│
Client (client.js) ◄──────────┘
├── sidebar panel (main + sidebar.panellist)
├── 用量 View tab (conversation.view)
├── header chip (conversation.session.header.utilities)
└── turn badges (conversation.chat.turnTail)
The Host keeps a derived in-memory index; it is a cache, not a second source of truth. The Client renders with theme tokens, does not import Harness Client packages, and reads session data only through the Host response.
More detail: docs/architecture.md.
dsh-session-usage/
├── index.js Host half: route, session scan, caches
├── client.js Web Client half: slots, charts, badges, locales
├── lib/
│ ├── pricing.js Price table, peak windows, cost formula
│ └── stats.js Event fold, per-turn/day aggregation
├── locale/{en,zh}.json Plugin Manager display metadata
├── cordis.patch.yml Bundle layer: one Host row
├── icon.svg Plugin icon (original artwork, MIT)
├── scripts/check.mjs Dependency-free structural checks / CI
├── tests/usage.test.mjs Behavioral accounting and pricing regressions
├── docs/ Architecture, configuration, pricing, publishing
├── examples/ Example profile patch
├── CHANGELOG.md
├── RELEASE_NOTES.md Detailed body for the current GitHub release
├── CONTRIBUTING.md
├── CODE_OF_CONDUCT.md
├── SECURITY.md
└── LICENSE
There is no compilation step. Edit client.js / index.js / lib/*.js and run:
npm test # structural checks + behavioral accounting tests
npm run check # structural checks only
npm test runs scripts/check.mjs (manifest, exports, locale metadata, SVG
size, Client loader id, JavaScript syntax, temporary files) and then the
24-test node:test suite in tests/usage.test.mjs. The behavioral suite asserts
exact prices, peak/off-peak rates, failed-attempt accounting, same-call usage
revisions, retry slots, stream fallback, pricing-config errors, live-to-cold tail
sync, project-before-cap filtering, path identity, SemVer ordering, and the
concurrent cold-load regression; a change that silently changes the amount fails
CI.
To preview a local checkout, install its directory as a bundle (see above). Client-only edits are picked up by a page refresh after the bundle reloads; Host-side edits need the plugin to be toggled or the app restarted.
pricing.models and pricing.holidays for other providers or
new prices.cwd values using platform case rules
(insensitive on Windows, sensitive on POSIX); it is not a full workspace
registry mapping.dsh-session-usage is occupied by an unrelated project.
This repository is distributed as a GitHub/local bundle. See
docs/publishing.md before attempting an npm release.Issues and pull requests are welcome. Read CONTRIBUTING.md and follow the Code of Conduct.
MIT © 2026 Cottins-Vanilla.
DeepSeek, DeepSeek Harness, and related marks belong to their respective owners. This plugin is not an official DeepSeek product.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek。