dsh-context-compression-improved 0.6.1 → 0.6.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.
@@ -1,118 +1,118 @@
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
-
20
- vi.mock('@deepseek-ai/dsh-client-ui-primitives', () => ({
21
- IconChevronDownOutline14: () => null,
22
- Menu: () => null,
23
- }))
24
-
25
- interface CapturedRegistration {
26
- readonly slot: string
27
- readonly options: Record<string, unknown>
28
- readonly component: unknown
29
- }
30
-
31
- /**
32
- * Drive apply against a stub host and capture every slot registration.
33
- * @param options - `registerThrows` models an older host that does not declare
34
- * the seat: the slot boundary rejects the registration, exactly the shape the
35
- * 0.1.2-era hosts had.
36
- */
37
- function collectRegistrations(
38
- options: { readonly registerThrows?: boolean } = {},
39
- ): { declared: string[]; registrations: CapturedRegistration[] } {
40
- const declared: string[] = []
41
- const registrations: CapturedRegistration[] = []
42
- const ctx = {
43
- locale: { register: vi.fn(() => () => {}), bind: () => (key: string) => key },
44
- configForms: { get: vi.fn(() => ({}) as never) },
45
- slots: {
46
- inject: (slot: string, factory: () => (() => void) | Generator<() => void>) => {
47
- declared.push(slot)
48
- const result = factory()
49
- const steps: Iterable<() => void> = typeof (result as { [Symbol.iterator]?: unknown })?.[Symbol.iterator] === 'function'
50
- ? (result as Generator<() => void>)
51
- : [result as () => void]
52
- for (const step of steps) { void step }
53
- return () => {}
54
- },
55
- register: (record: Record<string, unknown>, component: unknown) => {
56
- if (options.registerThrows === true) throw new Error(`unknown slot ${String(record['name'])}`)
57
- registrations.push({ slot: String(record['name']), options: record, component })
58
- return () => {}
59
- },
60
- },
61
- }
62
- apply(ctx as unknown as ClientContext)
63
- return { declared, registrations }
64
- }
65
-
66
- describe('settings-seat contract (standalone settings.section only)', () => {
67
- it('declares the services apply consumes (cordis waits; no lazy-get race)', () => {
68
- expect(inject).toEqual(['slots', 'locale', 'configForms'])
69
- })
70
-
71
- it('injects exactly the settings.section seat and nothing else', () => {
72
- const { declared, registrations } = collectRegistrations()
73
- expect(declared).toEqual(['settings.section'])
74
- expect(registrations).toHaveLength(1)
75
- expect(registrations[0]!.slot).toBe('settings.section')
76
- })
77
-
78
- it('no longer claims a shell.overlay float (the review panel it served is gone)', () => {
79
- const { declared } = collectRegistrations()
80
- expect(declared).not.toContain('shell.overlay')
81
- })
82
-
83
- it('pins the section identity (id/order/label/locale) and the panel component', () => {
84
- const { registrations } = collectRegistrations()
85
- const { options, component } = registrations[0]!
86
- expect(options['id']).toBe('context-compression')
87
- expect(options['order']).toBe(17)
88
- expect(options['locale']).toBe('context-compression')
89
- expect((options['label'] as () => string)()).toBe('nav')
90
- expect(typeof options['inject']).toBe('function')
91
- const face = (options['inject'] as () => Record<string, unknown>)()
92
- expect(Object.keys(face).sort()).toEqual(['hooks', 'saveAutoCompact', 'saveCodeSkeleton', 'saveCustom', 'savePresetOptions', 'select', 'resetCustom'].sort())
93
- expect(component).toBe(ContextCompressionSettingsSection)
94
- })
95
-
96
- it('never adds a Plugins-section card or tab alongside the standalone section', () => {
97
- const { declared } = collectRegistrations()
98
- expect(declared).not.toContain('settings.plugins.tab')
99
- expect(declared).not.toContain('settings.plugin.item')
100
- })
101
-
102
- it('survives an older host that does not declare the seat, warning instead of crashing', () => {
103
- // Cross-version tolerance: a host without this seat rejects the
104
- // registration at the slot boundary. apply() must swallow that and warn —
105
- // the historical failure mode was apply() bailing out, which silently took
106
- // EVERY settings entry down with it.
107
- const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
108
- try {
109
- const { declared } = collectRegistrations({ registerThrows: true })
110
- // It tried the seat (so the degradation is "loud", not a silent no-op)…
111
- expect(declared).toEqual(['settings.section'])
112
- // …and the rejection never escaped apply().
113
- expect(warn).toHaveBeenCalled()
114
- } finally {
115
- warn.mockRestore()
116
- }
117
- })
118
- })
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
+
20
+ vi.mock('@deepseek-ai/dsh-client-ui-primitives', () => ({
21
+ IconChevronDownOutlineMedium: () => null,
22
+ Menu: () => null,
23
+ }))
24
+
25
+ interface CapturedRegistration {
26
+ readonly slot: string
27
+ readonly options: Record<string, unknown>
28
+ readonly component: unknown
29
+ }
30
+
31
+ /**
32
+ * Drive apply against a stub host and capture every slot registration.
33
+ * @param options - `registerThrows` models an older host that does not declare
34
+ * the seat: the slot boundary rejects the registration, exactly the shape the
35
+ * 0.1.2-era hosts had.
36
+ */
37
+ function collectRegistrations(
38
+ options: { readonly registerThrows?: boolean } = {},
39
+ ): { declared: string[]; registrations: CapturedRegistration[] } {
40
+ const declared: string[] = []
41
+ const registrations: CapturedRegistration[] = []
42
+ const ctx = {
43
+ locale: { register: vi.fn(() => () => {}), bind: () => (key: string) => key },
44
+ configForms: { get: vi.fn(() => ({}) as never) },
45
+ slots: {
46
+ inject: (slot: string, factory: () => (() => void) | Generator<() => void>) => {
47
+ declared.push(slot)
48
+ const result = factory()
49
+ const steps: Iterable<() => void> = typeof (result as { [Symbol.iterator]?: unknown })?.[Symbol.iterator] === 'function'
50
+ ? (result as Generator<() => void>)
51
+ : [result as () => void]
52
+ for (const step of steps) { void step }
53
+ return () => {}
54
+ },
55
+ register: (record: Record<string, unknown>, component: unknown) => {
56
+ if (options.registerThrows === true) throw new Error(`unknown slot ${String(record['name'])}`)
57
+ registrations.push({ slot: String(record['name']), options: record, component })
58
+ return () => {}
59
+ },
60
+ },
61
+ }
62
+ apply(ctx as unknown as ClientContext)
63
+ return { declared, registrations }
64
+ }
65
+
66
+ describe('settings-seat contract (standalone settings.section only)', () => {
67
+ it('declares the services apply consumes (cordis waits; no lazy-get race)', () => {
68
+ expect(inject).toEqual(['slots', 'locale', 'configForms'])
69
+ })
70
+
71
+ it('injects exactly the settings.section seat and nothing else', () => {
72
+ const { declared, registrations } = collectRegistrations()
73
+ expect(declared).toEqual(['settings.section'])
74
+ expect(registrations).toHaveLength(1)
75
+ expect(registrations[0]!.slot).toBe('settings.section')
76
+ })
77
+
78
+ it('no longer claims a shell.overlay float (the review panel it served is gone)', () => {
79
+ const { declared } = collectRegistrations()
80
+ expect(declared).not.toContain('shell.overlay')
81
+ })
82
+
83
+ it('pins the section identity (id/order/label/locale) and the panel component', () => {
84
+ const { registrations } = collectRegistrations()
85
+ const { options, component } = registrations[0]!
86
+ expect(options['id']).toBe('context-compression')
87
+ expect(options['order']).toBe(17)
88
+ expect(options['locale']).toBe('context-compression')
89
+ expect((options['label'] as () => string)()).toBe('nav')
90
+ expect(typeof options['inject']).toBe('function')
91
+ const face = (options['inject'] as () => Record<string, unknown>)()
92
+ expect(Object.keys(face).sort()).toEqual(['hooks', 'saveAutoCompact', 'saveCodeSkeleton', 'saveCustom', 'savePresetOptions', 'select', 'resetCustom'].sort())
93
+ expect(component).toBe(ContextCompressionSettingsSection)
94
+ })
95
+
96
+ it('never adds a Plugins-section card or tab alongside the standalone section', () => {
97
+ const { declared } = collectRegistrations()
98
+ expect(declared).not.toContain('settings.plugins.tab')
99
+ expect(declared).not.toContain('settings.plugin.item')
100
+ })
101
+
102
+ it('survives an older host that does not declare the seat, warning instead of crashing', () => {
103
+ // Cross-version tolerance: a host without this seat rejects the
104
+ // registration at the slot boundary. apply() must swallow that and warn —
105
+ // the historical failure mode was apply() bailing out, which silently took
106
+ // EVERY settings entry down with it.
107
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
108
+ try {
109
+ const { declared } = collectRegistrations({ registerThrows: true })
110
+ // It tried the seat (so the degradation is "loud", not a silent no-op)…
111
+ expect(declared).toEqual(['settings.section'])
112
+ // …and the rejection never escaped apply().
113
+ expect(warn).toHaveBeenCalled()
114
+ } finally {
115
+ warn.mockRestore()
116
+ }
117
+ })
118
+ })
@@ -1,34 +1,34 @@
1
- import type { ReactNode } from 'react'
2
-
3
- interface MenuItem {
4
- id: string
5
- label: ReactNode
6
- }
7
-
8
- interface MenuProps {
9
- anchor: ReactNode
10
- items: readonly MenuItem[]
11
- onSelect: (id: string) => void
12
- open: boolean
13
- }
14
-
15
- export function IconChevronDownOutline14({ className }: { className?: string }) {
16
- return <span aria-hidden="true" className={className}>⌄</span>
17
- }
18
-
19
- export function Menu({ anchor, items, onSelect, open }: MenuProps) {
20
- return (
21
- <>
22
- {anchor}
23
- {open ? (
24
- <div role="menu">
25
- {items.map(item => (
26
- <button key={item.id} role="menuitem" type="button" onClick={() => { onSelect(item.id) }}>
27
- {item.label}
28
- </button>
29
- ))}
30
- </div>
31
- ) : null}
32
- </>
33
- )
34
- }
1
+ import type { ReactNode } from 'react'
2
+
3
+ interface MenuItem {
4
+ id: string
5
+ label: ReactNode
6
+ }
7
+
8
+ interface MenuProps {
9
+ anchor: ReactNode
10
+ items: readonly MenuItem[]
11
+ onSelect: (id: string) => void
12
+ open: boolean
13
+ }
14
+
15
+ export function IconChevronDownOutlineMedium({ className }: { className?: string }) {
16
+ return <span aria-hidden="true" className={className}>⌄</span>
17
+ }
18
+
19
+ export function Menu({ anchor, items, onSelect, open }: MenuProps) {
20
+ return (
21
+ <>
22
+ {anchor}
23
+ {open ? (
24
+ <div role="menu">
25
+ {items.map(item => (
26
+ <button key={item.id} role="menuitem" type="button" onClick={() => { onSelect(item.id) }}>
27
+ {item.label}
28
+ </button>
29
+ ))}
30
+ </div>
31
+ ) : null}
32
+ </>
33
+ )
34
+ }
@@ -16,48 +16,48 @@ overrides:
16
16
  '@deepseek-ai/cordis-plugin-group': '1.0.1'
17
17
  '@deepseek-ai/cordis-plugin-include': '1.0.6'
18
18
  '@deepseek-ai/cordis-plugin-loader': '1.0.2'
19
- '@deepseek-ai/dsh-agent': '0.1.5-rc.2'
20
- '@deepseek-ai/dsh-agent-loop': '0.1.5-rc.2'
21
- '@deepseek-ai/dsh-agent-loop-testkit': '0.1.5-rc.2'
22
- '@deepseek-ai/dsh-agent-presets': '0.1.5-rc.2'
23
- '@deepseek-ai/dsh-client-locale': '0.1.5-rc.2'
24
- '@deepseek-ai/dsh-client-ui-primitives': '0.1.5-rc.2'
25
- '@deepseek-ai/dsh-client-ui-settings': '0.1.5-rc.2'
26
- '@deepseek-ai/dsh-client-ui-slots': '0.1.5-rc.2'
27
- '@deepseek-ai/dsh-client-store': '0.1.5-rc.2'
28
- '@deepseek-ai/dsh-client-ui-workspace': '0.1.5-rc.2'
29
- '@deepseek-ai/dsh-command-compact': '0.1.5-rc.2'
30
- '@deepseek-ai/dsh-commands': '0.1.5-rc.2'
31
- '@deepseek-ai/dsh-compaction': '0.1.5-rc.2'
32
- '@deepseek-ai/dsh-compaction-basic': '0.1.5-rc.2'
33
- '@deepseek-ai/dsh-invariants': '0.1.5-rc.2'
34
- '@deepseek-ai/dsh-llm': '0.1.5-rc.2'
35
- '@deepseek-ai/dsh-llm-deepseek': '0.1.5-rc.2'
36
- '@deepseek-ai/dsh-scope': '0.1.5-rc.2'
37
- '@deepseek-ai/dsh-session': '0.1.5-rc.2'
38
- '@deepseek-ai/dsh-settings': '0.1.5-rc.2'
39
- '@deepseek-ai/dsh-subagent': '0.1.5-rc.2'
40
- '@deepseek-ai/dsh-subagent-fork-in-process': '0.1.5-rc.2'
41
- '@deepseek-ai/dsh-subagent-spawn-in-process': '0.1.5-rc.2'
42
- '@deepseek-ai/dsh-system-prompt': '0.1.5-rc.2'
43
- '@deepseek-ai/dsh-token-meter': '0.1.5-rc.2'
44
- '@deepseek-ai/dsh-tools': '0.1.5-rc.2'
45
- '@deepseek-ai/dsh-anonymous-user-id': '0.1.5-rc.2'
46
- '@deepseek-ai/dsh-atomic-write': '0.1.5-rc.2'
47
- '@deepseek-ai/dsh-attachment': '0.1.5-rc.2'
48
- '@deepseek-ai/dsh-code-runtime': '0.1.5-rc.2'
49
- '@deepseek-ai/dsh-credentials': '0.1.5-rc.2'
50
- '@deepseek-ai/dsh-home-paths': '0.1.5-rc.2'
51
- '@deepseek-ai/dsh-launch-environment': '0.1.5-rc.2'
52
- '@deepseek-ai/dsh-llm-retry': '0.1.5-rc.2'
53
- '@deepseek-ai/dsh-sandbox': '0.1.5-rc.2'
54
- '@deepseek-ai/dsh-session-persistence': '0.1.5-rc.2'
55
- '@deepseek-ai/dsh-session-projection': '0.1.5-rc.2'
56
- '@deepseek-ai/dsh-subagent-in-process-driver': '0.1.5-rc.2'
57
- '@deepseek-ai/dsh-user-approval': '0.1.5-rc.2'
58
- '@deepseek-ai/schemastery': '3.18.2'
59
- '@deepseek-ai/dsh-client-ui-session': '0.1.5-rc.2'
60
- '@deepseek-ai/dsh-api-session-controller': '0.1.5-rc.2'
19
+ '@deepseek-ai/dsh-agent': '0.1.7-rc.2'
20
+ '@deepseek-ai/dsh-agent-loop': '0.1.7-rc.2'
21
+ '@deepseek-ai/dsh-agent-loop-testkit': '0.1.7-rc.1'
22
+ '@deepseek-ai/dsh-agent-presets': '0.1.6-alpha.2'
23
+ '@deepseek-ai/dsh-client-locale': '0.1.7-rc.2'
24
+ '@deepseek-ai/dsh-client-ui-primitives': '0.1.7-rc.2'
25
+ '@deepseek-ai/dsh-client-ui-settings': '0.1.7-rc.2'
26
+ '@deepseek-ai/dsh-client-ui-slots': '0.1.7-rc.2'
27
+ '@deepseek-ai/dsh-client-store': '0.1.7-rc.2'
28
+ '@deepseek-ai/dsh-client-ui-workspace': '0.1.7-rc.2'
29
+ '@deepseek-ai/dsh-command-compact': '0.1.7-rc.2'
30
+ '@deepseek-ai/dsh-commands': '0.1.7-rc.2'
31
+ '@deepseek-ai/dsh-compaction': '0.1.7-rc.2'
32
+ '@deepseek-ai/dsh-compaction-basic': '0.1.7-rc.2'
33
+ '@deepseek-ai/dsh-invariants': '0.1.7-rc.2'
34
+ '@deepseek-ai/dsh-llm': '0.1.7-rc.2'
35
+ '@deepseek-ai/dsh-llm-deepseek': '0.1.7-rc.2'
36
+ '@deepseek-ai/dsh-scope': '0.1.7-rc.2'
37
+ '@deepseek-ai/dsh-session': '0.1.7-rc.2'
38
+ '@deepseek-ai/dsh-settings': '0.1.7-rc.2'
39
+ '@deepseek-ai/dsh-subagent': '0.1.7-rc.2'
40
+ '@deepseek-ai/dsh-subagent-fork-in-process': '0.1.7-rc.2'
41
+ '@deepseek-ai/dsh-subagent-spawn-in-process': '0.1.7-rc.2'
42
+ '@deepseek-ai/dsh-system-prompt': '0.1.7-rc.2'
43
+ '@deepseek-ai/dsh-token-meter': '0.1.7-rc.2'
44
+ '@deepseek-ai/dsh-tools': '0.1.7-rc.2'
45
+ '@deepseek-ai/dsh-anonymous-user-id': '0.1.7-rc.2'
46
+ '@deepseek-ai/dsh-atomic-write': '0.1.7-rc.2'
47
+ '@deepseek-ai/dsh-attachment': '0.1.7-rc.2'
48
+ '@deepseek-ai/dsh-code-runtime': '0.1.5-rc.3'
49
+ '@deepseek-ai/dsh-credentials': '0.1.7-rc.2'
50
+ '@deepseek-ai/dsh-home-paths': '0.1.7-rc.2'
51
+ '@deepseek-ai/dsh-launch-environment': '0.1.7-rc.2'
52
+ '@deepseek-ai/dsh-llm-retry': '0.1.7-rc.2'
53
+ '@deepseek-ai/dsh-sandbox': '0.1.7-rc.2'
54
+ '@deepseek-ai/dsh-session-persistence': '0.1.7-rc.2'
55
+ '@deepseek-ai/dsh-session-projection': '0.1.7-rc.2'
56
+ '@deepseek-ai/dsh-subagent-in-process-driver': '0.1.7-rc.2'
57
+ '@deepseek-ai/dsh-user-approval': '0.1.7-rc.2'
58
+ '@deepseek-ai/schemastery': '3.18.4'
59
+ '@deepseek-ai/dsh-client-ui-session': '0.1.7-rc.2'
60
+ '@deepseek-ai/dsh-api-session-controller': '0.1.7-rc.2'
61
61
  # Scoped, not global: @deepseek-ai/cordis-plugin-include (^4.1.0) and
62
62
  # @deepseek-ai/dsh-agent-presets resolve js-yaml 4.3.1 from ranges that already
63
63
  # allow the patched release, so pin the vulnerable ones without waiting on their