dsh-context-compression-improved 0.6.4 → 0.6.5

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 (40) hide show
  1. package/.agents-stash-064.patch +39 -0
  2. package/CHANGELOG.ja.md +42 -0
  3. package/CHANGELOG.ko.md +38 -0
  4. package/CHANGELOG.md +46 -0
  5. package/CHANGELOG.zh.md +38 -0
  6. package/README.ja.md +2 -2
  7. package/README.ko.md +2 -2
  8. package/README.md +5 -3
  9. package/README.zh.md +2 -2
  10. package/_dsh_devdeps.json +50 -0
  11. package/_verify064/package/package.json +162 -0
  12. package/_verify064/package/packages/selector/src/client/index.ts +232 -0
  13. package/package.json +163 -162
  14. package/packages/selector/dsh.plugin.json +16 -16
  15. package/packages/selector/lib/client.js +2 -1
  16. package/packages/selector/lib/style.css +46 -46
  17. package/packages/selector/package.json +114 -114
  18. package/packages/selector/src/client/index.ts +213 -232
  19. package/packages/selector/src/client/scope-face.ts +24 -24
  20. package/packages/selector/src/index.ts +0 -1
  21. package/packages/selector/src/pruner.ts +0 -1
  22. package/packages/selector/tests/custom-contract.client.spec.ts +222 -222
  23. package/packages/selector/tests/helpers/legacy-namespace.ts +8 -4
  24. package/packages/selector/tests/helpers/legacy-settings/index.ts +15 -0
  25. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +41 -0
  26. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +647 -0
  27. package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +78 -0
  28. package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +234 -0
  29. package/packages/selector/tests/host-preset-overlay.host.spec.ts +3 -5
  30. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +200 -206
  31. package/packages/selector/tests/public/package-contract.client.spec.ts +78 -78
  32. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +230 -233
  33. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2731 -2727
  34. package/packages/selector/tests/settings-seat.client.spec.ts +165 -165
  35. package/packages/selector/tests/standing-generation.host.spec.ts +724 -704
  36. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +18 -2
  37. package/packages/selector/tests/support/ui-primitives.tsx +34 -34
  38. package/pnpm-workspace.yaml +1 -1
  39. package/scripts/packed-install-e2e.mjs +6 -6
  40. package/scripts/verify-release.mjs +1 -1
@@ -1,165 +1,165 @@
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 surfaces, and NOT a `shell.overlay` float
7
- * (the retired review panel's seat was removed with the gate). History this
8
- * pins against: the 0.1.5 line first lost every entry (a lazy `ctx.get` of
9
- * locale/settingsScope raced the settings client and apply bailed), then showed
10
- * the panel twice (item card + tab on top of the standalone section). Both were
11
- * fixed by the declarative-inject + single-section shape below. When a future
12
- * DSH line moves the seat again, migrate src/client/index.ts AND this file
13
- * together.
14
- */
15
- import { describe, expect, it, vi } from 'vitest'
16
- import type { Context as ClientContext } from '@deepseek-ai/cordis'
17
- import { apply, inject } from '../src/client/index.ts'
18
- import { ContextCompressionSettingsSection } from '../src/client/CompressionProfileSelector.tsx'
19
- import { DEFAULT_CUSTOM_COMPRESSION_POLICY } from '../src/profiles.ts'
20
-
21
- vi.mock('@deepseek-ai/dsh-client-ui-primitives', () => ({
22
- IconChevronDownOutlineMedium: () => null,
23
- Menu: () => null,
24
- }))
25
-
26
- interface CapturedRegistration {
27
- readonly slot: string
28
- readonly options: Record<string, unknown>
29
- readonly component: unknown
30
- }
31
-
32
- /**
33
- * Drive apply against a stub host and capture every slot registration.
34
- * @param options - `registerThrows` models an older host that does not declare
35
- * the seat: the slot boundary rejects the registration, exactly the shape the
36
- * 0.1.2-era hosts had.
37
- */
38
- function collectRegistrations(
39
- options: { readonly registerThrows?: boolean } = {},
40
- ): { declared: string[]; registrations: CapturedRegistration[] } {
41
- const declared: string[] = []
42
- const registrations: CapturedRegistration[] = []
43
- const ctx = {
44
- locale: { register: vi.fn(() => () => {}), bind: () => (key: string) => key },
45
- configForms: { get: vi.fn(() => ({}) as never) },
46
- slots: {
47
- inject: (slot: string, factory: () => (() => void) | Generator<() => void>) => {
48
- declared.push(slot)
49
- const result = factory()
50
- const steps: Iterable<() => void> = typeof (result as { [Symbol.iterator]?: unknown })?.[Symbol.iterator] === 'function'
51
- ? (result as Generator<() => void>)
52
- : [result as () => void]
53
- for (const step of steps) { void step }
54
- return () => {}
55
- },
56
- register: (record: Record<string, unknown>, component: unknown) => {
57
- if (options.registerThrows === true) throw new Error(`unknown slot ${String(record['name'])}`)
58
- registrations.push({ slot: String(record['name']), options: record, component })
59
- return () => {}
60
- },
61
- },
62
- }
63
- apply(ctx as unknown as ClientContext)
64
- return { declared, registrations }
65
- }
66
-
67
- describe('settings-seat contract (standalone settings.section only)', () => {
68
- it('declares the services apply consumes (cordis waits; no lazy-get race)', () => {
69
- expect(inject).toEqual(['slots', 'locale', 'configForms'])
70
- })
71
-
72
- it('injects exactly the settings.section seat and nothing else', () => {
73
- const { declared, registrations } = collectRegistrations()
74
- expect(declared).toEqual(['settings.section'])
75
- expect(registrations).toHaveLength(1)
76
- expect(registrations[0]!.slot).toBe('settings.section')
77
- })
78
-
79
- it('no longer claims a shell.overlay float (the review panel it served is gone)', () => {
80
- const { declared } = collectRegistrations()
81
- expect(declared).not.toContain('shell.overlay')
82
- })
83
-
84
- it('pins the section identity (id/order/label/locale) and the panel component', () => {
85
- const { registrations } = collectRegistrations()
86
- const { options, component } = registrations[0]!
87
- expect(options['id']).toBe('context-compression')
88
- expect(options['order']).toBe(17)
89
- expect(options['locale']).toBe('context-compression')
90
- expect((options['label'] as () => string)()).toBe('nav')
91
- expect(typeof options['inject']).toBe('function')
92
- const face = (options['inject'] as () => Record<string, unknown>)()
93
- expect(Object.keys(face).sort()).toEqual(['hooks', 'saveAutoCompact', 'saveCodeSkeleton', 'saveCustom', 'savePresetOptions', 'select', 'resetCustom'].sort())
94
- expect(component).toBe(ContextCompressionSettingsSection)
95
- })
96
-
97
- it('never adds a Plugins-section card or tab alongside the standalone section', () => {
98
- const { declared } = collectRegistrations()
99
- expect(declared).not.toContain('settings.plugins.tab')
100
- expect(declared).not.toContain('settings.plugin.item')
101
- })
102
-
103
- it('projects an identity-stable snapshot between form changes (React #185 regression)', () => {
104
- // The 0.1.7 adapter wraps configForms into the legacy scope shape. Its
105
- // getSnapshot MUST return the same object reference until the underlying
106
- // form snapshot changes: a fresh literal per call re-renders
107
- // useSyncExternalStore forever — "Minified React error #185" (maximum
108
- // update depth exceeded), and the slot boundary abdicates the whole
109
- // settings.section on the production host.
110
- let source = {
111
- status: 'ready' as const,
112
- value: { settings: { profile: 'balanced', custom: DEFAULT_CUSTOM_COMPRESSION_POLICY } },
113
- revision: 1, writable: true, base: undefined, user: undefined, mode: 'host' as const,
114
- }
115
- const listeners: (() => void)[] = []
116
- const ctx = {
117
- locale: { register: vi.fn(() => () => {}), bind: () => (key: string) => key },
118
- configForms: { get: () => ({
119
- getSnapshot: () => source,
120
- subscribe: (listener: () => void) => { listeners.push(listener); return () => {} },
121
- set: async () => true,
122
- }) },
123
- slots: {
124
- inject: (_slot: string, factory: () => (() => void) | Generator<() => void>) => { void factory() },
125
- register: (record: Record<string, unknown>) => {
126
- registrations.push({ slot: String(record['name']), options: record, component: null })
127
- return () => {}
128
- },
129
- },
130
- }
131
- const registrations: CapturedRegistration[] = []
132
- apply(ctx as unknown as ClientContext)
133
- const face = (registrations[0]!.options['inject'] as () => { hooks: { compression: { getSnapshot(): unknown; subscribe(l: () => void): () => void } } })()
134
- const scope = face.hooks.compression
135
-
136
- const first = scope.getSnapshot()
137
- expect(scope.getSnapshot()).toBe(first)
138
- // value decodes through the whole strict validator
139
- expect(first && typeof first === 'object' && 'value' in first && (first as { value?: { profile?: string } }).value?.profile).toBe('balanced')
140
-
141
- // Host accepts a change → NEW form snapshot object → projection recomputes
142
- source = { ...source, revision: 2, value: { settings: { profile: 'off', custom: DEFAULT_CUSTOM_COMPRESSION_POLICY } } }
143
- for (const listener of listeners) listener()
144
- const second = scope.getSnapshot()
145
- expect(second).not.toBe(first)
146
- expect(second && typeof second === 'object' && 'value' in second && (second as { value?: { profile?: string } }).value?.profile).toBe('off')
147
- })
148
-
149
- it('survives an older host that does not declare the seat, warning instead of crashing', () => {
150
- // Cross-version tolerance: a host without this seat rejects the
151
- // registration at the slot boundary. apply() must swallow that and warn —
152
- // the historical failure mode was apply() bailing out, which silently took
153
- // EVERY settings entry down with it.
154
- const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
155
- try {
156
- const { declared } = collectRegistrations({ registerThrows: true })
157
- // It tried the seat (so the degradation is "loud", not a silent no-op)…
158
- expect(declared).toEqual(['settings.section'])
159
- // …and the rejection never escaped apply().
160
- expect(warn).toHaveBeenCalled()
161
- } finally {
162
- warn.mockRestore()
163
- }
164
- })
165
- })
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 surfaces, and NOT a `shell.overlay` float
7
+ * (the retired review panel's seat was removed with the gate). History this
8
+ * pins against: the 0.1.5 line first lost every entry (a lazy `ctx.get` of
9
+ * locale/settingsScope raced the settings client and apply bailed), then showed
10
+ * the panel twice (item card + tab on top of the standalone section). Both were
11
+ * fixed by the declarative-inject + single-section shape below. When a future
12
+ * DSH line moves the seat again, migrate src/client/index.ts AND this file
13
+ * together.
14
+ */
15
+ import { describe, expect, it, vi } from 'vitest'
16
+ import type { Context as ClientContext } from '@deepseek-ai/cordis'
17
+ import { apply, inject } from '../src/client/index.ts'
18
+ import { ContextCompressionSettingsSection } from '../src/client/CompressionProfileSelector.tsx'
19
+ import { DEFAULT_CUSTOM_COMPRESSION_POLICY } from '../src/profiles.ts'
20
+
21
+ vi.mock('@deepseek-ai/dsh-client-ui-primitives', () => ({
22
+ IconChevronDownOutlineMedium: () => null,
23
+ Menu: () => null,
24
+ }))
25
+
26
+ interface CapturedRegistration {
27
+ readonly slot: string
28
+ readonly options: Record<string, unknown>
29
+ readonly component: unknown
30
+ }
31
+
32
+ /**
33
+ * Drive apply against a stub host and capture every slot registration.
34
+ * @param options - `registerThrows` models an older host that does not declare
35
+ * the seat: the slot boundary rejects the registration, exactly the shape the
36
+ * 0.1.2-era hosts had.
37
+ */
38
+ function collectRegistrations(
39
+ options: { readonly registerThrows?: boolean } = {},
40
+ ): { declared: string[]; registrations: CapturedRegistration[] } {
41
+ const declared: string[] = []
42
+ const registrations: CapturedRegistration[] = []
43
+ const ctx = {
44
+ locale: { register: vi.fn(() => () => {}), bind: () => (key: string) => key },
45
+ configForms: { get: vi.fn(() => ({}) as never) },
46
+ slots: {
47
+ inject: (slot: string, factory: () => (() => void) | Generator<() => void>) => {
48
+ declared.push(slot)
49
+ const result = factory()
50
+ const steps: Iterable<() => void> = typeof (result as { [Symbol.iterator]?: unknown })?.[Symbol.iterator] === 'function'
51
+ ? (result as Generator<() => void>)
52
+ : [result as () => void]
53
+ for (const step of steps) { void step }
54
+ return () => {}
55
+ },
56
+ register: (record: Record<string, unknown>, component: unknown) => {
57
+ if (options.registerThrows === true) throw new Error(`unknown slot ${String(record['name'])}`)
58
+ registrations.push({ slot: String(record['name']), options: record, component })
59
+ return () => {}
60
+ },
61
+ },
62
+ }
63
+ apply(ctx as unknown as ClientContext)
64
+ return { declared, registrations }
65
+ }
66
+
67
+ describe('settings-seat contract (standalone settings.section only)', () => {
68
+ it('declares the services apply consumes (cordis waits; no lazy-get race)', () => {
69
+ expect(inject).toEqual(['slots', 'locale', 'configForms'])
70
+ })
71
+
72
+ it('injects exactly the settings.section seat and nothing else', () => {
73
+ const { declared, registrations } = collectRegistrations()
74
+ expect(declared).toEqual(['settings.section'])
75
+ expect(registrations).toHaveLength(1)
76
+ expect(registrations[0]!.slot).toBe('settings.section')
77
+ })
78
+
79
+ it('no longer claims a shell.overlay float (the review panel it served is gone)', () => {
80
+ const { declared } = collectRegistrations()
81
+ expect(declared).not.toContain('shell.overlay')
82
+ })
83
+
84
+ it('pins the section identity (id/order/label/locale) and the panel component', () => {
85
+ const { registrations } = collectRegistrations()
86
+ const { options, component } = registrations[0]!
87
+ expect(options['id']).toBe('context-compression')
88
+ expect(options['order']).toBe(17)
89
+ expect(options['locale']).toBe('context-compression')
90
+ expect((options['label'] as () => string)()).toBe('nav')
91
+ expect(typeof options['inject']).toBe('function')
92
+ const face = (options['inject'] as () => Record<string, unknown>)()
93
+ expect(Object.keys(face).sort()).toEqual(['hooks', 'saveAutoCompact', 'saveCodeSkeleton', 'saveCustom', 'savePresetOptions', 'select', 'resetCustom'].sort())
94
+ expect(component).toBe(ContextCompressionSettingsSection)
95
+ })
96
+
97
+ it('never adds a Plugins-section card or tab alongside the standalone section', () => {
98
+ const { declared } = collectRegistrations()
99
+ expect(declared).not.toContain('settings.plugins.tab')
100
+ expect(declared).not.toContain('settings.plugin.item')
101
+ })
102
+
103
+ it('projects an identity-stable snapshot between form changes (React #185 regression)', () => {
104
+ // The 0.1.7 adapter wraps configForms into the legacy scope shape. Its
105
+ // getSnapshot MUST return the same object reference until the underlying
106
+ // form snapshot changes: a fresh literal per call re-renders
107
+ // useSyncExternalStore forever — "Minified React error #185" (maximum
108
+ // update depth exceeded), and the slot boundary abdicates the whole
109
+ // settings.section on the production host.
110
+ let source = {
111
+ status: 'ready' as const,
112
+ value: { settings: { profile: 'balanced', custom: DEFAULT_CUSTOM_COMPRESSION_POLICY } },
113
+ revision: 1, writable: true, base: undefined, user: undefined, mode: 'host' as const,
114
+ }
115
+ const listeners: (() => void)[] = []
116
+ const ctx = {
117
+ locale: { register: vi.fn(() => () => {}), bind: () => (key: string) => key },
118
+ configForms: { get: () => ({
119
+ getSnapshot: () => source,
120
+ subscribe: (listener: () => void) => { listeners.push(listener); return () => {} },
121
+ set: async () => true,
122
+ }) },
123
+ slots: {
124
+ inject: (_slot: string, factory: () => (() => void) | Generator<() => void>) => { void factory() },
125
+ register: (record: Record<string, unknown>) => {
126
+ registrations.push({ slot: String(record['name']), options: record, component: null })
127
+ return () => {}
128
+ },
129
+ },
130
+ }
131
+ const registrations: CapturedRegistration[] = []
132
+ apply(ctx as unknown as ClientContext)
133
+ const face = (registrations[0]!.options['inject'] as () => { hooks: { compression: { getSnapshot(): unknown; subscribe(l: () => void): () => void } } })()
134
+ const scope = face.hooks.compression
135
+
136
+ const first = scope.getSnapshot()
137
+ expect(scope.getSnapshot()).toBe(first)
138
+ // value decodes through the whole strict validator
139
+ expect(first && typeof first === 'object' && 'value' in first && (first as { value?: { profile?: string } }).value?.profile).toBe('balanced')
140
+
141
+ // Host accepts a change → NEW form snapshot object → projection recomputes
142
+ source = { ...source, revision: 2, value: { settings: { profile: 'off', custom: DEFAULT_CUSTOM_COMPRESSION_POLICY } } }
143
+ for (const listener of listeners) listener()
144
+ const second = scope.getSnapshot()
145
+ expect(second).not.toBe(first)
146
+ expect(second && typeof second === 'object' && 'value' in second && (second as { value?: { profile?: string } }).value?.profile).toBe('off')
147
+ })
148
+
149
+ it('survives an older host that does not declare the seat, warning instead of crashing', () => {
150
+ // Cross-version tolerance: a host without this seat rejects the
151
+ // registration at the slot boundary. apply() must swallow that and warn —
152
+ // the historical failure mode was apply() bailing out, which silently took
153
+ // EVERY settings entry down with it.
154
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
155
+ try {
156
+ const { declared } = collectRegistrations({ registerThrows: true })
157
+ // It tried the seat (so the degradation is "loud", not a silent no-op)…
158
+ expect(declared).toEqual(['settings.section'])
159
+ // …and the rejection never escaped apply().
160
+ expect(warn).toHaveBeenCalled()
161
+ } finally {
162
+ warn.mockRestore()
163
+ }
164
+ })
165
+ })