dsh-redteam-model
SeaOf0
基于dsh web实现的多种模式,目的是服务于redteam进行授权的安全研究,覆盖渗透测试、红队评估、代码审计等范围领域,请勿用于非法行为。(允许二开,赋予模块各位自己的业务逻辑,方法论只有自己熟练的才好用,好的方法论=好的生态)
Seren-715/dsh-token-heatmap
A daily Token-usage heatmap for the DSH settings page, including an estimated daily cost in CNY from DeepSeek list prices. Aggregated entirely from local session logs; no external requests. | DSH 设置中的每日 Token 用量热力图,含人民币估算消费金额;数据取自本机会话日志,不发起外部请求。
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:Seren-715/dsh-token-heatmap
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
中文 | English
A daily token-usage heatmap that adds a "Token usage" section to the DSH settings page. One cell per day; theme-aware greyscale indicates relative usage.
Selecting a day also shows an estimated cost in CNY, derived from DeepSeek's published list prices and their peak/off-peak schedule.
All data is derived from DSH's own local session logs. No external network requests and no separate usage ledger.
Privacy: this plugin makes no outbound requests. Session logs are read on the local machine only, and the aggregated result is served to your local DSH page. The repository contains no personal data or credentials.
settings.section slot and renders React elements only. It does not append to document.body, does not replace the application root, and imports no Harness client package. It therefore occupies the settings sidebar alongside the built-in sections rather than floating above the application. See Implementation notes.seq values and truncated tail frames are each handled as distinct cases. A single-pass decompression retains only the first frame of a multi-frame log and therefore under-reports usage. See Data source.Input+output is provided as a separate metric.Esc collapses first and clears the selection second. Reading a sequence of days therefore requires no intermediate close step.--dsw-alias-*), and all visible text is registered through ctx.locale.register, so an application language change re-renders the section. Number units are localized as well (万/亿 in Chinese, K/M/B in English).Note on screenshot currency. The images below predate v0.5.0 and have not been re-captured since. Three UI changes made since are therefore not visible in them:
- Empty-day cells render darker. Days without recorded usage now occupy the dimmest level, reserving the brightness range for days with usage (v0.4.1).
- Collapsing a day retains its selection. Selecting the same date again collapses only the detail body; the selection outline remains on the heatmap and the collapsed row carries an expand control (v0.4.1).
- The detail panel shows an estimated cost. A daily cost in CNY is displayed next to the daily total (v0.5.0).
The textual descriptions throughout this document reflect the current behaviour.
Open Settings → Token usage. The default range is six months. Choose total, input+output, cache read or output, and switch between daily and weekly views. The range selector offers six months or a full year; the year is split into two rows.
Hover a date cell to display three lines: the date (YYYY-MM-DD), the selected metric's Token count, and “Click to view details”. The example below shows 2026-10-13 with a total of 117,405,946 Token. Selecting the cell displays that day's breakdown below the heatmap. The outline indicates hover or selection; today's cell has no default highlight. Cells with no recorded usage remain at the dimmest level, so the brightness range is reserved for days with usage.

Selecting a date displays its details inline below the heatmap, without navigating away from the page. A single-line hint above the footnote indicates the interaction until a date is selected. Selecting the same date again collapses the detail body while retaining the selection outline on the heatmap, so the selected date remains identifiable; the collapsed row provides an expand control. Selecting a different date switches the details directly, with no intermediate collapse step. For keyboard users, Esc on a focused cell collapses the details, and a second press clears the selection. All filters remain available throughout.
Details include the total, input, output, cache reads and calls, plus cache writes when present, and an estimated daily cost in CNY. The grayscale bar shows each component's share by Token count. The October 13, 2026 example shows 117,405,946 Token, with cache reads accounting for 99.09%. These are screenshot examples; your statistics come from your local logs.

Labels, months, dates and number units follow the host language. The same daily total appears as “1.17 亿” in Chinese and “117.41M” in English.


Esc both collapse, and selecting another date switches without an intermediate collapseCNY ¥4.98 so the currency is explicit.<DSH_HOME>/sessions/<project>/<session>/session.v*.jsonl.zstd
The plugin reads log records containing a valid timestamp and data.usage:
inputTokens / outputTokens / cacheReadTokens / cacheWriteTokens / totalTokens
plus time (epoch milliseconds) and data.message.source.model. Bucketing those by local calendar day gives the daily totals.
Three details that must be handled correctly:
seq can appear more than once (replay) — deduplicate by seq, otherwise a day gets inflated.Parsed results are cached by file size, modification time and aggregation time zone. New or changed files, and files whose aggregation time zone has changed, are parsed again.
Total includes cache reads reported in the logs; their share depends on usage. Input+output counts only those two fields. DSH logs record token counts but no currency amounts, so the cost shown in the detail panel is an estimate computed by this plugin.
Colour buckets use quantiles (25th/50th/75th percentiles of the local data set) rather than absolute thresholds, so the chart remains readable even though the four metrics differ by orders of magnitude.
Cost is computed per session-log record, because DeepSeek prices depend on the time of day:
cost = cacheReadTokens/1e6 × cacheHitPrice
+ inputTokens/1e6 × cacheMissPrice
+ outputTokens/1e6 × outputPrice
deepseek-flash uses 0.02 / 1 / 4 (off-peak) and 0.04 / 2 / 8 (peak); deepseek-v4-pro uses 0.15 / 4.5 / 13.5 and 0.3 / 9 / 27.CNY (for example CNY ¥4.98) rather than converting to USD. No exchange-rate conversion is applied.The table and the 2026 holiday list live in lib/pricing.js and must be updated when DeepSeek changes prices or when the State Council publishes the following year's holiday schedule.
The desktop app's profile is managed exclusively by the app, and dsh plugin refuses to touch it, so install from inside the app:
dsh plugin add "link:<path>")Uninstall: open the bundle's card on the same page → Uninstall.
Optional, set in the bundle row's config. Defaults apply when omitted.
| Key | Default | Meaning |
|---|---|---|
timeZone |
Asia/Shanghai |
Which time zone decides a "day" |
sessionsRoot |
<DSH_HOME>/sessions |
Session log root directory |
maxDepth |
2 |
Directory depth to walk (project / session) |
| Path | Purpose |
|---|---|
lib/index.js |
Host side: frame-by-frame decompression, daily aggregation, serves /dsh-token-heatmap/data |
lib/pricing.js |
DeepSeek price table, peak/off-peak schedule and per-record cost calculation |
client.js |
Browser side: the React component registered into settings.section |
package.json |
Manifest: dsh.bundle.patch for mounting, dsh.client for the browser half |
cordis.patch.yml |
Mount declaration; the insert name must match the package name exactly |
tools/test-plugin.mjs |
Runs the host-side aggregation over real session logs |
tools/test-apply.mjs |
Runs apply() against a stub Cordis context to check route registration |
tools/test-client.mjs |
Client rendering and interaction checks using React hook stubs |
tools/test-host.mjs |
Synthetic-log checks for frames, deduplication, caching, time zone changes, peak/off-peak tiers and cost |
tools/test-weekly.mjs |
Verifies weekly aggregation: week boundaries, month ticks, no double counting |
Use a Node.js version supporting node:zlib / zstdDecompressSync (Node.js 24 recommended). Client and weekly tests need no session logs. npm test uses deterministic fixtures and host stubs. npm run test:logs reads local logs; set DSH_SESSIONS_ROOT to override the path.
Self-tests:
npm ci
npm run check
npm test
npm run test:logs
Formatting is defined by .editorconfig and Prettier. Run npm run format to format the repository and npm run check to check formatting and entry-point syntax. Prettier is a development dependency only.
The UI goes through a slot, it does not inject DOM. The component registers into settings.section and only renders React elements. It imports no Harness client package and writes its own styles primarily using host theme tokens. (The DSH plugin guide explicitly forbids appending to document.body or replacing the app root.)
Adaptive sizing. A ResizeObserver measures the container and computes each cell's edge length into the CSS variable --dth-cell. Sizing fits 26 columns for the half year and at most 27 columns per row for the year, capped at 20px and accounting for gaps and padding.
Week alignment. The range starts 25 or 52 weeks before the Sunday of the current week, so every column is a complete natural week, and cells after today stay empty. Month labels are placed on columns containing the first day of a month, with an additional label at each row start.
Localization. Visible text is never hardcoded. The plugin registers its own dictionary namespace with ctx.locale.register(ns, { zh, en }) and reads it through the framework's injected t seat, so a language switch re-renders the section. Number units are localized too (万/亿 in Chinese, K/M/B in English).
Client checks execute client.js with React hook stubs, covering the first visible render, compact tooltips, inline details, range switching and composition. They do not replace layout, animation, focus or theme verification in DSH.
See CHANGELOG.md for changes.
MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: privacy。