dsh-context-compression-improved 0.7.0-beta.1 → 0.7.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.
Files changed (83) hide show
  1. package/.github/workflows/ci.yml +39 -39
  2. package/CHANGELOG.ja.md +217 -220
  3. package/CHANGELOG.ko.md +211 -214
  4. package/CHANGELOG.md +401 -376
  5. package/CHANGELOG.zh.md +196 -199
  6. package/README.md +97 -97
  7. package/README.zh.md +86 -86
  8. package/package.json +1 -1
  9. package/packages/selector/dsh.plugin.json +1 -1
  10. package/packages/selector/lib/client.d.ts +44 -0
  11. package/packages/selector/lib/client.js +1733 -6
  12. package/packages/selector/lib/{intent-gate.js → config.js} +799 -136
  13. package/packages/selector/lib/index.d.ts +13 -1
  14. package/packages/selector/lib/index.js +204 -3
  15. package/packages/selector/lib/profiles.d.ts +6 -0
  16. package/packages/selector/lib/pruner.d.ts +6 -0
  17. package/packages/selector/lib/pruner.js +90 -258
  18. package/packages/selector/lib/style.css +88 -46
  19. package/packages/selector/src/client/CompressionProfileControls.tsx +293 -226
  20. package/packages/selector/src/client/CompressionProfileSelector.module.css +199 -170
  21. package/packages/selector/src/client/CompressionProfileSelector.tsx +85 -83
  22. package/packages/selector/src/client/decode.ts +57 -53
  23. package/packages/selector/src/client/index.ts +307 -213
  24. package/packages/selector/src/client/locales/de.ts +141 -0
  25. package/packages/selector/src/client/locales/es.ts +141 -0
  26. package/packages/selector/src/client/locales/fr.ts +141 -0
  27. package/packages/selector/src/client/locales/it.ts +141 -0
  28. package/packages/selector/src/client/locales/ja.ts +141 -0
  29. package/packages/selector/src/client/locales/ko.ts +141 -0
  30. package/packages/selector/src/client/locales/ru.ts +141 -0
  31. package/packages/selector/src/client/locales.ts +282 -196
  32. package/packages/selector/src/client/monitor-fab.ts +336 -0
  33. package/packages/selector/src/client/savings-card.tsx +150 -0
  34. package/packages/selector/src/client/settings-section.tsx +140 -124
  35. package/packages/selector/src/deepseek-v4-tokenizer.ts +205 -205
  36. package/packages/selector/src/index.ts +207 -5
  37. package/packages/selector/src/preset-overlay.ts +629 -629
  38. package/packages/selector/src/profiles.ts +431 -414
  39. package/packages/selector/src/pruner/content.ts +198 -198
  40. package/packages/selector/src/pruner/state.ts +57 -57
  41. package/packages/selector/src/pruner.ts +2759 -2665
  42. package/packages/selector/src/runtime/audit.ts +303 -303
  43. package/packages/selector/src/runtime/config.ts +756 -731
  44. package/packages/selector/src/runtime/monitor.ts +235 -0
  45. package/packages/selector/src/runtime/reducers.ts +1674 -1674
  46. package/packages/selector/src/runtime/retrieve.ts +479 -457
  47. package/packages/selector/src/runtime/savings.ts +337 -0
  48. package/packages/selector/src/runtime/summary-command.ts +133 -133
  49. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -233
  50. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -204
  51. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +53 -53
  52. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -65
  53. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -125
  54. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -37
  55. package/packages/selector/src/runtime/tokenpilot/locator.ts +128 -128
  56. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +306 -306
  57. package/packages/selector/src/runtime/types.ts +365 -358
  58. package/packages/selector/tests/built/client-artifact.spec.ts +61 -61
  59. package/packages/selector/tests/code-skeleton.client.spec.ts +2 -2
  60. package/packages/selector/tests/custom-contract.client.spec.ts +2 -2
  61. package/packages/selector/tests/estimator-channel.client.spec.tsx +2 -0
  62. package/packages/selector/tests/estimator-route-registration.host.spec.ts +194 -188
  63. package/packages/selector/tests/helpers/legacy-settings/index.ts +15 -15
  64. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +41 -41
  65. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +647 -647
  66. package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +78 -78
  67. package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +234 -234
  68. package/packages/selector/tests/host-preset-overlay.host.spec.ts +203 -203
  69. package/packages/selector/tests/monitor-fab.client.spec.ts +138 -0
  70. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +523 -523
  71. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +122 -122
  72. package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -62
  73. package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -156
  74. package/packages/selector/tests/runtime/monitor.spec.ts +301 -0
  75. package/packages/selector/tests/runtime/savings.spec.ts +120 -0
  76. package/packages/selector/tests/runtime/summary-command.spec.ts +154 -154
  77. package/packages/selector/tests/settings-seat.client.spec.ts +177 -165
  78. package/scripts/packed-components-smoke.mjs +734 -734
  79. package/scripts/packed-install-e2e.mjs +1 -1
  80. package/scripts/verify-release.mjs +1 -1
  81. package/tests/TEST_INVENTORY.md +41 -41
  82. package/tsconfig.tests.json +17 -17
  83. package/vitest.config.ts +57 -57
package/CHANGELOG.md CHANGED
@@ -1,376 +1,401 @@
1
- # Changelog
2
-
3
- All notable changes use this file. The project follows semantic versioning after `0.1.0`.
4
-
5
- <<<<<<< HEAD
6
- ## 0.7.0-beta.1 - 2026-09-27
7
-
8
- ### Added
9
-
10
- - Turn-tail intent summary (`intentSummary.enabled`, default off): when the
11
- growth gate passes (live surface > 45% of the context window AND more than
12
- 50K tokens grown since the last fold), the turn-boundary postflight masks
13
- the consumed increment to semantic-role records — read-class tool results
14
- become one-line target/scale records via the shared `classifyToolSource()`
15
- classifier plus a write-class layer, write-class results keep skeleton
16
- heads plus verbatim error lines — and spends ONE summary-writer LLM call
17
- (todolist-anchored, JSON-only, fail-open). The staged fold lands on the
18
- next pressure round through the ordinary plan/apply machinery as per-
19
- candidate `intent-summary` blocks: the first carries the LLM summary
20
- segment, consulted-record lines, and verbatim error lines; the rest carry
21
- their mask line and a seq-range provenance footer. Fold-once: folded seqs
22
- (and anything carrying the `INTENT_FOLD_MARKER`) are never re-candidated.
23
- Rewrite audits carry `intent-summary-outcome` records with retention ratio
24
- and summary-call credit accounting.
25
- - `/ctx-summary off|on|status`: session-scoped temporary override for the
26
- gate (settings are session-frozen, so "temporary" can only live in runtime
27
- state); dies with the process, never crosses sessions, and reports the
28
- override, observed settings flag, gate constants, and the last landed fold.
29
- =======
30
- ## 0.6.5 - 2026-09-29
31
-
32
- ### Fixed
33
-
34
- - Dev-dependency alignment to the Harness 0.1.7 line: 46 of the 48 `@deepseek-ai/dsh-*`
35
- dev-dependencies moved from the precise `0.1.5-rc.2` pin to the precise `0.1.7-rc.2` pin,
36
- and `pnpm-lock.yaml` was regenerated from a clean tree. Typecheck, build, test, lint, and
37
- `verify:release` now run against the real 0.1.7-rc.2 baseline instead of validating the
38
- 0.1.7 adaptations against 0.1.5 inputs (a false green). Two packages have no 0.1.7-line
39
- release at all and keep their install-time pinned values: `@deepseek-ai/dsh-agent-presets`
40
- (`0.1.6-alpha.2`) and `@deepseek-ai/dsh-code-runtime` (`0.1.5-rc.3`). `react-dom` gained an
41
- explicit `^18.2.0` dev-dependency so a fresh resolution cannot pair React-DOM 19 with
42
- React 18 under the test suites.
43
- - The test-host settings seam was rebuilt against the real 0.1.7 host: `SettingsProvider`
44
- no longer exists in `@deepseek-ai/dsh-settings` (replaced by the declarative
45
- `SettingsForms`), while the plugin keeps the legacy `ctx.settings.get(ns)` read as a
46
- host-shape fallback. The specs now mount a vendored copy of the 0.1.5-rc.2 provider
47
- (`tests/helpers/legacy-settings/`) to exercise exactly that fallback, and the
48
- legacy-namespace registrar narrows the service at the seam. The live DeepSeek harness test
49
- registers the provider through the 0.1.7 adapter seam instead of the removed
50
- self-contained `llm-deepseek` plugin.
51
- - Test adaptations surfaced by the real baseline: the compaction-engine fixtures pass
52
- `headroomTokens: 0` (0.1.7-rc.2 defaults a 65536-token compaction headroom, which swallows
53
- the fixtures' 1k-token probe windows), and the tool-result asset assertion follows the
54
- first-class `role: 'tool'` message shape (no wrapping `tool-result` content block).
55
- - Release gates re-pinned to the official 0.1.7 release: `verify-release.mjs` and the packed
56
- E2E now assert selector peers `>=0.1.7-rc.1 <0.2.0-0`, and the packed E2E's official-harness
57
- clone asserts tag `dsh-v0.1.7-rc.2` (commit `477b4f42`, tree `e3e63253`).
58
- - `packages/selector/dsh.plugin.json` now carries the release version (0.6.5; every earlier
59
- 0.6.x shipped it frozen at 0.1.0) and declares the honest engine range
60
- `>=0.1.7-rc.1 <0.2.0-0`.
61
- - Lint debt from the 0.6.3 manual adaptations cleared: unused imports/locals removed in
62
- `src/index.ts`, `src/client/index.ts`, `src/pruner.ts`, and three host specs; the
63
- standing-generation staging-leftover scan now scopes to the spec's own store so a
64
- concurrently publishing spec cannot fail it.
65
-
66
- ## 0.6.4 - 2026-09-26
67
-
68
- ### Fixed
69
-
70
- - The client locale binder is eager: switching the host locale now re-renders the
71
- compression settings UI without a remount.
72
- - Released from a stash and never committed to any branch (the working tree that published it
73
- was lost); compat/0.1.7 restored the exact content in 0.6.5 and byte-verified it against
74
- the registry tarball before continuing.
75
- >>>>>>> compat/0.1.7
76
-
77
- ## 0.5.4 - 2026-09-20
78
-
79
- ### Fixed
80
-
81
- - The install surface declares `@deepseek-ai/schemastery` as a runtime dependency. The packaged
82
- runtime imports it unconditionally (`import z from '@deepseek-ai/schemastery'` in
83
- `packages/selector/lib/index.js`, `lib/pruner.js` and `lib/advisor-state.js`), but 0.5.3
84
- declared it nowhere a consumer install reads: the shipped root manifest listed only
85
- `@huggingface/tokenizers` and `js-yaml`, and `packages/selector/package.json` listed it as a
86
- peer, which no package manager consults for a nested package it installs. Resolution therefore
87
- depended on an unrelated installed package hoisting `@deepseek-ai/schemastery` into the
88
- profile. In a clean install the import fell through to the Harness installation's
89
- shared-module fallback at `$DSH_HOME/profiles/node_modules`; where that fallback held no built
90
- package, every plugin entry failed to load and the host booted without the Bundle layer. Both
91
- manifests now pin `3.18.2`, the version this release is built and tested against, and the
92
- selector package no longer claims a peer obligation it does not have.
93
-
94
- ### Added
95
-
96
- - `verify:release` derives the install-surface dependencies from the bare specifiers the
97
- packaged runtime files import, instead of naming `@huggingface/tokenizers` and `js-yaml` by
98
- hand. Which packages ship with the plugin and which the Harness installation provides is a
99
- reviewed list, and an import whose provider is in neither manifest fails the gate with the
100
- missing name. The gate was added as a negative control against the unfixed manifests, where it
101
- failed on `@deepseek-ai/schemastery`.
102
-
103
- ## 0.5.3 - 2026-09-20
104
-
105
- ### Fixed
106
-
107
- - The Bundle patch no longer sets the retired review route flag. `reviewQueueRoute` was
108
- removed from the plugin's Config schema when the review gate was retired, but it stayed in
109
- `packages/selector/cordis.patch.yml`, where it advertised a route that can never register.
110
- Hosts tolerate the unknown key today (the plugin loads and serves — verified on a live host),
111
- so this is a stale-config defect rather than a break, but it would break on any host that
112
- validates plugin config strictly.
113
- - Generated artifacts are pinned to LF (`packages/selector/lib/** text eol=lf`). With
114
- `core.autocrlf=true` every checkout rewrote the committed `lib/**` to CRLF, so any branch
115
- switch or merge left the whole artifact directory reported as modified with EOL-only
116
- differences. Nothing was ever committed from that state, but it made every tree look dirty
117
- and it would hide a real artifact change.
118
-
119
- ### Added
120
-
121
- - A negative-control contract pin on the Bundle patch: it fails when a retired config key is
122
- set in the patch (asserted on key-setting lines, so the explanatory comment may still name
123
- the key), and it requires the live `estimatorCatalogRoute` flag to stay wired.
124
-
125
- ### Tests
126
-
127
- - The client seat contract also pins the older-host degradation: a host that does not declare
128
- the seat rejects the registration at the slot boundary, and `apply()` must swallow it and
129
- warn instead of taking every settings entry down with it.
130
-
131
- ## 0.5.2 - 2026-09-20
132
-
133
- ### Changed
134
-
135
- - The human-gated review pipeline (beta) is **retired**. Its semantics are replaced by
136
- advice: the benefit model still prices every pass as ONE merged mutation, but the band it
137
- computes (`profitable` / `high-impact` / `slow-payback` / `unpriceable` / `not-worth-it`)
138
- is now published as a `reduction-advice` audit record and snapshotted onto the advisor
139
- report route — it never withholds, delays, or rewrites a reduction. The gate contradicted
140
- the feature's own requirement (a reduction must never block automatic processing) and, with
141
- the shipped defaults (`reviewMode` on plus a 4,000-token high-impact threshold against an
142
- 8,192-token fresh trigger), diverted 100% of a fresh batch into human review, leaving the
143
- automatic path effectively off for anyone who opted in. The advice thresholds are now
144
- module constants (α `0.1`, high-impact `4,000` tokens): nothing acts on them, so they are
145
- no longer settings.
146
- - Removed with the gate: the review queue and its `storageDomain` adapter, the process-wide
147
- registry, the `review-queue` / `review-decide` HTTP routes and the `reviewQueueRoute`
148
- deployment flag, the `shell.overlay` client panel, the `reviewMode` /
149
- `reviewTimeoutTurns` / `cacheHitDiscountAlpha` / `reviewHighImpactTokens` settings keys,
150
- and the `review-outcome` audit kind. The four settings keys stay ACCEPTED and IGNORED by
151
- both decoders — an existing document (the live one carries `reviewMode: false`) still loads
152
- and still renders its settings card — and never reach the resolved policy. The read-only
153
- `GET .../advisor-report` route additionally serves `lastAdvice`.
154
-
155
- ### Added
156
-
157
- - Regression pins for the retirement: a host-integration spec drives the exact settings that
158
- used to divert everything (`reviewMode: true`, `reviewHighImpactTokens: 1`) and asserts the
159
- fresh batch LANDS, described by a `high-impact` advice record; a deprecation-contract spec
160
- pins accept-and-ignore for the retired keys on both the runtime parser and the browser
161
- decoder.
162
-
163
- ### Rollback
164
-
165
- - Reinstall the last release that still ships the gate: `npm dist-tag add
166
- dsh-context-compression-improved@0.5.1 dsh-0.1.5 --registry https://registry.npmjs.org/`
167
- then `dsh plugin --profile web add dsh-context-compression-improved@0.5.1`.
168
-
169
- ## 0.5.1 - 2026-09-20
170
-
171
- ### Fixed
172
-
173
- - Concurrent preset-overlay composition of one identity no longer fails on Windows.
174
- Publication is now serialized per destination path, and when the atomic rename still
175
- loses the race the destination is confirmed to already carry this staging file's
176
- `{mtimeMs, size}` standing key before the publish reports success. Windows `MoveFileEx`
177
- reports that lost race as `EPERM`/`EBUSY` where POSIX `rename` simply replaces the
178
- destination, which made `standingKeyFor()` throw during concurrent session start. A
179
- destination that does not match still fails loudly, so a silently reused generation
180
- stays forbidden.
181
- - Release-gate and test repairs that had been hiding this and other pre-existing red
182
- gates: stale identifiers and a retired audit reason in the packed smokes, a stale
183
- client-inject expectation, and Windows-only spawn traps (`git` and multi-line
184
- `node -e` scripts were routed through `cmd.exe`, which rewrote their arguments).
185
-
186
- ## 0.5.0 - 2026-09-20
187
-
188
- ### Added
189
-
190
- - Advisory relevance advisor (statistics and suggestions only, default off): at every turn
191
- boundary a fire-and-forget pass summarizes the session's tail-task semantics from the
192
- most recent `todo/write` event (falling back to recent user text), incrementally scores
193
- historical tool-result candidates for content-and-comment relevance against the current
194
- task, and computes a prefix-decay figure (character-pressure-weighted mean relevance).
195
- Low-relevance old segments are marked `recertified` as suggestions for later
196
- history-aggressiveness decisions — nothing this round consumes them, and advisor output
197
- can never suppress, delay, or rewrite any reduction that would land (pinned by a
198
- dedicated invariant test). Configure through the `presetOptions.advisor*` settings keys
199
- (`advisorMode` `''|'host'|'direct'`, default `''`; the direct channel reuses the
200
- estimator endpoint; `SideChannel` gained an optional overrides parameter so the
201
- estimator's transport is shared without sharing its configuration). Observability: new
202
- `advisor-outcome` audit records (content-free, one per phase: summary / scoring / decay)
203
- and a read-only `GET .../advisor-report?sessionId=` HTTP route (opt-in deployment flag
204
- `advisorReportRoute`, mirroring the review routes). Client UI is intentionally absent
205
- this round.
206
-
207
- ## 0.4.0 - 2026-09-20
208
-
209
- ### Fixed
210
-
211
- - The plugin no longer depends on the routed model id: every planning gate now decides on
212
- the character basis (Unicode code points via `characterPressure` / `pressureCost`) instead
213
- of exact tokenizer counts, so a route without a bundled tokenizer (the live
214
- `deepseek-flash`) lands rewrites again instead of silently skipping. Token thresholds keep
215
- their names and values (converted at the documented 4.0 chars/token convention, frozen
216
- profile baseline untouched); token figures become telemetry, labelled honestly by the new
217
- `measurementBasis` field on rewrite audit records (`exact-tokenizer` vs `characters`,
218
- with `tokenizerId: 'characters'` / `tokenizerRevision: 'chars-per-token-4.0'` when derived).
219
- Rollback: `git revert 7a1972a` restores the exact-tokenizer gates as a single unit; confirm
220
- no later change re-introduced a model-id split that relies on this commit first.
221
-
222
- ### Added
223
-
224
- - Batch-level benefit pricing (R1): a review pass is priced as ONE merged mutation — the
225
- tail KV-cache refill penalty is paid once per batch instead of per candidate, so real
226
- batches (5×50k with a 64k tail) reach the auto band instead of all dropping.
227
- - Original-event line mapping (R9a): terminal normalization returns folded lines that each
228
- carry their 1-based original-event line number; `retrieve` reads raw events, so printed
229
- ranges resolve to the right lines.
230
- - Document skeleton and universal prose keep (R8/R8b): structured documents keep headings,
231
- section first/last lines, list starts and table headers; every other non-code text keeps
232
- head AND tail with an R9 line-range marker (prose was previously head-only truncated).
233
- - Two-tier search folding (R10, fixes D8): a lossless per-file L1 locator plus a
234
- water-filled L2 content quota.
235
- - Non-adjacent frequency folding (R11): separated exact repeats (up to 8.37% of large
236
- results) fold to first occurrence plus one counted marker.
237
- - Long-string placeholders (R12): base64/hex/UUID blobs become length summaries with a
238
- 16-char recognition prefix.
239
- - Two-stage HTML reduction (R13, fixes D9): `html-slim` then `html-skeleton`, line-aligned
240
- so original line numbers survive.
241
- - R9b anchors: contiguous masks cite original line ranges, scatter masks report
242
- `lines 1-N scanned, K kept`, and every retrieve hint carries a pasteable
243
- `{"ref":…,"start_line":N,"max_lines":80}`.
244
- - Document census: omitted-document summaries list section headings instead of a constant
245
- `0 error, 0 warn, N info` histogram.
246
-
247
- ## 0.3.1 - 2026-09-18
248
-
249
- ### Changed
250
-
251
- - The runtime package is merged into the selector package: one install brings the whole
252
- stack, the repository root is the install surface (`name`, `main`, `types`, `exports` with
253
- `./pruner` and `./invariant`, `dependencies`, `dsh`), and the toolchain, scripts and CI were
254
- swept to the single package. The verified estimator-catalog registration (dual prefix, guarded
255
- two-channel activation, per-request service resolution, visible lifecycle lines) was replayed
256
- onto this line with a host-side guard; the settings schema that `ab2175a` had downgraded to
257
- `z.any()` is restored, so the daily Custom defaults are published again.
258
- - Adapt to the official DeepSeek Harness `v0.1.5-rc.2` on this branch. All `@deepseek-ai/dsh-*` dev dependencies and the pinned e2e host set move from `0.1.1-rc.2` to `0.1.5-rc.2` (cordis `4.0.2`, schemastery `3.18.2`), including the new split packages (`dsh-session-projection`, `dsh-session-persistence`, `dsh-atomic-write`, `dsh-home-paths`, `dsh-sandbox`, and related) and the `dsh-client-store` client stack.
259
- - Surface replace operations now use the v3 `startSeq`/`endSeq` shape with branded `SessionSeq` values; `compaction/prune` manifests keep the durable `start`/`end` fields. Events are resolved from surface nodes by seq lookup instead of array indexing.
260
- - The client bundle no longer imports the removed `@deepseek-ai/dsh-client-runtime`: settings types now come from `@deepseek-ai/dsh-client-ui-settings` and the session hooks merge from `@deepseek-ai/dsh-client-ui-session`. `engines.dsh >=0.1.5-alpha.1 <0.2.0-0` is declared in both package manifests and `dsh.plugin.json`.
261
- - Harness 0.1.5 no longer exposes the session `agentPreset` to the browser, so the client can no longer detect Minimal-only sessions; the selector stays selectable and the old unavailable banner is unreachable.
262
- - Test batteries updated for 0.1.5 semantics: cordis plugin starts require `.await()`, the Token Meter requires a mounted `SessionProjectionRegistry`, assistant events carry `stream: []`, and settings namespaces are plain strings.
263
-
264
- ### Fixed
265
-
266
- - The estimator card no longer demands an API key on the Harness host channel. Selecting the host channel shows the live provider/model dropdowns, names the route that would actually run (explicit override, else the session default), and renders neither a key field nor a second manual model input: the base URL, the model text field, and the write-only key belong to the direct endpoint channel alone.
267
- - `presetOptions` writes are path-addressed. Writing the whole section replaced it, so touching any second estimator field (a provider, a model, an endpoint) deleted `estimatorMode` and every sibling override — silently switching the estimator back off while the panel still reported a successful save. Each field now writes only itself, `undefined` clears exactly the field it names, and the confirmation read validates the same field set instead of the mode alone.
268
- - New coverage: `packages/selector/tests/preset-options-write.client.spec.ts` (path-scoped writes, sibling preservation, explicit clears, no-op patches, uncommitted-write reporting) and `packages/selector/tests/estimator-channel.client.spec.tsx` (per-channel fields, catalog dropdowns, manual fallback).
269
-
270
-
271
- ### Added
272
-
273
- - New `tokenpilot-inspired` profile: a TokenPilot-paper-inspired capability matrix layered on the Balanced thresholds, selected explicitly from the settings UI; every pre-existing profile keeps a byte-identical resolved policy (enforced by a captured-baseline golden test).
274
- - Byte-identical repeated tool-result dedup: an oversized repeat is replaced with a pointer to the first occurrence's append-only original event (`dedupe-pointer`), with a per-session SHA-256 index (2,048-entry insertion-order eviction, hash+seq metadata only).
275
- - No-net-savings guard: replacements whose text is not smaller than the original are rejected even when the exact tokenizer reports a token saving.
276
- - Recovery exemption: recovery-tool output is permanently exempt from every reduction pass via a unified per-session exemption set, preventing compress-restore oscillation.
277
- - Auto Compact summary locator: after `compaction/end`, the landed summary checkpoint gains an Exact Sources block (shadowed seq range, spill files, touched files) so summarized-away details stay recoverable; skipped when it would locate nothing concrete.
278
- - Read-state semantics: a historical read whose file was later mutated is `superseded` and takes the small whole-result placeholder; optional error/warn/info clustering of omitted lines is appended to historical placeholders.
279
- - Optional residual-utility estimator (three channels: off / Harness host model / direct OpenAI-compatible endpoint) with per-session exponential backoff, strict timeout, advisory-only verdicts consumed by the next pressure pass, and numeric-only `estimator-outcome` audits. The estimator card appears only while the new profile is selected; the API key is write-only in settings and never enters the frozen policy, audits, or logs.
280
- - New audit records: `summary-locator` and `estimator-outcome`; the rewrite record covers dedup via the `dedupe-pointer` reducer. Audit field allowlists are unchanged.
281
- - Simplified Chinese and English copy for the new profile and estimator card; unit and golden coverage under `packages/runtime/tests/tokenpilot/`.
282
-
283
- - Orthogonal code-skeleton compression gate (`codeSkeleton.enabled`, default off): the first exposure of an oversized fresh source-code tool result can keep an imports-and-declarations skeleton with bodies elided and error lines preserved, falling back to the original head pruning. The gate is independent of every profile and gated on exact tokenizer measurement.
284
- - Settings-UI toggle for the gate in the selector settings section, with Simplified Chinese and English copy.
285
- - Browser/runtime decode parity for the new section, confirm-on-write contract tests for `saveCodeSkeleton`, and a full-document parity matrix extension.
286
-
287
- ### Changed
288
-
289
- - Added an ESLint flat-config baseline (`pnpm lint`, enforced in CI) and a `pnpm test:watch` TDD loop; removed dead imports and hardened two error paths surfaced by the lint baseline.
290
- - This repository is now maintained as an improved fork of `WilliamShi666/dsh-context-compression-selector`; documentation ships in English, Simplified Chinese, Japanese, and Korean.
291
-
292
- ## 0.1.0 - 2026-09-03
293
-
294
- ### Added
295
-
296
- - Stable release of DeepSeek V4 Flash Vision tokenizer integration for `deepseek-v4-flash-vision-exp`, including exact text counting and bounded image-token estimates.
297
- - User-configurable model-driven Auto Compact threshold in the selector settings section.
298
- - Auto Compact threshold linkage for each standard profile's History / micro-compact watermarks and related compression parameters.
299
-
300
- ### Changed
301
-
302
- - The threshold editor now uses one direct numeric input; the slider and fixed quick-value buttons were removed.
303
- - Runtime session-event access supports both the established Harness `events` accessor and the newer `snapshotEvents()` public API.
304
-
305
- ## 0.1.0-beta.4 - 2026-09-02
306
-
307
- ### Fixed
308
-
309
- - Support the official DeepSeek Harness `dsh-v0.1.2-alpha.5` public API while retaining compatibility with the existing `0.1.1-rc.2` peer range. The plugin now owns the two small immutable-value helpers that the newer Harness no longer exports, and uses the same public `context-compression` namespace literal accepted by both Settings implementations. No Harness core code is modified.
310
-
311
- ## 0.1.0-beta.3 - 2026-09-01
312
-
313
- ### Scope
314
-
315
- This is a staged release. Exact **text-class** token counting for `deepseek-v4-flash-vision-exp`, best-effort bounded **vision-class image** estimates, and the Auto Compact threshold/UI/audit work are delivered. Exact image measurement remains **BLOCKED upstream**: the current measurement seam exposes neither the adapter's projected request-image dimensions nor the absolute serialized position, so estimates cannot be promoted to `exact-tokenizer`.
316
-
317
- ### Added
318
-
319
- - DeepSeek V4 Flash Vision support for `deepseek-v4-flash-vision-exp` via a separately bundled official tokenizer pinned at `deepseek-ai/DeepSeek-V4-Flash-Vision-Exp` revision `6821d6ad3681a4b137b066b76094fa82ebd0a380`. Text, reasoning, tool-call arguments, and pure-text tool results are counted exactly; image-bearing tool-result candidates stay fail-open.
320
- - Vision image-token arithmetic ported line-by-line from the official `inference/image_processor.py` (patch size 14, downsample 3, 384-token cap, min pixels 147456, 8:1 aspect clamp, and position-dependent alignment padding), validated against golden fixtures generated by executing the official Python implementation. Valid intrinsic dimensions now produce `tokenizer-estimate` at the midpoint of all four alignment residues with a 384-token per-image upper bound; malformed or unevaluable dimensions use a documented 256-token fallback. Mixed text/image surfaces aggregate exact text and estimated images without promoting them to exact.
321
- - `autoCompact.thresholdPercent` setting (default 80, integer 50–90, step 1) with one shared validation contract across the settings UI, the persisted schema, and the runtime resolver. The editor lives inside the context-compression selector settings section.
322
- - Standard-profile History linkage to the Auto Compact watermark: `A = floor(C × a)` rescales the History trigger, minimum reclaim, and recent-token tail; `D = floor(A × 0.875)` replaces the fixed 0.7 capacity-pressure ratio as the micro-compact last-chance gate; one batch must justify its cache break by pulling the complete request back below the deadline. Defaults at 80% reproduce the previous numbers exactly.
323
- - The preset overlay writes the saved threshold into the generated `compaction-basic` composition as `thresholdRatio` (with `retainRatio` pinned at 0.16) and, from the same read, into the plugin runtime's deployment config as `autoCompactThresholdPercent`, so one standing generation never runs Auto Compact and micro compact on two different thresholds. Any generation-identity change — threshold, source, or module paths, including equal-length ones — produces a new standing composition generation. Deterministic identity-derived stamps use an 8-hex whole-second window; equal-prefix identities can collide in that first window on a coarse filesystem, so the overlay observes the staging file's real `mtimeMs+size` key and escalates to later hash windows before the atomic rename. Content, permissions, and the final unique stamp are complete before publication; already-running sessions keep their frozen policy.
324
- - `policy-resolved` audits now record the Auto Compact coordination facts (threshold percent, `A`, `D`, parameter source — including `deployment-override`/`mixed` when deployment config replaces linked History watermarks), the routed provider/model, and the bundled tokenizer identity.
325
- - Persisted settings reject present-but-invalid sections (`profile: null`, `custom: null`, own-property `undefined`) before any schema default can absorb them; a malformed stored document freezes the session losslessly (`profile: off`, audited as `settingsInvalidFallback: lossless-off`) instead of silently enabling the lossy Balanced default. The browser decoder applies the same rule and canonicalizes legacy Custom v1/v2 documents to the same v3 document the runtime resolver produces.
326
- - The History planner returns a discriminated outcome, and `component-evaluation` audits distinguish the full skip taxonomy: `below-profile-trigger`, `below-micro-deadline`, `exact-tokenizer-unavailable`, `no-safe-candidates` (only recovery-tool output or already-cleared results), `protected-working-set` (everything inside the protected tail), `insufficient-reclaim` and `cannot-reach-deadline-target` (with the reached/required token numbers), `adaptive-cost-rejected`, and `recovery-tool-unavailable`.
327
-
328
- ### Known limitations
329
-
330
- - Images never claim exact counts. The official expansion depends on the absolute prompt position (system prompt, chat-template framing, adapter image handles) and on the adapter's final request-image projection (including per-route `imagePixelBudget`/`imageDetail` overrides and byte-cap reprojection), none of which is exposed through the current measurement seam. Intrinsic/default estimates may therefore differ materially from provider accounting. Upstream capability requests remain projected request-image dimensions and the absolute serialized position exposed to token-meter extensions.
331
- - History skips the whole batch whenever any tool-result candidate lacks an exact count, including image-bearing candidates, even though sibling text candidates are individually exact.
332
- - Custom remains manual token mode; its History parameters do not follow the Auto Compact watermark.
333
- - A vision token breakdown UI is not shipped; image estimates and the intrinsic alignment diagnostic are available on the measured token view, while lossy rewrite proofs still require exact counts.
334
-
335
- ### Deferred
336
-
337
- - Audit `modality` field and the tokenizer artifact SHA-256 inside audit records (the audits already carry the routed provider/model and tokenizer identity).
338
- - Publishing the (now complete) runtime skip-reason taxonomy as a user-facing documentation table.
339
- - Custom-profile display of the A/D watermarks and an above-D warning; Custom remains fully manual.
340
- - Vision token breakdown UI and promotion of image estimates to exact measurement.
341
-
342
- ## 0.1.0-beta.2 - 2026-08-28
343
-
344
- ### Fixed
345
-
346
- - Resolve the official DeepSeek V4 Flash tokenizer route so Fresh and Aggregate can evaluate tool results for the supported V4 models.
347
- - Run Cache Strict History at the real request boundary once its configured capacity-pressure condition is met; trigger the capacity condition at 70% routed-context utilization.
348
- - Disable Harness-native head/middle/tail tool-result pruning whenever a selector profile is active, leaving the selector as the sole tool-result compactor.
349
-
350
- ### Changed
351
-
352
- - Protect the newest 10 agent tool calls and a 64,000-token tool-result tail window before History/microcompact rewrites older results.
353
-
354
- ## 0.1.0-beta.1 - 2026-08-27
355
-
356
- ### Added
357
-
358
- - One-install DeepSeek Harness Product Bundle backed by a separate exact-version runtime package.
359
- - Web profile selector with preset-stable settings and an explicit built-in Minimal exception.
360
- - Fresh, Aggregate, routine/capacity-aware History, Native tool-result pruning, and default-off Custom TailTrim.
361
- - Standard-event TailTrim protocol using `compaction/prune` plus recoverable `user/message` replacement.
362
- - Plugin-owned `context_compression_retrieve` recovery tool.
363
- - Structured, content-free policy, evaluation, rewrite, failure, and Native auto-compact audit records.
364
- - Pinned official DeepSeek V4 tokenizer assets with runtime SHA-256 validation and upstream license.
365
- - Public-API component E2E, preset/Minimal, and parent/fork/spawn cache-prefix regression tests.
366
-
367
- ### Compatibility
368
-
369
- - Verified against DeepSeek Harness `dsh-v0.1.1-rc.2` public packages.
370
- - Exact tokenizer mapping is currently limited to `deepseek-v4-flash` and `deepseek-v4-pro`.
371
-
372
- ### Known limitations
373
-
374
- - Adaptive ordinary History fails closed when public request-level route/cache evidence is incomplete; capacity pressure remains a separate safety override.
375
- - Cache-prefix tests prove native fork inheritance and identical serialized prefixes, not a provider-specific cache allocation or a guaranteed DeepSeek cache hit.
376
- - Settings snapshots and first-exposure decisions are process-local to the mounted runtime.
1
+ # Changelog
2
+
3
+ All notable changes use this file. The project follows semantic versioning after `0.1.0`.
4
+
5
+ ## 0.7.0 - 2026-10-03
6
+
7
+ ### Added
8
+
9
+ - **Savings statistics with honest accounting** (inspired by the dsh-token-optimizer concept): every published reduction now lands in a per-process ledger (`runtime/savings.ts`) keyed by the rewrite audit's own `tokensBefore − tokensAfter` — realized savings only, never the theoretical maximum. **Negative savings are paired, not ignored**: the original text of each reduction is SHA-256 registered, and when the model later re-reads that content in full (a new tool result whose hash matches, or a `context_compression_retrieve` return), the re-read tokens are booked as an offset against the earlier claim — skeleton-then-full-read nets negative, exactly as it should. Exact-tokenizer and chars/4 bases are aggregated separately and never merged into one number.
10
+ - Surfaces: read-only `GET /{endpoint,api}/dsh-context-compression-improved/savings` snapshot route (always-on, aggregates only — no session content), and a savings card in the settings section (net/gross/offsets, per-component breakdown, recent offsets) in all nine UI languages.
11
+ - **Usage aggregation & cache-hit monitoring** (the dsh-token-optimizer monitor concept, merged with the honest ledger): every fresh request boundary records the official TokenMeter usage of the last completed request into the same per-session ledger; the snapshot aggregates real input/output/cache-read/cache-write tokens and derives the cache hit rate — the health metric that tells you whether compression is actually saving money or just destroying prefix cache. Sessions are bucketed per net savings (top 8), and a one-line per-session account (net, offsets, requests, cache hit) is logged to the Harness logger on `session/disposed` (probe-registered: hosts without the event stay silent).
12
+ - **Cost estimation on the snapshot route**: when the current host route resolves to an official DeepSeek price record, the response carries the actual aggregated cost plus an estimated saved cost (net exact tokens priced at the cache-miss input band, explicitly labeled an estimate); third-party routes fail closed to no pricing rather than inventing numbers.
13
+
14
+ ## 0.7.0-beta.2 - 2026-10-01
15
+
16
+ ### Added
17
+
18
+ - Merged the turn-tail intent summary feature onto this line (previously released
19
+ as 0.7.0-beta.1 from the feat/intent-summary line): nine-language dictionaries
20
+ and the intent-summary fold pipeline now ship together. See 0.7.0-beta.1 below.
21
+
22
+ ### Fixed
23
+
24
+ - CHANGELOG.zh/ja/ko carried unresolved conflict markers committed during the
25
+ 0.6.5-closure merge; the sections are reconstructed clean.
26
+
27
+ ## Unreleased
28
+
29
+ ### Added
30
+
31
+ - Japanese (`ja`) and Korean (`ko`) UI locale dictionaries, plus the fr/de/it/ru/es dictionaries ported from main — the selector settings section now speaks nine languages (zh / en / de / es / fr / it / ja / ko / ru). Dictionaries are type-checked against `ContextCompressionLocaleKey`; labels are self-described and fall back to English per key. Client-only, host-agnostic.
32
+
33
+ ## 0.7.0-beta.1 - 2026-09-27
34
+
35
+ ### Added
36
+
37
+ - Turn-tail intent summary (`intentSummary.enabled`, default off): when the
38
+ growth gate passes (live surface > 45% of the context window AND more than
39
+ 50K tokens grown since the last fold), the turn-boundary postflight masks
40
+ the consumed increment to semantic-role records — read-class tool results
41
+ become one-line target/scale records via the shared `classifyToolSource()`
42
+ classifier plus a write-class layer, write-class results keep skeleton
43
+ heads plus verbatim error lines — and spends ONE summary-writer LLM call
44
+ (todolist-anchored, JSON-only, fail-open). The staged fold lands on the
45
+ next pressure round through the ordinary plan/apply machinery as per-
46
+ candidate `intent-summary` blocks: the first carries the LLM summary
47
+ segment, consulted-record lines, and verbatim error lines; the rest carry
48
+ their mask line and a seq-range provenance footer. Fold-once: folded seqs
49
+ (and anything carrying the `INTENT_FOLD_MARKER`) are never re-candidated.
50
+ Rewrite audits carry `intent-summary-outcome` records with retention ratio
51
+ and summary-call credit accounting.
52
+ - `/ctx-summary off|on|status`: session-scoped temporary override for the
53
+ gate (settings are session-frozen, so "temporary" can only live in runtime
54
+ state); dies with the process, never crosses sessions, and reports the
55
+ override, observed settings flag, gate constants, and the last landed fold.
56
+ ## 0.6.5 - 2026-09-29
57
+
58
+ ### Fixed
59
+
60
+ - Dev-dependency alignment to the Harness 0.1.7 line: 46 of the 48 `@deepseek-ai/dsh-*`
61
+ dev-dependencies moved from the precise `0.1.5-rc.2` pin to the precise `0.1.7-rc.2` pin,
62
+ and `pnpm-lock.yaml` was regenerated from a clean tree. Typecheck, build, test, lint, and
63
+ `verify:release` now run against the real 0.1.7-rc.2 baseline instead of validating the
64
+ 0.1.7 adaptations against 0.1.5 inputs (a false green). Two packages have no 0.1.7-line
65
+ release at all and keep their install-time pinned values: `@deepseek-ai/dsh-agent-presets`
66
+ (`0.1.6-alpha.2`) and `@deepseek-ai/dsh-code-runtime` (`0.1.5-rc.3`). `react-dom` gained an
67
+ explicit `^18.2.0` dev-dependency so a fresh resolution cannot pair React-DOM 19 with
68
+ React 18 under the test suites.
69
+ - The test-host settings seam was rebuilt against the real 0.1.7 host: `SettingsProvider`
70
+ no longer exists in `@deepseek-ai/dsh-settings` (replaced by the declarative
71
+ `SettingsForms`), while the plugin keeps the legacy `ctx.settings.get(ns)` read as a
72
+ host-shape fallback. The specs now mount a vendored copy of the 0.1.5-rc.2 provider
73
+ (`tests/helpers/legacy-settings/`) to exercise exactly that fallback, and the
74
+ legacy-namespace registrar narrows the service at the seam. The live DeepSeek harness test
75
+ registers the provider through the 0.1.7 adapter seam instead of the removed
76
+ self-contained `llm-deepseek` plugin.
77
+ - Test adaptations surfaced by the real baseline: the compaction-engine fixtures pass
78
+ `headroomTokens: 0` (0.1.7-rc.2 defaults a 65536-token compaction headroom, which swallows
79
+ the fixtures' 1k-token probe windows), and the tool-result asset assertion follows the
80
+ first-class `role: 'tool'` message shape (no wrapping `tool-result` content block).
81
+ - Release gates re-pinned to the official 0.1.7 release: `verify-release.mjs` and the packed
82
+ E2E now assert selector peers `>=0.1.7-rc.1 <0.2.0-0`, and the packed E2E's official-harness
83
+ clone asserts tag `dsh-v0.1.7-rc.2` (commit `477b4f42`, tree `e3e63253`).
84
+ - `packages/selector/dsh.plugin.json` now carries the release version (0.6.5; every earlier
85
+ 0.6.x shipped it frozen at 0.1.0) and declares the honest engine range
86
+ `>=0.1.7-rc.1 <0.2.0-0`.
87
+ - Lint debt from the 0.6.3 manual adaptations cleared: unused imports/locals removed in
88
+ `src/index.ts`, `src/client/index.ts`, `src/pruner.ts`, and three host specs; the
89
+ standing-generation staging-leftover scan now scopes to the spec's own store so a
90
+ concurrently publishing spec cannot fail it.
91
+
92
+ ## 0.6.4 - 2026-09-26
93
+
94
+ ### Fixed
95
+
96
+ - The client locale binder is eager: switching the host locale now re-renders the
97
+ compression settings UI without a remount.
98
+ - Released from a stash and never committed to any branch (the working tree that published it
99
+ was lost); compat/0.1.7 restored the exact content in 0.6.5 and byte-verified it against
100
+ the registry tarball before continuing.
101
+
102
+ ## 0.5.4 - 2026-09-20
103
+
104
+ ### Fixed
105
+
106
+ - The install surface declares `@deepseek-ai/schemastery` as a runtime dependency. The packaged
107
+ runtime imports it unconditionally (`import z from '@deepseek-ai/schemastery'` in
108
+ `packages/selector/lib/index.js`, `lib/pruner.js` and `lib/advisor-state.js`), but 0.5.3
109
+ declared it nowhere a consumer install reads: the shipped root manifest listed only
110
+ `@huggingface/tokenizers` and `js-yaml`, and `packages/selector/package.json` listed it as a
111
+ peer, which no package manager consults for a nested package it installs. Resolution therefore
112
+ depended on an unrelated installed package hoisting `@deepseek-ai/schemastery` into the
113
+ profile. In a clean install the import fell through to the Harness installation's
114
+ shared-module fallback at `$DSH_HOME/profiles/node_modules`; where that fallback held no built
115
+ package, every plugin entry failed to load and the host booted without the Bundle layer. Both
116
+ manifests now pin `3.18.2`, the version this release is built and tested against, and the
117
+ selector package no longer claims a peer obligation it does not have.
118
+
119
+ ### Added
120
+
121
+ - `verify:release` derives the install-surface dependencies from the bare specifiers the
122
+ packaged runtime files import, instead of naming `@huggingface/tokenizers` and `js-yaml` by
123
+ hand. Which packages ship with the plugin and which the Harness installation provides is a
124
+ reviewed list, and an import whose provider is in neither manifest fails the gate with the
125
+ missing name. The gate was added as a negative control against the unfixed manifests, where it
126
+ failed on `@deepseek-ai/schemastery`.
127
+
128
+ ## 0.5.3 - 2026-09-20
129
+
130
+ ### Fixed
131
+
132
+ - The Bundle patch no longer sets the retired review route flag. `reviewQueueRoute` was
133
+ removed from the plugin's Config schema when the review gate was retired, but it stayed in
134
+ `packages/selector/cordis.patch.yml`, where it advertised a route that can never register.
135
+ Hosts tolerate the unknown key today (the plugin loads and serves — verified on a live host),
136
+ so this is a stale-config defect rather than a break, but it would break on any host that
137
+ validates plugin config strictly.
138
+ - Generated artifacts are pinned to LF (`packages/selector/lib/** text eol=lf`). With
139
+ `core.autocrlf=true` every checkout rewrote the committed `lib/**` to CRLF, so any branch
140
+ switch or merge left the whole artifact directory reported as modified with EOL-only
141
+ differences. Nothing was ever committed from that state, but it made every tree look dirty
142
+ and it would hide a real artifact change.
143
+
144
+ ### Added
145
+
146
+ - A negative-control contract pin on the Bundle patch: it fails when a retired config key is
147
+ set in the patch (asserted on key-setting lines, so the explanatory comment may still name
148
+ the key), and it requires the live `estimatorCatalogRoute` flag to stay wired.
149
+
150
+ ### Tests
151
+
152
+ - The client seat contract also pins the older-host degradation: a host that does not declare
153
+ the seat rejects the registration at the slot boundary, and `apply()` must swallow it and
154
+ warn instead of taking every settings entry down with it.
155
+
156
+ ## 0.5.2 - 2026-09-20
157
+
158
+ ### Changed
159
+
160
+ - The human-gated review pipeline (beta) is **retired**. Its semantics are replaced by
161
+ advice: the benefit model still prices every pass as ONE merged mutation, but the band it
162
+ computes (`profitable` / `high-impact` / `slow-payback` / `unpriceable` / `not-worth-it`)
163
+ is now published as a `reduction-advice` audit record and snapshotted onto the advisor
164
+ report route — it never withholds, delays, or rewrites a reduction. The gate contradicted
165
+ the feature's own requirement (a reduction must never block automatic processing) and, with
166
+ the shipped defaults (`reviewMode` on plus a 4,000-token high-impact threshold against an
167
+ 8,192-token fresh trigger), diverted 100% of a fresh batch into human review, leaving the
168
+ automatic path effectively off for anyone who opted in. The advice thresholds are now
169
+ module constants (α `0.1`, high-impact `4,000` tokens): nothing acts on them, so they are
170
+ no longer settings.
171
+ - Removed with the gate: the review queue and its `storageDomain` adapter, the process-wide
172
+ registry, the `review-queue` / `review-decide` HTTP routes and the `reviewQueueRoute`
173
+ deployment flag, the `shell.overlay` client panel, the `reviewMode` /
174
+ `reviewTimeoutTurns` / `cacheHitDiscountAlpha` / `reviewHighImpactTokens` settings keys,
175
+ and the `review-outcome` audit kind. The four settings keys stay ACCEPTED and IGNORED by
176
+ both decoders — an existing document (the live one carries `reviewMode: false`) still loads
177
+ and still renders its settings card — and never reach the resolved policy. The read-only
178
+ `GET .../advisor-report` route additionally serves `lastAdvice`.
179
+
180
+ ### Added
181
+
182
+ - Regression pins for the retirement: a host-integration spec drives the exact settings that
183
+ used to divert everything (`reviewMode: true`, `reviewHighImpactTokens: 1`) and asserts the
184
+ fresh batch LANDS, described by a `high-impact` advice record; a deprecation-contract spec
185
+ pins accept-and-ignore for the retired keys on both the runtime parser and the browser
186
+ decoder.
187
+
188
+ ### Rollback
189
+
190
+ - Reinstall the last release that still ships the gate: `npm dist-tag add
191
+ dsh-context-compression-improved@0.5.1 dsh-0.1.5 --registry https://registry.npmjs.org/`
192
+ then `dsh plugin --profile web add dsh-context-compression-improved@0.5.1`.
193
+
194
+ ## 0.5.1 - 2026-09-20
195
+
196
+ ### Fixed
197
+
198
+ - Concurrent preset-overlay composition of one identity no longer fails on Windows.
199
+ Publication is now serialized per destination path, and when the atomic rename still
200
+ loses the race the destination is confirmed to already carry this staging file's
201
+ `{mtimeMs, size}` standing key before the publish reports success. Windows `MoveFileEx`
202
+ reports that lost race as `EPERM`/`EBUSY` where POSIX `rename` simply replaces the
203
+ destination, which made `standingKeyFor()` throw during concurrent session start. A
204
+ destination that does not match still fails loudly, so a silently reused generation
205
+ stays forbidden.
206
+ - Release-gate and test repairs that had been hiding this and other pre-existing red
207
+ gates: stale identifiers and a retired audit reason in the packed smokes, a stale
208
+ client-inject expectation, and Windows-only spawn traps (`git` and multi-line
209
+ `node -e` scripts were routed through `cmd.exe`, which rewrote their arguments).
210
+
211
+ ## 0.5.0 - 2026-09-20
212
+
213
+ ### Added
214
+
215
+ - Advisory relevance advisor (statistics and suggestions only, default off): at every turn
216
+ boundary a fire-and-forget pass summarizes the session's tail-task semantics from the
217
+ most recent `todo/write` event (falling back to recent user text), incrementally scores
218
+ historical tool-result candidates for content-and-comment relevance against the current
219
+ task, and computes a prefix-decay figure (character-pressure-weighted mean relevance).
220
+ Low-relevance old segments are marked `recertified` as suggestions for later
221
+ history-aggressiveness decisions — nothing this round consumes them, and advisor output
222
+ can never suppress, delay, or rewrite any reduction that would land (pinned by a
223
+ dedicated invariant test). Configure through the `presetOptions.advisor*` settings keys
224
+ (`advisorMode` `''|'host'|'direct'`, default `''`; the direct channel reuses the
225
+ estimator endpoint; `SideChannel` gained an optional overrides parameter so the
226
+ estimator's transport is shared without sharing its configuration). Observability: new
227
+ `advisor-outcome` audit records (content-free, one per phase: summary / scoring / decay)
228
+ and a read-only `GET .../advisor-report?sessionId=` HTTP route (opt-in deployment flag
229
+ `advisorReportRoute`, mirroring the review routes). Client UI is intentionally absent
230
+ this round.
231
+
232
+ ## 0.4.0 - 2026-09-20
233
+
234
+ ### Fixed
235
+
236
+ - The plugin no longer depends on the routed model id: every planning gate now decides on
237
+ the character basis (Unicode code points via `characterPressure` / `pressureCost`) instead
238
+ of exact tokenizer counts, so a route without a bundled tokenizer (the live
239
+ `deepseek-flash`) lands rewrites again instead of silently skipping. Token thresholds keep
240
+ their names and values (converted at the documented 4.0 chars/token convention, frozen
241
+ profile baseline untouched); token figures become telemetry, labelled honestly by the new
242
+ `measurementBasis` field on rewrite audit records (`exact-tokenizer` vs `characters`,
243
+ with `tokenizerId: 'characters'` / `tokenizerRevision: 'chars-per-token-4.0'` when derived).
244
+ Rollback: `git revert 7a1972a` restores the exact-tokenizer gates as a single unit; confirm
245
+ no later change re-introduced a model-id split that relies on this commit first.
246
+
247
+ ### Added
248
+
249
+ - Batch-level benefit pricing (R1): a review pass is priced as ONE merged mutation — the
250
+ tail KV-cache refill penalty is paid once per batch instead of per candidate, so real
251
+ batches (5×50k with a 64k tail) reach the auto band instead of all dropping.
252
+ - Original-event line mapping (R9a): terminal normalization returns folded lines that each
253
+ carry their 1-based original-event line number; `retrieve` reads raw events, so printed
254
+ ranges resolve to the right lines.
255
+ - Document skeleton and universal prose keep (R8/R8b): structured documents keep headings,
256
+ section first/last lines, list starts and table headers; every other non-code text keeps
257
+ head AND tail with an R9 line-range marker (prose was previously head-only truncated).
258
+ - Two-tier search folding (R10, fixes D8): a lossless per-file L1 locator plus a
259
+ water-filled L2 content quota.
260
+ - Non-adjacent frequency folding (R11): separated exact repeats (up to 8.37% of large
261
+ results) fold to first occurrence plus one counted marker.
262
+ - Long-string placeholders (R12): base64/hex/UUID blobs become length summaries with a
263
+ 16-char recognition prefix.
264
+ - Two-stage HTML reduction (R13, fixes D9): `html-slim` then `html-skeleton`, line-aligned
265
+ so original line numbers survive.
266
+ - R9b anchors: contiguous masks cite original line ranges, scatter masks report
267
+ `lines 1-N scanned, K kept`, and every retrieve hint carries a pasteable
268
+ `{"ref":…,"start_line":N,"max_lines":80}`.
269
+ - Document census: omitted-document summaries list section headings instead of a constant
270
+ `0 error, 0 warn, N info` histogram.
271
+
272
+ ## 0.3.1 - 2026-09-18
273
+
274
+ ### Changed
275
+
276
+ - The runtime package is merged into the selector package: one install brings the whole
277
+ stack, the repository root is the install surface (`name`, `main`, `types`, `exports` with
278
+ `./pruner` and `./invariant`, `dependencies`, `dsh`), and the toolchain, scripts and CI were
279
+ swept to the single package. The verified estimator-catalog registration (dual prefix, guarded
280
+ two-channel activation, per-request service resolution, visible lifecycle lines) was replayed
281
+ onto this line with a host-side guard; the settings schema that `ab2175a` had downgraded to
282
+ `z.any()` is restored, so the daily Custom defaults are published again.
283
+ - Adapt to the official DeepSeek Harness `v0.1.5-rc.2` on this branch. All `@deepseek-ai/dsh-*` dev dependencies and the pinned e2e host set move from `0.1.1-rc.2` to `0.1.5-rc.2` (cordis `4.0.2`, schemastery `3.18.2`), including the new split packages (`dsh-session-projection`, `dsh-session-persistence`, `dsh-atomic-write`, `dsh-home-paths`, `dsh-sandbox`, and related) and the `dsh-client-store` client stack.
284
+ - Surface replace operations now use the v3 `startSeq`/`endSeq` shape with branded `SessionSeq` values; `compaction/prune` manifests keep the durable `start`/`end` fields. Events are resolved from surface nodes by seq lookup instead of array indexing.
285
+ - The client bundle no longer imports the removed `@deepseek-ai/dsh-client-runtime`: settings types now come from `@deepseek-ai/dsh-client-ui-settings` and the session hooks merge from `@deepseek-ai/dsh-client-ui-session`. `engines.dsh >=0.1.5-alpha.1 <0.2.0-0` is declared in both package manifests and `dsh.plugin.json`.
286
+ - Harness 0.1.5 no longer exposes the session `agentPreset` to the browser, so the client can no longer detect Minimal-only sessions; the selector stays selectable and the old unavailable banner is unreachable.
287
+ - Test batteries updated for 0.1.5 semantics: cordis plugin starts require `.await()`, the Token Meter requires a mounted `SessionProjectionRegistry`, assistant events carry `stream: []`, and settings namespaces are plain strings.
288
+
289
+ ### Fixed
290
+
291
+ - The estimator card no longer demands an API key on the Harness host channel. Selecting the host channel shows the live provider/model dropdowns, names the route that would actually run (explicit override, else the session default), and renders neither a key field nor a second manual model input: the base URL, the model text field, and the write-only key belong to the direct endpoint channel alone.
292
+ - `presetOptions` writes are path-addressed. Writing the whole section replaced it, so touching any second estimator field (a provider, a model, an endpoint) deleted `estimatorMode` and every sibling override — silently switching the estimator back off while the panel still reported a successful save. Each field now writes only itself, `undefined` clears exactly the field it names, and the confirmation read validates the same field set instead of the mode alone.
293
+ - New coverage: `packages/selector/tests/preset-options-write.client.spec.ts` (path-scoped writes, sibling preservation, explicit clears, no-op patches, uncommitted-write reporting) and `packages/selector/tests/estimator-channel.client.spec.tsx` (per-channel fields, catalog dropdowns, manual fallback).
294
+
295
+
296
+ ### Added
297
+
298
+ - New `tokenpilot-inspired` profile: a TokenPilot-paper-inspired capability matrix layered on the Balanced thresholds, selected explicitly from the settings UI; every pre-existing profile keeps a byte-identical resolved policy (enforced by a captured-baseline golden test).
299
+ - Byte-identical repeated tool-result dedup: an oversized repeat is replaced with a pointer to the first occurrence's append-only original event (`dedupe-pointer`), with a per-session SHA-256 index (2,048-entry insertion-order eviction, hash+seq metadata only).
300
+ - No-net-savings guard: replacements whose text is not smaller than the original are rejected even when the exact tokenizer reports a token saving.
301
+ - Recovery exemption: recovery-tool output is permanently exempt from every reduction pass via a unified per-session exemption set, preventing compress-restore oscillation.
302
+ - Auto Compact summary locator: after `compaction/end`, the landed summary checkpoint gains an Exact Sources block (shadowed seq range, spill files, touched files) so summarized-away details stay recoverable; skipped when it would locate nothing concrete.
303
+ - Read-state semantics: a historical read whose file was later mutated is `superseded` and takes the small whole-result placeholder; optional error/warn/info clustering of omitted lines is appended to historical placeholders.
304
+ - Optional residual-utility estimator (three channels: off / Harness host model / direct OpenAI-compatible endpoint) with per-session exponential backoff, strict timeout, advisory-only verdicts consumed by the next pressure pass, and numeric-only `estimator-outcome` audits. The estimator card appears only while the new profile is selected; the API key is write-only in settings and never enters the frozen policy, audits, or logs.
305
+ - New audit records: `summary-locator` and `estimator-outcome`; the rewrite record covers dedup via the `dedupe-pointer` reducer. Audit field allowlists are unchanged.
306
+ - Simplified Chinese and English copy for the new profile and estimator card; unit and golden coverage under `packages/runtime/tests/tokenpilot/`.
307
+
308
+ - Orthogonal code-skeleton compression gate (`codeSkeleton.enabled`, default off): the first exposure of an oversized fresh source-code tool result can keep an imports-and-declarations skeleton with bodies elided and error lines preserved, falling back to the original head pruning. The gate is independent of every profile and gated on exact tokenizer measurement.
309
+ - Settings-UI toggle for the gate in the selector settings section, with Simplified Chinese and English copy.
310
+ - Browser/runtime decode parity for the new section, confirm-on-write contract tests for `saveCodeSkeleton`, and a full-document parity matrix extension.
311
+
312
+ ### Changed
313
+
314
+ - Added an ESLint flat-config baseline (`pnpm lint`, enforced in CI) and a `pnpm test:watch` TDD loop; removed dead imports and hardened two error paths surfaced by the lint baseline.
315
+ - This repository is now maintained as an improved fork of `WilliamShi666/dsh-context-compression-selector`; documentation ships in English, Simplified Chinese, Japanese, and Korean.
316
+
317
+ ## 0.1.0 - 2026-09-03
318
+
319
+ ### Added
320
+
321
+ - Stable release of DeepSeek V4 Flash Vision tokenizer integration for `deepseek-v4-flash-vision-exp`, including exact text counting and bounded image-token estimates.
322
+ - User-configurable model-driven Auto Compact threshold in the selector settings section.
323
+ - Auto Compact threshold linkage for each standard profile's History / micro-compact watermarks and related compression parameters.
324
+
325
+ ### Changed
326
+
327
+ - The threshold editor now uses one direct numeric input; the slider and fixed quick-value buttons were removed.
328
+ - Runtime session-event access supports both the established Harness `events` accessor and the newer `snapshotEvents()` public API.
329
+
330
+ ## 0.1.0-beta.4 - 2026-09-02
331
+
332
+ ### Fixed
333
+
334
+ - Support the official DeepSeek Harness `dsh-v0.1.2-alpha.5` public API while retaining compatibility with the existing `0.1.1-rc.2` peer range. The plugin now owns the two small immutable-value helpers that the newer Harness no longer exports, and uses the same public `context-compression` namespace literal accepted by both Settings implementations. No Harness core code is modified.
335
+
336
+ ## 0.1.0-beta.3 - 2026-09-01
337
+
338
+ ### Scope
339
+
340
+ This is a staged release. Exact **text-class** token counting for `deepseek-v4-flash-vision-exp`, best-effort bounded **vision-class image** estimates, and the Auto Compact threshold/UI/audit work are delivered. Exact image measurement remains **BLOCKED upstream**: the current measurement seam exposes neither the adapter's projected request-image dimensions nor the absolute serialized position, so estimates cannot be promoted to `exact-tokenizer`.
341
+
342
+ ### Added
343
+
344
+ - DeepSeek V4 Flash Vision support for `deepseek-v4-flash-vision-exp` via a separately bundled official tokenizer pinned at `deepseek-ai/DeepSeek-V4-Flash-Vision-Exp` revision `6821d6ad3681a4b137b066b76094fa82ebd0a380`. Text, reasoning, tool-call arguments, and pure-text tool results are counted exactly; image-bearing tool-result candidates stay fail-open.
345
+ - Vision image-token arithmetic ported line-by-line from the official `inference/image_processor.py` (patch size 14, downsample 3, 384-token cap, min pixels 147456, 8:1 aspect clamp, and position-dependent alignment padding), validated against golden fixtures generated by executing the official Python implementation. Valid intrinsic dimensions now produce `tokenizer-estimate` at the midpoint of all four alignment residues with a 384-token per-image upper bound; malformed or unevaluable dimensions use a documented 256-token fallback. Mixed text/image surfaces aggregate exact text and estimated images without promoting them to exact.
346
+ - `autoCompact.thresholdPercent` setting (default 80, integer 50–90, step 1) with one shared validation contract across the settings UI, the persisted schema, and the runtime resolver. The editor lives inside the context-compression selector settings section.
347
+ - Standard-profile History linkage to the Auto Compact watermark: `A = floor(C × a)` rescales the History trigger, minimum reclaim, and recent-token tail; `D = floor(A × 0.875)` replaces the fixed 0.7 capacity-pressure ratio as the micro-compact last-chance gate; one batch must justify its cache break by pulling the complete request back below the deadline. Defaults at 80% reproduce the previous numbers exactly.
348
+ - The preset overlay writes the saved threshold into the generated `compaction-basic` composition as `thresholdRatio` (with `retainRatio` pinned at 0.16) and, from the same read, into the plugin runtime's deployment config as `autoCompactThresholdPercent`, so one standing generation never runs Auto Compact and micro compact on two different thresholds. Any generation-identity change — threshold, source, or module paths, including equal-length ones — produces a new standing composition generation. Deterministic identity-derived stamps use an 8-hex whole-second window; equal-prefix identities can collide in that first window on a coarse filesystem, so the overlay observes the staging file's real `mtimeMs+size` key and escalates to later hash windows before the atomic rename. Content, permissions, and the final unique stamp are complete before publication; already-running sessions keep their frozen policy.
349
+ - `policy-resolved` audits now record the Auto Compact coordination facts (threshold percent, `A`, `D`, parameter source — including `deployment-override`/`mixed` when deployment config replaces linked History watermarks), the routed provider/model, and the bundled tokenizer identity.
350
+ - Persisted settings reject present-but-invalid sections (`profile: null`, `custom: null`, own-property `undefined`) before any schema default can absorb them; a malformed stored document freezes the session losslessly (`profile: off`, audited as `settingsInvalidFallback: lossless-off`) instead of silently enabling the lossy Balanced default. The browser decoder applies the same rule and canonicalizes legacy Custom v1/v2 documents to the same v3 document the runtime resolver produces.
351
+ - The History planner returns a discriminated outcome, and `component-evaluation` audits distinguish the full skip taxonomy: `below-profile-trigger`, `below-micro-deadline`, `exact-tokenizer-unavailable`, `no-safe-candidates` (only recovery-tool output or already-cleared results), `protected-working-set` (everything inside the protected tail), `insufficient-reclaim` and `cannot-reach-deadline-target` (with the reached/required token numbers), `adaptive-cost-rejected`, and `recovery-tool-unavailable`.
352
+
353
+ ### Known limitations
354
+
355
+ - Images never claim exact counts. The official expansion depends on the absolute prompt position (system prompt, chat-template framing, adapter image handles) and on the adapter's final request-image projection (including per-route `imagePixelBudget`/`imageDetail` overrides and byte-cap reprojection), none of which is exposed through the current measurement seam. Intrinsic/default estimates may therefore differ materially from provider accounting. Upstream capability requests remain projected request-image dimensions and the absolute serialized position exposed to token-meter extensions.
356
+ - History skips the whole batch whenever any tool-result candidate lacks an exact count, including image-bearing candidates, even though sibling text candidates are individually exact.
357
+ - Custom remains manual token mode; its History parameters do not follow the Auto Compact watermark.
358
+ - A vision token breakdown UI is not shipped; image estimates and the intrinsic alignment diagnostic are available on the measured token view, while lossy rewrite proofs still require exact counts.
359
+
360
+ ### Deferred
361
+
362
+ - Audit `modality` field and the tokenizer artifact SHA-256 inside audit records (the audits already carry the routed provider/model and tokenizer identity).
363
+ - Publishing the (now complete) runtime skip-reason taxonomy as a user-facing documentation table.
364
+ - Custom-profile display of the A/D watermarks and an above-D warning; Custom remains fully manual.
365
+ - Vision token breakdown UI and promotion of image estimates to exact measurement.
366
+
367
+ ## 0.1.0-beta.2 - 2026-08-28
368
+
369
+ ### Fixed
370
+
371
+ - Resolve the official DeepSeek V4 Flash tokenizer route so Fresh and Aggregate can evaluate tool results for the supported V4 models.
372
+ - Run Cache Strict History at the real request boundary once its configured capacity-pressure condition is met; trigger the capacity condition at 70% routed-context utilization.
373
+ - Disable Harness-native head/middle/tail tool-result pruning whenever a selector profile is active, leaving the selector as the sole tool-result compactor.
374
+
375
+ ### Changed
376
+
377
+ - Protect the newest 10 agent tool calls and a 64,000-token tool-result tail window before History/microcompact rewrites older results.
378
+
379
+ ## 0.1.0-beta.1 - 2026-08-27
380
+
381
+ ### Added
382
+
383
+ - One-install DeepSeek Harness Product Bundle backed by a separate exact-version runtime package.
384
+ - Web profile selector with preset-stable settings and an explicit built-in Minimal exception.
385
+ - Fresh, Aggregate, routine/capacity-aware History, Native tool-result pruning, and default-off Custom TailTrim.
386
+ - Standard-event TailTrim protocol using `compaction/prune` plus recoverable `user/message` replacement.
387
+ - Plugin-owned `context_compression_retrieve` recovery tool.
388
+ - Structured, content-free policy, evaluation, rewrite, failure, and Native auto-compact audit records.
389
+ - Pinned official DeepSeek V4 tokenizer assets with runtime SHA-256 validation and upstream license.
390
+ - Public-API component E2E, preset/Minimal, and parent/fork/spawn cache-prefix regression tests.
391
+
392
+ ### Compatibility
393
+
394
+ - Verified against DeepSeek Harness `dsh-v0.1.1-rc.2` public packages.
395
+ - Exact tokenizer mapping is currently limited to `deepseek-v4-flash` and `deepseek-v4-pro`.
396
+
397
+ ### Known limitations
398
+
399
+ - Adaptive ordinary History fails closed when public request-level route/cache evidence is incomplete; capacity pressure remains a separate safety override.
400
+ - Cache-prefix tests prove native fork inheritance and identical serialized prefixes, not a provider-specific cache allocation or a guaranteed DeepSeek cache hit.
401
+ - Settings snapshots and first-exposure decisions are process-local to the mounted runtime.