dsh-context-compression-improved 0.7.0-beta.1 → 0.8.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.de.md +539 -0
  2. package/CHANGELOG.es.md +547 -0
  3. package/CHANGELOG.fr.md +534 -0
  4. package/CHANGELOG.it.md +536 -0
  5. package/CHANGELOG.ja.md +226 -220
  6. package/CHANGELOG.ko.md +220 -214
  7. package/CHANGELOG.md +372 -376
  8. package/CHANGELOG.ru.md +517 -0
  9. package/CHANGELOG.zh.md +204 -199
  10. package/README.de.md +98 -0
  11. package/README.es.md +98 -0
  12. package/README.fr.md +98 -0
  13. package/README.it.md +98 -0
  14. package/README.ja.md +85 -85
  15. package/README.ko.md +85 -85
  16. package/README.md +98 -97
  17. package/README.ru.md +98 -0
  18. package/README.zh.md +85 -86
  19. package/docs/installation.de.md +104 -0
  20. package/docs/installation.es.md +104 -0
  21. package/docs/installation.fr.md +104 -0
  22. package/docs/installation.it.md +104 -0
  23. package/docs/installation.ja.md +78 -78
  24. package/docs/installation.ko.md +78 -78
  25. package/docs/installation.md +103 -103
  26. package/docs/installation.ru.md +104 -0
  27. package/docs/installation.zh.md +100 -100
  28. package/eslint.config.js +30 -76
  29. package/package.json +69 -70
  30. package/packages/selector/dsh.plugin.json +2 -2
  31. package/packages/selector/lib/{intent-gate.js → advisor-state.js} +3 -91
  32. package/packages/selector/lib/client.js +736 -14
  33. package/packages/selector/lib/index.js +1 -92
  34. package/packages/selector/lib/profiles.d.ts +0 -9
  35. package/packages/selector/lib/pruner.d.ts +0 -59
  36. package/packages/selector/lib/pruner.js +7 -410
  37. package/packages/selector/lib/style.css +46 -46
  38. package/packages/selector/package.json +114 -114
  39. package/packages/selector/src/client/decode.ts +2 -6
  40. package/packages/selector/src/client/index.ts +244 -213
  41. package/packages/selector/src/client/locales/de.ts +98 -0
  42. package/packages/selector/src/client/locales/es.ts +98 -0
  43. package/packages/selector/src/client/locales/fr.ts +98 -0
  44. package/packages/selector/src/client/locales/it.ts +98 -0
  45. package/packages/selector/src/client/locales/ja.ts +98 -0
  46. package/packages/selector/src/client/locales/ko.ts +98 -0
  47. package/packages/selector/src/client/locales/ru.ts +98 -0
  48. package/packages/selector/src/deepseek-v4-tokenizer.ts +1 -1
  49. package/packages/selector/src/index.ts +411 -418
  50. package/packages/selector/src/preset-overlay.ts +0 -3
  51. package/packages/selector/src/profiles.ts +10 -30
  52. package/packages/selector/src/pruner/content.ts +1 -1
  53. package/packages/selector/src/pruner/state.ts +0 -7
  54. package/packages/selector/src/pruner.ts +9 -253
  55. package/packages/selector/src/runtime/audit.ts +0 -17
  56. package/packages/selector/src/runtime/config.ts +11 -36
  57. package/packages/selector/src/runtime/reducers.ts +1 -1
  58. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +1 -46
  59. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +0 -55
  60. package/packages/selector/src/runtime/tokenpilot/locator.ts +2 -2
  61. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +1 -4
  62. package/packages/selector/src/runtime/types.ts +0 -12
  63. package/packages/selector/tests/auto-compact.client.spec.tsx +213 -214
  64. package/packages/selector/tests/built/client-artifact.spec.ts +59 -61
  65. package/packages/selector/tests/code-skeleton.client.spec.ts +93 -94
  66. package/packages/selector/tests/custom-contract.client.spec.ts +222 -223
  67. package/packages/selector/tests/estimator-channel.client.spec.tsx +252 -252
  68. package/packages/selector/tests/host-preset-overlay.host.spec.ts +204 -204
  69. package/packages/selector/tests/preset-options-write.client.spec.ts +187 -188
  70. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +200 -200
  71. package/packages/selector/tests/profiles.client.spec.tsx +434 -436
  72. package/packages/selector/tests/public/package-contract.client.spec.ts +78 -78
  73. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +230 -230
  74. package/packages/selector/tests/runtime/audit.spec.ts +274 -275
  75. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +3 -3
  76. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +4 -4
  77. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2731 -2736
  78. package/packages/selector/tests/standing-generation.host.spec.ts +724 -704
  79. package/pnpm-workspace.yaml +66 -66
  80. package/scripts/packed-components-smoke.mjs +0 -2
  81. package/scripts/packed-install-e2e.mjs +5 -7
  82. package/scripts/verify-release.mjs +2 -3
  83. package/tests/TEST_INVENTORY.md +41 -41
  84. package/tsconfig.tests.json +1 -3
  85. package/vitest.config.ts +0 -14
  86. package/packages/selector/src/runtime/summary-command.ts +0 -133
  87. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +0 -53
  88. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +0 -65
  89. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +0 -125
  90. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +0 -37
  91. package/packages/selector/tests/runtime/intent-gate.spec.ts +0 -62
  92. package/packages/selector/tests/runtime/intent-summary.spec.ts +0 -156
  93. package/packages/selector/tests/runtime/summary-command.spec.ts +0 -154
@@ -1,61 +1,59 @@
1
- import { readFileSync } from 'node:fs'
2
- import { resolve } from 'node:path'
3
- import * as React from 'react'
4
- import * as jsxRuntime from 'react/jsx-runtime'
5
- import { describe, expect, it } from 'vitest'
6
-
7
- const artifact = resolve(import.meta.dirname, '../../lib/client.js')
8
-
9
- describe('built Harness client artifact', () => {
10
- it('registers a self-contained lazy-CJS factory and injects its CSS', () => {
11
- const code = readFileSync(artifact, 'utf8')
12
- let registration: { id: string, factory: (require: (id: string) => unknown) => unknown } | undefined
13
- const moduleLoader = {
14
- load(value: typeof registration) {
15
- registration = value
16
- },
17
- }
18
- Object.defineProperty(window, '__ModuleLoader__', { configurable: true, value: moduleLoader })
19
-
20
- // The smoke evaluates the built IIFE bundle the same way a browser page would.
21
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
22
- expect(() => Function(code)()).not.toThrow()
23
- expect(registration?.id).toBe('dsh-context-compression-improved')
24
-
25
- const modules = new Map<string, unknown>([
26
- ['react', React],
27
- ['react/jsx-runtime', jsxRuntime],
28
- // The current selector only keeps this official package as a side-effect
29
- // external. A minimal public-module stub proves the artifact asks the
30
- // Harness loader for it without importing the package's raw CSS in Node.
31
- ['@deepseek-ai/dsh-client-ui-primitives', {}],
32
- ])
33
- const exported = registration?.factory((id) => {
34
- if (!modules.has(id)) throw new Error(`unexpected client dependency: ${id}`)
35
- return modules.get(id)
36
- }) as { apply?: unknown, inject?: unknown }
37
-
38
- expect(exported.apply).toBeTypeOf('function')
39
- // Declare every consumed service: cordis holds apply until each one is
40
- // provided, which is the official client-plugin pattern on this 0.1.5 host
41
- // line (dsh-thinking-levels does the same). The earlier lazy alternative —
42
- // resolving `locale` / `settingsScope` through ctx.get() inside apply —
43
- // raced the settings client's activation; on a loss the apply
44
- // early-returned and EVERY settings entry (the standalone section, the
45
- // plugins-tab card, the item card) silently vanished. See the rationale
46
- // recorded in src/client/index.ts.
47
- expect(exported.inject).toEqual(['slots', 'locale', 'settingsScope'])
48
- const style = document.querySelector<HTMLStyleElement>(
49
- 'style[data-plugin-css="dsh-context-compression-improved/CompressionProfileSelector.module.css"]',
50
- )
51
- expect(style?.dataset.plugin).toBe('dsh-context-compression-improved')
52
- expect(style?.textContent).toContain('profileGrid')
53
- expect(document.querySelectorAll('style[data-plugin-css]').length).toBe(1)
54
-
55
- registration?.factory((id) => modules.get(id))
56
- expect(document.querySelectorAll('style[data-plugin-css]').length).toBe(1)
57
- expect(code).not.toMatch(/^\s*(?:import|export)\s/mu)
58
- expect(code).not.toMatch(/(?:\/home\/|[A-Za-z]:\\Users\\)/u)
59
- expect(code).not.toContain('sourceMappingURL')
60
- })
61
- })
1
+ import { readFileSync } from 'node:fs'
2
+ import { resolve } from 'node:path'
3
+ import * as React from 'react'
4
+ import * as jsxRuntime from 'react/jsx-runtime'
5
+ import { describe, expect, it } from 'vitest'
6
+
7
+ const artifact = resolve(import.meta.dirname, '../../lib/client.js')
8
+
9
+ describe('built Harness client artifact', () => {
10
+ it('registers a self-contained lazy-CJS factory and injects its CSS', () => {
11
+ const code = readFileSync(artifact, 'utf8')
12
+ let registration: { id: string, factory: (require: (id: string) => unknown) => unknown } | undefined
13
+ const moduleLoader = {
14
+ load(value: typeof registration) {
15
+ registration = value
16
+ },
17
+ }
18
+ Object.defineProperty(window, '__ModuleLoader__', { configurable: true, value: moduleLoader })
19
+
20
+ expect(() => Function(code)()).not.toThrow()
21
+ expect(registration?.id).toBe('dsh-context-compression-improved')
22
+
23
+ const modules = new Map<string, unknown>([
24
+ ['react', React],
25
+ ['react/jsx-runtime', jsxRuntime],
26
+ // The current selector only keeps this official package as a side-effect
27
+ // external. A minimal public-module stub proves the artifact asks the
28
+ // Harness loader for it without importing the package's raw CSS in Node.
29
+ ['@deepseek-ai/dsh-client-ui-primitives', {}],
30
+ ])
31
+ const exported = registration?.factory((id) => {
32
+ if (!modules.has(id)) throw new Error(`unexpected client dependency: ${id}`)
33
+ return modules.get(id)
34
+ }) as { apply?: unknown, inject?: unknown }
35
+
36
+ expect(exported.apply).toBeTypeOf('function')
37
+ // Declare every consumed service: cordis holds apply until each one is
38
+ // provided, which is the official client-plugin pattern on this 0.1.5 host
39
+ // line (dsh-thinking-levels does the same). The earlier lazy alternative —
40
+ // resolving `locale` / `configForms` through ctx.get() inside apply —
41
+ // raced the settings client's activation; on a loss the apply
42
+ // early-returned and EVERY settings entry (the standalone section, the
43
+ // plugins-tab card, the item card) silently vanished. See the rationale
44
+ // recorded in src/client/index.ts.
45
+ expect(exported.inject).toEqual(['slots', 'locale', 'configForms'])
46
+ const style = document.querySelector<HTMLStyleElement>(
47
+ 'style[data-plugin-css="dsh-context-compression-improved/CompressionProfileSelector.module.css"]',
48
+ )
49
+ expect(style?.dataset.plugin).toBe('dsh-context-compression-improved')
50
+ expect(style?.textContent).toContain('profileGrid')
51
+ expect(document.querySelectorAll('style[data-plugin-css]').length).toBe(1)
52
+
53
+ registration?.factory((id) => modules.get(id))
54
+ expect(document.querySelectorAll('style[data-plugin-css]').length).toBe(1)
55
+ expect(code).not.toMatch(/^\s*(?:import|export)\s/mu)
56
+ expect(code).not.toMatch(/(?:\/home\/|[A-Za-z]:\\Users\\)/u)
57
+ expect(code).not.toContain('sourceMappingURL')
58
+ })
59
+ })
@@ -1,94 +1,93 @@
1
- // @vitest-environment jsdom
2
-
3
- import { describe, expect, it, vi } from 'vitest'
4
- import { DEFAULT_CUSTOM_COMPRESSION_POLICY } from '../src/profiles.ts'
5
- import { apply } from '../src/client/index.ts'
6
- import type { CompressionSelectorInjected } from '../src/client/CompressionProfileSelector.tsx'
7
- import type { ContextCompressionSettings } from '../src/profiles.ts'
8
-
9
- /**
10
- * 0.1.7 contract: `codeSkeleton` rides the entry config as part of the volatile
11
- * `settings` whole-object field. Every write commits the full doc through
12
- * `configForms.set('settings', doc)`; the confirm-on-write semantics are
13
- * unchanged — a host that silently drops (or flips) the section fails the
14
- * acceptance check on the post-commit snapshot.
15
- */
16
-
17
- describe('codeSkeleton confirm-on-write client contract', () => {
18
- it('resolves only when the host confirms the toggled value and rejects silent drops', async () => {
19
- let revision = 3
20
- let commit = false
21
- let flipEnabled = false
22
- let value: ContextCompressionSettings = {
23
- profile: 'balanced',
24
- custom: structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY),
25
- autoCompact: { thresholdPercent: 80 },
26
- codeSkeleton: { enabled: false },
27
- intentSummary: { enabled: false },
28
- }
29
- const form = {
30
- getSnapshot: vi.fn(() => ({
31
- status: 'ready' as const,
32
- value: { settings: value },
33
- base: undefined,
34
- user: undefined,
35
- revision,
36
- writable: true,
37
- mode: 'host' as const,
38
- })),
39
- subscribe: vi.fn(() => () => {}),
40
- set: vi.fn(async (_field: string, next: unknown) => {
41
- if (!commit) return false
42
- revision += 1
43
- const doc = structuredClone(next) as ContextCompressionSettings
44
- if (flipEnabled) {
45
- const accepted = structuredClone(doc.codeSkeleton)
46
- accepted.enabled = !accepted.enabled
47
- value = { ...doc, codeSkeleton: accepted }
48
- return true
49
- }
50
- value = doc
51
- return true
52
- }),
53
- unset: vi.fn(async () => false),
54
- }
55
- let injected: (() => CompressionSelectorInjected) | undefined
56
- const ctx = {
57
- effect: (install: () => unknown) => { install() },
58
- locale: { register: vi.fn(() => () => {}) },
59
- configForms: { get: vi.fn(() => form) },
60
- slots: {
61
- inject: (_slot: string, install: () => unknown) => { install() },
62
- register: (registration: { inject?: () => CompressionSelectorInjected }) => {
63
- // The R4 overlay registration carries no inject face; keep the card's.
64
- if (typeof registration.inject === 'function') injected = registration.inject
65
- return () => {}
66
- },
67
- },
68
- } as unknown as Parameters<typeof apply>[0]
69
-
70
- apply(ctx)
71
- const actions = injected?.()
72
- expect(actions).toBeDefined()
73
- if (actions === undefined) throw new Error('selector injection was not registered')
74
-
75
- // A silent host drop leaves the revision untouched: the write must reject.
76
- await expect(actions.saveCodeSkeleton(true)).rejects.toThrow('were not saved')
77
-
78
- // A committed write resolves and persists the exact section payload under
79
- // the volatile `settings` field.
80
- commit = true
81
- await expect(actions.saveCodeSkeleton(true)).resolves.toBeUndefined()
82
- expect(form.set).toHaveBeenLastCalledWith('settings', expect.objectContaining({ codeSkeleton: { enabled: true } }))
83
- expect(value.codeSkeleton).toEqual({ enabled: true })
84
-
85
- // A host that flips the toggled bit fails the acceptance check.
86
- flipEnabled = true
87
- await expect(actions.saveCodeSkeleton(false)).rejects.toThrow('were not saved')
88
-
89
- flipEnabled = false
90
- await expect(actions.saveCodeSkeleton(false)).resolves.toBeUndefined()
91
- expect(form.set).toHaveBeenLastCalledWith('settings', expect.objectContaining({ codeSkeleton: { enabled: false } }))
92
- expect(value.codeSkeleton).toEqual({ enabled: false })
93
- })
94
- })
1
+ // @vitest-environment jsdom
2
+
3
+ import { describe, expect, it, vi } from 'vitest'
4
+ import { DEFAULT_CUSTOM_COMPRESSION_POLICY } from '../src/profiles.ts'
5
+ import { apply } from '../src/client/index.ts'
6
+ import type { CompressionSelectorInjected } from '../src/client/CompressionProfileSelector.tsx'
7
+ import type { ContextCompressionSettings } from '../src/profiles.ts'
8
+
9
+ /**
10
+ * 0.1.7 contract: `codeSkeleton` rides the entry config as part of the volatile
11
+ * `settings` whole-object field. Every write commits the full doc through
12
+ * `configForms.set('settings', doc)`; the confirm-on-write semantics are
13
+ * unchanged — a host that silently drops (or flips) the section fails the
14
+ * acceptance check on the post-commit snapshot.
15
+ */
16
+
17
+ describe('codeSkeleton confirm-on-write client contract', () => {
18
+ it('resolves only when the host confirms the toggled value and rejects silent drops', async () => {
19
+ let revision = 3
20
+ let commit = false
21
+ let flipEnabled = false
22
+ let value: ContextCompressionSettings = {
23
+ profile: 'balanced',
24
+ custom: structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY),
25
+ autoCompact: { thresholdPercent: 80 },
26
+ codeSkeleton: { enabled: false },
27
+ }
28
+ const form = {
29
+ getSnapshot: vi.fn(() => ({
30
+ status: 'ready' as const,
31
+ value: { settings: value },
32
+ base: undefined,
33
+ user: undefined,
34
+ revision,
35
+ writable: true,
36
+ mode: 'host' as const,
37
+ })),
38
+ subscribe: vi.fn(() => () => {}),
39
+ set: vi.fn(async (_field: string, next: unknown) => {
40
+ if (!commit) return false
41
+ revision += 1
42
+ const doc = structuredClone(next) as ContextCompressionSettings
43
+ if (flipEnabled) {
44
+ const accepted = structuredClone(doc.codeSkeleton)
45
+ accepted.enabled = !accepted.enabled
46
+ value = { ...doc, codeSkeleton: accepted }
47
+ return true
48
+ }
49
+ value = doc
50
+ return true
51
+ }),
52
+ unset: vi.fn(async () => false),
53
+ }
54
+ let injected: (() => CompressionSelectorInjected) | undefined
55
+ const ctx = {
56
+ effect: (install: () => unknown) => { install() },
57
+ locale: { register: vi.fn(() => () => {}) },
58
+ configForms: { get: vi.fn(() => form) },
59
+ slots: {
60
+ inject: (_slot: string, install: () => unknown) => { install() },
61
+ register: (registration: { inject?: () => CompressionSelectorInjected }) => {
62
+ // The R4 overlay registration carries no inject face; keep the card's.
63
+ if (typeof registration.inject === 'function') injected = registration.inject
64
+ return () => {}
65
+ },
66
+ },
67
+ } as unknown as Parameters<typeof apply>[0]
68
+
69
+ apply(ctx)
70
+ const actions = injected?.()
71
+ expect(actions).toBeDefined()
72
+ if (actions === undefined) throw new Error('selector injection was not registered')
73
+
74
+ // A silent host drop leaves the revision untouched: the write must reject.
75
+ await expect(actions.saveCodeSkeleton(true)).rejects.toThrow('were not saved')
76
+
77
+ // A committed write resolves and persists the exact section payload under
78
+ // the volatile `settings` field.
79
+ commit = true
80
+ await expect(actions.saveCodeSkeleton(true)).resolves.toBeUndefined()
81
+ expect(form.set).toHaveBeenLastCalledWith('settings', expect.objectContaining({ codeSkeleton: { enabled: true } }))
82
+ expect(value.codeSkeleton).toEqual({ enabled: true })
83
+
84
+ // A host that flips the toggled bit fails the acceptance check.
85
+ flipEnabled = true
86
+ await expect(actions.saveCodeSkeleton(false)).rejects.toThrow('were not saved')
87
+
88
+ flipEnabled = false
89
+ await expect(actions.saveCodeSkeleton(false)).resolves.toBeUndefined()
90
+ expect(form.set).toHaveBeenLastCalledWith('settings', expect.objectContaining({ codeSkeleton: { enabled: false } }))
91
+ expect(value.codeSkeleton).toEqual({ enabled: false })
92
+ })
93
+ })