dsh-context-compression-improved 0.7.0-beta.2 → 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 (46) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/package.json +17 -18
  3. package/packages/selector/dsh.plugin.json +1 -1
  4. package/packages/selector/lib/client.d.ts +44 -0
  5. package/packages/selector/lib/client.js +1007 -13
  6. package/packages/selector/lib/{intent-gate.js → config.js} +799 -136
  7. package/packages/selector/lib/index.d.ts +13 -1
  8. package/packages/selector/lib/index.js +204 -3
  9. package/packages/selector/lib/profiles.d.ts +6 -0
  10. package/packages/selector/lib/pruner.d.ts +6 -0
  11. package/packages/selector/lib/pruner.js +90 -258
  12. package/packages/selector/lib/style.css +42 -0
  13. package/packages/selector/src/client/CompressionProfileControls.tsx +293 -226
  14. package/packages/selector/src/client/CompressionProfileSelector.module.css +199 -170
  15. package/packages/selector/src/client/CompressionProfileSelector.tsx +85 -83
  16. package/packages/selector/src/client/decode.ts +5 -1
  17. package/packages/selector/src/client/index.ts +307 -243
  18. package/packages/selector/src/client/locales/de.ts +43 -0
  19. package/packages/selector/src/client/locales/es.ts +43 -0
  20. package/packages/selector/src/client/locales/fr.ts +43 -0
  21. package/packages/selector/src/client/locales/it.ts +43 -0
  22. package/packages/selector/src/client/locales/ja.ts +43 -0
  23. package/packages/selector/src/client/locales/ko.ts +43 -0
  24. package/packages/selector/src/client/locales/ru.ts +43 -0
  25. package/packages/selector/src/client/locales.ts +282 -196
  26. package/packages/selector/src/client/monitor-fab.ts +336 -0
  27. package/packages/selector/src/client/savings-card.tsx +150 -0
  28. package/packages/selector/src/client/settings-section.tsx +140 -124
  29. package/packages/selector/src/index.ts +207 -5
  30. package/packages/selector/src/profiles.ts +17 -0
  31. package/packages/selector/src/pruner.ts +96 -2
  32. package/packages/selector/src/runtime/config.ts +26 -1
  33. package/packages/selector/src/runtime/monitor.ts +235 -0
  34. package/packages/selector/src/runtime/retrieve.ts +479 -457
  35. package/packages/selector/src/runtime/savings.ts +337 -0
  36. package/packages/selector/src/runtime/types.ts +7 -0
  37. package/packages/selector/tests/code-skeleton.client.spec.ts +2 -2
  38. package/packages/selector/tests/custom-contract.client.spec.ts +2 -2
  39. package/packages/selector/tests/estimator-channel.client.spec.tsx +2 -0
  40. package/packages/selector/tests/estimator-route-registration.host.spec.ts +194 -188
  41. package/packages/selector/tests/monitor-fab.client.spec.ts +138 -0
  42. package/packages/selector/tests/runtime/monitor.spec.ts +301 -0
  43. package/packages/selector/tests/runtime/savings.spec.ts +120 -0
  44. package/packages/selector/tests/settings-seat.client.spec.ts +177 -165
  45. package/scripts/packed-install-e2e.mjs +1 -1
  46. package/scripts/verify-release.mjs +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes use this file. The project follows semantic versioning after `0.1.0`.
4
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
+
5
14
  ## 0.7.0-beta.2 - 2026-10-01
6
15
 
7
16
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-context-compression-improved",
3
- "version": "0.7.0-beta.2",
3
+ "version": "0.7.0",
4
4
  "publishConfig": {
5
5
  "tag": "dsh-0.1.7"
6
6
  },
@@ -50,26 +50,10 @@
50
50
  "type": "git",
51
51
  "url": "git+https://github.com/drscrewdriver/dsh-context-compression-improved.git"
52
52
  },
53
- "packageManager": "pnpm@11.7.0",
54
53
  "engines": {
55
54
  "node": "^22.19.0 || >=24.0.0",
56
55
  "dsh": ">=0.1.7-rc.1 <0.1.8-0"
57
56
  },
58
- "scripts": {
59
- "build": "pnpm -r --if-present run bundle",
60
- "typecheck": "pnpm --filter dsh-context-compression-improved run bundle && pnpm --filter dsh-context-compression-improved run typecheck && pnpm run typecheck:tests",
61
- "typecheck:tests": "tsc --noEmit -p tsconfig.tests.json",
62
- "lint": "eslint packages scripts eslint.config.js",
63
- "lint:fix": "eslint packages scripts eslint.config.js --fix",
64
- "test": "vitest run",
65
- "test:coverage": "vitest run --coverage",
66
- "test:watch": "vitest",
67
- "test:built": "vitest run --config vitest.built.config.ts",
68
- "test:e2e:packed": "node scripts/packed-install-e2e.mjs",
69
- "test:unit": "vitest run",
70
- "verify:release": "node scripts/verify-release.mjs",
71
- "pack:dry-run": "pnpm -r --if-present run pack:dry-run"
72
- },
73
57
  "peerDependencies": {
74
58
  "@deepseek-ai/dsh-client-locale": ">=0.1.7-rc.1 <0.1.8-0",
75
59
  "@deepseek-ai/dsh-client-ui-primitives": ">=0.1.7-rc.1 <0.1.8-0",
@@ -161,5 +145,20 @@
161
145
  "typescript": "^6.0.3",
162
146
  "typescript-eslint": "^8.69.0",
163
147
  "vitest": "^4.1.8"
148
+ },
149
+ "scripts": {
150
+ "build": "pnpm -r --if-present run bundle",
151
+ "typecheck": "pnpm --filter dsh-context-compression-improved run bundle && pnpm --filter dsh-context-compression-improved run typecheck && pnpm run typecheck:tests",
152
+ "typecheck:tests": "tsc --noEmit -p tsconfig.tests.json",
153
+ "lint": "eslint packages scripts eslint.config.js",
154
+ "lint:fix": "eslint packages scripts eslint.config.js --fix",
155
+ "test": "vitest run",
156
+ "test:coverage": "vitest run --coverage",
157
+ "test:watch": "vitest",
158
+ "test:built": "vitest run --config vitest.built.config.ts",
159
+ "test:e2e:packed": "node scripts/packed-install-e2e.mjs",
160
+ "test:unit": "vitest run",
161
+ "verify:release": "node scripts/verify-release.mjs",
162
+ "pack:dry-run": "pnpm -r --if-present run pack:dry-run"
164
163
  }
165
- }
164
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-context-compression-improved",
3
- "version": "0.7.0-beta.2",
3
+ "version": "0.7.0",
4
4
  "main": "./lib/index.js",
5
5
  "description": "Auditable tool-result context-compression selector with code-skeleton gate for DeepSeek Harness",
6
6
  "engines": {
@@ -71,6 +71,34 @@ declare const zh: {
71
71
  'codeSkeleton.enabled': string;
72
72
  'codeSkeleton.enabled.on': string;
73
73
  'codeSkeleton.enabled.off': string;
74
+ 'intentSummary.title': string;
75
+ 'intentSummary.description': string;
76
+ 'intentSummary.enabled': string;
77
+ 'intentSummary.enabled.on': string;
78
+ 'intentSummary.enabled.off': string;
79
+ 'monitor.fab.title': string;
80
+ 'monitor.panel.title': string;
81
+ 'monitor.panel.net': string;
82
+ 'monitor.panel.gross': string;
83
+ 'monitor.panel.offsets': string;
84
+ 'monitor.panel.context': string;
85
+ 'monitor.panel.suggest': string;
86
+ 'monitor.panel.cacheHit': string;
87
+ 'monitor.panel.cost': string;
88
+ 'monitor.panel.intent': string;
89
+ 'monitor.panel.overrideHint': string;
90
+ 'monitor.panel.resume': string;
91
+ 'monitor.panel.disable': string;
92
+ 'monitor.panel.stateOn': string;
93
+ 'monitor.panel.stateOff': string;
94
+ 'monitor.panel.gateUnknown': string;
95
+ 'monitor.panel.lastFold': string;
96
+ 'monitor.panel.stale': string;
97
+ 'monitorPanel.title': string;
98
+ 'monitorPanel.description': string;
99
+ 'monitorPanel.enabled': string;
100
+ 'monitorPanel.enabled.on': string;
101
+ 'monitorPanel.enabled.off': string;
74
102
  'custom.title': string;
75
103
  'custom.settingsHint': string;
76
104
  'custom.sessionScope': string;
@@ -102,6 +130,20 @@ declare const zh: {
102
130
  'custom.save': string;
103
131
  'custom.reset': string;
104
132
  'custom.invalid': string;
133
+ 'savings.title': string;
134
+ 'savings.netExact': string;
135
+ 'savings.netEstimated': string;
136
+ 'savings.gross': string;
137
+ 'savings.offsets': string;
138
+ 'savings.empty': string;
139
+ 'savings.basisExact': string;
140
+ 'savings.basisEstimated': string;
141
+ 'savings.basisNote': string;
142
+ 'savings.requests': string;
143
+ 'savings.cacheHit': string;
144
+ 'savings.actualCost': string;
145
+ 'savings.savedMoney': string;
146
+ 'savings.perSession': string;
105
147
  };
106
148
  /** Locale keys that every context-compression selector dictionary must provide. */
107
149
  type ContextCompressionLocaleKey = keyof typeof zh;
@@ -145,6 +187,8 @@ interface CompressionSelectorInjected {
145
187
  resetCustom: () => Promise<void>;
146
188
  saveAutoCompact: (thresholdPercent: number) => Promise<void>;
147
189
  saveCodeSkeleton: (enabled: boolean) => Promise<void>;
190
+ saveIntentSummary: (enabled: boolean) => Promise<void>;
191
+ saveMonitorPanel: (enabled: boolean) => Promise<void>;
148
192
  /** Patch of `presetOptions` members; an explicit `undefined` clears that field. */
149
193
  savePresetOptions: (options: PresetOptionsPatch) => Promise<void>;
150
194
  }