dsh-context-compression-improved 0.11.0 → 0.11.2

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 (310) hide show
  1. package/README.md +15 -110
  2. package/README.zh.md +14 -104
  3. package/THIRD_PARTY_NOTICES.md +25 -7
  4. package/{packages/selector/dsh.plugin.json → dsh.plugin.json} +2 -2
  5. package/{packages/selector/lib → lib}/index.js +101 -0
  6. package/package.json +129 -116
  7. package/screenshots.json +3 -6
  8. package/.agents/plans/improve/checklist.md +0 -32
  9. package/.agents/plans/improve/findings.md +0 -102
  10. package/.agents/plans/improve/spec.md +0 -53
  11. package/.agents/plans/improve/tasks.md +0 -70
  12. package/.gitattributes +0 -2
  13. package/.githooks/pre-push +0 -37
  14. package/.github/workflows/ci.yml +0 -47
  15. package/CHANGELOG.de.md +0 -580
  16. package/CHANGELOG.es.md +0 -588
  17. package/CHANGELOG.fr.md +0 -576
  18. package/CHANGELOG.it.md +0 -577
  19. package/CHANGELOG.ja.md +0 -261
  20. package/CHANGELOG.ko.md +0 -254
  21. package/CHANGELOG.md +0 -557
  22. package/CHANGELOG.ru.md +0 -554
  23. package/CHANGELOG.zh.md +0 -247
  24. package/CONTRIBUTING.md +0 -22
  25. package/README.de.md +0 -96
  26. package/README.es.md +0 -96
  27. package/README.fr.md +0 -96
  28. package/README.it.md +0 -96
  29. package/README.ja.md +0 -102
  30. package/README.ko.md +0 -102
  31. package/README.ru.md +0 -96
  32. package/SECURITY.md +0 -18
  33. package/assets/board.png +0 -0
  34. package/assets/context.png +0 -0
  35. package/docs/assets/context-compression-selector-profiles.jpg +0 -0
  36. package/docs/assets/context-compression-selector-settings.png +0 -0
  37. package/docs/compat-0.1.5-report.md +0 -77
  38. package/docs/installation.de.md +0 -104
  39. package/docs/installation.es.md +0 -104
  40. package/docs/installation.fr.md +0 -104
  41. package/docs/installation.it.md +0 -104
  42. package/docs/installation.ja.md +0 -78
  43. package/docs/installation.ko.md +0 -78
  44. package/docs/installation.md +0 -103
  45. package/docs/installation.ru.md +0 -104
  46. package/docs/installation.zh.md +0 -100
  47. package/docs/repair-log.md +0 -657
  48. package/docs/shallow-teaching-preset-template.md +0 -46
  49. package/eslint.config.js +0 -30
  50. package/packages/selector/LICENSE +0 -21
  51. package/packages/selector/README.md +0 -26
  52. package/packages/selector/README.zh.md +0 -24
  53. package/packages/selector/THIRD_PARTY_NOTICES.md +0 -32
  54. package/packages/selector/docs/history-tool-call-working-set-spec.md +0 -112
  55. package/packages/selector/docs/native-tool-result-selector-spec.md +0 -34
  56. package/packages/selector/docs/subagent-cache-reuse-spec.md +0 -46
  57. package/packages/selector/lib/style.css +0 -350
  58. package/packages/selector/package.json +0 -178
  59. package/packages/selector/screenshots.json +0 -3
  60. package/packages/selector/src/client/CompressionProfileControls.tsx +0 -352
  61. package/packages/selector/src/client/CompressionProfileSelector.module.css +0 -199
  62. package/packages/selector/src/client/CompressionProfileSelector.tsx +0 -89
  63. package/packages/selector/src/client/CustomPolicyEditor.tsx +0 -216
  64. package/packages/selector/src/client/EstimatorControls.tsx +0 -277
  65. package/packages/selector/src/client/bridge-scope.ts +0 -125
  66. package/packages/selector/src/client/decode.ts +0 -68
  67. package/packages/selector/src/client/fab-pos.ts +0 -71
  68. package/packages/selector/src/client/index.ts +0 -438
  69. package/packages/selector/src/client/locales/de.ts +0 -167
  70. package/packages/selector/src/client/locales/es.ts +0 -167
  71. package/packages/selector/src/client/locales/fr.ts +0 -167
  72. package/packages/selector/src/client/locales/it.ts +0 -167
  73. package/packages/selector/src/client/locales/ja.ts +0 -167
  74. package/packages/selector/src/client/locales/ko.ts +0 -167
  75. package/packages/selector/src/client/locales/ru.ts +0 -167
  76. package/packages/selector/src/client/locales.ts +0 -334
  77. package/packages/selector/src/client/monitor-fab.ts +0 -445
  78. package/packages/selector/src/client/preset-options.ts +0 -88
  79. package/packages/selector/src/client/savings-card.tsx +0 -269
  80. package/packages/selector/src/client/scope-face.ts +0 -24
  81. package/packages/selector/src/client/settings-section.tsx +0 -156
  82. package/packages/selector/src/compat/host-generation.ts +0 -96
  83. package/packages/selector/src/compat/llm-messages.ts +0 -50
  84. package/packages/selector/src/compat/settings-lease.ts +0 -108
  85. package/packages/selector/src/compat/tool-result.ts +0 -91
  86. package/packages/selector/src/css-modules.d.ts +0 -6
  87. package/packages/selector/src/deepseek-v4-tokenizer.ts +0 -205
  88. package/packages/selector/src/estimator-catalog.ts +0 -104
  89. package/packages/selector/src/index.ts +0 -890
  90. package/packages/selector/src/invariant.ts +0 -113
  91. package/packages/selector/src/preset-overlay.ts +0 -749
  92. package/packages/selector/src/profiles.ts +0 -554
  93. package/packages/selector/src/pruner/content.ts +0 -199
  94. package/packages/selector/src/pruner/session.ts +0 -97
  95. package/packages/selector/src/pruner/state.ts +0 -61
  96. package/packages/selector/src/pruner/tuning.ts +0 -23
  97. package/packages/selector/src/pruner/types.ts +0 -78
  98. package/packages/selector/src/pruner.ts +0 -3222
  99. package/packages/selector/src/runtime/adaptive-cost.ts +0 -205
  100. package/packages/selector/src/runtime/audit.ts +0 -321
  101. package/packages/selector/src/runtime/config.ts +0 -887
  102. package/packages/selector/src/runtime/custom-policy.ts +0 -300
  103. package/packages/selector/src/runtime/deepseek-official-pricing.ts +0 -298
  104. package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +0 -254
  105. package/packages/selector/src/runtime/display-prefs.ts +0 -98
  106. package/packages/selector/src/runtime/fold-router.ts +0 -143
  107. package/packages/selector/src/runtime/measurement.ts +0 -444
  108. package/packages/selector/src/runtime/monitor.ts +0 -341
  109. package/packages/selector/src/runtime/panel-command.ts +0 -213
  110. package/packages/selector/src/runtime/reducers.ts +0 -1755
  111. package/packages/selector/src/runtime/retrieve.ts +0 -505
  112. package/packages/selector/src/runtime/savings-integral.ts +0 -117
  113. package/packages/selector/src/runtime/savings-projection.ts +0 -229
  114. package/packages/selector/src/runtime/savings-verify.ts +0 -446
  115. package/packages/selector/src/runtime/savings.ts +0 -526
  116. package/packages/selector/src/runtime/sediment-card.ts +0 -126
  117. package/packages/selector/src/runtime/sediment-clock.ts +0 -87
  118. package/packages/selector/src/runtime/sediment-guard.ts +0 -136
  119. package/packages/selector/src/runtime/sediment-publish.ts +0 -144
  120. package/packages/selector/src/runtime/sediment-span.ts +0 -170
  121. package/packages/selector/src/runtime/sediment.ts +0 -209
  122. package/packages/selector/src/runtime/session-events.ts +0 -30
  123. package/packages/selector/src/runtime/session-file-decode.ts +0 -523
  124. package/packages/selector/src/runtime/shallow-tools.ts +0 -342
  125. package/packages/selector/src/runtime/stats-backfill.ts +0 -541
  126. package/packages/selector/src/runtime/stats-db.ts +0 -492
  127. package/packages/selector/src/runtime/stats-schema.ts +0 -123
  128. package/packages/selector/src/runtime/stats-sync.ts +0 -307
  129. package/packages/selector/src/runtime/summary-command.ts +0 -127
  130. package/packages/selector/src/runtime/tail-trim.ts +0 -177
  131. package/packages/selector/src/runtime/token-count.ts +0 -72
  132. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +0 -233
  133. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +0 -204
  134. package/packages/selector/src/runtime/tokenpilot/advisor.ts +0 -419
  135. package/packages/selector/src/runtime/tokenpilot/benefit.ts +0 -200
  136. package/packages/selector/src/runtime/tokenpilot/dedup.ts +0 -82
  137. package/packages/selector/src/runtime/tokenpilot/estimator.ts +0 -151
  138. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +0 -53
  139. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +0 -65
  140. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +0 -125
  141. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +0 -37
  142. package/packages/selector/src/runtime/tokenpilot/locator.ts +0 -129
  143. package/packages/selector/src/runtime/tokenpilot/read-state.ts +0 -98
  144. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +0 -303
  145. package/packages/selector/src/runtime/tool-names.ts +0 -42
  146. package/packages/selector/src/runtime/toolclass.ts +0 -103
  147. package/packages/selector/src/runtime/triage/masks.ts +0 -128
  148. package/packages/selector/src/runtime/triage/shallow.ts +0 -132
  149. package/packages/selector/src/runtime/triage/signals.ts +0 -167
  150. package/packages/selector/src/runtime/triage/types.ts +0 -125
  151. package/packages/selector/src/runtime/types.ts +0 -396
  152. package/packages/selector/src/runtime/value.ts +0 -48
  153. package/packages/selector/src/settings-bridge.ts +0 -175
  154. package/packages/selector/tests/advisor-report.host.spec.ts +0 -223
  155. package/packages/selector/tests/auto-compact.client.spec.tsx +0 -214
  156. package/packages/selector/tests/built/client-artifact.spec.ts +0 -56
  157. package/packages/selector/tests/cache-prefix-audit.spec.ts +0 -123
  158. package/packages/selector/tests/code-skeleton.client.spec.ts +0 -98
  159. package/packages/selector/tests/compat/compat-narrow-waist.spec.ts +0 -150
  160. package/packages/selector/tests/custom-contract.client.spec.ts +0 -226
  161. package/packages/selector/tests/estimator-catalog.spec.ts +0 -70
  162. package/packages/selector/tests/estimator-channel.client.spec.tsx +0 -253
  163. package/packages/selector/tests/estimator-route-registration.host.spec.ts +0 -202
  164. package/packages/selector/tests/fab-pos.client.spec.ts +0 -47
  165. package/packages/selector/tests/fixtures/sediment-pool/52adc205-cloud-5.orig.txt +0 -231
  166. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-25.orig.txt +0 -236
  167. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-38.orig.txt +0 -220
  168. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-42.orig.txt +0 -140
  169. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-53.orig.txt +0 -117
  170. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-local-10.orig.txt +0 -67
  171. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-45.orig.txt +0 -119
  172. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-49.orig.txt +0 -119
  173. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-63.orig.txt +0 -131
  174. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-75.orig.txt +0 -196
  175. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-76.orig.txt +0 -71
  176. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-85.orig.txt +0 -126
  177. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-86.orig.txt +0 -86
  178. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-87.orig.txt +0 -50
  179. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-96.orig.txt +0 -102
  180. package/packages/selector/tests/helpers/legacy-namespace.ts +0 -35
  181. package/packages/selector/tests/helpers/legacy-settings/index.ts +0 -15
  182. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +0 -41
  183. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +0 -647
  184. package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +0 -78
  185. package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +0 -234
  186. package/packages/selector/tests/host-preset-overlay.host.spec.ts +0 -204
  187. package/packages/selector/tests/monitor-fab.client.spec.ts +0 -240
  188. package/packages/selector/tests/preset-options-write.client.spec.ts +0 -192
  189. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +0 -200
  190. package/packages/selector/tests/preset-overlay.host.spec.ts +0 -246
  191. package/packages/selector/tests/profiles.client.spec.tsx +0 -436
  192. package/packages/selector/tests/ptc-custom-write.client.spec.ts +0 -86
  193. package/packages/selector/tests/public/package-contract.client.spec.ts +0 -89
  194. package/packages/selector/tests/runtime/adaptive-cost.spec.ts +0 -167
  195. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +0 -230
  196. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +0 -272
  197. package/packages/selector/tests/runtime/advisor.spec.ts +0 -226
  198. package/packages/selector/tests/runtime/audit.spec.ts +0 -275
  199. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +0 -523
  200. package/packages/selector/tests/runtime/char-basis.spec.ts +0 -30
  201. package/packages/selector/tests/runtime/code-skeleton.spec.ts +0 -152
  202. package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +0 -186
  203. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +0 -122
  204. package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +0 -122
  205. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +0 -96
  206. package/packages/selector/tests/runtime/fixtures/profile-baseline.json +0 -273
  207. package/packages/selector/tests/runtime/fixtures/session-v4-dump.jsonl +0 -46
  208. package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +0 -106
  209. package/packages/selector/tests/runtime/fixtures/vision-golden.json +0 -459
  210. package/packages/selector/tests/runtime/fold-router.spec.ts +0 -140
  211. package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +0 -74
  212. package/packages/selector/tests/runtime/fresh-gate.spec.ts +0 -43
  213. package/packages/selector/tests/runtime/html-reducer.spec.ts +0 -212
  214. package/packages/selector/tests/runtime/intent-gate.spec.ts +0 -62
  215. package/packages/selector/tests/runtime/intent-summary.spec.ts +0 -156
  216. package/packages/selector/tests/runtime/jsonl-reducer.spec.ts +0 -79
  217. package/packages/selector/tests/runtime/line-mapping.spec.ts +0 -153
  218. package/packages/selector/tests/runtime/monitor.spec.ts +0 -354
  219. package/packages/selector/tests/runtime/panel-command.spec.ts +0 -101
  220. package/packages/selector/tests/runtime/prose-reducers.spec.ts +0 -133
  221. package/packages/selector/tests/runtime/ptc-profile.spec.ts +0 -133
  222. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +0 -2795
  223. package/packages/selector/tests/runtime/read-input-cap.spec.ts +0 -33
  224. package/packages/selector/tests/runtime/savings-accounting.spec.ts +0 -291
  225. package/packages/selector/tests/runtime/savings-integral.spec.ts +0 -169
  226. package/packages/selector/tests/runtime/savings-projection.spec.ts +0 -89
  227. package/packages/selector/tests/runtime/savings-verify.spec.ts +0 -226
  228. package/packages/selector/tests/runtime/savings.spec.ts +0 -139
  229. package/packages/selector/tests/runtime/search-reducer.spec.ts +0 -110
  230. package/packages/selector/tests/runtime/sediment-card.spec.ts +0 -111
  231. package/packages/selector/tests/runtime/sediment-config.spec.ts +0 -56
  232. package/packages/selector/tests/runtime/sediment-guard.spec.ts +0 -71
  233. package/packages/selector/tests/runtime/sediment-masks.spec.ts +0 -95
  234. package/packages/selector/tests/runtime/sediment-orchestrator.spec.ts +0 -166
  235. package/packages/selector/tests/runtime/sediment-pool-share.spec.ts +0 -65
  236. package/packages/selector/tests/runtime/sediment-publish.spec.ts +0 -142
  237. package/packages/selector/tests/runtime/sediment-real-shapes.spec.ts +0 -158
  238. package/packages/selector/tests/runtime/sediment-settings.spec.ts +0 -73
  239. package/packages/selector/tests/runtime/sediment-signals.spec.ts +0 -124
  240. package/packages/selector/tests/runtime/sediment-span.spec.ts +0 -92
  241. package/packages/selector/tests/runtime/session-events.spec.ts +0 -27
  242. package/packages/selector/tests/runtime/session-file-decode.spec.ts +0 -281
  243. package/packages/selector/tests/runtime/settings-unwrap.spec.ts +0 -58
  244. package/packages/selector/tests/runtime/shallow-primitives.spec.ts +0 -135
  245. package/packages/selector/tests/runtime/sidechannel.spec.ts +0 -241
  246. package/packages/selector/tests/runtime/stats-backfill-scheduler.spec.ts +0 -167
  247. package/packages/selector/tests/runtime/stats-backfill.spec.ts +0 -350
  248. package/packages/selector/tests/runtime/stats-db.spec.ts +0 -361
  249. package/packages/selector/tests/runtime/stats-privacy.spec.ts +0 -55
  250. package/packages/selector/tests/runtime/stats-sync.spec.ts +0 -278
  251. package/packages/selector/tests/runtime/summary-command.spec.ts +0 -154
  252. package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +0 -159
  253. package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +0 -53
  254. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +0 -217
  255. package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +0 -52
  256. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +0 -79
  257. package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +0 -76
  258. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +0 -121
  259. package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +0 -82
  260. package/packages/selector/tests/runtime/toolclass.spec.ts +0 -156
  261. package/packages/selector/tests/runtime/value.spec.ts +0 -23
  262. package/packages/selector/tests/savings-sessions.client.spec.tsx +0 -140
  263. package/packages/selector/tests/settings-seat.client.spec.ts +0 -215
  264. package/packages/selector/tests/standing-generation.host.spec.ts +0 -724
  265. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +0 -269
  266. package/packages/selector/tests/support/cache-prefix-audit.ts +0 -105
  267. package/packages/selector/tests/support/mock-adapter.ts +0 -37
  268. package/packages/selector/tests/support/ui-primitives.tsx +0 -34
  269. package/packages/selector/tsconfig.json +0 -11
  270. package/packages/selector/tsdown.client.config.ts +0 -102
  271. package/packages/selector/tsdown.config.ts +0 -20
  272. package/pnpm-workspace.yaml +0 -76
  273. package/scripts/capture-profile-baseline.mjs +0 -42
  274. package/scripts/cell-browser-e2e.mjs +0 -354
  275. package/scripts/generate-tokenizer-fixtures.py +0 -81
  276. package/scripts/generate-vision-fixtures.py +0 -208
  277. package/scripts/hosts.d.mts +0 -3
  278. package/scripts/hosts.mjs +0 -79
  279. package/scripts/packed-components-smoke.mjs +0 -763
  280. package/scripts/packed-install-e2e.mjs +0 -1346
  281. package/scripts/sediment-latency-report.mjs +0 -63
  282. package/scripts/sync-hosts.mjs +0 -174
  283. package/scripts/toolclass-corpus-replay.mjs +0 -281
  284. package/scripts/verify-release.mjs +0 -343
  285. package/tests/TEST_INVENTORY.md +0 -41
  286. package/tsconfig.base.json +0 -18
  287. package/tsconfig.json +0 -7
  288. package/tsconfig.tests.json +0 -15
  289. package/vitest.built.config.ts +0 -9
  290. package/vitest.config.ts +0 -54
  291. /package/{packages/selector/assets → assets}/deepseek-v4/LICENSE.DeepSeek-V4-Pro.txt +0 -0
  292. /package/{packages/selector/assets → assets}/deepseek-v4/manifest.json +0 -0
  293. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer.json +0 -0
  294. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer_config.json +0 -0
  295. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/LICENSE.DeepSeek-V4-Flash-Vision-Exp.txt +0 -0
  296. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/manifest.json +0 -0
  297. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer.json +0 -0
  298. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer_config.json +0 -0
  299. /package/{packages/selector/cordis.patch.yml → cordis.patch.yml} +0 -0
  300. /package/{packages/selector/lib → lib}/client.d.ts +0 -0
  301. /package/{packages/selector/lib → lib}/client.js +0 -0
  302. /package/{packages/selector/lib → lib}/index.d.ts +0 -0
  303. /package/{packages/selector/lib → lib}/invariant.d.ts +0 -0
  304. /package/{packages/selector/lib → lib}/invariant.js +0 -0
  305. /package/{packages/selector/lib → lib}/profiles.d.ts +0 -0
  306. /package/{packages/selector/lib → lib}/pruner.d.ts +0 -0
  307. /package/{packages/selector/lib → lib}/pruner.js +0 -0
  308. /package/{packages/selector/lib → lib}/savings-integral.js +0 -0
  309. /package/{packages/selector/lib → lib}/tail-trim.js +0 -0
  310. /package/{packages/selector/lib → lib}/tool-result.js +0 -0
@@ -1,98 +0,0 @@
1
- // @vitest-environment jsdom
2
-
3
- import { describe, expect, it, vi } from 'vitest'
4
- import { DEFAULT_CUSTOM_COMPRESSION_POLICY } from '../src/profiles.ts'
5
- import { apply } from '../src/client/index.ts'
6
- import type { CompressionSelectorInjected } from '../src/client/CompressionProfileSelector.tsx'
7
- import type { ContextCompressionSettings } from '../src/profiles.ts'
8
-
9
- /**
10
- * 0.1.7 contract: `codeSkeleton` rides the entry config as part of the volatile
11
- * `settings` whole-object field. Every write commits the full doc through
12
- * `configForms.set('settings', doc)`; the confirm-on-write semantics are
13
- * unchanged — a host that silently drops (or flips) the section fails the
14
- * acceptance check on the post-commit snapshot.
15
- */
16
-
17
- describe('codeSkeleton confirm-on-write client contract', () => {
18
- it('resolves only when the host confirms the toggled value and rejects silent drops', async () => {
19
- let revision = 3
20
- let commit = false
21
- let flipEnabled = false
22
- let value: ContextCompressionSettings = {
23
- profile: 'balanced',
24
- custom: structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY),
25
- autoCompact: { thresholdPercent: 80 },
26
- codeSkeleton: { enabled: false },
27
- intentSummary: { enabled: false },
28
- }
29
- const form = {
30
- getSnapshot: vi.fn(() => ({
31
- status: 'ready' as const,
32
- value: { settings: value },
33
- base: undefined,
34
- user: undefined,
35
- revision,
36
- writable: true,
37
- mode: 'host' as const,
38
- })),
39
- subscribe: vi.fn(() => () => {}),
40
- set: vi.fn(async (_field: string, next: unknown) => {
41
- if (!commit) return false
42
- revision += 1
43
- const doc = structuredClone(next) as ContextCompressionSettings
44
- if (flipEnabled) {
45
- const accepted = structuredClone(doc.codeSkeleton)
46
- accepted.enabled = !accepted.enabled
47
- value = { ...doc, codeSkeleton: accepted }
48
- return true
49
- }
50
- value = doc
51
- return true
52
- }),
53
- unset: vi.fn(async () => false),
54
- }
55
- let injected: (() => CompressionSelectorInjected) | undefined
56
- const ctx = {
57
- effect: (install: () => unknown) => { install() },
58
- locale: { register: vi.fn(() => () => {}) },
59
- configForms: { get: vi.fn(() => form) },
60
- // Scoped sub-inject seam: host resolves configForms and fires the arm
61
- inject: (services: string[], cb: (service: unknown) => void) => {
62
- if (services.includes('configForms')) cb(ctx.configForms)
63
- },
64
- slots: {
65
- inject: (_slot: string, install: () => unknown) => { install() },
66
- register: (registration: { name?: string, inject?: () => CompressionSelectorInjected }) => {
67
- // The R4 overlay registration carries no inject face; keep the card's.
68
- if (registration.name === 'settings.section' && typeof registration.inject === 'function') injected = registration.inject
69
- return () => {}
70
- },
71
- },
72
- } as unknown as Parameters<typeof apply>[0]
73
-
74
- apply(ctx)
75
- const actions = injected?.()
76
- expect(actions).toBeDefined()
77
- if (actions === undefined) throw new Error('selector injection was not registered')
78
-
79
- // A silent host drop leaves the revision untouched: the write must reject.
80
- await expect(actions.saveCodeSkeleton(true)).rejects.toThrow('were not saved')
81
-
82
- // A committed write resolves and persists the exact section payload under
83
- // the volatile `settings` field.
84
- commit = true
85
- await expect(actions.saveCodeSkeleton(true)).resolves.toBeUndefined()
86
- expect(form.set).toHaveBeenLastCalledWith('settings', expect.objectContaining({ codeSkeleton: { enabled: true } }))
87
- expect(value.codeSkeleton).toEqual({ enabled: true })
88
-
89
- // A host that flips the toggled bit fails the acceptance check.
90
- flipEnabled = true
91
- await expect(actions.saveCodeSkeleton(false)).rejects.toThrow('were not saved')
92
-
93
- flipEnabled = false
94
- await expect(actions.saveCodeSkeleton(false)).resolves.toBeUndefined()
95
- expect(form.set).toHaveBeenLastCalledWith('settings', expect.objectContaining({ codeSkeleton: { enabled: false } }))
96
- expect(value.codeSkeleton).toEqual({ enabled: false })
97
- })
98
- })
@@ -1,150 +0,0 @@
1
- /**
2
- * compat narrow-waist unit tests: tool-result triple view, legacy source-kind
3
- * escape, generation probe, and the settings lease no-op on modern hosts.
4
- */
5
- import { describe, expect, it } from 'vitest'
6
- import { viewToolResult, compressionMessageSource } from '../../src/compat/tool-result.ts'
7
- import { detectHostGeneration, resetHostGenerationCache, noteResolvedSettingsService, hostGenerationSnapshot } from '../../src/compat/host-generation.ts'
8
- import { acquireSettingsLease } from '../../src/compat/settings-lease.ts'
9
-
10
- const MODERN_TOOL_RESULT = {
11
- content: [{ type: 'text', text: 'hello' }, { type: 'text', text: 'world' }],
12
- isError: true,
13
- toolCallId: 'call-modern',
14
- }
15
-
16
- const LEGACY_TOOL_RESULT = {
17
- content: [{
18
- type: 'tool-result',
19
- content: [{ type: 'text', text: 'legacy body' }],
20
- isError: true,
21
- }],
22
- source: { callId: 'call-legacy' },
23
- }
24
-
25
- describe('viewToolResult (three-axis envelope adapter)', () => {
26
- it('reads the flat modern shape', () => {
27
- const view = viewToolResult(MODERN_TOOL_RESULT, 'modern')
28
- expect(view.blocks).toHaveLength(2)
29
- expect(view.isError).toBe(true)
30
- expect(view.callId).toBe('call-modern')
31
- })
32
-
33
- it('reads the enveloped legacy shape (strict signature overrides the flag)', () => {
34
- const view = viewToolResult(LEGACY_TOOL_RESULT, 'modern')
35
- expect(view.blocks).toEqual([{ type: 'text', text: 'legacy body' }])
36
- expect(view.isError).toBe(true)
37
- expect(view.callId).toBe('call-legacy')
38
- })
39
-
40
- it('honors the legacy flag when the signature check is inconclusive', () => {
41
- const loose = {
42
- content: [{ something: 'else' }],
43
- source: { callId: 'call-loose' },
44
- }
45
- const view = viewToolResult(loose, 'legacy')
46
- expect(view.blocks).toEqual([{ something: 'else' }])
47
- expect(view.callId).toBe('call-loose')
48
- })
49
-
50
- it('keeps the modern axes on an inconclusive modern message', () => {
51
- const view = viewToolResult(MODERN_TOOL_RESULT, 'legacy')
52
- expect(view.blocks).toEqual(MODERN_TOOL_RESULT.content)
53
- expect(view.isError).toBe(true)
54
- expect(view.callId).toBe('call-modern')
55
- })
56
-
57
- it('never throws on absent fields', () => {
58
- const view = viewToolResult({}, 'modern')
59
- expect(view.blocks).toEqual([])
60
- expect(view.isError).toBe(false)
61
- expect(view.callId).toBeUndefined()
62
- })
63
- })
64
-
65
- describe('compressionMessageSource (legacy kind escape)', () => {
66
- it('returns the per-producer kind on modern hosts', () => {
67
- expect(compressionMessageSource('modern')).toEqual({ kind: 'dsh-context-compression' })
68
- })
69
-
70
- it('escapes to the shared plugin kind on legacy hosts', () => {
71
- const source = compressionMessageSource('legacy')
72
- expect(source.kind).toBe('plugin')
73
- expect((source as { plugin?: string }).plugin).toBe('dsh-context-compression-improved')
74
- })
75
- })
76
-
77
- describe('detectHostGeneration (capability probe)', () => {
78
- it('classifies a register-capable settings service as legacy', () => {
79
- resetHostGenerationCache()
80
- expect(detectHostGeneration({ get: (name) => (name === 'settings' ? { register: () => ({}) } : undefined) })).toBe('legacy')
81
- })
82
-
83
- it('classifies a register-less settings service as modern', () => {
84
- resetHostGenerationCache()
85
- expect(detectHostGeneration({ get: (name) => (name === 'settings' ? { describe: () => [] } : undefined) })).toBe('modern')
86
- })
87
-
88
- it('defaults to modern when the settings service is absent', () => {
89
- resetHostGenerationCache()
90
- expect(detectHostGeneration({ get: () => undefined })).toBe('modern')
91
- resetHostGenerationCache()
92
- })
93
-
94
- it('does not cache the provisional verdict taken while the service is absent', () => {
95
- // Measured on the real 0.1.0-rc.2 cell: rows compose before the host
96
- // settings service, and the old probe cached that absence as 'modern'
97
- // forever — the legacy lease arm went dead on the line it was built for.
98
- resetHostGenerationCache()
99
- expect(detectHostGeneration({ get: () => undefined })).toBe('modern')
100
- // Later evidence (the settings inject callback) must still flip it.
101
- expect(noteResolvedSettingsService({ register: () => ({}) })).toBe('legacy')
102
- })
103
-
104
- it('noteResolvedSettingsService overrides even a definitive earlier verdict', () => {
105
- resetHostGenerationCache()
106
- expect(detectHostGeneration({ get: () => ({ describe: () => [] }) })).toBe('modern')
107
- expect(noteResolvedSettingsService({ register: () => ({}) })).toBe('legacy')
108
- expect(hostGenerationSnapshot()).toBe('legacy')
109
- })
110
-
111
- it('hostGenerationSnapshot defaults to modern without any evidence', () => {
112
- resetHostGenerationCache()
113
- expect(hostGenerationSnapshot()).toBe('modern')
114
- })
115
- })
116
-
117
- describe('acquireSettingsLease', () => {
118
- it('is a no-op face on modern hosts (register absent, P1-13)', async () => {
119
- resetHostGenerationCache()
120
- const effects: Array<{ name?: string }> = []
121
- const ctx = {
122
- effect: (factory: () => unknown, name?: string) => { effects.push(name === undefined ? {} : { name }); void factory },
123
- settings: { describe: () => [] },
124
- } as unknown as Parameters<typeof acquireSettingsLease>[0]
125
- const face = acquireSettingsLease(ctx, 'context-compression', {})
126
- expect(face.get()).toBeUndefined()
127
- await expect(face.update({ marker: 1 })).resolves.toBe(false)
128
- })
129
-
130
- it('registers once and reads/writes through the host service on legacy hosts', async () => {
131
- const registrations: string[] = []
132
- const stored = new Map<string, Record<string, unknown>>()
133
- const settings = {
134
- register: (ns: string) => { registrations.push(ns); return { get: () => stored.get(ns) } },
135
- get: (ns: string) => stored.get(ns),
136
- update: async (ns: string, patch: Record<string, unknown>) => { stored.set(ns, patch) },
137
- }
138
- const effects: Array<() => void> = []
139
- const ctx = {
140
- effect: (factory: () => () => void) => { effects.push(factory()) },
141
- settings,
142
- } as unknown as Parameters<typeof acquireSettingsLease>[0]
143
- const face = acquireSettingsLease(ctx, 'context-compression', {})
144
- expect(registrations).toEqual(['context-compression'])
145
- await expect(face.update({ profile: 'balanced' })).resolves.toBe(true)
146
- expect(face.get()).toEqual({ profile: 'balanced' })
147
- // Disposal must not throw when this was the only owner.
148
- for (const dispose of effects) dispose()
149
- })
150
- })
@@ -1,226 +0,0 @@
1
- import { describe, expect, it, vi } from 'vitest'
2
- import type { Context as ClientContext } from '@deepseek-ai/cordis'
3
- import type { ScopeSnapshot } from '../src/client/scope-face.ts'
4
- import {
5
- DEFAULT_CUSTOM_COMPRESSION_POLICY,
6
- isCustomCompressionPolicy,
7
- } from '../src/profiles.ts'
8
- import { apply } from '../src/client/index.ts'
9
- import { decodeSettings } from '../src/client/decode.ts'
10
- import type {
11
- CompressionSelectorInjected,
12
- ContextCompressionSettings,
13
- } from '../src/client/CompressionProfileSelector.tsx'
14
-
15
- vi.mock('@deepseek-ai/dsh-client-ui-primitives', () => ({
16
- IconChevronDownOutlineMedium: () => null,
17
- Menu: () => null,
18
- }))
19
-
20
- const CUSTOM = {
21
- version: 1,
22
- unit: 'tokens',
23
- fresh: { enabled: true, trigger: 4_096, target: 2_048 },
24
- aggregate: { enabled: true, trigger: 16_384, target: 8_192 },
25
- history: {
26
- enabled: true,
27
- trigger: 32_768,
28
- keepRecentTurns: 2,
29
- keepRecent: 16_384,
30
- minReclaim: 8_192,
31
- },
32
- prefixPolicy: 'pressure-break',
33
- } as const satisfies ContextCompressionSettings['custom']
34
-
35
- describe('context compression browser contract', () => {
36
- it('accepts legacy v1 and defaults new edits to v3 with TailTrim disabled', () => {
37
- expect(isCustomCompressionPolicy(CUSTOM)).toBe(true)
38
- expect(DEFAULT_CUSTOM_COMPRESSION_POLICY).toMatchObject({
39
- version: 3,
40
- tailTrim: { enabled: false, trigger: 700_000 },
41
- })
42
- expect(isCustomCompressionPolicy(DEFAULT_CUSTOM_COMPRESSION_POLICY)).toBe(true)
43
- })
44
-
45
- it('fails the browser narrowing for unknown or invalid Custom fields', () => {
46
- expect(isCustomCompressionPolicy({
47
- ...structuredClone(CUSTOM),
48
- tailTrim: { enabled: true },
49
- })).toBe(false)
50
- expect(isCustomCompressionPolicy({
51
- ...structuredClone(CUSTOM),
52
- fresh: { enabled: true, trigger: 100, target: 100 },
53
- })).toBe(false)
54
- for (const trigger of [0, -1]) {
55
- expect(isCustomCompressionPolicy({
56
- ...structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY),
57
- tailTrim: { enabled: true, trigger },
58
- })).toBe(false)
59
- }
60
- expect(isCustomCompressionPolicy({
61
- ...structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY),
62
- unit: 'context-percent',
63
- tailTrim: { enabled: true, trigger: 101 },
64
- })).toBe(false)
65
- })
66
-
67
- it('decodes legacy settings to the default threshold and rejects malformed sections', async () => {
68
- // Legacy documents stored before autoCompact existed inherit 80%.
69
- const legacy = decodeSettings({ profile: 'balanced', custom: structuredClone(CUSTOM) })
70
- expect(legacy).toMatchObject({ autoCompact: { thresholdPercent: 80 } })
71
- // A present-but-invalid threshold fails the whole decode.
72
- expect(decodeSettings({
73
- profile: 'balanced',
74
- custom: structuredClone(CUSTOM),
75
- autoCompact: { thresholdPercent: 91 },
76
- })).toBeUndefined()
77
- })
78
-
79
- it('reports a recovered no-op write only on the selector boundary', async () => {
80
- let revision = 7
81
- let commit = false
82
- let rewriteCustom = false
83
- let rewriteReset = false
84
- let dropTailTrim = false
85
- let downgradeVersion = false
86
- let value: ContextCompressionSettings = {
87
- profile: 'balanced',
88
- custom: structuredClone(CUSTOM),
89
- autoCompact: { thresholdPercent: 80 },
90
- codeSkeleton: { enabled: false },
91
- intentSummary: { enabled: false },
92
- }
93
- const snapshot = (): ScopeSnapshot<ContextCompressionSettings> => ({
94
- status: 'ready',
95
- value,
96
- base: undefined,
97
- user: undefined,
98
- revision,
99
- writable: true,
100
- mode: 'host',
101
- })
102
- const scope = {
103
- getSnapshot: snapshot,
104
- subscribe: vi.fn(() => () => {}),
105
- set: vi.fn(async (field: string, next: unknown) => {
106
- if (!commit) return
107
- revision += 1
108
- if (field === 'custom' && rewriteCustom) {
109
- const accepted = structuredClone(next as ContextCompressionSettings['custom'])
110
- accepted.fresh.trigger += 1
111
- value = { ...value, custom: accepted }
112
- return
113
- }
114
- if (field === 'custom' && rewriteReset) {
115
- const accepted = structuredClone(next as ContextCompressionSettings['custom'])
116
- accepted.fresh.trigger += 1
117
- value = { ...value, custom: accepted }
118
- return
119
- }
120
- if (field === 'custom' && dropTailTrim) {
121
- const accepted = structuredClone(next as ContextCompressionSettings['custom'])
122
- if (accepted.version === 3) {
123
- accepted.tailTrim = { enabled: false, trigger: 700_000 }
124
- }
125
- value = { ...value, custom: accepted }
126
- return
127
- }
128
- if (field === 'custom' && downgradeVersion) {
129
- value = { ...value, custom: structuredClone(CUSTOM) }
130
- return
131
- }
132
- value = { ...value, [field]: next }
133
- }),
134
- unset: vi.fn(async () => {
135
- if (!commit) return
136
- revision += 1
137
- const custom: ContextCompressionSettings['custom'] = structuredClone(CUSTOM)
138
- if (rewriteReset) {
139
- custom.fresh.trigger = 8_192
140
- custom.fresh.target = 4_096
141
- }
142
- value = { ...value, custom }
143
- }),
144
- }
145
- let injected: (() => CompressionSelectorInjected) | undefined
146
- const ctx = {
147
- effect: (install: () => unknown) => { install() },
148
- locale: { register: vi.fn(() => () => {}) },
149
- // 0.1.7: the plugin commits the whole doc through configForms; the fake
150
- // routes each changed top-level field back onto the old scope stub so
151
- // the rewrite/drop semantics below stay observable per field.
152
- inject: (services: string[], cb: (service: unknown) => void) => {
153
- if (services.includes('configForms')) cb(ctx.configForms)
154
- },
155
- configForms: {
156
- get: vi.fn(() => ({
157
- getSnapshot: () => ({ ...snapshot(), value: { settings: value } }),
158
- subscribe: scope.subscribe,
159
- set: async (_field: string, doc: unknown) => {
160
- const next = doc as unknown as Record<string, unknown>
161
- for (const key of Object.keys(next)) {
162
- if (JSON.stringify((value as unknown as Record<string, unknown>)[key]) !== JSON.stringify(next[key])) {
163
- await scope.set(key, (next as Record<string, unknown>)[key])
164
- }
165
- }
166
- return true
167
- },
168
- unset: scope.unset,
169
- })),
170
- },
171
- slots: {
172
- inject: (_slot: string, install: () => unknown) => { install() },
173
- register: (registration: { name?: string, inject?: () => CompressionSelectorInjected }) => {
174
- // The R4 overlay registration carries no inject face; keep the card's.
175
- if (registration.name === 'settings.section' && typeof registration.inject === 'function') injected = registration.inject
176
- return () => {}
177
- },
178
- },
179
- } as unknown as ClientContext
180
-
181
- apply(ctx)
182
- const actions = injected?.()
183
- expect(actions).toBeDefined()
184
- if (actions === undefined) throw new Error('selector injection was not registered')
185
- await expect(actions.select('native')).rejects.toThrow('were not saved')
186
-
187
- commit = true
188
- await expect(actions.select('native')).resolves.toBeUndefined()
189
- expect(value.profile).toBe('native')
190
-
191
- const requested: ContextCompressionSettings['custom'] = structuredClone(CUSTOM)
192
- requested.fresh.trigger = 8_192
193
- requested.fresh.target = 4_096
194
- rewriteCustom = true
195
- await expect(actions.saveCustom(requested)).rejects.toThrow('were not saved')
196
-
197
- rewriteCustom = false
198
- const requestedV3 = structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY)
199
- if (requestedV3.version !== 3) throw new Error('Custom TailTrim persistence fixture requires policy v3')
200
- requestedV3.tailTrim = { enabled: true, trigger: 49_152 }
201
- dropTailTrim = true
202
- await expect(actions.saveCustom(requestedV3)).rejects.toThrow('were not saved')
203
-
204
- dropTailTrim = false
205
- downgradeVersion = true
206
- await expect(actions.saveCustom(requestedV3)).rejects.toThrow('were not saved')
207
-
208
- downgradeVersion = false
209
- rewriteReset = true
210
- await expect(actions.resetCustom()).rejects.toThrow('were not saved')
211
-
212
- rewriteReset = false
213
- await expect(actions.resetCustom()).resolves.toBeUndefined()
214
- expect(scope.set).toHaveBeenLastCalledWith('custom', DEFAULT_CUSTOM_COMPRESSION_POLICY)
215
- expect(scope.unset).not.toHaveBeenCalled()
216
-
217
- // The Auto Compact threshold shares the same confirm-on-write boundary:
218
- // committed writes resolve, and a silent host drop rejects.
219
- commit = false
220
- await expect(actions.saveAutoCompact(73)).rejects.toThrow('were not saved')
221
- commit = true
222
- await expect(actions.saveAutoCompact(73)).resolves.toBeUndefined()
223
- expect(scope.set).toHaveBeenLastCalledWith('autoCompact', { thresholdPercent: 73 })
224
- expect(value.autoCompact).toEqual({ thresholdPercent: 73 })
225
- })
226
- })
@@ -1,70 +0,0 @@
1
- /** Estimator catalog projection: never throws, selection precedence, inline errors. */
2
-
3
- import { describe, expect, it } from 'vitest'
4
- import {
5
- buildEstimatorCatalog, resolveHostRoute,
6
- type EstimatorCatalogDeps,
7
- } from '../src/estimator-catalog.ts'
8
-
9
- describe('resolveHostRoute', () => {
10
- it('prefers explicit overrides over the host default selection', () => {
11
- expect(resolveHostRoute({
12
- overrideProvider: 'p1',
13
- overrideModel: 'm1',
14
- currentSelection: () => ({ provider: 'p2', model: 'm2' }),
15
- })).toEqual({ provider: 'p1', model: 'm1' })
16
- })
17
-
18
- it('falls back to the host default selection when overrides are empty', () => {
19
- expect(resolveHostRoute({
20
- overrideProvider: '',
21
- overrideModel: '',
22
- currentSelection: () => ({ provider: 'p2', model: 'm2' }),
23
- })).toEqual({ provider: 'p2', model: 'm2' })
24
- })
25
-
26
- it('fills missing override fields from the selection, per field', () => {
27
- expect(resolveHostRoute({ overrideProvider: 'p1', currentSelection: () => ({ model: 'm2' }) }))
28
- .toEqual({ provider: 'p1', model: 'm2' })
29
- })
30
-
31
- it('reports undefined when neither source yields a complete route', () => {
32
- expect(resolveHostRoute({ currentSelection: () => ({ provider: 'p' }) })).toBeUndefined()
33
- expect(resolveHostRoute({})).toBeUndefined()
34
- })
35
- })
36
-
37
- describe('buildEstimatorCatalog', () => {
38
- it('lists every provider with its models and never throws on one broken group', async () => {
39
- const llm = {
40
- listProviders: () => [{ id: 'deepseek', name: 'DeepSeek' }, { id: 'broken', name: 'Broken' }],
41
- listModels: async (providerId: string) => {
42
- if (providerId === 'broken') throw new Error('adapter offline')
43
- return [{ id: 'm1', name: 'Model 1' }]
44
- },
45
- }
46
- const catalog = await buildEstimatorCatalog({ llm })
47
- expect(catalog.providers).toHaveLength(2)
48
- expect(catalog.providers[0]).toEqual({ id: 'deepseek', name: 'DeepSeek', models: [{ id: 'm1', name: 'Model 1' }] })
49
- expect(catalog.providers[1]?.error).toBe('adapter offline')
50
- })
51
-
52
- it('uses route discovery when listModels is absent or silent', async () => {
53
- const llm: NonNullable<EstimatorCatalogDeps['llm']> = {
54
- listProviders: () => [{ id: 'self-hosted', name: 'Self hosted' }],
55
- listConfigurableProviders: () => [{ provider: 'self-hosted', settingsNs: 'llm.self-hosted' }],
56
- discoverModels: async () => [{ id: 'm9' }],
57
- }
58
- const catalog = await buildEstimatorCatalog({ llm })
59
- expect(catalog.providers[0]?.models).toEqual([{ id: 'm9', name: 'm9' }])
60
- expect(catalog.providers[0]?.error).toBeUndefined()
61
- })
62
-
63
- it('returns the host selection even when the llm service is unavailable', async () => {
64
- const catalog = await buildEstimatorCatalog({
65
- currentSelection: () => ({ provider: 'p', model: 'm' }),
66
- })
67
- expect(catalog.providers).toEqual([])
68
- expect(catalog.selection).toEqual({ provider: 'p', model: 'm' })
69
- })
70
- })