dsh-pulse-overview 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +376 -2
- package/README_EN.md +289 -0
- package/assets/icon-180.png +0 -0
- package/assets/icon.svg +14 -0
- package/client/index.mjs +1675 -0
- package/cordis.patch.yml +3 -0
- package/index.mjs +427 -0
- package/lib/activity.mjs +234 -0
- package/lib/books.mjs +215 -0
- package/lib/config.mjs +93 -0
- package/lib/overview.mjs +311 -0
- package/lib/sessions.mjs +150 -0
- package/lib/token-index.mjs +669 -0
- package/lib/zstd-frames.mjs +98 -0
- package/locale/de.json +6 -0
- package/locale/en.json +6 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +70 -4
- package/scripts/check-npm-token.mjs +69 -0
- package/scripts/lib/skip-report.mjs +46 -0
- package/scripts/render-preview.py +355 -0
- package/scripts/verify-activity.mjs +439 -0
- package/scripts/verify-books.mjs +245 -0
- package/scripts/verify-client.mjs +569 -0
- package/scripts/verify-config.mjs +214 -0
- package/scripts/verify-host.mjs +372 -0
- package/scripts/verify-overview.mjs +395 -0
- package/scripts/verify-placement.mjs +436 -0
- package/scripts/verify-render.mjs +726 -0
- package/scripts/verify-token-index.mjs +559 -0
package/README_EN.md
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# dsh-pulse
|
|
2
|
+
|
|
3
|
+
Two additions to [DeepSeek Harness](https://github.com/deepseek-ai)'s New Session screen:
|
|
4
|
+
|
|
5
|
+
1. **Activity overview** — sessions / messages / total tokens / active days / current streak /
|
|
6
|
+
longest streak / peak hours / top model in a 2 × 4 metric grid, with all / 365 / 30 / 7-day ranges;
|
|
7
|
+
2. **Activity heat map** — how active each day of the past year was, with **session count** and
|
|
8
|
+
**token usage** sharing one grid.
|
|
9
|
+
|
|
10
|
+
The cards are built from the host's own design tokens (same fill, hairline stroke, corners and shadow
|
|
11
|
+
as the composer below them), and the palette follows the host's achromatic-chrome rule: accents are
|
|
12
|
+
DeepSeek brand blue, level 0 is the host's skeleton grey.
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
┌ Overview [All] [365 days] [30 days] [7 days] ┐
|
|
18
|
+
│ All 140 sessions │
|
|
19
|
+
│ ┌Sessions┐ ┌Messages┐ ┌Tokens┐ ┌Active days┐ │
|
|
20
|
+
│ │ 140 │ │ 48,589 │ │ 1.49B │ │ 58 d │ │
|
|
21
|
+
│ └────────┘ └────────┘ └───────┘ └───────────┘ │
|
|
22
|
+
│ ┌Streak┐ ┌Longest┐ ┌Peak hour┐ ┌Top model┐ │
|
|
23
|
+
│ │ 7 d │ │ 8 d │ │ 17:00 │ │ v4.1-… │ │
|
|
24
|
+
│ └──────┘ └────────┘ └──────────┘ └─────────┘ │
|
|
25
|
+
│ 00:00 ▁▁▂▂▅▃▁▁▂▃▃▃▆▂▂▂▁▂▃▃▁▁▂▁ 23:00 │
|
|
26
|
+
│ ≈ 8.9 × 《二十四史》 │
|
|
27
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
28
|
+
┌ Activity [Sessions] [Tokens] 139 sessions Less ▢ ▢ ▣ ▣ ▣ More ┐
|
|
29
|
+
│ ▢ ▢ ▢ ▢ ▢ ▢ ▢ ▢ ▢ ▢ ▢ ▢ ▢ ▢ ▢ ▢ ▢ ▣ ▣ ▢ ▣ ▣ ▣ ▣ ▣ ▣ ▣ ▣ ▣ ▣ … │
|
|
30
|
+
│ Jan Feb Mar Apr May Jun Jul … │
|
|
31
|
+
└──────────────────────────────────────────────────────────────────────────────────┘
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Activity overview
|
|
35
|
+
|
|
36
|
+
- **Eight metrics** aligned with mainstream coding clients' home dashboards.
|
|
37
|
+
- **Time range**: all / 365 / 30 / 7 days, defaulting to **all**. Total tokens, longest streak
|
|
38
|
+
and active days are whole-history concepts; a half-year window silently truncates them.
|
|
39
|
+
Widening costs nothing (mtimes are scanned in full and the index already stores every date).
|
|
40
|
+
The 365 tier lines up with the heat map's one-year grid. Invalid values fall back to "all".
|
|
41
|
+
- **Active days under "all"** shows the real span (earliest data through today) as its subtitle
|
|
42
|
+
instead of a constant window length.
|
|
43
|
+
- **Footer (DSH-specific)**: a 24-hour message histogram (peak bar solid) plus an
|
|
44
|
+
"≈ N books" conversion — token counts have no intuition until expressed as how many
|
|
45
|
+
books that would be. It uses the **new-content** basis (input + output, excluding
|
|
46
|
+
cacheRead); the difference between the two bases appears on hover. Under heavy use
|
|
47
|
+
cacheRead can be 96% (the same context re-read), so comparing the repeat-inclusive
|
|
48
|
+
total to "books read" would be badly inflated.
|
|
49
|
+
- **Sources**: sessions / active days / streaks come from session mtimes (same source as the
|
|
50
|
+
heat map); messages / tokens / peak hours / top model come from the token index's v2 day
|
|
51
|
+
buckets, whose accounting matches the host's `token-meter` exactly.
|
|
52
|
+
- **Peak hours** weight by **messages**, not tokens: one large overnight task would skew a
|
|
53
|
+
token histogram entirely; message counts track "when a human uses it".
|
|
54
|
+
- **Top model** comes from `message.source` on assistant messages (the provider/model that
|
|
55
|
+
actually settled), not `request/header` (request config, which drifts after retries or
|
|
56
|
+
model switches); ranked by windowed tokens, top three, the cell shows the model segment
|
|
57
|
+
with the full `provider/model` on hover.
|
|
58
|
+
- **Switch**: "Show the activity overview" in settings, on by default; when off, the slot is
|
|
59
|
+
unregistered, no requests are sent, and the session folder is not scanned — same semantics
|
|
60
|
+
as the heat map switch.
|
|
61
|
+
|
|
62
|
+
## Where it appears
|
|
63
|
+
|
|
64
|
+
The **New Session / empty state** screen — directly below the big headline ("Into the Unknown"),
|
|
65
|
+
above the workspace options row and the composer, horizontally centered. It is a rounded card **as wide as the composer
|
|
66
|
+
below** (measured from `[data-composer-card]` at runtime, so it follows window resizes): title on
|
|
67
|
+
the left, total and legend on the right, month labels under the grid.
|
|
68
|
+
|
|
69
|
+
The host exposes no slot in that position (`conversation.hero.options` lives in the workspace
|
|
70
|
+
row below), so the plugin uses its slot registration only as a "when to show" switch and portals
|
|
71
|
+
the content into the container right after the hero headline. If the host structure changes and
|
|
72
|
+
the mount point cannot be found, it falls back to inline rendering in the workspace row after
|
|
73
|
+
1.5 s — still functional, just in the old spot.
|
|
74
|
+
|
|
75
|
+
Once the first turn starts the hero area disappears and the heat map goes with it (that is the
|
|
76
|
+
host's own behavior; this plugin adds no other entry point).
|
|
77
|
+
|
|
78
|
+
Settings (**Settings → Activity**) has a single switch and one line of explanation.
|
|
79
|
+
No sidebar icon, no permanent space taken.
|
|
80
|
+
|
|
81
|
+
## Install
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
dsh plugin --profile web add dsh-pulse-overview
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
For local development you can install the directory directly:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
dsh plugin --profile web add <path>/dsh-pulse
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Reload the DSH web page and open a new session.
|
|
94
|
+
|
|
95
|
+
## The switch
|
|
96
|
+
|
|
97
|
+
"Show the session heat map" is **on** by default — it is the plugin's only feature.
|
|
98
|
+
|
|
99
|
+
Turning it off does not hide the widget with CSS. It:
|
|
100
|
+
|
|
101
|
+
- **unregisters** the heat map slot (the host no longer renders it, the component never mounts);
|
|
102
|
+
- stops requesting `GET /api/pulse/activity`;
|
|
103
|
+
- makes the server return an empty payload without **scanning** the session folder, even if asked.
|
|
104
|
+
|
|
105
|
+
Turning it back on takes effect immediately; no restart.
|
|
106
|
+
|
|
107
|
+
## Data source
|
|
108
|
+
|
|
109
|
+
```text
|
|
110
|
+
<DSH_HOME or ~/.dsh>/sessions/<project>/<sessionDir>/session*.jsonl.zstd
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- `<sessionDir>` comes in two shapes: `session-<uuid>` and bare `<uuid>`. Both are recognized.
|
|
114
|
+
- Session files carry a version segment (observed: `session.v4.jsonl.zstd`); the plugin matches
|
|
115
|
+
`session*.jsonl.zstd` so both names work.
|
|
116
|
+
- **Only the file mtime is read** — nothing is decompressed or parsed. One session directory
|
|
117
|
+
contributes one cell on one day.
|
|
118
|
+
- mtime is a UTC instant, so it is converted to a **local** calendar day. (Taking the first 10
|
|
119
|
+
characters of an ISO string would push sessions between 00:00 and 08:00 in UTC+8 onto the
|
|
120
|
+
previous day.)
|
|
121
|
+
- Missing folder, permission errors, a single unreadable project: skipped, partial data is
|
|
122
|
+
returned, nothing throws.
|
|
123
|
+
|
|
124
|
+
Counting rules:
|
|
125
|
+
|
|
126
|
+
| Value | Meaning |
|
|
127
|
+
| --- | --- |
|
|
128
|
+
| Per-day value | Number of session directories whose newest file mtime falls on that local day |
|
|
129
|
+
| Default window | Last 53 weeks (371 days, one year), Monday on the first row of each column |
|
|
130
|
+
| Last column | The current week; future days render as transparent placeholders and never count |
|
|
131
|
+
| Levels | `0` / `1-2` / `3-5` / `6-9` / `10+` |
|
|
132
|
+
|
|
133
|
+
## HTTP API
|
|
134
|
+
|
|
135
|
+
### "≈ N books"
|
|
136
|
+
|
|
137
|
+
The basis is **1 Chinese character ≈ 1.5 tokens**, verifiable against the reference
|
|
138
|
+
implementation (it shows "4.1M tokens ≈ 9.1 × 《三体·地球往事》", and that book is
|
|
139
|
+
about 300k characters → 300k × 1.5 = 450k tokens, 4.1M / 450k ≈ 9.1).
|
|
140
|
+
|
|
141
|
+
Selection: only works with a multiple ≥ 1 are considered (never "0.3 × 红楼梦"), and
|
|
142
|
+
the pick minimizes log-distance to **8** — perceptual gaps between 1.5× and 8× are
|
|
143
|
+
proportional, not additive. Three wordings: regular (`≈ 8.9 × 《二十四史》`),
|
|
144
|
+
under (`Less than one 《活着》`), and beyond (`More than 83 × 《四库全书》`).
|
|
145
|
+
|
|
146
|
+
The table holds **58 works** across CS / science / sci-fi / history / fiction /
|
|
147
|
+
biography / reference. Only **Chinese works** set the basis: English words
|
|
148
|
+
(≈ 1.3 tokens each) and Chinese characters (≈ 1.5) are different units, and mixing
|
|
149
|
+
them makes multiples incomparable — hence 《中国大百科全书》 rather than the
|
|
150
|
+
Britannica. Each work carries a character-count confidence mark.
|
|
151
|
+
|
|
152
|
+
### `GET /api/pulse/overview?range=all`
|
|
153
|
+
|
|
154
|
+
Aggregated overview data. `range` accepts `all` (default, also `0`) / `365` / `30` / `7`; invalid values fall back to
|
|
155
|
+
`all`, finite windows snap to the nearest tier.
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"ok": true,
|
|
160
|
+
"enabled": true,
|
|
161
|
+
"range": 0,
|
|
162
|
+
"spanDays": 108,
|
|
163
|
+
"today": "2026-11-29",
|
|
164
|
+
"sessions": 139,
|
|
165
|
+
"messages": 48668,
|
|
166
|
+
"tokens": 14940000000,
|
|
167
|
+
"freshTokens": 536000000,
|
|
168
|
+
"books": { "count": "8.9", "name": "《二十四史》", "under": false, "beyond": false },
|
|
169
|
+
"activeDays": 58,
|
|
170
|
+
"currentStreak": 7,
|
|
171
|
+
"longestStreak": 8,
|
|
172
|
+
"peakHour": "17:00",
|
|
173
|
+
"topModels": [{ "model": "workbuddy/deepseek-v4.1-flash", "tokens": 2940900000 }],
|
|
174
|
+
"hours": [0, 0, "...", 8741],
|
|
175
|
+
"index": { "ready": true, "running": false, "scanned": 139, "total": 139, "partial": false }
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
- `range: 0` means "all time"; `spanDays` is the real span from the earliest record through today.
|
|
180
|
+
- `hours` is a 24-bucket histogram of settled messages per local hour; `peakHour` is the peak bucket.
|
|
181
|
+
- Messages / tokens / hours / models depend on the token index: requests kick it in the
|
|
182
|
+
background (throttled), numbers are returned as known while `index.partial` is true and the
|
|
183
|
+
client polls until the index is ready.
|
|
184
|
+
- A streak does not break just because today has no activity yet: the current streak counts
|
|
185
|
+
back from yesterday and resumes naturally after today ends.
|
|
186
|
+
- When the overview switch is off the route returns `{ "ok": true, "enabled": false }` and
|
|
187
|
+
scans nothing.
|
|
188
|
+
|
|
189
|
+
### `GET /api/pulse/activity?weeks=53`
|
|
190
|
+
|
|
191
|
+
```json
|
|
192
|
+
{
|
|
193
|
+
"ok": true,
|
|
194
|
+
"enabled": true,
|
|
195
|
+
"weeks": 53,
|
|
196
|
+
"days": [{ "date": "2026-11-27", "count": 3, "level": 1 }],
|
|
197
|
+
"max": 12,
|
|
198
|
+
"total": 88,
|
|
199
|
+
"today": "2026-11-27"
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
- `days` always has `weeks * 7` entries, from the Monday of the first column to the Sunday of
|
|
204
|
+
the last. Each entry carries `level` (0–4), so the client renders in array order without any
|
|
205
|
+
date math.
|
|
206
|
+
- `today` lets the client draw future cells as transparent placeholders.
|
|
207
|
+
- Results are cached server-side for **60 seconds**. Invalid `weeks` falls back to 53; values
|
|
208
|
+
outside 1–53 are clamped.
|
|
209
|
+
- When the switch is off the route returns
|
|
210
|
+
`{ "ok": true, "enabled": false, "weeks": 0, "days": [], "max": 0, "total": 0, "today": null }`
|
|
211
|
+
and does **not** scan anything.
|
|
212
|
+
|
|
213
|
+
### `GET /api/pulse/config` / `POST /api/pulse/config`
|
|
214
|
+
|
|
215
|
+
```json
|
|
216
|
+
{ "ok": true, "config": { "heatmapEnabled": true, "overviewEnabled": true }, "configError": null }
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
`POST` requires `application/json`; booleans `heatmapEnabled` / `overviewEnabled` and the
|
|
220
|
+
`metric` enum are whitelist-validated.
|
|
221
|
+
|
|
222
|
+
## Configuration
|
|
223
|
+
|
|
224
|
+
`<DSH_HOME>/pulse-overview-config.json` (sibling of, and separate from, `soul-config.json`):
|
|
225
|
+
|
|
226
|
+
```json
|
|
227
|
+
{
|
|
228
|
+
"heatmapEnabled": true
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
A corrupt file falls back to the defaults (enabled) and reports `configError` to the settings
|
|
233
|
+
page; fixing the file recovers on the next read without a restart.
|
|
234
|
+
|
|
235
|
+
## Colors
|
|
236
|
+
|
|
237
|
+
Everything comes from theme tokens, so light and dark themes both work with no literal colors:
|
|
238
|
+
|
|
239
|
+
- card: `--dsw-specific-input-major` fill + `--dsw-elevation-stroke` hairline +
|
|
240
|
+
`--dsw-shadow-lv1` shadow + `--dsw-radius-lg` corners — the exact same set as InputBar's `.card`;
|
|
241
|
+
- level `0`: `var(--dsw-alias-bg-skeleton)` (the host's own skeleton grey)
|
|
242
|
+
- levels `1`–`3`: `color-mix(in srgb, var(--dsw-static-deepseek-500) N%, transparent)`
|
|
243
|
+
with N = 26 / 48 / 72
|
|
244
|
+
- level `4`: `var(--dsw-static-deepseek-500)`
|
|
245
|
+
|
|
246
|
+
Not green: green carries the "success state" meaning in the host, and a 371-cell green grid makes
|
|
247
|
+
the whole New Session screen read as a stream of success events. Brand blue keeps the host's
|
|
248
|
+
achromatic chrome and still says "this is DeepSeek Harness data".
|
|
249
|
+
|
|
250
|
+
Cells are square (`aspect-ratio: 1`) with 2px corners and a 3px gap; hovering scales a cell to
|
|
251
|
+
128% with an outline and opens a card with the date and the current metric's value (no native `title`).
|
|
252
|
+
|
|
253
|
+
## Development
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
npm run verify # seven offline, dependency-free checks
|
|
257
|
+
npm run verify:strict # skip = failure (nothing skips today)
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
| Script | Covers |
|
|
261
|
+
| --- | --- |
|
|
262
|
+
| `verify-config` | defaults, dirty-data fallback, input validation, manifest contract |
|
|
263
|
+
| `verify-activity` | local-timezone aggregation, Monday alignment, level boundaries, generation choice, real mtime scan, 60s cache |
|
|
264
|
+
| `verify-token-index` | zstd frame scan, usage fold rules, cross-day replacement, incremental resume, torn frames, persisted reuse |
|
|
265
|
+
| `verify-host` | runs `apply()` for real and asserts route responses, switch semantics, config on disk |
|
|
266
|
+
| `verify-client` | runs `apply(ctx)` for real and asserts 8 dictionaries, slot order, unregistration when off, style contract |
|
|
267
|
+
| `verify-render` | renders the component with a mini React: metric switch, levels, progress, tooltip, styles |
|
|
268
|
+
| `verify-placement` | fake hero DOM: portal under the headline, cleanup on unmount, fallback when the mount point is missing |
|
|
269
|
+
|
|
270
|
+
## Limitations (v0.2)
|
|
271
|
+
|
|
272
|
+
- Sessions count by mtime: a session with hundreds of turns still counts as one session that day.
|
|
273
|
+
- The token index takes ~20s to build the first time (depends on history size); progress is shown
|
|
274
|
+
meanwhile, and later updates are incremental.
|
|
275
|
+
- Token level thresholds (10M/50M/150M/500M per day) are fixed values calibrated on one heavily-used
|
|
276
|
+
machine. Usage profiles that differ by orders of magnitude will see a skewed histogram; there is no
|
|
277
|
+
per-user quantile adaptation yet.
|
|
278
|
+
- No per-project / per-model breakdown, no separate report page.
|
|
279
|
+
- No sidebar icon, no chart library.
|
|
280
|
+
|
|
281
|
+
## Privacy
|
|
282
|
+
|
|
283
|
+
Everything is local. The plugin reads **mtimes** under `<DSH_HOME>/sessions`; for the token view it
|
|
284
|
+
decompresses session logs locally and extracts only the `usage` counters — it never uploads anything,
|
|
285
|
+
never parses or stores conversation text, and the index only records how many tokens a day had.
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
MIT
|
|
Binary file
|
package/assets/icon.svg
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64" fill="none">
|
|
2
|
+
<rect width="64" height="64" rx="14" fill="#4D6BFE" fill-opacity="0.12"/>
|
|
3
|
+
<g fill="#4D6BFE">
|
|
4
|
+
<rect x="12" y="14" width="10" height="10" rx="2" fill-opacity="0.18"/>
|
|
5
|
+
<rect x="27" y="14" width="10" height="10" rx="2" fill-opacity="0.42"/>
|
|
6
|
+
<rect x="42" y="14" width="10" height="10" rx="2" fill-opacity="0.7"/>
|
|
7
|
+
<rect x="12" y="27" width="10" height="10" rx="2" fill-opacity="0.42"/>
|
|
8
|
+
<rect x="27" y="27" width="10" height="10" rx="2" fill-opacity="1"/>
|
|
9
|
+
<rect x="42" y="27" width="10" height="10" rx="2" fill-opacity="0.55"/>
|
|
10
|
+
<rect x="12" y="40" width="10" height="10" rx="2" fill-opacity="0.7"/>
|
|
11
|
+
<rect x="27" y="40" width="10" height="10" rx="2" fill-opacity="0.18"/>
|
|
12
|
+
<rect x="42" y="40" width="10" height="10" rx="2" fill-opacity="0.42"/>
|
|
13
|
+
</g>
|
|
14
|
+
</svg>
|