dsh-context-compression-improved 0.9.7 → 0.9.9-beta.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 (240) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +15 -98
  3. package/README.zh.md +14 -92
  4. package/THIRD_PARTY_NOTICES.md +32 -14
  5. package/{packages/selector/cordis.patch.yml → cordis.patch.yml} +27 -27
  6. package/{packages/selector/dsh.plugin.json → dsh.plugin.json} +2 -2
  7. package/{packages/selector/lib → lib}/client.d.ts +16 -0
  8. package/{packages/selector/lib → lib}/client.js +393 -116
  9. package/{packages/selector/lib → lib}/index.js +829 -10
  10. package/{packages/selector/lib → lib}/invariant.js +2 -1
  11. package/{packages/selector/lib → lib}/pruner.d.ts +1 -1
  12. package/{packages/selector/lib → lib}/pruner.js +77 -983
  13. package/lib/savings-integral.js +4515 -0
  14. package/{packages/selector/lib → lib}/tail-trim.js +2 -90
  15. package/lib/tool-result.js +150 -0
  16. package/package.json +129 -116
  17. package/screenshots.json +3 -6
  18. package/.gitattributes +0 -2
  19. package/.githooks/pre-push +0 -37
  20. package/.github/workflows/ci.yml +0 -39
  21. package/CHANGELOG.de.md +0 -580
  22. package/CHANGELOG.es.md +0 -588
  23. package/CHANGELOG.fr.md +0 -576
  24. package/CHANGELOG.it.md +0 -577
  25. package/CHANGELOG.ja.md +0 -261
  26. package/CHANGELOG.ko.md +0 -254
  27. package/CHANGELOG.md +0 -532
  28. package/CHANGELOG.ru.md +0 -554
  29. package/CHANGELOG.zh.md +0 -236
  30. package/CONTRIBUTING.md +0 -22
  31. package/README.de.md +0 -96
  32. package/README.es.md +0 -96
  33. package/README.fr.md +0 -96
  34. package/README.it.md +0 -96
  35. package/README.ja.md +0 -102
  36. package/README.ko.md +0 -102
  37. package/README.ru.md +0 -96
  38. package/SECURITY.md +0 -18
  39. package/assets/board.png +0 -0
  40. package/assets/context.png +0 -0
  41. package/docs/assets/context-compression-selector-profiles.jpg +0 -0
  42. package/docs/assets/context-compression-selector-settings.png +0 -0
  43. package/docs/compat-0.1.5-report.md +0 -77
  44. package/docs/installation.de.md +0 -104
  45. package/docs/installation.es.md +0 -104
  46. package/docs/installation.fr.md +0 -104
  47. package/docs/installation.it.md +0 -104
  48. package/docs/installation.ja.md +0 -78
  49. package/docs/installation.ko.md +0 -78
  50. package/docs/installation.md +0 -103
  51. package/docs/installation.ru.md +0 -104
  52. package/docs/installation.zh.md +0 -100
  53. package/docs/repair-log.md +0 -657
  54. package/eslint.config.js +0 -30
  55. package/packages/selector/LICENSE +0 -21
  56. package/packages/selector/README.md +0 -26
  57. package/packages/selector/README.zh.md +0 -24
  58. package/packages/selector/THIRD_PARTY_NOTICES.md +0 -32
  59. package/packages/selector/docs/history-tool-call-working-set-spec.md +0 -112
  60. package/packages/selector/docs/native-tool-result-selector-spec.md +0 -34
  61. package/packages/selector/docs/subagent-cache-reuse-spec.md +0 -46
  62. package/packages/selector/lib/config.js +0 -1777
  63. package/packages/selector/lib/host-generation.js +0 -62
  64. package/packages/selector/lib/style.css +0 -350
  65. package/packages/selector/package.json +0 -174
  66. package/packages/selector/screenshots.json +0 -3
  67. package/packages/selector/src/client/CompressionProfileControls.tsx +0 -293
  68. package/packages/selector/src/client/CompressionProfileSelector.module.css +0 -199
  69. package/packages/selector/src/client/CompressionProfileSelector.tsx +0 -85
  70. package/packages/selector/src/client/CustomPolicyEditor.tsx +0 -216
  71. package/packages/selector/src/client/EstimatorControls.tsx +0 -277
  72. package/packages/selector/src/client/bridge-scope.ts +0 -125
  73. package/packages/selector/src/client/decode.ts +0 -57
  74. package/packages/selector/src/client/index.ts +0 -421
  75. package/packages/selector/src/client/locales/de.ts +0 -142
  76. package/packages/selector/src/client/locales/es.ts +0 -142
  77. package/packages/selector/src/client/locales/fr.ts +0 -142
  78. package/packages/selector/src/client/locales/it.ts +0 -142
  79. package/packages/selector/src/client/locales/ja.ts +0 -142
  80. package/packages/selector/src/client/locales/ko.ts +0 -142
  81. package/packages/selector/src/client/locales/ru.ts +0 -142
  82. package/packages/selector/src/client/locales.ts +0 -284
  83. package/packages/selector/src/client/monitor-fab.ts +0 -349
  84. package/packages/selector/src/client/preset-options.ts +0 -88
  85. package/packages/selector/src/client/savings-card.tsx +0 -150
  86. package/packages/selector/src/client/scope-face.ts +0 -24
  87. package/packages/selector/src/client/settings-section.tsx +0 -140
  88. package/packages/selector/src/compat/host-generation.ts +0 -96
  89. package/packages/selector/src/compat/llm-messages.ts +0 -50
  90. package/packages/selector/src/compat/settings-lease.ts +0 -108
  91. package/packages/selector/src/compat/tool-result.ts +0 -91
  92. package/packages/selector/src/css-modules.d.ts +0 -6
  93. package/packages/selector/src/deepseek-v4-tokenizer.ts +0 -205
  94. package/packages/selector/src/estimator-catalog.ts +0 -104
  95. package/packages/selector/src/index.ts +0 -655
  96. package/packages/selector/src/invariant.ts +0 -113
  97. package/packages/selector/src/preset-overlay.ts +0 -749
  98. package/packages/selector/src/profiles.ts +0 -431
  99. package/packages/selector/src/pruner/content.ts +0 -198
  100. package/packages/selector/src/pruner/session.ts +0 -97
  101. package/packages/selector/src/pruner/state.ts +0 -61
  102. package/packages/selector/src/pruner/tuning.ts +0 -23
  103. package/packages/selector/src/pruner/types.ts +0 -78
  104. package/packages/selector/src/pruner.ts +0 -2868
  105. package/packages/selector/src/runtime/adaptive-cost.ts +0 -205
  106. package/packages/selector/src/runtime/audit.ts +0 -303
  107. package/packages/selector/src/runtime/config.ts +0 -756
  108. package/packages/selector/src/runtime/custom-policy.ts +0 -278
  109. package/packages/selector/src/runtime/deepseek-official-pricing.ts +0 -298
  110. package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +0 -254
  111. package/packages/selector/src/runtime/measurement.ts +0 -444
  112. package/packages/selector/src/runtime/monitor.ts +0 -235
  113. package/packages/selector/src/runtime/reducers.ts +0 -1754
  114. package/packages/selector/src/runtime/retrieve.ts +0 -484
  115. package/packages/selector/src/runtime/savings-projection.ts +0 -226
  116. package/packages/selector/src/runtime/savings.ts +0 -417
  117. package/packages/selector/src/runtime/session-events.ts +0 -30
  118. package/packages/selector/src/runtime/summary-command.ts +0 -127
  119. package/packages/selector/src/runtime/tail-trim.ts +0 -176
  120. package/packages/selector/src/runtime/token-count.ts +0 -72
  121. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +0 -233
  122. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +0 -204
  123. package/packages/selector/src/runtime/tokenpilot/advisor.ts +0 -419
  124. package/packages/selector/src/runtime/tokenpilot/benefit.ts +0 -200
  125. package/packages/selector/src/runtime/tokenpilot/dedup.ts +0 -81
  126. package/packages/selector/src/runtime/tokenpilot/estimator.ts +0 -151
  127. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +0 -53
  128. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +0 -65
  129. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +0 -125
  130. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +0 -37
  131. package/packages/selector/src/runtime/tokenpilot/locator.ts +0 -128
  132. package/packages/selector/src/runtime/tokenpilot/read-state.ts +0 -98
  133. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +0 -303
  134. package/packages/selector/src/runtime/toolclass.ts +0 -103
  135. package/packages/selector/src/runtime/types.ts +0 -365
  136. package/packages/selector/src/runtime/value.ts +0 -48
  137. package/packages/selector/src/settings-bridge.ts +0 -175
  138. package/packages/selector/tests/advisor-report.host.spec.ts +0 -223
  139. package/packages/selector/tests/auto-compact.client.spec.tsx +0 -214
  140. package/packages/selector/tests/built/client-artifact.spec.ts +0 -56
  141. package/packages/selector/tests/cache-prefix-audit.spec.ts +0 -123
  142. package/packages/selector/tests/code-skeleton.client.spec.ts +0 -98
  143. package/packages/selector/tests/compat/compat-narrow-waist.spec.ts +0 -150
  144. package/packages/selector/tests/custom-contract.client.spec.ts +0 -226
  145. package/packages/selector/tests/estimator-catalog.spec.ts +0 -70
  146. package/packages/selector/tests/estimator-channel.client.spec.tsx +0 -253
  147. package/packages/selector/tests/estimator-route-registration.host.spec.ts +0 -199
  148. package/packages/selector/tests/helpers/legacy-namespace.ts +0 -35
  149. package/packages/selector/tests/helpers/legacy-settings/index.ts +0 -15
  150. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +0 -41
  151. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +0 -647
  152. package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +0 -78
  153. package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +0 -234
  154. package/packages/selector/tests/host-preset-overlay.host.spec.ts +0 -204
  155. package/packages/selector/tests/monitor-fab.client.spec.ts +0 -138
  156. package/packages/selector/tests/preset-options-write.client.spec.ts +0 -192
  157. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +0 -200
  158. package/packages/selector/tests/preset-overlay.host.spec.ts +0 -246
  159. package/packages/selector/tests/profiles.client.spec.tsx +0 -436
  160. package/packages/selector/tests/public/package-contract.client.spec.ts +0 -86
  161. package/packages/selector/tests/runtime/adaptive-cost.spec.ts +0 -167
  162. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +0 -230
  163. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +0 -272
  164. package/packages/selector/tests/runtime/advisor.spec.ts +0 -226
  165. package/packages/selector/tests/runtime/audit.spec.ts +0 -275
  166. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +0 -523
  167. package/packages/selector/tests/runtime/char-basis.spec.ts +0 -30
  168. package/packages/selector/tests/runtime/code-skeleton.spec.ts +0 -152
  169. package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +0 -186
  170. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +0 -122
  171. package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +0 -122
  172. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +0 -96
  173. package/packages/selector/tests/runtime/fixtures/profile-baseline.json +0 -273
  174. package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +0 -106
  175. package/packages/selector/tests/runtime/fixtures/vision-golden.json +0 -459
  176. package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +0 -74
  177. package/packages/selector/tests/runtime/fresh-gate.spec.ts +0 -43
  178. package/packages/selector/tests/runtime/html-reducer.spec.ts +0 -212
  179. package/packages/selector/tests/runtime/intent-gate.spec.ts +0 -62
  180. package/packages/selector/tests/runtime/intent-summary.spec.ts +0 -156
  181. package/packages/selector/tests/runtime/jsonl-reducer.spec.ts +0 -79
  182. package/packages/selector/tests/runtime/line-mapping.spec.ts +0 -153
  183. package/packages/selector/tests/runtime/monitor.spec.ts +0 -301
  184. package/packages/selector/tests/runtime/prose-reducers.spec.ts +0 -133
  185. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +0 -2782
  186. package/packages/selector/tests/runtime/read-input-cap.spec.ts +0 -33
  187. package/packages/selector/tests/runtime/savings-projection.spec.ts +0 -89
  188. package/packages/selector/tests/runtime/savings.spec.ts +0 -139
  189. package/packages/selector/tests/runtime/search-reducer.spec.ts +0 -110
  190. package/packages/selector/tests/runtime/session-events.spec.ts +0 -27
  191. package/packages/selector/tests/runtime/settings-unwrap.spec.ts +0 -58
  192. package/packages/selector/tests/runtime/sidechannel.spec.ts +0 -241
  193. package/packages/selector/tests/runtime/summary-command.spec.ts +0 -154
  194. package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +0 -159
  195. package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +0 -53
  196. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +0 -217
  197. package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +0 -52
  198. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +0 -79
  199. package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +0 -76
  200. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +0 -119
  201. package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +0 -82
  202. package/packages/selector/tests/runtime/toolclass.spec.ts +0 -156
  203. package/packages/selector/tests/runtime/value.spec.ts +0 -23
  204. package/packages/selector/tests/settings-seat.client.spec.ts +0 -215
  205. package/packages/selector/tests/standing-generation.host.spec.ts +0 -724
  206. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +0 -269
  207. package/packages/selector/tests/support/cache-prefix-audit.ts +0 -105
  208. package/packages/selector/tests/support/mock-adapter.ts +0 -37
  209. package/packages/selector/tests/support/ui-primitives.tsx +0 -34
  210. package/packages/selector/tsconfig.json +0 -11
  211. package/packages/selector/tsdown.client.config.ts +0 -102
  212. package/packages/selector/tsdown.config.ts +0 -20
  213. package/pnpm-workspace.yaml +0 -72
  214. package/scripts/capture-profile-baseline.mjs +0 -42
  215. package/scripts/cell-browser-e2e.mjs +0 -354
  216. package/scripts/generate-tokenizer-fixtures.py +0 -81
  217. package/scripts/generate-vision-fixtures.py +0 -208
  218. package/scripts/hosts.mjs +0 -77
  219. package/scripts/packed-components-smoke.mjs +0 -763
  220. package/scripts/packed-install-e2e.mjs +0 -1346
  221. package/scripts/sync-hosts.mjs +0 -174
  222. package/scripts/toolclass-corpus-replay.mjs +0 -281
  223. package/scripts/verify-release.mjs +0 -335
  224. package/tests/TEST_INVENTORY.md +0 -41
  225. package/tsconfig.base.json +0 -18
  226. package/tsconfig.json +0 -7
  227. package/tsconfig.tests.json +0 -15
  228. package/vitest.built.config.ts +0 -9
  229. package/vitest.config.ts +0 -46
  230. /package/{packages/selector/assets → assets}/deepseek-v4/LICENSE.DeepSeek-V4-Pro.txt +0 -0
  231. /package/{packages/selector/assets → assets}/deepseek-v4/manifest.json +0 -0
  232. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer.json +0 -0
  233. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer_config.json +0 -0
  234. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/LICENSE.DeepSeek-V4-Flash-Vision-Exp.txt +0 -0
  235. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/manifest.json +0 -0
  236. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer.json +0 -0
  237. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer_config.json +0 -0
  238. /package/{packages/selector/lib → lib}/index.d.ts +0 -0
  239. /package/{packages/selector/lib → lib}/invariant.d.ts +0 -0
  240. /package/{packages/selector/lib → lib}/profiles.d.ts +0 -0
@@ -1,156 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
- import { classifyToolSource } from '../../src/runtime/toolclass.ts'
3
- import { extractCommand, reduceFreshToolResult } from '../../src/runtime/reducers.ts'
4
-
5
- /** Checklist C1–C15 against the FOUR-class narrowing (tasks v2 G4): web/memory
6
- * search and research/sql names fall to generic, glob is path-listing, only
7
- * grep/rg/ripgrep are search, and the content fallback never overrides a
8
- * whitelist hit. */
9
- describe('classifyToolSource — name whitelist', () => {
10
- it('keeps web_search out of search (C1)', () => {
11
- expect(classifyToolSource('web_search', '')).toBe('generic')
12
- })
13
-
14
- it('routes glob to path-listing (C2)', () => {
15
- expect(classifyToolSource('glob', '')).toBe('path-listing')
16
- })
17
-
18
- it('keeps memory/conversation search generic — four classes only (C3, v2)', () => {
19
- expect(classifyToolSource('memory_search', '')).toBe('generic')
20
- expect(classifyToolSource('conversation_search', '')).toBe('generic')
21
- })
22
-
23
- it('routes grep/rg/ripgrep to search (C4)', () => {
24
- expect(classifyToolSource('grep', '')).toBe('search')
25
- expect(classifyToolSource('rg', '')).toBe('search')
26
- expect(classifyToolSource('ripgrep', '')).toBe('search')
27
- expect(classifyToolSource('grep_search', '')).toBe('search')
28
- })
29
-
30
- it('routes shell/bash/pwsh/terminal to shell-exec (C5)', () => {
31
- expect(classifyToolSource('shell', '')).toBe('shell')
32
- expect(classifyToolSource('bash', '')).toBe('shell')
33
- expect(classifyToolSource('pwsh', '')).toBe('shell')
34
- expect(classifyToolSource('powershell', '')).toBe('shell')
35
- expect(classifyToolSource('terminal', '')).toBe('shell')
36
- })
37
-
38
- it('routes read/read_file/cat/view/open_file to file-read (C6)', () => {
39
- expect(classifyToolSource('read', '')).toBe('read')
40
- expect(classifyToolSource('read_file', '')).toBe('read')
41
- expect(classifyToolSource('cat', '')).toBe('read')
42
- expect(classifyToolSource('view', '')).toBe('read')
43
- expect(classifyToolSource('view_file', '')).toBe('read')
44
- expect(classifyToolSource('open_file', '')).toBe('read')
45
- })
46
-
47
- it('is generic for mutation tools — no file-mutate class in the four-class set (C7, v2)', () => {
48
- expect(classifyToolSource('write', '')).toBe('generic')
49
- expect(classifyToolSource('edit', '')).toBe('generic')
50
- expect(classifyToolSource('apply_patch', '')).toBe('generic')
51
- })
52
-
53
- it('returns generic for any name with an mcp token, before content evidence (C8)', () => {
54
- expect(classifyToolSource('mcp__server__grep', '', 'src/a.ts:1: x')).toBe('generic')
55
- expect(classifyToolSource('mcp-grep', '', 'src/a.ts:1: x')).toBe('generic')
56
- })
57
-
58
- it('never misroutes `research` into a search class (C9)', () => {
59
- expect(classifyToolSource('research', '')).toBe('generic')
60
- expect(classifyToolSource('deep_research', '')).toBe('generic')
61
- })
62
-
63
- it('never misroutes `execute_sql` into shell-exec (C10)', () => {
64
- expect(classifyToolSource('execute_sql', '')).toBe('generic')
65
- })
66
-
67
- it('matches tokens exactly — no substring bleed (task_11)', () => {
68
- expect(classifyToolSource('advanced_search', '')).toBe('generic')
69
- expect(classifyToolSource('free_search_test', '')).toBe('generic')
70
- expect(classifyToolSource('theme_global', '')).toBe('generic')
71
- })
72
- })
73
-
74
- describe('classifyToolSource — command and content fallback', () => {
75
- it('routes rg/grep commands to search even from an unknown tool name', () => {
76
- expect(classifyToolSource('run_tool', 'rg pattern src/')).toBe('search')
77
- expect(classifyToolSource('run_tool', 'grep -n TODO .')).toBe('search')
78
- })
79
-
80
- it('routes find/fd/ls/tree commands to path-listing, not search', () => {
81
- expect(classifyToolSource('run_tool', 'find . -name "*.ts"')).toBe('path-listing')
82
- expect(classifyToolSource('run_tool', 'fd config')).toBe('path-listing')
83
- })
84
-
85
- it('falls back to search on a path:line:content line (C13)', () => {
86
- expect(classifyToolSource('unknown_tool', '', 'src/index.ts:12: export const x')).toBe('search')
87
- })
88
-
89
- it('does not let prose colons or URLs masquerade as grep output (C13 guard)', () => {
90
- expect(classifyToolSource('unknown_tool', '', 'Note: 2024 - something happened')).toBe('generic')
91
- expect(classifyToolSource('unknown_tool', '', 'see https://host.example:8080 - login')).toBe('generic')
92
- })
93
-
94
- it('falls back to path-listing when ≥80% of lines are pure paths (C14)', () => {
95
- const listing = ['src/index.ts', 'src/main.ts', 'src/util.ts', 'README.md'].join('\n')
96
- expect(classifyToolSource('unknown_tool', '', listing)).toBe('path-listing')
97
- })
98
-
99
- it('never overrides a whitelist hit with content evidence (C15)', () => {
100
- expect(classifyToolSource('bash', '', 'src/index.ts:12: export const x')).toBe('shell')
101
- expect(classifyToolSource('glob', '', 'src/index.ts:12: export const x')).toBe('path-listing')
102
- expect(classifyToolSource('read', '', 'src/index.ts')).toBe('read')
103
- })
104
- })
105
-
106
- describe('extractCommand — input key removed (C11/C12)', () => {
107
- it('returns empty for an input-only payload (C11)', () => {
108
- expect(extractCommand('{"input":"arbitrary model text"}')).toBe('')
109
- })
110
-
111
- it('still reads the command key (C12)', () => {
112
- expect(extractCommand('{"command":"npm test"}')).toBe('npm test')
113
- })
114
-
115
- it('still reads cmd/script fallbacks', () => {
116
- expect(extractCommand('{"cmd":"pnpm build"}')).toBe('pnpm build')
117
- expect(extractCommand('{"script":"ls"}')).toBe('ls')
118
- })
119
- })
120
-
121
- /** End-to-end dispatch guard for the misroute fixes: a `glob` result and an
122
- * `execute_sql` result must not land on the search reducer even when they
123
- * exceed every form gate. */
124
- describe('toolclass dispatch integration', () => {
125
- const paths = Array.from({ length: 200 }, (_, index) => `pkg/dir${String(index)}/file${String(index)}.ts`)
126
- const globText = paths.join('\n')
127
-
128
- it('routes a large glob result away from search-salience (task_11)', () => {
129
- const output = reduceFreshToolResult({
130
- toolName: 'glob',
131
- argumentsText: '{}',
132
- text: globText,
133
- budgetChars: 4_000,
134
- sourceRef: 'session://probe/glob',
135
- isError: false,
136
- })
137
- expect(output).not.toBeNull()
138
- expect(output!.reducer).not.toBe('search-by-file')
139
- expect(output!.reducer).not.toBe('search-salience')
140
- })
141
-
142
- it('routes a large mcp web_search result away from the search reducer (C1/AD1)', () => {
143
- const web = Array.from({ length: 60 }, (_, index) =>
144
- `- [Result ${String(index)}](https://example.com/${String(index)}) — a summary paragraph of the ${String(index)}th hit.`).join('\n')
145
- const output = reduceFreshToolResult({
146
- toolName: 'mcp__web__web_search',
147
- argumentsText: '{}',
148
- text: web,
149
- budgetChars: 2_000,
150
- sourceRef: 'session://probe/web',
151
- isError: false,
152
- })
153
- expect(output).not.toBeNull()
154
- expect(output!.reducer).not.toBe('search-by-file')
155
- })
156
- })
@@ -1,23 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
- import { assertNever, deepFreeze } from '../../src/runtime/value.ts'
3
-
4
- describe('version-neutral runtime values', () => {
5
- it('freezes nested and cyclic data without freezing a live AbortSignal', () => {
6
- const controller = new AbortController()
7
- const value: { nested: { value: number }, self?: unknown, signal: AbortSignal } = {
8
- nested: { value: 1 },
9
- signal: controller.signal,
10
- }
11
- value.self = value
12
-
13
- expect(deepFreeze(value)).toBe(value)
14
- expect(Object.isFrozen(value)).toBe(true)
15
- expect(Object.isFrozen(value.nested)).toBe(true)
16
- expect(Object.isFrozen(controller.signal)).toBe(false)
17
- })
18
-
19
- it('reports an escaped closed-union member with its switch context', () => {
20
- expect(() => assertNever({ kind: 'unexpected' } as never, 'value test'))
21
- .toThrow('unreachable variant in value test: {"kind":"unexpected"}')
22
- })
23
- })
@@ -1,215 +0,0 @@
1
- /**
2
- * Settings-seat contract pin for dsh-context-compression-improved's client.
3
- *
4
- * This spec locks WHERE the compression settings panel mounts: exactly ONE
5
- * seat — the standalone `settings.section` entry (设置 → 上下文压缩) — and
6
- * explicitly NOT the Plugins-section config surfaces (settings.plugins.tab /
7
- * settings.plugin.item), and NOT a `shell.overlay` float
8
- * (the retired review panel's seat was removed with the gate). History this
9
- * pins against: the 0.1.5 line first lost every entry (a lazy `ctx.get` of
10
- * locale/settingsScope raced the settings client and apply bailed), then showed
11
- * the panel twice (item card + tab on top of the standalone section). Both were
12
- * fixed by the declarative-inject + single-section shape below. When a future
13
- * DSH line moves the seat again, migrate src/client/index.ts AND this file
14
- * together.
15
- */
16
- import { describe, expect, it, vi } from 'vitest'
17
- import type { Context as ClientContext } from '@deepseek-ai/cordis'
18
- import { apply, inject } from '../src/client/index.ts'
19
- import { ContextCompressionSettingsSection } from '../src/client/CompressionProfileSelector.tsx'
20
- import { DEFAULT_CUSTOM_COMPRESSION_POLICY } from '../src/profiles.ts'
21
-
22
- vi.mock('@deepseek-ai/dsh-client-ui-primitives', () => ({
23
- IconChevronDownOutlineMedium: () => null,
24
- Menu: () => null,
25
- }))
26
-
27
- interface CapturedRegistration {
28
- readonly slot: string
29
- readonly options: Record<string, unknown>
30
- readonly component: unknown
31
- }
32
-
33
- /**
34
- * Drive apply against a stub host and capture every slot registration.
35
- * @param options - `registerThrows` models an older host that does not declare
36
- * the seat: the slot boundary rejects the registration, exactly the shape the
37
- * 0.1.2-era hosts had.
38
- */
39
- function collectRegistrations(
40
- options: { readonly registerThrows?: boolean } = {},
41
- ): { declared: string[]; registrations: CapturedRegistration[] } {
42
- const declared: string[] = []
43
- const registrations: CapturedRegistration[] = []
44
- const ctx = {
45
- locale: { register: vi.fn(() => () => {}), bind: () => (key: string) => key },
46
- configForms: { get: vi.fn(() => ({}) as never) },
47
- // Scoped sub-inject seam: the host resolves declared services and fires
48
- // the callback (configForms arm — 0.1.7+ lines only).
49
- inject: (services: string[], cb: (service: unknown) => void) => {
50
- if (services.includes('configForms')) cb(ctx.configForms)
51
- },
52
- slots: {
53
- inject: (slot: string, factory: () => (() => void) | Generator<() => void>) => {
54
- declared.push(slot)
55
- const result = factory()
56
- const steps: Iterable<() => void> = typeof (result as { [Symbol.iterator]?: unknown })?.[Symbol.iterator] === 'function'
57
- ? (result as Generator<() => void>)
58
- : [result as () => void]
59
- for (const step of steps) { void step }
60
- return () => {}
61
- },
62
- register: (record: Record<string, unknown>, component: unknown) => {
63
- if (options.registerThrows === true) throw new Error(`unknown slot ${String(record['name'])}`)
64
- registrations.push({ slot: String(record['name']), options: record, component })
65
- return () => {}
66
- },
67
- },
68
- }
69
- apply(ctx as unknown as ClientContext)
70
- return { declared, registrations }
71
- }
72
-
73
- describe('settings-seat contract (standalone settings.section + input-bar session binder)', () => {
74
- it('declares the services apply consumes (cordis waits; no lazy-get race)', () => {
75
- // compat-legacy 单版本(B8):顶层只声明六线通用服务;数据面由 scoped
76
- // sub-inject 双臂选择(桥默认 + configForms 升级),不再出现在顶层表。
77
- expect(inject).toEqual(['slots', 'locale'])
78
- })
79
-
80
- it('injects exactly three seats: the settings.section panel + the input-bar session binder + the 0.1.7+ bundle detail card', () => {
81
- const { declared, registrations } = collectRegistrations()
82
- expect(declared).toEqual(['settings.section', 'conversation.input.left', 'plugins.bundle.config'])
83
- expect(registrations).toHaveLength(3)
84
- expect(registrations[0]!.slot).toBe('settings.section')
85
- expect(registrations[1]!.slot).toBe('conversation.input.left')
86
- expect(registrations[2]!.slot).toBe('plugins.bundle.config')
87
- // bundle 卡 keyed=包名,0.1.x 宿主无此槽时由 registerThrows 分支另行覆盖
88
- expect(registrations[2]!.options['key']).toBe('dsh-context-compression-improved')
89
- })
90
-
91
- it('no longer claims a shell.overlay float (the review panel it served is gone)', () => {
92
- const { declared } = collectRegistrations()
93
- expect(declared).not.toContain('shell.overlay')
94
- })
95
-
96
- it('pins the section identity (id/order/label/locale) and the panel component', () => {
97
- const { registrations } = collectRegistrations()
98
- const { options, component } = registrations[0]!
99
- expect(options['id']).toBe('context-compression')
100
- expect(options['order']).toBe(17)
101
- expect(options['locale']).toBe('context-compression')
102
- expect((options['label'] as () => string)()).toBe('nav')
103
- expect(typeof options['inject']).toBe('function')
104
- const face = (options['inject'] as () => Record<string, unknown>)()
105
- expect(Object.keys(face).sort()).toEqual(['hooks', 'saveAutoCompact', 'saveCodeSkeleton', 'saveCustom', 'saveIntentSummary', 'saveMonitorPanel', 'savePresetOptions', 'select', 'resetCustom'].sort())
106
- expect(component).toBe(ContextCompressionSettingsSection)
107
- })
108
-
109
- it('pins the input-bar binder: invisible component, inject captures the bare sessionId', () => {
110
- const { registrations } = collectRegistrations()
111
- const inputSeat = registrations[1]!
112
- expect(inputSeat.options['id']).toBe('context-compression-session-bind')
113
- expect(inputSeat.options['order']).toBe(170)
114
- expect(typeof inputSeat.options['inject']).toBe('function')
115
- const face = (inputSeat.options['inject'] as (sessionId: string) => Record<string, unknown>)('sess-42')
116
- expect(face).toEqual({})
117
- expect(inputSeat.component).toBeTypeOf('function')
118
- })
119
-
120
- it('never adds a Plugins-section card or tab alongside the standalone section', () => {
121
- const { declared } = collectRegistrations()
122
- expect(declared).not.toContain('settings.plugins.tab')
123
- expect(declared).not.toContain('settings.plugin.item')
124
- })
125
-
126
- it('projects an identity-stable snapshot between form changes (React #185 regression)', () => {
127
- // The 0.1.7 adapter wraps configForms into the legacy scope shape. Its
128
- // getSnapshot MUST return the same object reference until the underlying
129
- // form snapshot changes: a fresh literal per call re-renders
130
- // useSyncExternalStore forever — "Minified React error #185" (maximum
131
- // update depth exceeded), and the slot boundary abdicates the whole
132
- // settings.section on the production host.
133
- let source = {
134
- status: 'ready' as const,
135
- value: { settings: { profile: 'balanced', custom: DEFAULT_CUSTOM_COMPRESSION_POLICY } },
136
- revision: 1, writable: true, base: undefined, user: undefined, mode: 'host' as const,
137
- }
138
- const listeners: (() => void)[] = []
139
- const ctx = {
140
- locale: { register: vi.fn(() => () => {}), bind: () => (key: string) => key },
141
- configForms: { get: () => ({
142
- getSnapshot: () => source,
143
- subscribe: (listener: () => void) => { listeners.push(listener); return () => {} },
144
- set: async () => true,
145
- }) },
146
- inject: (services: string[], cb: (service: unknown) => void) => {
147
- if (services.includes('configForms')) cb(ctx.configForms)
148
- },
149
- slots: {
150
- inject: (_slot: string, factory: () => (() => void) | Generator<() => void>) => { void factory() },
151
- register: (record: Record<string, unknown>) => {
152
- registrations.push({ slot: String(record['name']), options: record, component: null })
153
- return () => {}
154
- },
155
- },
156
- }
157
- const registrations: CapturedRegistration[] = []
158
- apply(ctx as unknown as ClientContext)
159
- const face = (registrations[0]!.options['inject'] as () => { hooks: { compression: { getSnapshot(): unknown; subscribe(l: () => void): () => void } } })()
160
- const scope = face.hooks.compression
161
-
162
- const first = scope.getSnapshot()
163
- expect(scope.getSnapshot()).toBe(first)
164
- // value decodes through the whole strict validator
165
- expect(first && typeof first === 'object' && 'value' in first && (first as { value?: { profile?: string } }).value?.profile).toBe('balanced')
166
-
167
- // Host accepts a change → NEW form snapshot object → projection recomputes
168
- source = { ...source, revision: 2, value: { settings: { profile: 'off', custom: DEFAULT_CUSTOM_COMPRESSION_POLICY } } }
169
- for (const listener of listeners) listener()
170
- const second = scope.getSnapshot()
171
- expect(second).not.toBe(first)
172
- expect(second && typeof second === 'object' && 'value' in second && (second as { value?: { profile?: string } }).value?.profile).toBe('off')
173
- })
174
-
175
- it('defaults to the bridge scope when the configForms arm never resolves (pre-0.1.7 lines)', () => {
176
- // B8 dual-arm: on 0.1.x hosts configForms does not exist, the scoped
177
- // sub-inject never fires, and the selector must stand on the HTTP bridge
178
- // scope (status loading until the first GET returns).
179
- const registrations: CapturedRegistration[] = []
180
- const ctx = {
181
- locale: { register: vi.fn(() => () => {}), bind: () => (key: string) => key },
182
- // No `inject` at all: neither arm resolves, bridge stays the scope.
183
- slots: {
184
- inject: (_slot: string, factory: () => (() => void) | Generator<() => void>) => { void factory() },
185
- register: (record: Record<string, unknown>) => {
186
- registrations.push({ slot: String(record['name']), options: record, component: null })
187
- return () => {}
188
- },
189
- },
190
- }
191
- apply(ctx as unknown as ClientContext)
192
- const face = (registrations[0]!.options['inject'] as () => { hooks: { compression: { getSnapshot(): unknown } } })()
193
- const scope = face.hooks.compression
194
- const snapshot = scope.getSnapshot() as { status?: string }
195
- expect(snapshot.status).toBe('loading')
196
- })
197
-
198
- it('survives an older host that does not declare the seat, warning instead of crashing', () => {
199
- // Cross-version tolerance: a host without this seat rejects the
200
- // registration at the slot boundary. apply() must swallow that and warn —
201
- // the historical failure mode was apply() bailing out, which silently took
202
- // EVERY settings entry down with it.
203
- const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
204
- try {
205
- const { declared } = collectRegistrations({ registerThrows: true })
206
- // It tried all three seats (so the degradation is "loud", not a silent
207
- // no-op)…
208
- expect(declared).toEqual(['settings.section', 'conversation.input.left', 'plugins.bundle.config'])
209
- // …and the rejection never escaped apply().
210
- expect(warn).toHaveBeenCalled()
211
- } finally {
212
- warn.mockRestore()
213
- }
214
- })
215
- })