dsh-context-compression-improved 0.5.7 → 0.5.8
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/CHANGELOG.md +9 -0
- package/package.json +16 -17
- package/packages/selector/dsh.plugin.json +1 -1
- package/packages/selector/lib/client.d.ts +59 -0
- package/packages/selector/lib/client.js +1012 -17
- package/packages/selector/lib/{advisor-state.js → config.js} +816 -65
- package/packages/selector/lib/index.d.ts +13 -1
- package/packages/selector/lib/index.js +295 -3
- package/packages/selector/lib/pruner.d.ts +65 -0
- package/packages/selector/lib/pruner.js +497 -262
- package/packages/selector/lib/style.css +42 -0
- package/packages/selector/src/client/CompressionProfileControls.tsx +67 -0
- package/packages/selector/src/client/CompressionProfileSelector.module.css +29 -0
- package/packages/selector/src/client/CompressionProfileSelector.tsx +2 -0
- package/packages/selector/src/client/decode.ts +10 -2
- package/packages/selector/src/client/index.ts +62 -0
- package/packages/selector/src/client/locales/de.ts +43 -0
- package/packages/selector/src/client/locales/es.ts +43 -0
- package/packages/selector/src/client/locales/fr.ts +43 -0
- package/packages/selector/src/client/locales/it.ts +43 -0
- package/packages/selector/src/client/locales/ja.ts +43 -0
- package/packages/selector/src/client/locales/ko.ts +43 -0
- package/packages/selector/src/client/locales/ru.ts +43 -0
- package/packages/selector/src/client/locales.ts +86 -0
- package/packages/selector/src/client/monitor-fab.ts +336 -0
- package/packages/selector/src/client/savings-card.tsx +150 -0
- package/packages/selector/src/client/settings-section.tsx +18 -2
- package/packages/selector/src/index.ts +215 -5
- package/packages/selector/src/profiles.ts +37 -0
- package/packages/selector/src/pruner/state.ts +7 -0
- package/packages/selector/src/pruner.ts +337 -3
- package/packages/selector/src/runtime/audit.ts +17 -0
- package/packages/selector/src/runtime/config.ts +52 -2
- package/packages/selector/src/runtime/monitor.ts +235 -0
- package/packages/selector/src/runtime/retrieve.ts +24 -2
- package/packages/selector/src/runtime/savings.ts +337 -0
- package/packages/selector/src/runtime/summary-command.ts +127 -0
- package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +46 -1
- package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +55 -0
- package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +53 -0
- package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -0
- package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -0
- package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -0
- package/packages/selector/src/runtime/types.ts +19 -0
- package/packages/selector/tests/auto-compact.client.spec.tsx +2 -1
- package/packages/selector/tests/code-skeleton.client.spec.ts +3 -2
- package/packages/selector/tests/custom-contract.client.spec.ts +3 -2
- package/packages/selector/tests/estimator-channel.client.spec.tsx +1 -0
- package/packages/selector/tests/estimator-route-registration.host.spec.ts +10 -4
- package/packages/selector/tests/monitor-fab.client.spec.ts +138 -0
- package/packages/selector/tests/preset-options-write.client.spec.ts +1 -0
- package/packages/selector/tests/profiles.client.spec.tsx +4 -2
- package/packages/selector/tests/runtime/audit.spec.ts +1 -0
- package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -0
- package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -0
- package/packages/selector/tests/runtime/monitor.spec.ts +301 -0
- package/packages/selector/tests/runtime/savings.spec.ts +120 -0
- package/packages/selector/tests/runtime/summary-command.spec.ts +154 -0
- package/packages/selector/tests/settings-seat.client.spec.ts +19 -7
- package/scripts/packed-install-e2e.mjs +1 -1
- package/scripts/verify-release.mjs +2 -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.5.8 - 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.5.7 - 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.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org",
|
|
6
6
|
"access": "public",
|
|
@@ -52,25 +52,10 @@
|
|
|
52
52
|
"type": "git",
|
|
53
53
|
"url": "git+https://github.com/drscrewdriver/dsh-context-compression-improved.git"
|
|
54
54
|
},
|
|
55
|
-
"packageManager": "pnpm@11.7.0",
|
|
56
55
|
"engines": {
|
|
57
56
|
"node": "^22.19.0 || >=24.0.0",
|
|
58
57
|
"dsh": ">=0.1.5-rc.1 <0.1.6-0"
|
|
59
58
|
},
|
|
60
|
-
"scripts": {
|
|
61
|
-
"build": "pnpm -r --if-present run bundle",
|
|
62
|
-
"typecheck": "pnpm --filter dsh-context-compression-improved run bundle && pnpm --filter dsh-context-compression-improved run typecheck && pnpm run typecheck:tests",
|
|
63
|
-
"typecheck:tests": "tsc --noEmit -p tsconfig.tests.json",
|
|
64
|
-
"lint": "eslint packages scripts eslint.config.js",
|
|
65
|
-
"lint:fix": "eslint packages scripts eslint.config.js --fix",
|
|
66
|
-
"test": "vitest run",
|
|
67
|
-
"test:watch": "vitest",
|
|
68
|
-
"test:built": "vitest run --config vitest.built.config.ts",
|
|
69
|
-
"test:e2e:packed": "node scripts/packed-install-e2e.mjs",
|
|
70
|
-
"test:unit": "vitest run",
|
|
71
|
-
"verify:release": "node scripts/verify-release.mjs",
|
|
72
|
-
"pack:dry-run": "pnpm -r --if-present run pack:dry-run"
|
|
73
|
-
},
|
|
74
59
|
"peerDependencies": {
|
|
75
60
|
"@deepseek-ai/dsh-client-locale": ">=0.1.5-rc.1 <0.1.6-0",
|
|
76
61
|
"@deepseek-ai/dsh-client-ui-primitives": ">=0.1.5-rc.1 <0.1.6-0",
|
|
@@ -160,5 +145,19 @@
|
|
|
160
145
|
"typescript": "^6.0.3",
|
|
161
146
|
"typescript-eslint": "^8.69.0",
|
|
162
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:watch": "vitest",
|
|
157
|
+
"test:built": "vitest run --config vitest.built.config.ts",
|
|
158
|
+
"test:e2e:packed": "node scripts/packed-install-e2e.mjs",
|
|
159
|
+
"test:unit": "vitest run",
|
|
160
|
+
"verify:release": "node scripts/verify-release.mjs",
|
|
161
|
+
"pack:dry-run": "pnpm -r --if-present run pack:dry-run"
|
|
163
162
|
}
|
|
164
|
-
}
|
|
163
|
+
}
|
|
@@ -72,6 +72,17 @@ interface AutoCompactSettings {
|
|
|
72
72
|
interface CodeSkeletonSettings {
|
|
73
73
|
enabled: boolean;
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Orthogonal turn-tail intent-summary gate, mirrored browser-safe from the
|
|
77
|
+
* runtime: independent of every profile, default off.
|
|
78
|
+
*/
|
|
79
|
+
interface IntentSummarySettings {
|
|
80
|
+
enabled: boolean;
|
|
81
|
+
}
|
|
82
|
+
/** Floating compression-monitor panel (FAB); visibility switch. */
|
|
83
|
+
interface MonitorPanelSettings {
|
|
84
|
+
enabled: boolean;
|
|
85
|
+
}
|
|
75
86
|
/** Browser-safe mirror of the runtime presetOptions section. */
|
|
76
87
|
interface PresetOptionsSettings {
|
|
77
88
|
readonly dedupeToolResults?: boolean;
|
|
@@ -102,6 +113,10 @@ interface ContextCompressionSettings {
|
|
|
102
113
|
autoCompact: AutoCompactSettings;
|
|
103
114
|
/** Code-skeleton reducer gate captured independently of `profile`. */
|
|
104
115
|
codeSkeleton: CodeSkeletonSettings;
|
|
116
|
+
/** Turn-tail intent-summary gate captured independently of `profile`. */
|
|
117
|
+
intentSummary: IntentSummarySettings;
|
|
118
|
+
/** Floating compression-monitor panel (FAB); absent inherits hidden. */
|
|
119
|
+
monitorPanel?: MonitorPanelSettings;
|
|
105
120
|
/** Optional tokenpilot-inspired sub-capability overrides (presence-validated only). */
|
|
106
121
|
presetOptions?: PresetOptionsSettings;
|
|
107
122
|
}
|
|
@@ -175,6 +190,34 @@ declare const zh: {
|
|
|
175
190
|
'codeSkeleton.enabled': string;
|
|
176
191
|
'codeSkeleton.enabled.on': string;
|
|
177
192
|
'codeSkeleton.enabled.off': string;
|
|
193
|
+
'intentSummary.title': string;
|
|
194
|
+
'intentSummary.description': string;
|
|
195
|
+
'intentSummary.enabled': string;
|
|
196
|
+
'intentSummary.enabled.on': string;
|
|
197
|
+
'intentSummary.enabled.off': string;
|
|
198
|
+
'monitor.fab.title': string;
|
|
199
|
+
'monitor.panel.title': string;
|
|
200
|
+
'monitor.panel.net': string;
|
|
201
|
+
'monitor.panel.gross': string;
|
|
202
|
+
'monitor.panel.offsets': string;
|
|
203
|
+
'monitor.panel.context': string;
|
|
204
|
+
'monitor.panel.suggest': string;
|
|
205
|
+
'monitor.panel.cacheHit': string;
|
|
206
|
+
'monitor.panel.cost': string;
|
|
207
|
+
'monitor.panel.intent': string;
|
|
208
|
+
'monitor.panel.overrideHint': string;
|
|
209
|
+
'monitor.panel.resume': string;
|
|
210
|
+
'monitor.panel.disable': string;
|
|
211
|
+
'monitor.panel.stateOn': string;
|
|
212
|
+
'monitor.panel.stateOff': string;
|
|
213
|
+
'monitor.panel.gateUnknown': string;
|
|
214
|
+
'monitor.panel.lastFold': string;
|
|
215
|
+
'monitor.panel.stale': string;
|
|
216
|
+
'monitorPanel.title': string;
|
|
217
|
+
'monitorPanel.description': string;
|
|
218
|
+
'monitorPanel.enabled': string;
|
|
219
|
+
'monitorPanel.enabled.on': string;
|
|
220
|
+
'monitorPanel.enabled.off': string;
|
|
178
221
|
'custom.title': string;
|
|
179
222
|
'custom.settingsHint': string;
|
|
180
223
|
'custom.sessionScope': string;
|
|
@@ -206,6 +249,20 @@ declare const zh: {
|
|
|
206
249
|
'custom.save': string;
|
|
207
250
|
'custom.reset': string;
|
|
208
251
|
'custom.invalid': string;
|
|
252
|
+
'savings.title': string;
|
|
253
|
+
'savings.netExact': string;
|
|
254
|
+
'savings.netEstimated': string;
|
|
255
|
+
'savings.gross': string;
|
|
256
|
+
'savings.offsets': string;
|
|
257
|
+
'savings.empty': string;
|
|
258
|
+
'savings.basisExact': string;
|
|
259
|
+
'savings.basisEstimated': string;
|
|
260
|
+
'savings.basisNote': string;
|
|
261
|
+
'savings.requests': string;
|
|
262
|
+
'savings.cacheHit': string;
|
|
263
|
+
'savings.actualCost': string;
|
|
264
|
+
'savings.savedMoney': string;
|
|
265
|
+
'savings.perSession': string;
|
|
209
266
|
};
|
|
210
267
|
/** Locale keys that every context-compression selector dictionary must provide. */
|
|
211
268
|
type ContextCompressionLocaleKey = keyof typeof zh;
|
|
@@ -220,6 +277,8 @@ interface CompressionSelectorInjected {
|
|
|
220
277
|
resetCustom: () => Promise<void>;
|
|
221
278
|
saveAutoCompact: (thresholdPercent: number) => Promise<void>;
|
|
222
279
|
saveCodeSkeleton: (enabled: boolean) => Promise<void>;
|
|
280
|
+
saveIntentSummary: (enabled: boolean) => Promise<void>;
|
|
281
|
+
saveMonitorPanel: (enabled: boolean) => Promise<void>;
|
|
223
282
|
/** Patch of `presetOptions` members; an explicit `undefined` clears that field. */
|
|
224
283
|
savePresetOptions: (options: PresetOptionsPatch) => Promise<void>;
|
|
225
284
|
}
|