dsh-context-compression-improved 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +162 -162
- package/packages/selector/lib/client.d.ts +29 -19
- package/packages/selector/lib/client.js +28 -14
- package/packages/selector/lib/pruner.d.ts +7 -0
- package/packages/selector/lib/pruner.js +20 -33
- package/packages/selector/lib/tail-trim.js +3 -6
- package/packages/selector/package.json +114 -114
- package/packages/selector/src/client/CompressionProfileControls.tsx +2 -2
- package/packages/selector/src/client/CompressionProfileSelector.tsx +1 -1
- package/packages/selector/src/client/index.ts +225 -212
- package/packages/selector/src/client/scope-face.ts +24 -0
- package/packages/selector/src/pruner/content.ts +0 -3
- package/packages/selector/src/pruner/session.ts +4 -2
- package/packages/selector/src/pruner.ts +26 -15
- package/packages/selector/src/runtime/measurement.ts +3 -8
- package/packages/selector/src/runtime/retrieve.ts +3 -3
- package/packages/selector/src/runtime/tail-trim.ts +4 -5
- package/packages/selector/tests/custom-contract.client.spec.ts +222 -222
- package/packages/selector/tests/public/package-contract.client.spec.ts +78 -78
- package/packages/selector/tests/settings-seat.client.spec.ts +165 -118
- package/packages/selector/tests/support/ui-primitives.tsx +34 -34
- package/pnpm-workspace.yaml +42 -42
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
2
|
-
import { resolve } from 'node:path'
|
|
3
|
-
import { describe, expect, it } from 'vitest'
|
|
4
|
-
|
|
5
|
-
const root = resolve(import.meta.dirname, '../../..')
|
|
6
|
-
|
|
7
|
-
describe('standalone package contract', () => {
|
|
8
|
-
it('ships one install-facing package with no intra-repo dependency edge', () => {
|
|
9
|
-
const selector = JSON.parse(readFileSync(resolve(root, 'selector/package.json'), 'utf8')) as {
|
|
10
|
-
name: string
|
|
11
|
-
version: string
|
|
12
|
-
dependencies?: Record<string, string>
|
|
13
|
-
peerDependencies?: Record<string, string>
|
|
14
|
-
publishConfig?: { tag?: string }
|
|
15
|
-
}
|
|
16
|
-
expect(selector.name).toBe('dsh-context-compression-improved')
|
|
17
|
-
expect(selector.dependencies?.['@huggingface/tokenizers']).toBe('0.1.3')
|
|
18
|
-
expect(Object.keys(selector.dependencies ?? {})).not.toContain('dsh-context-compression-improved-runtime')
|
|
19
|
-
expect(Object.keys(selector.peerDependencies ?? {})).not.toContain('dsh-context-compression-improved-runtime')
|
|
20
|
-
expect(Object.keys(selector.peerDependencies ?? {})).not.toContain('@deepseek-ai/dsh-compaction-tool-result-pruner')
|
|
21
|
-
expect(selector.peerDependencies?.['@deepseek-ai/dsh-compaction-basic'])
|
|
22
|
-
.toBe('>=0.1.7-rc.1 <0.2.0-0')
|
|
23
|
-
expect(selector.peerDependencies?.['@deepseek-ai/dsh-command-compact'])
|
|
24
|
-
.toBe('>=0.1.7-rc.1 <0.2.0-0')
|
|
25
|
-
expect(selector.publishConfig?.tag).toBe('latest')
|
|
26
|
-
expect(existsSync(resolve(root, '../runtime/package.json'))).toBe(false)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('makes the repository root the one git install surface', () => {
|
|
30
|
-
const rootManifest = JSON.parse(readFileSync(resolve(root, '../package.json'), 'utf8')) as {
|
|
31
|
-
name: string
|
|
32
|
-
exports?: Record<string, unknown>
|
|
33
|
-
dependencies?: Record<string, string>
|
|
34
|
-
engines?: Record<string, string>
|
|
35
|
-
dsh?: { bundle?: { patch?: string }, client?: { inject?: string[] } }
|
|
36
|
-
}
|
|
37
|
-
expect(rootManifest.name).toBe('dsh-context-compression-improved')
|
|
38
|
-
for (const specifier of ['.', './invariant', './pruner', './client']) {
|
|
39
|
-
expect(rootManifest.exports?.[specifier]).toBeDefined()
|
|
40
|
-
}
|
|
41
|
-
expect(rootManifest.dependencies?.['@huggingface/tokenizers']).toBe('0.1.3')
|
|
42
|
-
expect(rootManifest.dependencies?.['js-yaml']).toBe('^4.3.2')
|
|
43
|
-
expect(rootManifest.dsh?.bundle?.patch).toBe('./packages/selector/cordis.patch.yml')
|
|
44
|
-
expect(rootManifest.dsh?.client?.inject).toEqual([
|
|
45
|
-
'@deepseek-ai/dsh-client-locale',
|
|
46
|
-
'@deepseek-ai/dsh-client-ui-primitives',
|
|
47
|
-
'@deepseek-ai/dsh-client-ui-slots',
|
|
48
|
-
'@deepseek-ai/dsh-client-ui-settings',
|
|
49
|
-
])
|
|
50
|
-
expect(rootManifest.engines?.dsh).toBe('>=0.1.
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it('uses the community package in the one Bundle patch', () => {
|
|
54
|
-
const patch = readFileSync(resolve(root, 'selector/cordis.patch.yml'), 'utf8')
|
|
55
|
-
expect(patch).toContain("name: 'dsh-context-compression-improved'")
|
|
56
|
-
expect(patch).not.toContain('@deepseek-ai/dsh-client-ui-context-compression-selector')
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('never ships a retired plugin config key in the Bundle patch', () => {
|
|
60
|
-
// Negative control: the patch is loaded by the host and validated against
|
|
61
|
-
// the plugin's own Config schema, but nothing tied the two together — so
|
|
62
|
-
// the retired review gate's `reviewQueueRoute` survived in this file after
|
|
63
|
-
// the key was removed from the schema, advertising a route that can never
|
|
64
|
-
// register. A retired key must fail here instead of shipping quietly.
|
|
65
|
-
//
|
|
66
|
-
// The pin is on KEY-SETTING lines, not on the whole document: the comments
|
|
67
|
-
// above the rows deliberately name the retired key while explaining why it
|
|
68
|
-
// is gone, and prose must not be mistaken for configuration.
|
|
69
|
-
const patch = readFileSync(resolve(root, 'selector/cordis.patch.yml'), 'utf8')
|
|
70
|
-
const lines = patch.split('\n')
|
|
71
|
-
for (const retired of ['reviewQueueRoute', 'reviewMode', 'reviewTimeoutTurns', 'reviewHighImpactTokens']) {
|
|
72
|
-
const setsRetired = lines.find(line => new RegExp(`^\\s*${retired}\\s*:`).test(line))
|
|
73
|
-
expect(setsRetired, `${retired} is still set in the Bundle patch`).toBeUndefined()
|
|
74
|
-
}
|
|
75
|
-
// And the live flag the routes row exists for is still wired.
|
|
76
|
-
expect(patch).toContain('estimatorCatalogRoute: true')
|
|
77
|
-
})
|
|
78
|
-
})
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
|
|
5
|
+
const root = resolve(import.meta.dirname, '../../..')
|
|
6
|
+
|
|
7
|
+
describe('standalone package contract', () => {
|
|
8
|
+
it('ships one install-facing package with no intra-repo dependency edge', () => {
|
|
9
|
+
const selector = JSON.parse(readFileSync(resolve(root, 'selector/package.json'), 'utf8')) as {
|
|
10
|
+
name: string
|
|
11
|
+
version: string
|
|
12
|
+
dependencies?: Record<string, string>
|
|
13
|
+
peerDependencies?: Record<string, string>
|
|
14
|
+
publishConfig?: { tag?: string }
|
|
15
|
+
}
|
|
16
|
+
expect(selector.name).toBe('dsh-context-compression-improved')
|
|
17
|
+
expect(selector.dependencies?.['@huggingface/tokenizers']).toBe('0.1.3')
|
|
18
|
+
expect(Object.keys(selector.dependencies ?? {})).not.toContain('dsh-context-compression-improved-runtime')
|
|
19
|
+
expect(Object.keys(selector.peerDependencies ?? {})).not.toContain('dsh-context-compression-improved-runtime')
|
|
20
|
+
expect(Object.keys(selector.peerDependencies ?? {})).not.toContain('@deepseek-ai/dsh-compaction-tool-result-pruner')
|
|
21
|
+
expect(selector.peerDependencies?.['@deepseek-ai/dsh-compaction-basic'])
|
|
22
|
+
.toBe('>=0.1.7-rc.1 <0.2.0-0')
|
|
23
|
+
expect(selector.peerDependencies?.['@deepseek-ai/dsh-command-compact'])
|
|
24
|
+
.toBe('>=0.1.7-rc.1 <0.2.0-0')
|
|
25
|
+
expect(selector.publishConfig?.tag).toBe('latest')
|
|
26
|
+
expect(existsSync(resolve(root, '../runtime/package.json'))).toBe(false)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('makes the repository root the one git install surface', () => {
|
|
30
|
+
const rootManifest = JSON.parse(readFileSync(resolve(root, '../package.json'), 'utf8')) as {
|
|
31
|
+
name: string
|
|
32
|
+
exports?: Record<string, unknown>
|
|
33
|
+
dependencies?: Record<string, string>
|
|
34
|
+
engines?: Record<string, string>
|
|
35
|
+
dsh?: { bundle?: { patch?: string }, client?: { inject?: string[] } }
|
|
36
|
+
}
|
|
37
|
+
expect(rootManifest.name).toBe('dsh-context-compression-improved')
|
|
38
|
+
for (const specifier of ['.', './invariant', './pruner', './client']) {
|
|
39
|
+
expect(rootManifest.exports?.[specifier]).toBeDefined()
|
|
40
|
+
}
|
|
41
|
+
expect(rootManifest.dependencies?.['@huggingface/tokenizers']).toBe('0.1.3')
|
|
42
|
+
expect(rootManifest.dependencies?.['js-yaml']).toBe('^4.3.2')
|
|
43
|
+
expect(rootManifest.dsh?.bundle?.patch).toBe('./packages/selector/cordis.patch.yml')
|
|
44
|
+
expect(rootManifest.dsh?.client?.inject).toEqual([
|
|
45
|
+
'@deepseek-ai/dsh-client-locale',
|
|
46
|
+
'@deepseek-ai/dsh-client-ui-primitives',
|
|
47
|
+
'@deepseek-ai/dsh-client-ui-slots',
|
|
48
|
+
'@deepseek-ai/dsh-client-ui-settings',
|
|
49
|
+
])
|
|
50
|
+
expect(rootManifest.engines?.dsh).toBe('>=0.1.7-rc.1 <0.1.8-0')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('uses the community package in the one Bundle patch', () => {
|
|
54
|
+
const patch = readFileSync(resolve(root, 'selector/cordis.patch.yml'), 'utf8')
|
|
55
|
+
expect(patch).toContain("name: 'dsh-context-compression-improved'")
|
|
56
|
+
expect(patch).not.toContain('@deepseek-ai/dsh-client-ui-context-compression-selector')
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('never ships a retired plugin config key in the Bundle patch', () => {
|
|
60
|
+
// Negative control: the patch is loaded by the host and validated against
|
|
61
|
+
// the plugin's own Config schema, but nothing tied the two together — so
|
|
62
|
+
// the retired review gate's `reviewQueueRoute` survived in this file after
|
|
63
|
+
// the key was removed from the schema, advertising a route that can never
|
|
64
|
+
// register. A retired key must fail here instead of shipping quietly.
|
|
65
|
+
//
|
|
66
|
+
// The pin is on KEY-SETTING lines, not on the whole document: the comments
|
|
67
|
+
// above the rows deliberately name the retired key while explaining why it
|
|
68
|
+
// is gone, and prose must not be mistaken for configuration.
|
|
69
|
+
const patch = readFileSync(resolve(root, 'selector/cordis.patch.yml'), 'utf8')
|
|
70
|
+
const lines = patch.split('\n')
|
|
71
|
+
for (const retired of ['reviewQueueRoute', 'reviewMode', 'reviewTimeoutTurns', 'reviewHighImpactTokens']) {
|
|
72
|
+
const setsRetired = lines.find(line => new RegExp(`^\\s*${retired}\\s*:`).test(line))
|
|
73
|
+
expect(setsRetired, `${retired} is still set in the Bundle patch`).toBeUndefined()
|
|
74
|
+
}
|
|
75
|
+
// And the live flag the routes row exists for is still wired.
|
|
76
|
+
expect(patch).toContain('estimatorCatalogRoute: true')
|
|
77
|
+
})
|
|
78
|
+
})
|
|
@@ -1,118 +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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
readonly
|
|
28
|
-
readonly
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
expect(
|
|
75
|
-
expect(registrations
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const {
|
|
86
|
-
|
|
87
|
-
expect(options['
|
|
88
|
-
expect(options['
|
|
89
|
-
expect(
|
|
90
|
-
expect(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
expect(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
expect(declared).not.toContain('settings.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
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
|
+
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,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
|
|
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
|
+
}
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -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.
|
|
20
|
-
'@deepseek-ai/dsh-agent-loop': '0.1.
|
|
21
|
-
'@deepseek-ai/dsh-agent-loop-testkit': '0.1.
|
|
22
|
-
'@deepseek-ai/dsh-agent-presets': '0.1.
|
|
23
|
-
'@deepseek-ai/dsh-client-locale': '0.1.
|
|
24
|
-
'@deepseek-ai/dsh-client-ui-primitives': '0.1.
|
|
25
|
-
'@deepseek-ai/dsh-client-ui-settings': '0.1.
|
|
26
|
-
'@deepseek-ai/dsh-client-ui-slots': '0.1.
|
|
27
|
-
'@deepseek-ai/dsh-client-store': '0.1.
|
|
28
|
-
'@deepseek-ai/dsh-client-ui-workspace': '0.1.
|
|
29
|
-
'@deepseek-ai/dsh-command-compact': '0.1.
|
|
30
|
-
'@deepseek-ai/dsh-commands': '0.1.
|
|
31
|
-
'@deepseek-ai/dsh-compaction': '0.1.
|
|
32
|
-
'@deepseek-ai/dsh-compaction-basic': '0.1.
|
|
33
|
-
'@deepseek-ai/dsh-invariants': '0.1.
|
|
34
|
-
'@deepseek-ai/dsh-llm': '0.1.
|
|
35
|
-
'@deepseek-ai/dsh-llm-deepseek': '0.1.
|
|
36
|
-
'@deepseek-ai/dsh-scope': '0.1.
|
|
37
|
-
'@deepseek-ai/dsh-session': '0.1.
|
|
38
|
-
'@deepseek-ai/dsh-settings': '0.1.
|
|
39
|
-
'@deepseek-ai/dsh-subagent': '0.1.
|
|
40
|
-
'@deepseek-ai/dsh-subagent-fork-in-process': '0.1.
|
|
41
|
-
'@deepseek-ai/dsh-subagent-spawn-in-process': '0.1.
|
|
42
|
-
'@deepseek-ai/dsh-system-prompt': '0.1.
|
|
43
|
-
'@deepseek-ai/dsh-token-meter': '0.1.
|
|
44
|
-
'@deepseek-ai/dsh-tools': '0.1.
|
|
45
|
-
'@deepseek-ai/dsh-anonymous-user-id': '0.1.
|
|
46
|
-
'@deepseek-ai/dsh-atomic-write': '0.1.
|
|
47
|
-
'@deepseek-ai/dsh-attachment': '0.1.
|
|
48
|
-
'@deepseek-ai/dsh-code-runtime': '0.1.5-rc.
|
|
49
|
-
'@deepseek-ai/dsh-credentials': '0.1.
|
|
50
|
-
'@deepseek-ai/dsh-home-paths': '0.1.
|
|
51
|
-
'@deepseek-ai/dsh-launch-environment': '0.1.
|
|
52
|
-
'@deepseek-ai/dsh-llm-retry': '0.1.
|
|
53
|
-
'@deepseek-ai/dsh-sandbox': '0.1.
|
|
54
|
-
'@deepseek-ai/dsh-session-persistence': '0.1.
|
|
55
|
-
'@deepseek-ai/dsh-session-projection': '0.1.
|
|
56
|
-
'@deepseek-ai/dsh-subagent-in-process-driver': '0.1.
|
|
57
|
-
'@deepseek-ai/dsh-user-approval': '0.1.
|
|
58
|
-
'@deepseek-ai/schemastery': '3.18.
|
|
59
|
-
'@deepseek-ai/dsh-client-ui-session': '0.1.
|
|
60
|
-
'@deepseek-ai/dsh-api-session-controller': '0.1.
|
|
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
|