dsh-context-compression-improved 0.11.1 → 0.11.3

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 (311) 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} +1 -1
  5. package/{packages/selector/lib → lib}/client.js +27 -10
  6. package/{packages/selector/lib → lib}/index.js +101 -0
  7. package/package.json +125 -112
  8. package/screenshots.json +3 -6
  9. package/.agents/plans/improve/checklist.md +0 -32
  10. package/.agents/plans/improve/findings.md +0 -102
  11. package/.agents/plans/improve/spec.md +0 -53
  12. package/.agents/plans/improve/tasks.md +0 -70
  13. package/.gitattributes +0 -2
  14. package/.githooks/pre-push +0 -37
  15. package/.github/workflows/ci.yml +0 -47
  16. package/CHANGELOG.de.md +0 -580
  17. package/CHANGELOG.es.md +0 -588
  18. package/CHANGELOG.fr.md +0 -576
  19. package/CHANGELOG.it.md +0 -577
  20. package/CHANGELOG.ja.md +0 -261
  21. package/CHANGELOG.ko.md +0 -254
  22. package/CHANGELOG.md +0 -557
  23. package/CHANGELOG.ru.md +0 -554
  24. package/CHANGELOG.zh.md +0 -247
  25. package/CONTRIBUTING.md +0 -22
  26. package/README.de.md +0 -96
  27. package/README.es.md +0 -96
  28. package/README.fr.md +0 -96
  29. package/README.it.md +0 -96
  30. package/README.ja.md +0 -102
  31. package/README.ko.md +0 -102
  32. package/README.ru.md +0 -96
  33. package/SECURITY.md +0 -18
  34. package/assets/board.png +0 -0
  35. package/assets/context.png +0 -0
  36. package/assets/dshfind-card.svg +0 -33
  37. package/docs/assets/context-compression-selector-profiles.jpg +0 -0
  38. package/docs/assets/context-compression-selector-settings.png +0 -0
  39. package/docs/compat-0.1.5-report.md +0 -77
  40. package/docs/installation.de.md +0 -104
  41. package/docs/installation.es.md +0 -104
  42. package/docs/installation.fr.md +0 -104
  43. package/docs/installation.it.md +0 -104
  44. package/docs/installation.ja.md +0 -78
  45. package/docs/installation.ko.md +0 -78
  46. package/docs/installation.md +0 -103
  47. package/docs/installation.ru.md +0 -104
  48. package/docs/installation.zh.md +0 -100
  49. package/docs/repair-log.md +0 -657
  50. package/docs/shallow-teaching-preset-template.md +0 -46
  51. package/eslint.config.js +0 -30
  52. package/packages/selector/LICENSE +0 -21
  53. package/packages/selector/README.md +0 -26
  54. package/packages/selector/README.zh.md +0 -24
  55. package/packages/selector/THIRD_PARTY_NOTICES.md +0 -32
  56. package/packages/selector/docs/history-tool-call-working-set-spec.md +0 -112
  57. package/packages/selector/docs/native-tool-result-selector-spec.md +0 -34
  58. package/packages/selector/docs/subagent-cache-reuse-spec.md +0 -46
  59. package/packages/selector/lib/style.css +0 -350
  60. package/packages/selector/package.json +0 -178
  61. package/packages/selector/screenshots.json +0 -3
  62. package/packages/selector/src/client/CompressionProfileControls.tsx +0 -352
  63. package/packages/selector/src/client/CompressionProfileSelector.module.css +0 -199
  64. package/packages/selector/src/client/CompressionProfileSelector.tsx +0 -89
  65. package/packages/selector/src/client/CustomPolicyEditor.tsx +0 -216
  66. package/packages/selector/src/client/EstimatorControls.tsx +0 -277
  67. package/packages/selector/src/client/bridge-scope.ts +0 -125
  68. package/packages/selector/src/client/decode.ts +0 -68
  69. package/packages/selector/src/client/fab-pos.ts +0 -71
  70. package/packages/selector/src/client/index.ts +0 -438
  71. package/packages/selector/src/client/locales/de.ts +0 -167
  72. package/packages/selector/src/client/locales/es.ts +0 -167
  73. package/packages/selector/src/client/locales/fr.ts +0 -167
  74. package/packages/selector/src/client/locales/it.ts +0 -167
  75. package/packages/selector/src/client/locales/ja.ts +0 -167
  76. package/packages/selector/src/client/locales/ko.ts +0 -167
  77. package/packages/selector/src/client/locales/ru.ts +0 -167
  78. package/packages/selector/src/client/locales.ts +0 -334
  79. package/packages/selector/src/client/monitor-fab.ts +0 -445
  80. package/packages/selector/src/client/preset-options.ts +0 -88
  81. package/packages/selector/src/client/savings-card.tsx +0 -269
  82. package/packages/selector/src/client/scope-face.ts +0 -24
  83. package/packages/selector/src/client/settings-section.tsx +0 -156
  84. package/packages/selector/src/compat/host-generation.ts +0 -96
  85. package/packages/selector/src/compat/llm-messages.ts +0 -50
  86. package/packages/selector/src/compat/settings-lease.ts +0 -108
  87. package/packages/selector/src/compat/tool-result.ts +0 -91
  88. package/packages/selector/src/css-modules.d.ts +0 -6
  89. package/packages/selector/src/deepseek-v4-tokenizer.ts +0 -205
  90. package/packages/selector/src/estimator-catalog.ts +0 -104
  91. package/packages/selector/src/index.ts +0 -890
  92. package/packages/selector/src/invariant.ts +0 -113
  93. package/packages/selector/src/preset-overlay.ts +0 -749
  94. package/packages/selector/src/profiles.ts +0 -554
  95. package/packages/selector/src/pruner/content.ts +0 -199
  96. package/packages/selector/src/pruner/session.ts +0 -97
  97. package/packages/selector/src/pruner/state.ts +0 -61
  98. package/packages/selector/src/pruner/tuning.ts +0 -23
  99. package/packages/selector/src/pruner/types.ts +0 -78
  100. package/packages/selector/src/pruner.ts +0 -3222
  101. package/packages/selector/src/runtime/adaptive-cost.ts +0 -205
  102. package/packages/selector/src/runtime/audit.ts +0 -321
  103. package/packages/selector/src/runtime/config.ts +0 -887
  104. package/packages/selector/src/runtime/custom-policy.ts +0 -300
  105. package/packages/selector/src/runtime/deepseek-official-pricing.ts +0 -298
  106. package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +0 -254
  107. package/packages/selector/src/runtime/display-prefs.ts +0 -98
  108. package/packages/selector/src/runtime/fold-router.ts +0 -143
  109. package/packages/selector/src/runtime/measurement.ts +0 -444
  110. package/packages/selector/src/runtime/monitor.ts +0 -341
  111. package/packages/selector/src/runtime/panel-command.ts +0 -213
  112. package/packages/selector/src/runtime/reducers.ts +0 -1755
  113. package/packages/selector/src/runtime/retrieve.ts +0 -505
  114. package/packages/selector/src/runtime/savings-integral.ts +0 -117
  115. package/packages/selector/src/runtime/savings-projection.ts +0 -229
  116. package/packages/selector/src/runtime/savings-verify.ts +0 -446
  117. package/packages/selector/src/runtime/savings.ts +0 -526
  118. package/packages/selector/src/runtime/sediment-card.ts +0 -126
  119. package/packages/selector/src/runtime/sediment-clock.ts +0 -87
  120. package/packages/selector/src/runtime/sediment-guard.ts +0 -136
  121. package/packages/selector/src/runtime/sediment-publish.ts +0 -144
  122. package/packages/selector/src/runtime/sediment-span.ts +0 -170
  123. package/packages/selector/src/runtime/sediment.ts +0 -209
  124. package/packages/selector/src/runtime/session-events.ts +0 -30
  125. package/packages/selector/src/runtime/session-file-decode.ts +0 -523
  126. package/packages/selector/src/runtime/shallow-tools.ts +0 -342
  127. package/packages/selector/src/runtime/stats-backfill.ts +0 -541
  128. package/packages/selector/src/runtime/stats-db.ts +0 -492
  129. package/packages/selector/src/runtime/stats-schema.ts +0 -123
  130. package/packages/selector/src/runtime/stats-sync.ts +0 -307
  131. package/packages/selector/src/runtime/summary-command.ts +0 -127
  132. package/packages/selector/src/runtime/tail-trim.ts +0 -177
  133. package/packages/selector/src/runtime/token-count.ts +0 -72
  134. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +0 -233
  135. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +0 -204
  136. package/packages/selector/src/runtime/tokenpilot/advisor.ts +0 -419
  137. package/packages/selector/src/runtime/tokenpilot/benefit.ts +0 -200
  138. package/packages/selector/src/runtime/tokenpilot/dedup.ts +0 -82
  139. package/packages/selector/src/runtime/tokenpilot/estimator.ts +0 -151
  140. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +0 -53
  141. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +0 -65
  142. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +0 -125
  143. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +0 -37
  144. package/packages/selector/src/runtime/tokenpilot/locator.ts +0 -129
  145. package/packages/selector/src/runtime/tokenpilot/read-state.ts +0 -98
  146. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +0 -303
  147. package/packages/selector/src/runtime/tool-names.ts +0 -42
  148. package/packages/selector/src/runtime/toolclass.ts +0 -103
  149. package/packages/selector/src/runtime/triage/masks.ts +0 -128
  150. package/packages/selector/src/runtime/triage/shallow.ts +0 -132
  151. package/packages/selector/src/runtime/triage/signals.ts +0 -167
  152. package/packages/selector/src/runtime/triage/types.ts +0 -125
  153. package/packages/selector/src/runtime/types.ts +0 -396
  154. package/packages/selector/src/runtime/value.ts +0 -48
  155. package/packages/selector/src/settings-bridge.ts +0 -175
  156. package/packages/selector/tests/advisor-report.host.spec.ts +0 -223
  157. package/packages/selector/tests/auto-compact.client.spec.tsx +0 -214
  158. package/packages/selector/tests/built/client-artifact.spec.ts +0 -56
  159. package/packages/selector/tests/cache-prefix-audit.spec.ts +0 -123
  160. package/packages/selector/tests/code-skeleton.client.spec.ts +0 -98
  161. package/packages/selector/tests/compat/compat-narrow-waist.spec.ts +0 -150
  162. package/packages/selector/tests/custom-contract.client.spec.ts +0 -226
  163. package/packages/selector/tests/estimator-catalog.spec.ts +0 -70
  164. package/packages/selector/tests/estimator-channel.client.spec.tsx +0 -253
  165. package/packages/selector/tests/estimator-route-registration.host.spec.ts +0 -202
  166. package/packages/selector/tests/fab-pos.client.spec.ts +0 -47
  167. package/packages/selector/tests/fixtures/sediment-pool/52adc205-cloud-5.orig.txt +0 -231
  168. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-25.orig.txt +0 -236
  169. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-38.orig.txt +0 -220
  170. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-42.orig.txt +0 -140
  171. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-53.orig.txt +0 -117
  172. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-local-10.orig.txt +0 -67
  173. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-45.orig.txt +0 -119
  174. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-49.orig.txt +0 -119
  175. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-63.orig.txt +0 -131
  176. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-75.orig.txt +0 -196
  177. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-76.orig.txt +0 -71
  178. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-85.orig.txt +0 -126
  179. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-86.orig.txt +0 -86
  180. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-87.orig.txt +0 -50
  181. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-96.orig.txt +0 -102
  182. package/packages/selector/tests/helpers/legacy-namespace.ts +0 -35
  183. package/packages/selector/tests/helpers/legacy-settings/index.ts +0 -15
  184. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +0 -41
  185. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +0 -647
  186. package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +0 -78
  187. package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +0 -234
  188. package/packages/selector/tests/host-preset-overlay.host.spec.ts +0 -204
  189. package/packages/selector/tests/monitor-fab.client.spec.ts +0 -240
  190. package/packages/selector/tests/preset-options-write.client.spec.ts +0 -192
  191. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +0 -200
  192. package/packages/selector/tests/preset-overlay.host.spec.ts +0 -246
  193. package/packages/selector/tests/profiles.client.spec.tsx +0 -436
  194. package/packages/selector/tests/ptc-custom-write.client.spec.ts +0 -86
  195. package/packages/selector/tests/public/package-contract.client.spec.ts +0 -89
  196. package/packages/selector/tests/runtime/adaptive-cost.spec.ts +0 -167
  197. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +0 -230
  198. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +0 -272
  199. package/packages/selector/tests/runtime/advisor.spec.ts +0 -226
  200. package/packages/selector/tests/runtime/audit.spec.ts +0 -275
  201. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +0 -523
  202. package/packages/selector/tests/runtime/char-basis.spec.ts +0 -30
  203. package/packages/selector/tests/runtime/code-skeleton.spec.ts +0 -152
  204. package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +0 -186
  205. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +0 -122
  206. package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +0 -122
  207. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +0 -96
  208. package/packages/selector/tests/runtime/fixtures/profile-baseline.json +0 -273
  209. package/packages/selector/tests/runtime/fixtures/session-v4-dump.jsonl +0 -46
  210. package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +0 -106
  211. package/packages/selector/tests/runtime/fixtures/vision-golden.json +0 -459
  212. package/packages/selector/tests/runtime/fold-router.spec.ts +0 -140
  213. package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +0 -74
  214. package/packages/selector/tests/runtime/fresh-gate.spec.ts +0 -43
  215. package/packages/selector/tests/runtime/html-reducer.spec.ts +0 -212
  216. package/packages/selector/tests/runtime/intent-gate.spec.ts +0 -62
  217. package/packages/selector/tests/runtime/intent-summary.spec.ts +0 -156
  218. package/packages/selector/tests/runtime/jsonl-reducer.spec.ts +0 -79
  219. package/packages/selector/tests/runtime/line-mapping.spec.ts +0 -153
  220. package/packages/selector/tests/runtime/monitor.spec.ts +0 -354
  221. package/packages/selector/tests/runtime/panel-command.spec.ts +0 -101
  222. package/packages/selector/tests/runtime/prose-reducers.spec.ts +0 -133
  223. package/packages/selector/tests/runtime/ptc-profile.spec.ts +0 -133
  224. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +0 -2795
  225. package/packages/selector/tests/runtime/read-input-cap.spec.ts +0 -33
  226. package/packages/selector/tests/runtime/savings-accounting.spec.ts +0 -291
  227. package/packages/selector/tests/runtime/savings-integral.spec.ts +0 -169
  228. package/packages/selector/tests/runtime/savings-projection.spec.ts +0 -89
  229. package/packages/selector/tests/runtime/savings-verify.spec.ts +0 -226
  230. package/packages/selector/tests/runtime/savings.spec.ts +0 -139
  231. package/packages/selector/tests/runtime/search-reducer.spec.ts +0 -110
  232. package/packages/selector/tests/runtime/sediment-card.spec.ts +0 -111
  233. package/packages/selector/tests/runtime/sediment-config.spec.ts +0 -56
  234. package/packages/selector/tests/runtime/sediment-guard.spec.ts +0 -71
  235. package/packages/selector/tests/runtime/sediment-masks.spec.ts +0 -95
  236. package/packages/selector/tests/runtime/sediment-orchestrator.spec.ts +0 -166
  237. package/packages/selector/tests/runtime/sediment-pool-share.spec.ts +0 -65
  238. package/packages/selector/tests/runtime/sediment-publish.spec.ts +0 -142
  239. package/packages/selector/tests/runtime/sediment-real-shapes.spec.ts +0 -158
  240. package/packages/selector/tests/runtime/sediment-settings.spec.ts +0 -73
  241. package/packages/selector/tests/runtime/sediment-signals.spec.ts +0 -124
  242. package/packages/selector/tests/runtime/sediment-span.spec.ts +0 -92
  243. package/packages/selector/tests/runtime/session-events.spec.ts +0 -27
  244. package/packages/selector/tests/runtime/session-file-decode.spec.ts +0 -281
  245. package/packages/selector/tests/runtime/settings-unwrap.spec.ts +0 -58
  246. package/packages/selector/tests/runtime/shallow-primitives.spec.ts +0 -135
  247. package/packages/selector/tests/runtime/sidechannel.spec.ts +0 -241
  248. package/packages/selector/tests/runtime/stats-backfill-scheduler.spec.ts +0 -167
  249. package/packages/selector/tests/runtime/stats-backfill.spec.ts +0 -350
  250. package/packages/selector/tests/runtime/stats-db.spec.ts +0 -361
  251. package/packages/selector/tests/runtime/stats-privacy.spec.ts +0 -55
  252. package/packages/selector/tests/runtime/stats-sync.spec.ts +0 -278
  253. package/packages/selector/tests/runtime/summary-command.spec.ts +0 -154
  254. package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +0 -159
  255. package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +0 -53
  256. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +0 -217
  257. package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +0 -52
  258. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +0 -79
  259. package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +0 -76
  260. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +0 -121
  261. package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +0 -82
  262. package/packages/selector/tests/runtime/toolclass.spec.ts +0 -156
  263. package/packages/selector/tests/runtime/value.spec.ts +0 -23
  264. package/packages/selector/tests/savings-sessions.client.spec.tsx +0 -140
  265. package/packages/selector/tests/settings-seat.client.spec.ts +0 -215
  266. package/packages/selector/tests/standing-generation.host.spec.ts +0 -724
  267. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +0 -269
  268. package/packages/selector/tests/support/cache-prefix-audit.ts +0 -105
  269. package/packages/selector/tests/support/mock-adapter.ts +0 -37
  270. package/packages/selector/tests/support/ui-primitives.tsx +0 -34
  271. package/packages/selector/tsconfig.json +0 -11
  272. package/packages/selector/tsdown.client.config.ts +0 -102
  273. package/packages/selector/tsdown.config.ts +0 -20
  274. package/pnpm-workspace.yaml +0 -76
  275. package/scripts/capture-profile-baseline.mjs +0 -42
  276. package/scripts/cell-browser-e2e.mjs +0 -354
  277. package/scripts/generate-tokenizer-fixtures.py +0 -81
  278. package/scripts/generate-vision-fixtures.py +0 -208
  279. package/scripts/hosts.d.mts +0 -3
  280. package/scripts/hosts.mjs +0 -81
  281. package/scripts/packed-components-smoke.mjs +0 -763
  282. package/scripts/packed-install-e2e.mjs +0 -1346
  283. package/scripts/sediment-latency-report.mjs +0 -63
  284. package/scripts/sync-hosts.mjs +0 -174
  285. package/scripts/toolclass-corpus-replay.mjs +0 -281
  286. package/scripts/verify-release.mjs +0 -343
  287. package/tests/TEST_INVENTORY.md +0 -41
  288. package/tsconfig.base.json +0 -18
  289. package/tsconfig.json +0 -7
  290. package/tsconfig.tests.json +0 -15
  291. package/vitest.built.config.ts +0 -9
  292. package/vitest.config.ts +0 -54
  293. /package/{packages/selector/assets → assets}/deepseek-v4/LICENSE.DeepSeek-V4-Pro.txt +0 -0
  294. /package/{packages/selector/assets → assets}/deepseek-v4/manifest.json +0 -0
  295. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer.json +0 -0
  296. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer_config.json +0 -0
  297. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/LICENSE.DeepSeek-V4-Flash-Vision-Exp.txt +0 -0
  298. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/manifest.json +0 -0
  299. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer.json +0 -0
  300. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer_config.json +0 -0
  301. /package/{packages/selector/cordis.patch.yml → cordis.patch.yml} +0 -0
  302. /package/{packages/selector/lib → lib}/client.d.ts +0 -0
  303. /package/{packages/selector/lib → lib}/index.d.ts +0 -0
  304. /package/{packages/selector/lib → lib}/invariant.d.ts +0 -0
  305. /package/{packages/selector/lib → lib}/invariant.js +0 -0
  306. /package/{packages/selector/lib → lib}/profiles.d.ts +0 -0
  307. /package/{packages/selector/lib → lib}/pruner.d.ts +0 -0
  308. /package/{packages/selector/lib → lib}/pruner.js +0 -0
  309. /package/{packages/selector/lib → lib}/savings-integral.js +0 -0
  310. /package/{packages/selector/lib → lib}/tail-trim.js +0 -0
  311. /package/{packages/selector/lib → lib}/tool-result.js +0 -0
package/README.md CHANGED
@@ -1,121 +1,26 @@
1
1
  # dsh-context-compression-improved
2
2
 
3
- > An improved fork of [dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector) — an auditable tool-result context-compression selector for DeepSeek Harness — adding an orthogonal **code-skeleton compression gate**.
3
+ The installable Product Bundle for the unofficial community DeepSeek Harness context-compression selector.
4
4
 
5
- [中文说明](README.zh.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [Français](README.fr.md) · [Deutsch](README.de.md) · [Italiano](README.it.md) · [Русский](README.ru.md) · [Español](README.es.md) · [Changelog](CHANGELOG.md) · [Installation guide](docs/installation.md)
6
-
7
- > [!NOTE]
8
- > **What this fork adds on top of upstream 0.1.0:**
9
- >
10
- > - An orthogonal **code-skeleton compression gate** (`codeSkeleton.enabled`, default off): the first exposure of an oversized fresh source-code tool result can keep a skeleton of imports and declarations — bodies elided, error lines kept — before the regular reducers run.
11
- > - A settings toggle for that gate in the same selector settings section, independent of every compression profile.
12
- > - An ESLint baseline wired into CI, a `test:watch` TDD loop, and documentation in English, Simplified Chinese, Japanese, and Korean.
13
-
14
- > [!IMPORTANT]
15
- > This project supports **DeepSeek models only**. Lossless measurement and lossy compression depend on the bundled official DeepSeek tokenizers (`deepseek-v4-flash`, `deepseek-v4-pro`, `deepseek-v4-flash-vision-exp`). Everything else fails open and keeps original tool results. See the [upstream README](https://github.com/WilliamShi666/dsh-context-compression-selector#model-support-and-safety) for the full safety model.
16
-
17
- > [!TIP]
18
- > **Recommended: connect DeepSeek with your own API key via a custom Responses API endpoint.** Prefer a custom OpenAI-compatible endpoint (`/v1/responses`) over the official-account Messages API route: it does not go through the Anthropic-style message serialization, so requests never trip message-format issues or `tool_use`/`tool_result` pairing validation (the official route's resume-replay 400s cannot be repaired from the plugin side), and you can switch endpoint nodes over time and keep existing sessions running.
19
-
20
- <!-- host-compat:begin — generated by scripts/sync-hosts.mjs from scripts/hosts.mjs; DO NOT EDIT -->
21
- - **Supported DSH hosts:** `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` (21 rc releases across lines 0.1.0 / 0.1.1 / 0.1.2 / 0.1.5 / 0.1.7 / 0.2.0 / 0.2.1)
22
- <!-- host-compat:end -->
23
-
24
- ## What it is
25
-
26
- Long-running agent tasks accumulate a large amount of tool output. This community plugin adds selectable, auditable policies for reducing that tool-result context without modifying DeepSeek Harness core:
27
-
28
- - **Fresh** pre-compresses a newly oversized tool-result segment before the model receives it.
29
- - **Aggregate** pre-compresses fresh material again when it still grows beyond its budget.
30
- - **History / micro-compact** replaces eligible old tool results while preserving recent working context.
31
- - **TailTrim** is an optional Custom-only tail reduction path.
32
- - **Native** preserves the Harness-style head/middle/tail trimming as one explicit profile.
33
- - **Code skeleton (new, orthogonal gate)** — see below.
34
-
35
- Every decision is recorded: stage, reducer, trigger, skip reason, and exact token counts where available.
36
-
37
- ## Code skeleton gate (new)
38
-
39
- When the gate is enabled, an oversized **fresh source-code tool result** (for example a large `read_file`) first tries a skeleton reduction: imports and type/function/class declarations are kept, function bodies are elided with a marker, and error lines inside elided bodies are preserved. If the skeleton cannot be produced or verified, the result falls back to the original head pruning — the gate can never make context worse.
40
-
41
- Properties:
42
-
43
- - **Orthogonal**: independent of the selected profile (`balanced`, `savings`, `cache-strict`, `adaptive`, `custom`, `off`, `native`). All profiles get the gate.
44
- - **Off by default**: `codeSkeleton: { enabled: false }` until you turn it on.
45
- - **Measurement-gated**: requires the exact DeepSeek tokenizer; without it the plugin fails open.
46
- - **Session-frozen**: like all selector settings, changes affect newly observed sessions only.
47
- - **Strictly parsed**: `codeSkeleton` must be exactly `{ enabled: boolean }`; malformed values throw on the runtime side and show as unreadable in the browser UI.
48
-
49
- ## Settings UI
50
-
51
- Choose a compression profile, set the Auto Compact trigger level, and toggle code-skeleton compression in the same settings section. The toggle saves on change and shows the saved state on reload.
52
-
53
- ![Context Compression Selector settings UI](docs/assets/context-compression-selector-settings.png)
54
-
55
- ## Monitoring UI
56
-
57
- While compression runs, the plugin gives you a live view of what it saves: a **compression monitor** panel — net/gross savings, offsets, context usage, cache-hit rate, cost estimate, and the turn-tail intent-summary state, with a per-session resume/disable override right in the panel — next to the session's context trend chart.
58
-
59
- ![Compression monitor panel](assets/board.png)
60
-
61
- Context trend for a session under compression: per-step / per-turn token composition with a timing overlay; the scissors mark where reductions landed.
62
-
63
- ![Context trend chart](assets/context.png)
64
-
65
- ## Stats semantics and persistence
66
-
67
- Savings are reported in three distinct semantics — never merged:
68
-
69
- - **Stock (currently active)** — net savings still in effect on the live surface; it rises and falls as compressed content moves in and out.
70
- - **Cumulative (across N calls)** — the stock sampled at every request boundary and summed; answers "how much was saved historically" and survives host restarts.
71
- - **Money saved** — cumulative weighted by cache hit/miss at official list prices (deepseek-official official routes only; other routes show the token figure).
72
-
73
- Stats persist in SQLite (`~/.dsh/storages/dsh-context-compression/stats.sqlite`) across host restarts; a missing driver or write failure degrades visibly (panel badge, in-memory fallback). Historical sessions are backfilled from on-disk behavior records (host `sessionQuery` service preferred, read-only session-log parsing as fallback — session files are never written). Records contain counts, sequence numbers, session identifiers, and enum component names only; original text and free-form text never enter the database. Delete the file to reset stats completely.
74
-
75
- The `/ccip` command drives the panel in real time: `rows stock|total|money on|off`, `mode compact|full`, `session <id|latest|off>`, `flush`, `backfill pause|resume|status`.
76
-
77
- ## Install
78
-
79
- **Recommended: install from npm.** One version covers every supported Harness line — `latest` carries the full 17-rc enum (0.1.0-rc.2 → 0.2.1-rc.2); the runtime picks per-line code paths on its own.
5
+ **0.1.0 highlights:** DeepSeek V4 Flash Vision's official tokenizer is included; users can choose the model-driven Auto Compact threshold; standard profile watermarks and compression parameters follow that choice.
80
6
 
81
7
  ```sh
82
- dsh plugin --profile web add dsh-context-compression-improved@latest
83
- dsh --profile web --dump-config
84
- ```
85
-
86
- From source (alternative — the internal package names intentionally stay upstream's):
87
-
88
8
  ```sh
89
- git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
90
- cd dsh-context-compression-improved
91
- pnpm install --frozen-lockfile
92
- pnpm build
9
+ dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.5
10
+ # DSH 0.1.2 line:
11
+ # dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.2
12
+ dsh --profile web --dump-config
93
13
  ```
94
-
95
- Then pack the selector package and add it to a Harness profile — the full walkthrough, including verification and uninstall steps, is in the [installation guide](docs/installation.md).
96
-
97
- ## Development
98
-
99
- ```sh
100
- pnpm install --frozen-lockfile
101
- pnpm lint # ESLint baseline (also enforced in CI)
102
- pnpm typecheck # runtime + selector + tests tsc, plus the bundle step
103
- pnpm test # full vitest suite
104
- pnpm test:watch # TDD loop: write the failing regression first, then make it pass
105
- pnpm build
106
- pnpm verify:release
14
+ dsh --profile web --dump-config
107
15
  ```
108
16
 
109
- Contributions follow the upstream discipline: add the failing regression first, keep every production change inside this repository, and explain “triggered”, “enabled but skipped”, and fail-open evidence separately. See [CONTRIBUTING.md](CONTRIBUTING.md).
110
-
111
- ## Compatibility
112
-
113
- - Built and tested against the official DeepSeek Harness releases; peers declare the full supported-hosts enum (`0.1.0-rc.2` → `0.2.1-rc.2`, seven lines) and the plugin uses public plugin and profile APIs only. The supported list is generated into the managed block above by `scripts/sync-hosts.mjs` from `scripts/hosts.mjs`.
114
- - Requires Node `^22.19.0 || >=24` and pnpm `11.7.0`.
115
- - The plugin uses only public Harness extension APIs and does not modify Harness core code. Unofficial community project, not affiliated with or endorsed by DeepSeek.
17
+ This one command installs the single `dsh-context-compression-improved` package: the compression
18
+ runtime, the Host settings, the Web UI and the reversible preset overlay all ship in it.
19
+ The Bundle contributes Host settings, the Web UI, and a reversible preset overlay. All presets
20
+ except the exact built-in `minimal` id receive the compression stack; switching non-Minimal
21
+ presets preserves the saved selector settings. Minimal pauses plugin compression without
22
+ deleting the setting.
116
23
 
117
- ## Credits and license
24
+ Verified compatibility: DeepSeek Harness `dsh-v0.1.1-rc.2` and `dsh-v0.1.2-alpha.5`, Node `^22.19.0 || >=24`. No Harness core patch is required.
118
25
 
119
- - Upstream project and all prior work: [WilliamShi666/dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector) by WilliamShi666 (MIT).
120
- - Fork additions (code-skeleton gate, tooling, localized docs): drscrewdriver.
121
- - MIT — see [LICENSE](LICENSE) (upstream copyright notice retained) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for bundled tokenizer provenance.
26
+ See the [full README](https://github.com/WilliamShi666/dsh-context-compression-improved#readme) for profiles, defaults, audit evidence, Adaptive/cache limitations, upgrade/removal, and security guidance. This package is not affiliated with or endorsed by DeepSeek.
package/README.zh.md CHANGED
@@ -1,114 +1,24 @@
1
1
  # dsh-context-compression-improved
2
2
 
3
- > [dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector) 的改进版 fork——面向 DeepSeek Harness 的可审计工具结果上下文压缩选择器,新增正交的**代码骨架压缩门*。
3
+ 这是可直接安装的非官方社区 DeepSeek Harness 上下文压缩选择器 Product Bundle。
4
4
 
5
- [English](README.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [Français](README.fr.md) · [Deutsch](README.de.md) · [Italiano](README.it.md) · [Русский](README.ru.md) · [Español](README.es.md) · [更新日志](CHANGELOG.zh.md) · [安装教程](docs/installation.zh.md)
6
-
7
- > [!NOTE]
8
- > **本fork 在上游 0.1.0 之上新增:*
9
- >
10
- > - 正交的**代码骨架压缩门**(`codeSkeleton.enabled`,默认关闭):超大源码类工具结果首次曝光时,可先保留导入与声明的骨架——省略函数体并保留错误行——再进入常规 reducer。
11
- > - 同一选择器设置区内新增该门的开关,独立于所有压缩 Profile。
12
- > - 接入 CI 的 ESLint 基线、`test:watch` TDD 环路,以及英/中日韩四语文档。
13
-
14
- > [!IMPORTANT]
15
- > 本项目仅支持 **DeepSeek 模型**。无损测量与有损压缩依赖内置的 DeepSeek 官方 tokenizer(`deepseek-v4-flash`、`deepseek-v4-pro`、`deepseek-v4-flash-vision-exp`)。其余模型一律 fail-open 并保留原始工具结果。完整安全模型见[上游 README](https://github.com/WilliamShi666/dsh-context-compression-selector#model-support-and-safety)。
16
-
17
- > [!TIP]
18
- > **推荐接入方式:用 API key 以自定义 Responses API 连接 DeepSeek。** 建议走自定义 OpenAI 兼容端点(`/v1/responses`)而不是官方账号的 Messages API 路由:前者不经过 Anthropic 风格的消息序列化,不会因为 message 格式而出现问题,可避开 `tool_use`/`tool_result` 配对校验限制(官方路由 resume-replay 时的 400 插件侧无法修复);也便于按时间切换节点后接续会话。
19
-
20
- <!-- host-compat:begin — generated by scripts/sync-hosts.mjs from scripts/hosts.mjs; DO NOT EDIT -->
21
- - **支持的 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`(覆盖 0.1.0 / 0.1.1 / 0.1.2 / 0.1.5 / 0.1.7 / 0.2.0 / 0.2.1 七条线共 21 个 rc)
22
- <!-- host-compat:end -->
23
-
24
- ## 它是什么
25
-
26
- 长时运行的 agent 任务会积累大量工具输出。本社区插件在不修改 DeepSeek Harness 核心的前提下,提供可选、可审计的工具结果上下文压缩策略:
27
-
28
- - **Fresh**:在模型收到之前,预压缩新近超限的工具结果段。
29
- - **Aggregate**:当 Fresh 压缩后仍超出预算时再次预压缩。
30
- - **History / micro-compact**:在保护近期工作上下文的前提下替换符合条件的旧工具结果。
31
- - **TailTrim**:仅在 Custom 下可选的尾窗收缩路径。
32
- - **Native**:把 Harness 原生头中尾裁剪保留为一个显式 Profile。
33
- - **代码骨架(新增,正交门)**——见下节。
34
-
35
- 每个决策都会留痕:阶段、reducer、触发原因、跳过原因,以及可得时的精确 token 数。
36
-
37
- ## 代码骨架门(新增)
38
-
39
- 开启后,超大**源码类新工具结果**(例如大型 `read_file`)会先尝试骨架化压缩:保留导入与类型/函数/类声明,省略函数体并加占位标记,被省略函数体内的错误行予以保留。若骨架无法生成或无法通过验证,则回退到原有的头部裁剪——这道门不会让上下文变得更差。
40
-
41
- 特性:
42
-
43
- - **正交**:独立于所选 Profile(`balanced`、`savings`、`cache-strict`、`adaptive`、`custom`、`off`、`native`),所有 Profile 都能拿到这道门。
44
- - **默认关闭**:`codeSkeleton: { enabled: false }`,需要显式开启。
45
- - **测量前置**:需要精确 DeepSeek tokenizer;不可用时 fail-open。
46
- - **会话冻结**:与所有选择器设置一致,修改只影响新观察的会话。
47
- - **严格解析**:`codeSkeleton` 必须恰好是 `{ enabled: boolean }`;畸形输入在运行时侧抛错、浏览器侧显示不可读。
48
-
49
- ## 设置界面
50
-
51
- 在同一设置区内选择压缩 Profile、调整 Auto Compact 触发水位,并开关代码骨架压缩。开关即改即存,刷新后显示已保存状态。
52
-
53
- ![Context Compression Selector 设置界面](docs/assets/context-compression-selector-settings.png)
54
-
55
- ## 监控界面
56
-
57
- 压缩运行时,插件提供节省量的实时视图:**压缩监控**悬浮面板——净节省/毛节省/抵消/上下文占用/缓存命中率/成本估算/回合末意图摘要状态,面板内可直接对当前会话恢复或停用——以及会话的上下文趋势图。
58
-
59
- ![压缩监控面板](assets/board.png)
60
-
61
- 压缩会话的上下文趋势:逐步骤/轮次的 token 组成与耗时叠加,剪刀标记指示裁剪/折叠落点。
62
-
63
- ![上下文趋势图](assets/context.png)
64
-
65
- ## 统计口径与持久化
66
-
67
- 节省统计分三个口径,语义不同、互不替代:
68
-
69
- - **存量(当前生效)**——当前上下文面上仍在生效的净节省,随压缩内容进出面而涨落;
70
- - **累计(按 N 次 call)**——每个请求边界对存量的采样求和,回答"历史上总共省了多少",跨宿主重启保留;
71
- - **省钱估计**——累计按缓存命中/未命中分权折算官方牌价(仅 deepseek-official 官方路由可解,其余只显示 token 口径)。
72
-
73
- 统计经 SQLite 持久化(`~/.dsh/storages/dsh-context-compression/stats.sqlite`),跨宿主重启保留;驱动缺席或写失败时可见降级(面板标注,统计退回内存口径)。历史会话可从磁盘行为记录回填统计(宿主 sessionQuery 服务优先,缺席时只读解析会话日志,绝不写会话文件)。记录只含计数/序号/会话标识与组件枚举名,原文与自由文本绝不入库;删除该文件即可完全重置统计。
74
-
75
- `/ccip` 命令提供面板实时控制:`rows stock|total|money on|off`(行开关)、`mode compact|full`、`session <id|latest|off>`(聚焦会话)、`flush`(强制落库)、`backfill pause|resume|status`(回填开关)。
76
-
77
- ## 安装
78
-
79
- 从源码构建并安装 —— 本 fork 亦已发布到 npm,包名为 `dsh-context-compression-improved`(单版本覆盖全部支持线:`latest` 携带 17 个 rc 的完整枚举 0.1.0-rc.2 → 0.2.1-rc.2,分线代码路径由运行时自行选择);内部包名有意保持与上游一致:
5
+ **0.1.0 更新:**已加入 DeepSeek V4 Flash 视觉模型的官方 tokenizer;用户可选择模型驱动 Auto Compact 的触发阈值;标准 Profile 的水位与压缩参数会随该选择联动。
80
6
 
81
7
  ```sh
82
- git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
83
- cd dsh-context-compression-improved
84
- pnpm install --frozen-lockfile
85
- pnpm build
86
- ```
87
-
88
- 随后打包 selector 包并安装到某个 Harness Profile——完整步骤(含验证与卸载)见[安装教程](docs/installation.zh.md)。
89
-
90
- ## 开发
91
-
92
8
  ```sh
93
- pnpm install --frozen-lockfile
94
- pnpm lint # ESLint 基线(CI 同步强制)
95
- pnpm typecheck # runtime + selector + tests tsc,含 bundle 步
96
- pnpm test # vitest 全量
97
- pnpm test:watch # TDD 环路:先写失败的回归用例,再让它通过
98
- pnpm build
99
- pnpm verify:release
9
+ dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.5
10
+ # DSH 0.1.2 line:
11
+ # dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.2
12
+ dsh --profile web --dump-config
13
+ ```
14
+ dsh --profile web --dump-config
100
15
  ```
101
16
 
102
- 贡献遵循上游纪律:先写失败的回归用例;所有生产改动收敛在本仓库内;对“已触发”“已启用但跳过”“fail-open”分别给出证据。见 [CONTRIBUTING.md](CONTRIBUTING.md)。
103
-
104
- ## 兼容性
105
-
106
- - 基于官方 DeepSeek Harness 发布版构建并测试;peers 声明完整支持清单枚举(`0.1.0-rc.2` → `0.2.1-rc.2` 七条线),仅使用公开的插件与 Profile API。支持清单由 `scripts/sync-hosts.mjs` 从 `scripts/hosts.mjs` 生成到上方管理块。
107
- - 需要 Node `^22.19.0 || >=24` 与 pnpm `11.7.0`。
108
- - 插件只使用 Harness 公开扩展 API,不修改 Harness 核心代码。非官方社区项目,与 DeepSeek 无隶属或背书关系。
17
+ 这一条命令安装单一的 `dsh-context-compression-improved` 包:压缩运行时、Host 设置、Web UI
18
+ 与可逆 preset overlay 全部包含在其中。除 id 精确等于内置 `minimal` 的 preset 外,
19
+ 其他 preset 都会获得压缩能力;非 Minimal preset 之间切换时已保存设置保持不变。
20
+ Minimal 只暂停插件压缩,不删除设置。
109
21
 
110
- ## 致谢与许可
22
+ 已验证兼容 DeepSeek Harness `dsh-v0.1.1-rc.2` 与 `dsh-v0.1.2-alpha.5`,Node `^22.19.0 || >=24`。不需要修改 Harness 核心。
111
23
 
112
- - 上游项目与全部既有工作:[WilliamShi666/dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector),作者 WilliamShi666(MIT)。
113
- - fork 新增内容(代码骨架门、工具链、多语文档):drscrewdriver。
114
- - MIT——见 [LICENSE](LICENSE)(保留上游版权声明);内置 tokenizer 来源见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
24
+ Profile、默认值、审计证据、Adaptive/cache 限制、升级/卸载与安全说明见[完整 README](https://github.com/WilliamShi666/dsh-context-compression-improved#readme)。本包与 DeepSeek 无隶属或背书关系。
@@ -1,14 +1,32 @@
1
1
  # Third-party notices
2
2
 
3
- This community project contains code adapted from the MIT-licensed [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness), verified against tag `dsh-v0.1.1-rc.2`, commit `b150a551b8d465e31e418e1b2eaf5e79bbb7d28e`.
3
+ Portions of this package are adapted from the MIT-licensed DeepSeek Harness, verified against `dsh-v0.1.1-rc.2` (`b150a551b8d465e31e418e1b2eaf5e79bbb7d28e`).
4
4
 
5
- The runtime package distributes tokenizer assets from these pinned official repositories, both under the MIT license:
5
+ ## DeepSeek Harness MIT notice
6
6
 
7
- - [deepseek-ai/DeepSeek-V4-Pro](https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro) at revision `0e1a0e5e52aea73055f50fef6f2423db370265b6`, recorded in `packages/selector/assets/deepseek-v4/manifest.json`.
8
- - [deepseek-ai/DeepSeek-V4-Flash-Vision-Exp](https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash-Vision-Exp) at revision `6821d6ad3681a4b137b066b76094fa82ebd0a380`, recorded in `packages/selector/assets/deepseek-v4-vision-exp/manifest.json`. The vision model is served by this distinct tokenizer, never as an alias of the text tokenizer.
7
+ Copyright (c) 2026 DeepSeek
9
8
 
10
- Exact file sizes and SHA-256 values are recorded in each directory's `manifest.json`; the upstream license text ships beside the assets.
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
11
15
 
12
- The install-time production dependency closure also contains `@huggingface/tokenizers` (Apache-2.0), `js-yaml` (MIT), and its `argparse` dependency (Python-2.0). Each dependency ships its own license text in its NPM package.
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
13
18
 
14
- The names DeepSeek and DeepSeek Harness identify upstream projects only. They do not imply affiliation or endorsement.
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+
27
+ This package carries the official DeepSeek tokenizer assets, with their exact license and
28
+ provenance manifests, under `assets/`.
29
+
30
+ This package depends on `js-yaml` under MIT; its production dependency `argparse` is licensed under Python-2.0. Their NPM packages carry the dependency license texts.
31
+
32
+ This is an unofficial community package and is not endorsed by DeepSeek.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-context-compression-improved",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "main": "./lib/index.js",
5
5
  "description": "Auditable tool-result context-compression selector with code-skeleton gate for DeepSeek Harness",
6
6
  "engines": {
@@ -3857,6 +3857,17 @@ window.__ModuleLoader__.load({
3857
3857
  if (left.version !== 3 || right.version !== 3) return false;
3858
3858
  return left.version === right.version && left.unit === right.unit && left.prefixPolicy === right.prefixPolicy && left.fresh.enabled === right.fresh.enabled && left.fresh.trigger === right.fresh.trigger && left.fresh.target === right.fresh.target && left.aggregate.enabled === right.aggregate.enabled && left.aggregate.trigger === right.aggregate.trigger && left.aggregate.target === right.aggregate.target && left.history.enabled === right.history.enabled && left.history.trigger === right.history.trigger && left.history.keepRecentToolCalls === right.history.keepRecentToolCalls && left.history.keepRecentTokens === right.history.keepRecentTokens && left.history.minReclaim === right.history.minReclaim && left.tailTrim.enabled === right.tailTrim.enabled && left.tailTrim.trigger === right.tailTrim.trigger;
3859
3859
  }
3860
+ /**
3861
+ * Host locale APIs throw on duplicate writes: `addLanguage` when the global
3862
+ * catalog already has the id (`... is already registered`), and `register` when
3863
+ * the namespace already carries that locale (`... already has locale "..."`).
3864
+ * This plugin is mounted twice by name (bundle row + estimator-catalog row) and
3865
+ * re-runs apply on `_reload`, so both throws are expected benign skips — the
3866
+ * entry is already present and usable — and must never surface as warning noise.
3867
+ */
3868
+ function isBenignLocaleDuplicate(error) {
3869
+ return error instanceof Error && /already (?:registered|has locale)/.test(error.message);
3870
+ }
3860
3871
  function apply(ctx) {
3861
3872
  try {
3862
3873
  ctx.locale.register(NS, {
@@ -3864,7 +3875,7 @@ window.__ModuleLoader__.load({
3864
3875
  en
3865
3876
  });
3866
3877
  } catch (error) {
3867
- console.warn("[dsh-context-compression-improved] locale 默认包(zh/en) 已注册,跳过:", error);
3878
+ if (!isBenignLocaleDuplicate(error)) console.warn("[dsh-context-compression-improved] locale zh/en register failed:", error);
3868
3879
  }
3869
3880
  const languages = [
3870
3881
  {
@@ -3903,15 +3914,21 @@ window.__ModuleLoader__.load({
3903
3914
  dict: ru
3904
3915
  }
3905
3916
  ];
3906
- for (const language of languages) try {
3907
- ctx.locale.register(NS, language.id, language.dict);
3908
- ctx.locale.addLanguage({
3909
- id: language.id,
3910
- label: language.label,
3911
- fallback: "en"
3912
- });
3913
- } catch (error) {
3914
- console.warn(`[dsh-context-compression-improved] locale "${language.id}" registration failed:`, error);
3917
+ for (const language of languages) {
3918
+ try {
3919
+ ctx.locale.register(NS, language.id, language.dict);
3920
+ } catch (error) {
3921
+ if (!isBenignLocaleDuplicate(error)) console.warn(`[dsh-context-compression-improved] locale "${language.id}" dictionary registration failed:`, error);
3922
+ }
3923
+ try {
3924
+ ctx.locale.addLanguage({
3925
+ id: language.id,
3926
+ label: language.label,
3927
+ fallback: "en"
3928
+ });
3929
+ } catch (error) {
3930
+ if (!isBenignLocaleDuplicate(error)) console.warn(`[dsh-context-compression-improved] locale "${language.id}" language registration failed:`, error);
3931
+ }
3915
3932
  }
3916
3933
  const tNav = ctx.locale?.bind?.(NS) ?? ((key) => key);
3917
3934
  let configFormsHandle;
@@ -78,6 +78,91 @@ async function buildEstimatorCatalog(deps) {
78
78
  };
79
79
  }
80
80
  //#endregion
81
+ //#region src/tui-command.ts
82
+ const MAX_LINES = 40;
83
+ const MAX_WIDTH = 100;
84
+ function clip(text, width = MAX_WIDTH) {
85
+ const value = String(text ?? "").replace(/[\r\n]+/g, " ").replace(/\s+$/, "");
86
+ return value.length <= width ? value : `${value.slice(0, width - 1)}…`;
87
+ }
88
+ function renderLines(lines, limit = MAX_LINES) {
89
+ const clipped = lines.map((line) => clip(line));
90
+ if (clipped.length <= limit) return clipped.join("\n");
91
+ const kept = clipped.slice(0, limit - 1);
92
+ return [...kept, `… 还有 ${clipped.length - kept.length} 行,加 --all 查看`].join("\n");
93
+ }
94
+ function sectionOf(ctx, ns) {
95
+ const raw = (ctx.get?.("settings"))?.describe?.();
96
+ const list = Array.isArray(raw) ? raw : raw?.namespaces;
97
+ if (!Array.isArray(list)) return void 0;
98
+ for (const entry of list) {
99
+ const row = entry;
100
+ if (row?.ns === ns && row.value !== null && typeof row.value === "object") return row.value;
101
+ }
102
+ }
103
+ function runCompressCommand(rawInput, deps) {
104
+ const argv = String(rawInput ?? "").trim().split(/\s+/).filter(Boolean);
105
+ const json = argv.includes("--json");
106
+ const sub = (argv.find((token) => !token.startsWith("--")) ?? "status").toLowerCase();
107
+ const wrap = (result, data) => {
108
+ if (!json) return result;
109
+ const body = result.kind === "error" ? {
110
+ ok: false,
111
+ cmd: "compress",
112
+ error: { message: result.text.split("\n")[0] ?? result.text }
113
+ } : {
114
+ ok: true,
115
+ cmd: "compress",
116
+ data
117
+ };
118
+ return {
119
+ kind: result.kind,
120
+ text: JSON.stringify(body)
121
+ };
122
+ };
123
+ if (sub === "help" || sub === "?") return wrap({
124
+ kind: "success",
125
+ text: renderLines([
126
+ "compress — 上下文压缩策略(只读回显)",
127
+ " /compress status 设置节内容(门限/保留轮数/开关)",
128
+ " /compress policy 同 status(别名)",
129
+ " flags --json 单行 JSON",
130
+ " note 改策略走 Desktop 设置页;命令层只读"
131
+ ])
132
+ }, { help: true });
133
+ if (sub !== "status" && sub !== "policy") return wrap({
134
+ kind: "error",
135
+ text: renderLines([`compress: 未知子命令 "${sub}"`, " next: /compress help"])
136
+ }, {});
137
+ const section = deps.section();
138
+ if (section === void 0) return wrap({
139
+ kind: "error",
140
+ text: renderLines([`compress: 设置节 ${deps.ns} 不在 profile 文档里`, " next 检查插件是否已进入 profile;或看 cordis.patch.yml"])
141
+ }, {});
142
+ const keys = Object.keys(section);
143
+ const lines = ["compress — 设置节(只读)"];
144
+ for (const key of keys.slice(0, 14)) {
145
+ const value = section[key];
146
+ lines.push(` ${key.padEnd(20)} ${clip(typeof value === "object" && value !== null ? JSON.stringify(value) : String(value), 60)}`);
147
+ }
148
+ if (keys.length > 14) lines.push(` … 还有 ${keys.length - 14} 个字段`);
149
+ return wrap({
150
+ kind: "success",
151
+ text: renderLines(lines)
152
+ }, section);
153
+ }
154
+ function registerCompressCommand(ctx, deps) {
155
+ const registry = ctx.commands;
156
+ if (!registry || typeof registry.register !== "function") return;
157
+ registry.register({
158
+ definitionId: "dsh-context-compression-improved",
159
+ name: "compress",
160
+ description: "Context compression console: read-only echo of the strategy section",
161
+ input: { hint: "[status|policy] [--json]" },
162
+ handler: (invocation) => runCompressCommand(invocation?.rawInput ?? "", deps)
163
+ });
164
+ }
165
+ //#endregion
81
166
  //#region src/runtime/savings-verify.ts
82
167
  /**
83
168
  * /ccip verify 验算核心:按会话 jsonl 原文独立重算节省六值,与持久 claims 对账。
@@ -2163,6 +2248,22 @@ const Config = z.object({
2163
2248
  });
2164
2249
  /** Register the persisted default read by the currently mounted root pruner. */
2165
2250
  function apply(ctx, config = {}) {
2251
+ ctx.inject?.(["commands"], (scope) => {
2252
+ const candidates = [
2253
+ "dsh-context-compression-improved",
2254
+ "context-compression",
2255
+ "dsh-context-compression"
2256
+ ];
2257
+ registerCompressCommand(scope, {
2258
+ ns: candidates[0],
2259
+ section: () => {
2260
+ for (const ns of candidates) {
2261
+ const hit = sectionOf(scope, ns);
2262
+ if (hit !== void 0) return hit;
2263
+ }
2264
+ }
2265
+ });
2266
+ });
2166
2267
  try {
2167
2268
  if (config.estimatorCatalogRoute === true) registerEstimatorCatalogRoute(ctx);
2168
2269
  registerSavingsRoute(ctx);