dsh-context-compression-improved 0.10.4 → 0.11.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 (310) hide show
  1. package/.agents/plans/improve/checklist.md +32 -0
  2. package/.agents/plans/improve/findings.md +102 -0
  3. package/.agents/plans/improve/spec.md +53 -0
  4. package/.agents/plans/improve/tasks.md +70 -0
  5. package/.gitattributes +2 -0
  6. package/.githooks/pre-push +37 -0
  7. package/.github/workflows/ci.yml +47 -0
  8. package/CHANGELOG.de.md +580 -0
  9. package/CHANGELOG.es.md +588 -0
  10. package/CHANGELOG.fr.md +576 -0
  11. package/CHANGELOG.it.md +577 -0
  12. package/CHANGELOG.ja.md +261 -0
  13. package/CHANGELOG.ko.md +254 -0
  14. package/CHANGELOG.md +557 -0
  15. package/CHANGELOG.ru.md +554 -0
  16. package/CHANGELOG.zh.md +247 -0
  17. package/CONTRIBUTING.md +22 -0
  18. package/README.de.md +96 -0
  19. package/README.es.md +96 -0
  20. package/README.fr.md +96 -0
  21. package/README.it.md +96 -0
  22. package/README.ja.md +102 -0
  23. package/README.ko.md +102 -0
  24. package/README.md +110 -15
  25. package/README.ru.md +96 -0
  26. package/README.zh.md +104 -14
  27. package/SECURITY.md +18 -0
  28. package/THIRD_PARTY_NOTICES.md +7 -25
  29. package/assets/board.png +0 -0
  30. package/assets/context.png +0 -0
  31. package/docs/assets/context-compression-selector-profiles.jpg +0 -0
  32. package/docs/assets/context-compression-selector-settings.png +0 -0
  33. package/docs/compat-0.1.5-report.md +77 -0
  34. package/docs/installation.de.md +104 -0
  35. package/docs/installation.es.md +104 -0
  36. package/docs/installation.fr.md +104 -0
  37. package/docs/installation.it.md +104 -0
  38. package/docs/installation.ja.md +78 -0
  39. package/docs/installation.ko.md +78 -0
  40. package/docs/installation.md +103 -0
  41. package/docs/installation.ru.md +104 -0
  42. package/docs/installation.zh.md +100 -0
  43. package/docs/repair-log.md +657 -0
  44. package/docs/shallow-teaching-preset-template.md +46 -0
  45. package/eslint.config.js +30 -0
  46. package/package.json +116 -129
  47. package/packages/selector/LICENSE +21 -0
  48. package/packages/selector/README.md +26 -0
  49. package/packages/selector/README.zh.md +24 -0
  50. package/packages/selector/THIRD_PARTY_NOTICES.md +32 -0
  51. package/packages/selector/docs/history-tool-call-working-set-spec.md +112 -0
  52. package/packages/selector/docs/native-tool-result-selector-spec.md +34 -0
  53. package/packages/selector/docs/subagent-cache-reuse-spec.md +46 -0
  54. package/{dsh.plugin.json → packages/selector/dsh.plugin.json} +1 -1
  55. package/{lib → packages/selector/lib}/client.d.ts +8 -0
  56. package/{lib → packages/selector/lib}/client.js +212 -3
  57. package/{lib → packages/selector/lib}/index.js +1 -1
  58. package/{lib → packages/selector/lib}/profiles.d.ts +34 -0
  59. package/{lib → packages/selector/lib}/pruner.d.ts +55 -0
  60. package/{lib → packages/selector/lib}/pruner.js +1925 -303
  61. package/{lib → packages/selector/lib}/savings-integral.js +126 -3
  62. package/packages/selector/lib/style.css +350 -0
  63. package/{lib → packages/selector/lib}/tool-result.js +9 -1
  64. package/packages/selector/package.json +178 -0
  65. package/packages/selector/screenshots.json +3 -0
  66. package/packages/selector/src/client/CompressionProfileControls.tsx +352 -0
  67. package/packages/selector/src/client/CompressionProfileSelector.module.css +199 -0
  68. package/packages/selector/src/client/CompressionProfileSelector.tsx +89 -0
  69. package/packages/selector/src/client/CustomPolicyEditor.tsx +216 -0
  70. package/packages/selector/src/client/EstimatorControls.tsx +277 -0
  71. package/packages/selector/src/client/bridge-scope.ts +125 -0
  72. package/packages/selector/src/client/decode.ts +68 -0
  73. package/packages/selector/src/client/fab-pos.ts +71 -0
  74. package/packages/selector/src/client/index.ts +438 -0
  75. package/packages/selector/src/client/locales/de.ts +167 -0
  76. package/packages/selector/src/client/locales/es.ts +167 -0
  77. package/packages/selector/src/client/locales/fr.ts +167 -0
  78. package/packages/selector/src/client/locales/it.ts +167 -0
  79. package/packages/selector/src/client/locales/ja.ts +167 -0
  80. package/packages/selector/src/client/locales/ko.ts +167 -0
  81. package/packages/selector/src/client/locales/ru.ts +167 -0
  82. package/packages/selector/src/client/locales.ts +334 -0
  83. package/packages/selector/src/client/monitor-fab.ts +445 -0
  84. package/packages/selector/src/client/preset-options.ts +88 -0
  85. package/packages/selector/src/client/savings-card.tsx +269 -0
  86. package/packages/selector/src/client/scope-face.ts +24 -0
  87. package/packages/selector/src/client/settings-section.tsx +156 -0
  88. package/packages/selector/src/compat/host-generation.ts +96 -0
  89. package/packages/selector/src/compat/llm-messages.ts +50 -0
  90. package/packages/selector/src/compat/settings-lease.ts +108 -0
  91. package/packages/selector/src/compat/tool-result.ts +91 -0
  92. package/packages/selector/src/css-modules.d.ts +6 -0
  93. package/packages/selector/src/deepseek-v4-tokenizer.ts +205 -0
  94. package/packages/selector/src/estimator-catalog.ts +104 -0
  95. package/packages/selector/src/index.ts +890 -0
  96. package/packages/selector/src/invariant.ts +113 -0
  97. package/packages/selector/src/preset-overlay.ts +749 -0
  98. package/packages/selector/src/profiles.ts +554 -0
  99. package/packages/selector/src/pruner/content.ts +199 -0
  100. package/packages/selector/src/pruner/session.ts +97 -0
  101. package/packages/selector/src/pruner/state.ts +61 -0
  102. package/packages/selector/src/pruner/tuning.ts +23 -0
  103. package/packages/selector/src/pruner/types.ts +78 -0
  104. package/packages/selector/src/pruner.ts +3222 -0
  105. package/packages/selector/src/runtime/adaptive-cost.ts +205 -0
  106. package/packages/selector/src/runtime/audit.ts +321 -0
  107. package/packages/selector/src/runtime/config.ts +887 -0
  108. package/packages/selector/src/runtime/custom-policy.ts +300 -0
  109. package/packages/selector/src/runtime/deepseek-official-pricing.ts +298 -0
  110. package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +254 -0
  111. package/packages/selector/src/runtime/display-prefs.ts +98 -0
  112. package/packages/selector/src/runtime/fold-router.ts +143 -0
  113. package/packages/selector/src/runtime/measurement.ts +444 -0
  114. package/packages/selector/src/runtime/monitor.ts +341 -0
  115. package/packages/selector/src/runtime/panel-command.ts +213 -0
  116. package/packages/selector/src/runtime/reducers.ts +1755 -0
  117. package/packages/selector/src/runtime/retrieve.ts +505 -0
  118. package/packages/selector/src/runtime/savings-integral.ts +117 -0
  119. package/packages/selector/src/runtime/savings-projection.ts +229 -0
  120. package/packages/selector/src/runtime/savings-verify.ts +446 -0
  121. package/packages/selector/src/runtime/savings.ts +526 -0
  122. package/packages/selector/src/runtime/sediment-card.ts +126 -0
  123. package/packages/selector/src/runtime/sediment-clock.ts +87 -0
  124. package/packages/selector/src/runtime/sediment-guard.ts +136 -0
  125. package/packages/selector/src/runtime/sediment-publish.ts +144 -0
  126. package/packages/selector/src/runtime/sediment-span.ts +170 -0
  127. package/packages/selector/src/runtime/sediment.ts +209 -0
  128. package/packages/selector/src/runtime/session-events.ts +30 -0
  129. package/packages/selector/src/runtime/session-file-decode.ts +523 -0
  130. package/packages/selector/src/runtime/shallow-tools.ts +342 -0
  131. package/packages/selector/src/runtime/stats-backfill.ts +541 -0
  132. package/packages/selector/src/runtime/stats-db.ts +492 -0
  133. package/packages/selector/src/runtime/stats-schema.ts +123 -0
  134. package/packages/selector/src/runtime/stats-sync.ts +307 -0
  135. package/packages/selector/src/runtime/summary-command.ts +127 -0
  136. package/packages/selector/src/runtime/tail-trim.ts +177 -0
  137. package/packages/selector/src/runtime/token-count.ts +72 -0
  138. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -0
  139. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -0
  140. package/packages/selector/src/runtime/tokenpilot/advisor.ts +419 -0
  141. package/packages/selector/src/runtime/tokenpilot/benefit.ts +200 -0
  142. package/packages/selector/src/runtime/tokenpilot/dedup.ts +82 -0
  143. package/packages/selector/src/runtime/tokenpilot/estimator.ts +151 -0
  144. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +53 -0
  145. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -0
  146. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -0
  147. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -0
  148. package/packages/selector/src/runtime/tokenpilot/locator.ts +129 -0
  149. package/packages/selector/src/runtime/tokenpilot/read-state.ts +98 -0
  150. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +303 -0
  151. package/packages/selector/src/runtime/tool-names.ts +42 -0
  152. package/packages/selector/src/runtime/toolclass.ts +103 -0
  153. package/packages/selector/src/runtime/triage/masks.ts +128 -0
  154. package/packages/selector/src/runtime/triage/shallow.ts +132 -0
  155. package/packages/selector/src/runtime/triage/signals.ts +167 -0
  156. package/packages/selector/src/runtime/triage/types.ts +125 -0
  157. package/packages/selector/src/runtime/types.ts +396 -0
  158. package/packages/selector/src/runtime/value.ts +48 -0
  159. package/packages/selector/src/settings-bridge.ts +175 -0
  160. package/packages/selector/tests/advisor-report.host.spec.ts +223 -0
  161. package/packages/selector/tests/auto-compact.client.spec.tsx +214 -0
  162. package/packages/selector/tests/built/client-artifact.spec.ts +56 -0
  163. package/packages/selector/tests/cache-prefix-audit.spec.ts +123 -0
  164. package/packages/selector/tests/code-skeleton.client.spec.ts +98 -0
  165. package/packages/selector/tests/compat/compat-narrow-waist.spec.ts +150 -0
  166. package/packages/selector/tests/custom-contract.client.spec.ts +226 -0
  167. package/packages/selector/tests/estimator-catalog.spec.ts +70 -0
  168. package/packages/selector/tests/estimator-channel.client.spec.tsx +253 -0
  169. package/packages/selector/tests/estimator-route-registration.host.spec.ts +202 -0
  170. package/packages/selector/tests/fab-pos.client.spec.ts +47 -0
  171. package/packages/selector/tests/fixtures/sediment-pool/52adc205-cloud-5.orig.txt +231 -0
  172. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-25.orig.txt +236 -0
  173. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-38.orig.txt +220 -0
  174. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-42.orig.txt +140 -0
  175. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-53.orig.txt +117 -0
  176. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-local-10.orig.txt +67 -0
  177. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-45.orig.txt +119 -0
  178. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-49.orig.txt +119 -0
  179. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-63.orig.txt +131 -0
  180. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-75.orig.txt +196 -0
  181. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-76.orig.txt +71 -0
  182. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-85.orig.txt +126 -0
  183. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-86.orig.txt +86 -0
  184. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-87.orig.txt +50 -0
  185. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-96.orig.txt +102 -0
  186. package/packages/selector/tests/helpers/legacy-namespace.ts +35 -0
  187. package/packages/selector/tests/helpers/legacy-settings/index.ts +15 -0
  188. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +41 -0
  189. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +647 -0
  190. package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +78 -0
  191. package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +234 -0
  192. package/packages/selector/tests/host-preset-overlay.host.spec.ts +204 -0
  193. package/packages/selector/tests/monitor-fab.client.spec.ts +240 -0
  194. package/packages/selector/tests/preset-options-write.client.spec.ts +192 -0
  195. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +200 -0
  196. package/packages/selector/tests/preset-overlay.host.spec.ts +246 -0
  197. package/packages/selector/tests/profiles.client.spec.tsx +436 -0
  198. package/packages/selector/tests/ptc-custom-write.client.spec.ts +86 -0
  199. package/packages/selector/tests/public/package-contract.client.spec.ts +89 -0
  200. package/packages/selector/tests/runtime/adaptive-cost.spec.ts +167 -0
  201. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +230 -0
  202. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +272 -0
  203. package/packages/selector/tests/runtime/advisor.spec.ts +226 -0
  204. package/packages/selector/tests/runtime/audit.spec.ts +275 -0
  205. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +523 -0
  206. package/packages/selector/tests/runtime/char-basis.spec.ts +30 -0
  207. package/packages/selector/tests/runtime/code-skeleton.spec.ts +152 -0
  208. package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +186 -0
  209. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +122 -0
  210. package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +122 -0
  211. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +96 -0
  212. package/packages/selector/tests/runtime/fixtures/profile-baseline.json +273 -0
  213. package/packages/selector/tests/runtime/fixtures/session-v4-dump.jsonl +46 -0
  214. package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +106 -0
  215. package/packages/selector/tests/runtime/fixtures/vision-golden.json +459 -0
  216. package/packages/selector/tests/runtime/fold-router.spec.ts +140 -0
  217. package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +74 -0
  218. package/packages/selector/tests/runtime/fresh-gate.spec.ts +43 -0
  219. package/packages/selector/tests/runtime/html-reducer.spec.ts +212 -0
  220. package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -0
  221. package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -0
  222. package/packages/selector/tests/runtime/jsonl-reducer.spec.ts +79 -0
  223. package/packages/selector/tests/runtime/line-mapping.spec.ts +153 -0
  224. package/packages/selector/tests/runtime/monitor.spec.ts +354 -0
  225. package/packages/selector/tests/runtime/panel-command.spec.ts +101 -0
  226. package/packages/selector/tests/runtime/prose-reducers.spec.ts +133 -0
  227. package/packages/selector/tests/runtime/ptc-profile.spec.ts +133 -0
  228. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2795 -0
  229. package/packages/selector/tests/runtime/read-input-cap.spec.ts +33 -0
  230. package/packages/selector/tests/runtime/savings-accounting.spec.ts +291 -0
  231. package/packages/selector/tests/runtime/savings-integral.spec.ts +169 -0
  232. package/packages/selector/tests/runtime/savings-projection.spec.ts +89 -0
  233. package/packages/selector/tests/runtime/savings-verify.spec.ts +226 -0
  234. package/packages/selector/tests/runtime/savings.spec.ts +139 -0
  235. package/packages/selector/tests/runtime/search-reducer.spec.ts +110 -0
  236. package/packages/selector/tests/runtime/sediment-card.spec.ts +111 -0
  237. package/packages/selector/tests/runtime/sediment-config.spec.ts +56 -0
  238. package/packages/selector/tests/runtime/sediment-guard.spec.ts +71 -0
  239. package/packages/selector/tests/runtime/sediment-masks.spec.ts +95 -0
  240. package/packages/selector/tests/runtime/sediment-orchestrator.spec.ts +166 -0
  241. package/packages/selector/tests/runtime/sediment-pool-share.spec.ts +65 -0
  242. package/packages/selector/tests/runtime/sediment-publish.spec.ts +142 -0
  243. package/packages/selector/tests/runtime/sediment-real-shapes.spec.ts +158 -0
  244. package/packages/selector/tests/runtime/sediment-settings.spec.ts +73 -0
  245. package/packages/selector/tests/runtime/sediment-signals.spec.ts +124 -0
  246. package/packages/selector/tests/runtime/sediment-span.spec.ts +92 -0
  247. package/packages/selector/tests/runtime/session-events.spec.ts +27 -0
  248. package/packages/selector/tests/runtime/session-file-decode.spec.ts +281 -0
  249. package/packages/selector/tests/runtime/settings-unwrap.spec.ts +58 -0
  250. package/packages/selector/tests/runtime/shallow-primitives.spec.ts +135 -0
  251. package/packages/selector/tests/runtime/sidechannel.spec.ts +241 -0
  252. package/packages/selector/tests/runtime/stats-backfill-scheduler.spec.ts +167 -0
  253. package/packages/selector/tests/runtime/stats-backfill.spec.ts +350 -0
  254. package/packages/selector/tests/runtime/stats-db.spec.ts +361 -0
  255. package/packages/selector/tests/runtime/stats-privacy.spec.ts +55 -0
  256. package/packages/selector/tests/runtime/stats-sync.spec.ts +278 -0
  257. package/packages/selector/tests/runtime/summary-command.spec.ts +154 -0
  258. package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +159 -0
  259. package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +53 -0
  260. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +217 -0
  261. package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +52 -0
  262. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +79 -0
  263. package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +76 -0
  264. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +121 -0
  265. package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +82 -0
  266. package/packages/selector/tests/runtime/toolclass.spec.ts +156 -0
  267. package/packages/selector/tests/runtime/value.spec.ts +23 -0
  268. package/packages/selector/tests/savings-sessions.client.spec.tsx +140 -0
  269. package/packages/selector/tests/settings-seat.client.spec.ts +215 -0
  270. package/packages/selector/tests/standing-generation.host.spec.ts +724 -0
  271. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +269 -0
  272. package/packages/selector/tests/support/cache-prefix-audit.ts +105 -0
  273. package/packages/selector/tests/support/mock-adapter.ts +37 -0
  274. package/packages/selector/tests/support/ui-primitives.tsx +34 -0
  275. package/packages/selector/tsconfig.json +11 -0
  276. package/packages/selector/tsdown.client.config.ts +102 -0
  277. package/packages/selector/tsdown.config.ts +20 -0
  278. package/pnpm-workspace.yaml +76 -0
  279. package/screenshots.json +6 -3
  280. package/scripts/capture-profile-baseline.mjs +42 -0
  281. package/scripts/cell-browser-e2e.mjs +354 -0
  282. package/scripts/generate-tokenizer-fixtures.py +81 -0
  283. package/scripts/generate-vision-fixtures.py +208 -0
  284. package/scripts/hosts.d.mts +3 -0
  285. package/scripts/hosts.mjs +79 -0
  286. package/scripts/packed-components-smoke.mjs +763 -0
  287. package/scripts/packed-install-e2e.mjs +1346 -0
  288. package/scripts/sediment-latency-report.mjs +63 -0
  289. package/scripts/sync-hosts.mjs +174 -0
  290. package/scripts/toolclass-corpus-replay.mjs +281 -0
  291. package/scripts/verify-release.mjs +343 -0
  292. package/tests/TEST_INVENTORY.md +41 -0
  293. package/tsconfig.base.json +18 -0
  294. package/tsconfig.json +7 -0
  295. package/tsconfig.tests.json +15 -0
  296. package/vitest.built.config.ts +9 -0
  297. package/vitest.config.ts +54 -0
  298. /package/{assets → packages/selector/assets}/deepseek-v4/LICENSE.DeepSeek-V4-Pro.txt +0 -0
  299. /package/{assets → packages/selector/assets}/deepseek-v4/manifest.json +0 -0
  300. /package/{assets → packages/selector/assets}/deepseek-v4/tokenizer.json +0 -0
  301. /package/{assets → packages/selector/assets}/deepseek-v4/tokenizer_config.json +0 -0
  302. /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/LICENSE.DeepSeek-V4-Flash-Vision-Exp.txt +0 -0
  303. /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/manifest.json +0 -0
  304. /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/tokenizer.json +0 -0
  305. /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/tokenizer_config.json +0 -0
  306. /package/{cordis.patch.yml → packages/selector/cordis.patch.yml} +0 -0
  307. /package/{lib → packages/selector/lib}/index.d.ts +0 -0
  308. /package/{lib → packages/selector/lib}/invariant.d.ts +0 -0
  309. /package/{lib → packages/selector/lib}/invariant.js +0 -0
  310. /package/{lib → packages/selector/lib}/tail-trim.js +0 -0
@@ -0,0 +1,178 @@
1
+ {
2
+ "name": "dsh-context-compression-improved",
3
+ "version": "0.11.0",
4
+ "description": "One-install context-compression selector bundle for DeepSeek Harness",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/index.d.ts",
11
+ "default": "./lib/index.js"
12
+ },
13
+ "./invariant": {
14
+ "types": "./lib/invariant.d.ts",
15
+ "default": "./lib/invariant.js"
16
+ },
17
+ "./pruner": {
18
+ "types": "./lib/pruner.d.ts",
19
+ "default": "./lib/pruner.js"
20
+ },
21
+ "./client": {
22
+ "types": "./lib/client.d.ts",
23
+ "default": "./lib/client.js"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "lib/**/*.js",
29
+ "lib/**/*.d.ts",
30
+ "cordis.patch.yml",
31
+ "dsh.plugin.json",
32
+ "screenshots.json",
33
+ "assets",
34
+ "README.md",
35
+ "README.zh.md",
36
+ "LICENSE",
37
+ "THIRD_PARTY_NOTICES.md"
38
+ ],
39
+ "dsh": {
40
+ "client": {
41
+ "inject": [
42
+ "@deepseek-ai/dsh-client-locale",
43
+ "@deepseek-ai/dsh-client-ui-slots",
44
+ "@deepseek-ai/dsh-client-ui-settings"
45
+ ],
46
+ "platform": "web"
47
+ },
48
+ "bundle": {
49
+ "patch": "./cordis.patch.yml"
50
+ },
51
+ "pluginDependencies": [
52
+ "dsh-reference-session-collector"
53
+ ]
54
+ },
55
+ "scripts": {
56
+ "bundle": "tsdown --config tsdown.config.ts && tsdown --config tsdown.client.config.ts",
57
+ "typecheck": "tsc --noEmit -p tsconfig.json",
58
+ "test": "vitest run --root ../.. --config vitest.config.ts --project runtime --project selector-host --project selector-client",
59
+ "pack:dry-run": "npm pack --dry-run"
60
+ },
61
+ "repository": {
62
+ "type": "git",
63
+ "url": "git+https://github.com/drscrewdriver/dsh-context-compression-improved.git",
64
+ "directory": "packages/selector"
65
+ },
66
+ "homepage": "https://github.com/drscrewdriver/dsh-context-compression-improved#readme",
67
+ "bugs": {
68
+ "url": "https://github.com/drscrewdriver/dsh-context-compression-improved/issues"
69
+ },
70
+ "author": "WilliamShi666",
71
+ "engines": {
72
+ "node": "^22.19.0 || >=24.0.0",
73
+ "dsh": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1"
74
+ },
75
+ "keywords": [
76
+ "deepseek",
77
+ "harness",
78
+ "context",
79
+ "compression",
80
+ "plugin"
81
+ ],
82
+ "license": "MIT",
83
+ "publishConfig": {
84
+ "access": "public",
85
+ "registry": "https://registry.npmjs.org",
86
+ "tag": "latest"
87
+ },
88
+ "dependencies": {
89
+ "@deepseek-ai/schemastery": "3.18.4",
90
+ "@huggingface/tokenizers": "0.1.3",
91
+ "js-yaml": "^4.3.2",
92
+ "dsh-reference-session-collector": ">=0.2.0-beta.0 <0.3.0"
93
+ },
94
+ "peerDependencies": {
95
+ "@deepseek-ai/cordis": ">=4.0.1 <5",
96
+ "@deepseek-ai/cordis-plugin-include": ">=1.0.6 <2",
97
+ "@deepseek-ai/cordis-plugin-loader": ">=1.0.2 <2",
98
+ "@deepseek-ai/dsh-agent": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
99
+ "@deepseek-ai/dsh-agent-presets": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
100
+ "@deepseek-ai/dsh-client-locale": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
101
+ "@deepseek-ai/dsh-client-store": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
102
+ "@deepseek-ai/dsh-client-ui-primitives": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
103
+ "@deepseek-ai/dsh-client-ui-session": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
104
+ "@deepseek-ai/dsh-client-ui-settings": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
105
+ "@deepseek-ai/dsh-client-ui-slots": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
106
+ "@deepseek-ai/dsh-client-ui-workspace": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
107
+ "@deepseek-ai/dsh-command-compact": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
108
+ "@deepseek-ai/dsh-compaction": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
109
+ "@deepseek-ai/dsh-compaction-basic": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
110
+ "@deepseek-ai/dsh-invariants": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
111
+ "@deepseek-ai/dsh-llm": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
112
+ "@deepseek-ai/dsh-session": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
113
+ "@deepseek-ai/dsh-settings": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
114
+ "@deepseek-ai/dsh-system-prompt": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
115
+ "@deepseek-ai/dsh-token-meter": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
116
+ "@deepseek-ai/dsh-tools": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
117
+ "react": ">=18 <19"
118
+ },
119
+ "peerDependenciesMeta": {
120
+ "@deepseek-ai/dsh-agent": {
121
+ "optional": true
122
+ },
123
+ "@deepseek-ai/dsh-agent-presets": {
124
+ "optional": true
125
+ },
126
+ "@deepseek-ai/dsh-client-locale": {
127
+ "optional": true
128
+ },
129
+ "@deepseek-ai/dsh-client-store": {
130
+ "optional": true
131
+ },
132
+ "@deepseek-ai/dsh-client-ui-primitives": {
133
+ "optional": true
134
+ },
135
+ "@deepseek-ai/dsh-client-ui-session": {
136
+ "optional": true
137
+ },
138
+ "@deepseek-ai/dsh-client-ui-settings": {
139
+ "optional": true
140
+ },
141
+ "@deepseek-ai/dsh-client-ui-slots": {
142
+ "optional": true
143
+ },
144
+ "@deepseek-ai/dsh-client-ui-workspace": {
145
+ "optional": true
146
+ },
147
+ "@deepseek-ai/dsh-command-compact": {
148
+ "optional": true
149
+ },
150
+ "@deepseek-ai/dsh-compaction": {
151
+ "optional": true
152
+ },
153
+ "@deepseek-ai/dsh-compaction-basic": {
154
+ "optional": true
155
+ },
156
+ "@deepseek-ai/dsh-invariants": {
157
+ "optional": true
158
+ },
159
+ "@deepseek-ai/dsh-llm": {
160
+ "optional": true
161
+ },
162
+ "@deepseek-ai/dsh-session": {
163
+ "optional": true
164
+ },
165
+ "@deepseek-ai/dsh-settings": {
166
+ "optional": true
167
+ },
168
+ "@deepseek-ai/dsh-system-prompt": {
169
+ "optional": true
170
+ },
171
+ "@deepseek-ai/dsh-token-meter": {
172
+ "optional": true
173
+ },
174
+ "@deepseek-ai/dsh-tools": {
175
+ "optional": true
176
+ }
177
+ }
178
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "screenshots": []
3
+ }
@@ -0,0 +1,352 @@
1
+ /**
2
+ * CompressionProfileControls: dropdown selector for compression profiles,
3
+ * plus AutoCompactThresholdControls and CodeSkeletonControls sub-components.
4
+ *
5
+ * Extracted from CompressionProfileSelector.tsx to reduce god-module size.
6
+ *
7
+ * @module dsh-context-compression-improved/client/CompressionProfileControls
8
+ */
9
+
10
+ import { useEffect, useId, useState } from 'react'
11
+ import { IconChevronDownOutlineMedium, Menu } from '@deepseek-ai/dsh-client-ui-primitives'
12
+ import type { ContextCompressionLocaleKey } from './locales.ts'
13
+ import css from './CompressionProfileSelector.module.css'
14
+ import {
15
+ AUTO_COMPACT_THRESHOLD_LIMITS,
16
+ COMPRESSION_PROFILES,
17
+ isValidAutoCompactThresholdPercent,
18
+ type CompressionProfile,
19
+ type CustomCompressionPolicyV3,
20
+ } from '../profiles.ts'
21
+ import type { CompressionProfileSelectorProps } from './CompressionProfileSelector.tsx'
22
+ import { CustomPolicyEditor, editableCustom } from './CustomPolicyEditor.tsx'
23
+
24
+ export function CompressionProfileControls({
25
+ useCompression, select, saveCustom, resetCustom, savePtcCustom, resetPtcCustom, t, showCustomEditor,
26
+ }: CompressionProfileSelectorProps & { showCustomEditor: boolean }) {
27
+ const state = useCompression(snapshot => snapshot)
28
+ // Harness 0.1.5 dropped browser-side agentPreset from session summaries; see
29
+ // the section component note. Only Minimal used to block initial
30
+ // configuration, and that signal is no longer available client-side.
31
+ const contextCompressionAvailable = true
32
+ const [open, setOpen] = useState(false)
33
+ const [saving, setSaving] = useState(false)
34
+ const [saveError, setSaveError] = useState<string | null>(null)
35
+ const [draft, setDraft] = useState<CustomCompressionPolicyV3 | null>(null)
36
+ const [ptcDraft, setPtcDraft] = useState<CustomCompressionPolicyV3 | null>(null)
37
+ const unavailableId = useId()
38
+ const current = state.value?.profile ?? 'balanced'
39
+ useEffect(() => {
40
+ if (state.status === 'ready' && state.writable && contextCompressionAvailable) return
41
+ setOpen(false)
42
+ }, [contextCompressionAvailable, state.status, state.writable])
43
+ useEffect(() => {
44
+ const custom = state.value?.custom
45
+ setDraft((current === 'custom' || current === 'tokenpilot-inspired') && custom !== undefined ? editableCustom(custom) : null)
46
+ }, [current, state.value?.custom])
47
+ useEffect(() => {
48
+ const ptcCustom = state.value?.ptcCustom
49
+ setPtcDraft(current === 'ptc' && ptcCustom !== undefined ? editableCustom(ptcCustom) : null)
50
+ }, [current, state.value?.ptcCustom])
51
+ if (state.status === 'unavailable') return null
52
+ const busy = state.status === 'loading' || saving
53
+ const label = busy ? t('status.loading') : t(`profile.${current}`)
54
+ return (
55
+ <div className={css.root}>
56
+ <Menu
57
+ open={open && contextCompressionAvailable}
58
+ onClose={() => { setOpen(false) }}
59
+ selectedId={current}
60
+ items={COMPRESSION_PROFILES.map(profile => ({
61
+ id: profile,
62
+ label: (
63
+ <span className={css.menuCopy}>
64
+ <span className={css.menuTitle}>{t(`profile.${profile}`)}</span>
65
+ <span className={css.menuDetail}>{t(`detail.${profile}`)}</span>
66
+ </span>
67
+ ),
68
+ }))}
69
+ onSelect={(id) => {
70
+ setOpen(false)
71
+ if (id === current || !COMPRESSION_PROFILES.includes(id as CompressionProfile)) return
72
+ setSaveError(null)
73
+ setSaving(true)
74
+ void select(id as CompressionProfile).then(
75
+ () => { setSaving(false) },
76
+ (error: unknown) => {
77
+ setSaving(false)
78
+ setSaveError(error instanceof Error && error.message !== '' ? error.message : t('status.saveFailed'))
79
+ },
80
+ )
81
+ }}
82
+ align="start"
83
+ portal
84
+ anchor={(
85
+ <button
86
+ type="button"
87
+ className={css.button}
88
+ aria-haspopup="menu"
89
+ aria-expanded={open && contextCompressionAvailable}
90
+ aria-describedby={contextCompressionAvailable ? undefined : unavailableId}
91
+ disabled={busy || !state.writable || !contextCompressionAvailable}
92
+ onClick={() => { setOpen(value => !value) }}
93
+ >
94
+ <span className={css.copy}>
95
+ <span className={css.label}>{t('label')}</span>
96
+ <span className={css.value}>{label}</span>
97
+ </span>
98
+ <IconChevronDownOutlineMedium className={css.chevron} />
99
+ </button>
100
+ )}
101
+ />
102
+ {contextCompressionAvailable ? null : (
103
+ <div id={unavailableId} className={css.unavailable} role="status">
104
+ {t('status.minimalUnavailable')}
105
+ </div>
106
+ )}
107
+ <div className={css.pricing}>{t('pricing.disclosure')}</div>
108
+ <div className={css.settingsHint}>
109
+ {t('autoCompact.summaryHint').replace('{percent}', String(state.value?.autoCompact?.thresholdPercent ?? AUTO_COMPACT_THRESHOLD_LIMITS.default))}
110
+ </div>
111
+ {current !== 'custom' && current !== 'tokenpilot-inspired' || showCustomEditor ? null : (
112
+ <div className={css.settingsHint}>{t('custom.settingsHint')}</div>
113
+ )}
114
+ {current !== 'custom' && current !== 'tokenpilot-inspired' || draft === null || !showCustomEditor ? null : (
115
+ <CustomPolicyEditor
116
+ value={draft}
117
+ disabled={busy || !state.writable || !contextCompressionAvailable}
118
+ setValue={setDraft}
119
+ save={() => saveCustom(structuredClone(draft))}
120
+ reset={resetCustom}
121
+ settle={(operation) => {
122
+ setSaveError(null)
123
+ setSaving(true)
124
+ void operation().then(
125
+ () => { setSaving(false) },
126
+ (error: unknown) => {
127
+ setSaving(false)
128
+ setSaveError(error instanceof Error && error.message !== '' ? error.message : t('status.saveFailed'))
129
+ },
130
+ )
131
+ }}
132
+ t={t}
133
+ />
134
+ )}
135
+ {current !== 'ptc' || ptcDraft === null || !showCustomEditor ? null : (
136
+ <CustomPolicyEditor
137
+ value={ptcDraft}
138
+ disabled={busy || !state.writable || !contextCompressionAvailable}
139
+ setValue={setPtcDraft}
140
+ save={() => savePtcCustom(structuredClone(ptcDraft))}
141
+ reset={resetPtcCustom}
142
+ settle={(operation) => {
143
+ setSaveError(null)
144
+ setSaving(true)
145
+ void operation().then(
146
+ () => { setSaving(false) },
147
+ (error: unknown) => {
148
+ setSaving(false)
149
+ setSaveError(error instanceof Error && error.message !== '' ? error.message : t('status.saveFailed'))
150
+ },
151
+ )
152
+ }}
153
+ t={t}
154
+ />
155
+ )}
156
+ {saveError === null ? null : <div className={css.error} role="alert">{saveError}</div>}
157
+ </div>
158
+ )
159
+ }
160
+
161
+ interface AutoCompactThresholdControlsProps {
162
+ value: number
163
+ disabled: boolean
164
+ save: (thresholdPercent: number) => Promise<void>
165
+ settle: (operation: () => Promise<void>) => void
166
+ t: (key: ContextCompressionLocaleKey) => string
167
+ }
168
+
169
+ /**
170
+ * The authoritative Auto Compact threshold editor for the context-compression
171
+ * section. A typed number input and its save path are kept deliberately simple;
172
+ * values outside the recommended 70–85 band warn without blocking.
173
+ */
174
+ export function AutoCompactThresholdControls({ value, disabled, save, settle, t }: AutoCompactThresholdControlsProps) {
175
+ const [draft, setDraft] = useState(String(value))
176
+ useEffect(() => { setDraft(String(value)) }, [value])
177
+ const parsed = Number(draft)
178
+ // Number inputs legally produce value-equivalent drafts such as '8e1';
179
+ // only the parsed value needs to be a valid threshold.
180
+ const valid = isValidAutoCompactThresholdPercent(parsed)
181
+ const risk = !valid
182
+ ? 'autoCompact.invalid'
183
+ : parsed < 70 ? 'autoCompact.riskLow'
184
+ : parsed > 85 ? 'autoCompact.riskHigh'
185
+ : undefined
186
+ return (
187
+ <section className={css.autoCompact} aria-labelledby="context-compression-autocompact-title">
188
+ <h3 id="context-compression-autocompact-title" className={css.autoCompactTitle}>{t('autoCompact.title')}</h3>
189
+ <p className={css.customNote}>{t('autoCompact.description')}</p>
190
+ <label className={css.field}>
191
+ <span>{t('autoCompact.inputLabel')}</span>
192
+ <input
193
+ type="number"
194
+ value={draft}
195
+ min={AUTO_COMPACT_THRESHOLD_LIMITS.min}
196
+ max={AUTO_COMPACT_THRESHOLD_LIMITS.max}
197
+ step={AUTO_COMPACT_THRESHOLD_LIMITS.step}
198
+ disabled={disabled}
199
+ aria-invalid={!valid}
200
+ onChange={(event) => { setDraft(event.currentTarget.value) }}
201
+ />
202
+ </label>
203
+ {risk === undefined ? null : (
204
+ <div className={risk === 'autoCompact.invalid' ? css.error : css.autoCompactRisk} role={risk === 'autoCompact.invalid' ? 'alert' : 'note'}>
205
+ {t(risk)}
206
+ </div>
207
+ )}
208
+ <div className={css.actions}>
209
+ <button
210
+ type="button"
211
+ disabled={disabled || !valid || parsed === value}
212
+ onClick={() => { settle(() => save(parsed)) }}
213
+ >
214
+ {t('autoCompact.save')}
215
+ </button>
216
+ </div>
217
+ </section>
218
+ )
219
+ }
220
+
221
+ interface CodeSkeletonControlsProps {
222
+ value: boolean
223
+ disabled: boolean
224
+ save: (enabled: boolean) => Promise<void>
225
+ settle: (operation: () => Promise<void>) => void
226
+ t: (key: ContextCompressionLocaleKey) => string
227
+ }
228
+
229
+ /**
230
+ * The authoritative code-skeleton reducer gate for the context-compression
231
+ * section. Deliberately minimal — an on/off select plus its own save path —
232
+ * because the gate is orthogonal to every profile and carries no parameters.
233
+ */
234
+ interface IntentSummaryControlsProps {
235
+ value: boolean
236
+ disabled: boolean
237
+ save: (enabled: boolean) => Promise<void>
238
+ settle: (operation: () => Promise<void>) => void
239
+ t: (key: ContextCompressionLocaleKey) => string
240
+ }
241
+
242
+ /**
243
+ * The turn-tail intent summary fold gate. Same deliberately minimal shape as
244
+ * the code-skeleton gate: an on/off select with its own save path; the fold
245
+ * itself is gated by the growth constants and the per-session /ctx-summary
246
+ * override, none of which belong in this card.
247
+ */
248
+ export function IntentSummaryControls({ value, disabled, save, settle, t }: IntentSummaryControlsProps) {
249
+ return (
250
+ <section className={css.autoCompact} aria-labelledby="context-compression-intentsummary-title">
251
+ <h3 id="context-compression-intentsummary-title" className={css.autoCompactTitle}>{t('intentSummary.title')}</h3>
252
+ <p className={css.customNote}>{t('intentSummary.description')}</p>
253
+ <label className={css.field}>
254
+ <span>{t('intentSummary.enabled')}</span>
255
+ <select
256
+ value={value ? 'on' : 'off'}
257
+ disabled={disabled}
258
+ onChange={(event) => { settle(() => save(event.currentTarget.value === 'on')) }}
259
+ >
260
+ <option value="on">{t('intentSummary.enabled.on')}</option>
261
+ <option value="off">{t('intentSummary.enabled.off')}</option>
262
+ </select>
263
+ </label>
264
+ </section>
265
+ )
266
+ }
267
+
268
+ interface MonitorPanelControlsProps {
269
+ value: boolean
270
+ disabled: boolean
271
+ save: (enabled: boolean) => Promise<void>
272
+ settle: (operation: () => Promise<void>) => void
273
+ t: (key: ContextCompressionLocaleKey) => string
274
+ }
275
+
276
+ /**
277
+ * Visibility switch of the floating compression-monitor panel (FAB). The
278
+ * panel itself is a body-level overlay driven by the monitor route; this card
279
+ * only decides whether it mounts.
280
+ */
281
+ export function MonitorPanelControls({ value, disabled, save, settle, t }: MonitorPanelControlsProps) {
282
+ return (
283
+ <section className={css.autoCompact} aria-labelledby="context-compression-monitorpanel-title">
284
+ <h3 id="context-compression-monitorpanel-title" className={css.autoCompactTitle}>{t('monitorPanel.title')}</h3>
285
+ <p className={css.customNote}>{t('monitorPanel.description')}</p>
286
+ <label className={css.field}>
287
+ <span>{t('monitorPanel.enabled')}</span>
288
+ <select
289
+ value={value ? 'on' : 'off'}
290
+ disabled={disabled}
291
+ onChange={(event) => { settle(() => save(event.currentTarget.value === 'on')) }}
292
+ >
293
+ <option value="on">{t('monitorPanel.enabled.on')}</option>
294
+ <option value="off">{t('monitorPanel.enabled.off')}</option>
295
+ </select>
296
+ </label>
297
+ </section>
298
+ )
299
+ }
300
+
301
+ export function CodeSkeletonControls({ value, disabled, save, settle, t }: CodeSkeletonControlsProps) {
302
+ return (
303
+ <section className={css.autoCompact} aria-labelledby="context-compression-codeskeleton-title">
304
+ <h3 id="context-compression-codeskeleton-title" className={css.autoCompactTitle}>{t('codeSkeleton.title')}</h3>
305
+ <p className={css.customNote}>{t('codeSkeleton.description')}</p>
306
+ <label className={css.field}>
307
+ <span>{t('codeSkeleton.enabled')}</span>
308
+ <select
309
+ value={value ? 'on' : 'off'}
310
+ disabled={disabled}
311
+ onChange={(event) => { settle(() => save(event.currentTarget.value === 'on')) }}
312
+ >
313
+ <option value="on">{t('codeSkeleton.enabled.on')}</option>
314
+ <option value="off">{t('codeSkeleton.enabled.off')}</option>
315
+ </select>
316
+ </label>
317
+ </section>
318
+ )
319
+ }
320
+
321
+ interface SedimentControlsProps {
322
+ value: boolean
323
+ disabled: boolean
324
+ save: (enabled: boolean) => Promise<void>
325
+ settle: (operation: () => Promise<void>) => void
326
+ t: (key: ContextCompressionLocaleKey) => string
327
+ }
328
+
329
+ /**
330
+ * Turn-tail sedimentation gate (plan cci-sedimentation-triage T3.7): on/off
331
+ * select with the display-impact disclosure in its description (M13) —
332
+ * replaced spans leave the transcript view; originals stay in the log.
333
+ */
334
+ export function SedimentControls({ value, disabled, save, settle, t }: SedimentControlsProps) {
335
+ return (
336
+ <section className={css.autoCompact} aria-labelledby="context-compression-sediment-title">
337
+ <h3 id="context-compression-sediment-title" className={css.autoCompactTitle}>{t('sediment.title')}</h3>
338
+ <p className={css.customNote}>{t('sediment.description')}</p>
339
+ <label className={css.field}>
340
+ <span>{t('sediment.enabled')}</span>
341
+ <select
342
+ value={value ? 'on' : 'off'}
343
+ disabled={disabled}
344
+ onChange={(event) => { settle(() => save(event.currentTarget.value === 'on')) }}
345
+ >
346
+ <option value="on">{t('sediment.enabled.on')}</option>
347
+ <option value="off">{t('sediment.enabled.off')}</option>
348
+ </select>
349
+ </label>
350
+ </section>
351
+ )
352
+ }