dsh-context 0.7.0 → 0.7.1
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/README.md +25 -88
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,119 +1,56 @@
|
|
|
1
1
|
# dsh-context
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/dsh-context)
|
|
4
|
+
[](https://github.com/bowenliang123/dsh-context)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
**See what your DeepSeek Harness agent's context window is actually made of and how it evolves.**
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
`dsh-context` is a [DeepSeek Harness](https://github.com/deepseek-ai/DeepSeek-Harness) plugin that adds a **Context Insight** panel to the web UI: a live, visual answer to *"what is the model carrying right now, and how did it get there?"* — context composition, per-request history, compactions, and injections, all in one place.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+

|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
dsh plugin --profile web add dsh-context
|
|
13
|
-
```
|
|
12
|
+
## Install
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
One command, from any DeepSeek Harness installation:
|
|
16
15
|
|
|
17
16
|
```sh
|
|
18
|
-
dsh web
|
|
17
|
+
dsh plugin --profile web add dsh-context
|
|
19
18
|
```
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
Then start the web UI with `dsh web`, open any session, and click the **上下文 / Context** tab. No build step, no restart.
|
|
22
21
|
|
|
23
|
-
##
|
|
22
|
+
## What you'll see
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
### 📊 Context stats — the session at a glance
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
- **History** — one stacked bar per model request (finer than per-turn), with Y-axis ticks and gridlines. Click any bar for its full breakdown, including the **provider-reported** prompt/output tokens next to the estimate. ✂ marks where compaction/pruning happened — watch the bars drop.
|
|
29
|
-
- **Context events** — compactions, tool-output prunes, skill injections (`Skill injected (code-review)`), plugin context injections, model switches — each with its token delta and timestamp.
|
|
30
|
-
- **Messages** — the currently model-visible surface, message by message, with per-message token costs.
|
|
26
|
+
Turns, steps, how much context has been recycled by compactions and prunes, how many injections happened, model switches, and the estimated total tokens sent — next to the provider-reported actuals, so you can see how the estimate holds up.
|
|
31
27
|
|
|
32
|
-
|
|
28
|
+
### 🧱 Current composition — what's in the window right now
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
dsh-context ships as a **dsh bundle**: an npm package with a `dsh.bundle` manifest (a `cordis.patch.yml` layer that inserts the plugin row) and a `dsh.client` manifest (the web UI half). No build step, no restart — the one-liner above installs it into the `web` profile (or any other profile you boot with `dsh --profile <name>`). The `dsh-context` loader row activates the host half, and the web app picks up the package's `./client` bundle and adds the **上下文 / Context** tab to every session view.
|
|
30
|
+
A six-color stacked bar scaled against the model's full context window (the gray track is your remaining headroom): system prompt, tool schemas, your messages, injected context, assistant replies, and tool results — plus the top-5 most expensive tool schemas. When a conversation starts degrading, this is where you find out *which part ate the budget*.
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
### 📈 History — watch the window grow (and get compacted)
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
dsh plugin --profile <name> add .
|
|
42
|
-
```
|
|
34
|
+
One stacked bar per model request, finer than per-message. Toggle between **Turn** and **Step** granularity, scroll sideways through the session, hover any bar for a quick tooltip, and click to pin the full breakdown — including provider-reported actual prompt/output tokens next to the estimate. **✂ marks where compaction or pruning happened** — watch the bars drop:
|
|
43
35
|
|
|
44
|
-
|
|
36
|
+

|
|
45
37
|
|
|
46
|
-
|
|
38
|
+
Above: a real session that grew to ~563k tokens across 48 turns, then compaction (✂) recycled −535.5k in one step, and the conversation continued from a fresh, small window.
|
|
47
39
|
|
|
48
|
-
|
|
40
|
+
### ⚡ Context events — when and why the window changed
|
|
49
41
|
|
|
50
|
-
-
|
|
51
|
-
- The overview bar is scaled to the model's context window, so ~13% full means ~13% of the window is spoken for.
|
|
52
|
-
- Numbers are estimates using the *same fixed-density heuristic as dsh's built-in tokenMeter* (~4 chars ≈ 1 token), so they match the harness's own stats. Wherever the provider reported real usage, it's shown alongside as "actual".
|
|
42
|
+
Every compaction, tool-output prune, skill or plugin context injection, and model switch — each with its token delta, turn/step attribution, and timestamp:
|
|
53
43
|
|
|
54
|
-
|
|
44
|
+

|
|
55
45
|
|
|
56
|
-
|
|
57
|
-
- **Transport**: host ↔ browser over a generic **Connection RPC channel** (`/dsh-context`, `ctx.connection.rpc` — the same channel mechanism the api gateway uses). The host half registers a `snapshot` endpoint; the client half calls it via `ctx.connection.rpc.call`.
|
|
58
|
-
- **Incremental fold**: per-session fold state lives in the Host half, so each poll only processes newly appended events — reopening the tab is instant.
|
|
59
|
-
- **Events decoded**: `request/header` (system prompt + tool schemas), surface events with `surfaceOp` (append/replace — compaction rewrites history in place), `compaction/summary|prune`, `assistant/message.usage` (real provider tokens), and message `source` metadata (`plugin` forms, `skill-invocation`) for injection events.
|
|
60
|
-
- **Architecture**: `src/host/` is a plain ESM Cordis plugin (zero runtime dependencies) loaded by the `dsh-context` loader row; `src/client/` is the browser half, bundled at build time into the web boot's closure-factory bundle (`window.__ModuleLoader__.load`). The client renders with bare `React.createElement` — theme-native via dsh CSS variables, bilingual via the client `locale` service. Both halves are strict TypeScript with local (drift-free) service contracts, sharing the wire model in `src/shared/types.ts`.
|
|
46
|
+
### 💬 Messages — the currently model-visible surface
|
|
61
47
|
|
|
62
|
-
|
|
48
|
+
The exact message list the model sees right now, newest first, with a per-message token cost.
|
|
63
49
|
|
|
64
|
-
The project is a pnpm workspace root (`pnpm-workspace.yaml`), so `pnpm install` never walks up into a parent workspace.
|
|
65
50
|
|
|
66
|
-
|
|
67
|
-
pnpm install # devDependencies only — the plugin itself stays dependency-free
|
|
68
|
-
pnpm run typecheck # tsc --noEmit (strict)
|
|
69
|
-
pnpm run build # esbuild: lib/index.js (host) + lib/client.js (client bundle)
|
|
70
|
-
pnpm test # typecheck + functional tests for both halves
|
|
71
|
-
pnpm run repro # real-React + jsdom render smoke (granularity-toggle regression)
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
`build.mjs` also smoke-checks the outputs (both halves must parse; the host half must import with the `name`/`inject`/`apply` plugin shape).
|
|
75
|
-
|
|
76
|
-
Commits are guarded by a [husky](https://typicode.github.io/husky/) pre-commit hook that runs `pnpm run typecheck` (`tsc --noEmit`, strict).
|
|
77
|
-
|
|
78
|
-
## Project structure
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
src/
|
|
82
|
-
shared/types.ts # Wire contract: Snapshot / RequestRecord / ContextEventRecord / SurfaceNode
|
|
83
|
-
host/ # Host half — folds the session log into the snapshot
|
|
84
|
-
index.ts # Plugin entry: name/inject/apply + /dsh-context RPC endpoint
|
|
85
|
-
services.ts # Local service contracts (sessions/sessionQuery/connection)
|
|
86
|
-
pricing.ts # dsh token-meter heuristic (estimateMessage/system/tools)
|
|
87
|
-
fold.ts # Incremental per-session fold + whole-turn retention
|
|
88
|
-
snapshot.ts # Snapshot building + event turn/step attribution + caching
|
|
89
|
-
client/ # Client half — the Context tab UI
|
|
90
|
-
index.ts # Plugin entry: dicts, styles, slot registration
|
|
91
|
-
view.ts # Composition root: ViewKit + component wiring
|
|
92
|
-
viewkit.ts # Shared component dependencies (t/tr/fmt/catLabel/event helpers)
|
|
93
|
-
i18n.ts / styles.ts # Bilingual dictionaries / theme-native styles
|
|
94
|
-
format.ts # Number (k/M) and time formatting
|
|
95
|
-
categories.ts # Category colors + partsOf breakdown projection
|
|
96
|
-
cache.ts # Per-session snapshot cache (stale-while-revalidate)
|
|
97
|
-
components/ # One module per component (TrendChart, RequestDetail, …)
|
|
98
|
-
scripts/ # build.mjs (esbuild) + publish.sh (npm release)
|
|
99
|
-
tests/ # host.test.mjs, client.test.mjs, repro-real-react.mjs
|
|
100
|
-
```
|
|
51
|
+
## Like it?
|
|
101
52
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
## Files
|
|
105
|
-
|
|
106
|
-
| File | Role |
|
|
107
|
-
| --- | --- |
|
|
108
|
-
| `src/shared/types.ts` | Shared wire contract (type-only; both halves import it) |
|
|
109
|
-
| `src/host/*.ts` | Host half: fold, pricing, snapshot, RPC entry |
|
|
110
|
-
| `src/client/*.ts` | Client half: view composition, components, i18n, styles |
|
|
111
|
-
| `tsconfig.json` | Strict typecheck config (noEmit; esbuild does the transpiling) |
|
|
112
|
-
| `package.json` | `dsh.bundle` (patch layer) + `dsh.client` (web UI) manifests |
|
|
113
|
-
| `cordis.patch.yml` | The bundle's patch layer: inserts the `dsh-context` row |
|
|
114
|
-
| `scripts/build.mjs` | esbuild-based build of `lib/index.js` + `lib/client.js` |
|
|
115
|
-
| `tests/*.mjs` | Functional tests for both halves + the real-React repro |
|
|
116
|
-
| `docs/screenshot.png` | The UI in action |
|
|
53
|
+
If `dsh-context` helped you understand what your agent is carrying around, a ⭐ on [GitHub](https://github.com/bowenliang123/dsh-context) is much appreciated — and issues/PRs are welcome!
|
|
117
54
|
|
|
118
55
|
## License
|
|
119
56
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-context",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"description": "Context insight panel for DeepSeek Harness:
|
|
3
|
+
"version": "0.7.1",
|
|
4
|
+
"description": "Context insight panel for DeepSeek Harness: see what the model's context window is made of and how it evolves — composition, per-request history, compactions, injections, and model switches.",
|
|
5
5
|
"author": "bowenliang123",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|