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,206 +1,200 @@
1
- import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
2
- import { tmpdir } from 'node:os'
3
- import { join } from 'node:path'
4
- import { pathToFileURL } from 'node:url'
5
- import { Context } from '@deepseek-ai/cordis'
6
- import Group from '@deepseek-ai/cordis-plugin-group'
7
- import Include from '@deepseek-ai/cordis-plugin-include'
8
- import { Config } from '../src/index.ts'
9
- import Loader from '@deepseek-ai/cordis-plugin-loader'
10
- import AgentRegistry, { type Agent } from '@deepseek-ai/dsh-agent'
11
- import AgentLoop from '@deepseek-ai/dsh-agent-loop'
12
- import AgentPresets, { COMPOSITION_FILE } from '@deepseek-ai/dsh-agent-presets'
13
- import CommandRuntime from '@deepseek-ai/dsh-commands'
14
- import LlmRuntime from '@deepseek-ai/dsh-llm'
15
- import SessionStore, { SessionId } from '@deepseek-ai/dsh-session'
16
- import { scopeOf } from '@deepseek-ai/dsh-scope'
17
- import {
18
- SettingsProvider,
19
- type SettingsNamespace,
20
- } from '@deepseek-ai/dsh-settings'
21
- import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
22
- import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
23
- import TokenMeter from '@deepseek-ai/dsh-token-meter'
24
- import ToolRuntime from '@deepseek-ai/dsh-tools'
25
- import { afterEach, describe, expect, it } from 'vitest'
26
- import { apply } from '../src/index.ts'
27
- import { LegacyNamespaceRegistrar } from './helpers/legacy-namespace.ts'
28
-
29
- // 0.1.5 removed the settingsNamespace() wrapper; namespaces are validated at runtime.
30
- const nsBrand = (value: string): SettingsNamespace => value as unknown as SettingsNamespace
31
-
32
- const CORDIS_ORIGINAL = Symbol.for('cordis.original')
33
- type Traceable = { [CORDIS_ORIGINAL]?: unknown }
34
-
35
- let ctx: Context | undefined
36
- let root: string | undefined
37
-
38
- afterEach(async () => {
39
- await ctx?.fiber.dispose()
40
- ctx = undefined
41
- if (root !== undefined) await rm(root, { recursive: true, force: true })
42
- root = undefined
43
- })
44
-
45
- class MemorySettings extends SettingsProvider {
46
- readonly writable = true
47
-
48
- protected load(): Promise<Record<string, unknown>> {
49
- return Promise.resolve({})
50
- }
51
-
52
- protected persist(_ns: SettingsNamespace, _section: Record<string, unknown>): Promise<void> {
53
- return Promise.resolve()
54
- }
55
- }
56
-
57
- interface CustomSettings {
58
- profile: string
59
- custom: {
60
- history: { trigger: number }
61
- tailTrim: { enabled: boolean; trigger: number }
62
- }
63
- }
64
-
65
- async function createPresetRoot(): Promise<string> {
66
- root = await mkdtemp(join(tmpdir(), 'dsh-selector-loader-e2e-'))
67
- const marker = join(root, 'marker.mjs')
68
- await writeFile(marker, 'export function apply() {}\n')
69
- const source = `- id: source-marker\n name: ${JSON.stringify(marker)}\n`
70
- for (const id of ['standard', 'custom', 'minimal']) {
71
- const directory = join(root, id)
72
- await mkdir(directory)
73
- await writeFile(join(directory, COMPOSITION_FILE), source)
74
- }
75
- return root
76
- }
77
-
78
- async function harness(): Promise<Context> {
79
- const presets = await createPresetRoot()
80
- const runtime = new Context()
81
- runtime.baseUrl = `${pathToFileURL(presets).href}/`
82
- await runtime.plugin(Loader).await()
83
- runtime.loader.builtins.include = Include
84
- runtime.loader.builtins.group = Group
85
- await runtime.plugin(LlmRuntime).await()
86
- await runtime.plugin(SessionStore).await()
87
- await runtime.plugin(SystemPrompt).await()
88
- await runtime.plugin(ToolRuntime).await()
89
- await runtime.plugin(AgentRegistry).await()
90
- await runtime.plugin(AgentLoop).await()
91
- await runtime.plugin(CommandRuntime).await()
92
- await runtime.plugin(SessionProjectionRegistry).await()
93
- await runtime.plugin(TokenMeter).await()
94
- await runtime.plugin(MemorySettings).await()
95
- await runtime.plugin(AgentPresets, {
96
- default: 'standard',
97
- roots: [{ path: presets, trust: 'system' }],
98
- includeShippedRoot: false,
99
- includeUserRoot: false,
100
- })
101
- await runtime.plugin({
102
- apply: (selectorCtx) => {
103
- apply(selectorCtx, { presetOverlay: true })
104
- },
105
- }).await()
106
- ctx = runtime
107
- return runtime
108
- }
109
-
110
- async function agentOn(runtime: Context, sessionId: string, preset: string): Promise<Agent> {
111
- const handle = await runtime.agents.create({
112
- sessionId: SessionId(sessionId),
113
- setup: async agentCtx => void await runtime.agentPresets.mount(agentCtx, preset),
114
- })
115
- return handle.agent
116
- }
117
-
118
- function hasCompressionRetrieve(runtime: Context, agent: Agent): boolean {
119
- return runtime.tools.get('context_compression_retrieve', scopeOf(agent.ctx)) !== undefined
120
- }
121
-
122
- function hasCompactCommand(runtime: Context, agent: Agent): boolean {
123
- return runtime.commands.list(agent).some(command => command.name === 'compact')
124
- }
125
-
126
- function expectCompleteCompressionStack(runtime: Context, agent: Agent): void {
127
- expect(runtime.agentPresets.serviceFor(agent, 'toolResultPruner')).toBeDefined()
128
- expect(runtime.agentPresets.serviceFor(agent, 'compaction')).toBeDefined()
129
- expect(hasCompressionRetrieve(runtime, agent)).toBe(true)
130
- expect(hasCompactCommand(runtime, agent)).toBe(true)
131
- }
132
-
133
- function expectNoCompressionStack(runtime: Context, agent: Agent): void {
134
- expect(runtime.agentPresets.serviceFor(agent, 'toolResultPruner')).toBeUndefined()
135
- expect(runtime.agentPresets.serviceFor(agent, 'compaction')).toBeUndefined()
136
- expect(hasCompressionRetrieve(runtime, agent)).toBe(false)
137
- expect(hasCompactCommand(runtime, agent)).toBe(false)
138
- }
139
-
140
- describe('standalone selector Bundle through the real preset Loader', () => {
141
- it('mounts the complete stack without changing source preset authoring', async () => {
142
- const runtime = await harness()
143
- const source = await runtime.agentPresets.resolve('standard')
144
- const sourceText = await runtime.agentPresets.read('standard')
145
-
146
- const agent = await agentOn(runtime, 'selector-loader-standard', 'standard')
147
-
148
- expectCompleteCompressionStack(runtime, agent)
149
- expect((await runtime.agentPresets.resolve('standard')).path).toBe(source.path)
150
- expect(await runtime.agentPresets.read('standard')).toBe(sourceText)
151
- expect(sourceText).not.toContain('tool-result-pruner')
152
- })
153
-
154
- it('keeps compression across preset changes and excludes only exact Minimal', async () => {
155
- const runtime = await harness()
156
- const agent = await agentOn(runtime, 'selector-loader-switch', 'standard')
157
- expectCompleteCompressionStack(runtime, agent)
158
-
159
- await runtime.agentPresets.recompose(agent.ctx, 'minimal')
160
- expectNoCompressionStack(runtime, agent)
161
-
162
- // `custom` deliberately contains the same source rows as Minimal. Its id,
163
- // not its copied contents, decides the one documented exception.
164
- await runtime.agentPresets.recompose(agent.ctx, 'custom')
165
- expectCompleteCompressionStack(runtime, agent)
166
- })
167
-
168
- it('gives a child the parent\'s exact compression service instances', async () => {
169
- const runtime = await harness()
170
- const parent = await agentOn(runtime, 'selector-loader-parent', 'standard')
171
- const childHandle = await runtime.agents.create({
172
- sessionId: SessionId('selector-loader-child'),
173
- setup: childCtx => void runtime.agentPresets.composeFrom(childCtx, parent.ctx),
174
- })
175
- const child = childHandle.agent
176
-
177
- const parentPruner = runtime.agentPresets.serviceFor(parent, 'toolResultPruner')
178
- const childPruner = runtime.agentPresets.serviceFor(child, 'toolResultPruner')
179
- const parentCompaction = runtime.agentPresets.serviceFor(parent, 'compaction')
180
- const childCompaction = runtime.agentPresets.serviceFor(child, 'compaction')
181
- expect(parentPruner).toBeDefined()
182
- expect(parentCompaction).toBeDefined()
183
- expect(Object.is(
184
- (childPruner as Traceable)[CORDIS_ORIGINAL],
185
- (parentPruner as Traceable)[CORDIS_ORIGINAL],
186
- )).toBe(true)
187
- expect(Object.is(
188
- (childCompaction as Traceable)[CORDIS_ORIGINAL],
189
- (parentCompaction as Traceable)[CORDIS_ORIGINAL],
190
- )).toBe(true)
191
- expect(hasCompressionRetrieve(runtime, child)).toBe(true)
192
- expect(hasCompactCommand(runtime, child)).toBe(true)
193
- })
194
-
195
- it('carries the daily Custom defaults on the bundle entry config schema', async () => {
196
- // 0.1.7: there is no plugin-owned settings row publishing defaults — the
197
- // volatile `settings` field's schema defaults ARE the daily Custom doc the
198
- // loader resolves into every composition.
199
- const settings = (Config({ presetOverlay: true }).settings as unknown as {
200
- get(): CustomSettings
201
- }).get()
202
-
203
- expect(settings.custom.history.trigger).toBe(500_000)
204
- expect(settings.custom.tailTrim).toEqual({ enabled: false, trigger: 700_000 })
205
- })
206
- })
1
+ import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
2
+ import { tmpdir } from 'node:os'
3
+ import { join } from 'node:path'
4
+ import { pathToFileURL } from 'node:url'
5
+ import { Context } from '@deepseek-ai/cordis'
6
+ import Group from '@deepseek-ai/cordis-plugin-group'
7
+ import Include from '@deepseek-ai/cordis-plugin-include'
8
+ import { Config } from '../src/index.ts'
9
+ import Loader from '@deepseek-ai/cordis-plugin-loader'
10
+ import AgentRegistry, { type Agent } from '@deepseek-ai/dsh-agent'
11
+ import AgentLoop from '@deepseek-ai/dsh-agent-loop'
12
+ import AgentPresets, { COMPOSITION_FILE } from '@deepseek-ai/dsh-agent-presets'
13
+ import CommandRuntime from '@deepseek-ai/dsh-commands'
14
+ import LlmRuntime from '@deepseek-ai/dsh-llm'
15
+ import SessionStore, { SessionId } from '@deepseek-ai/dsh-session'
16
+ import { scopeOf } from '@deepseek-ai/dsh-scope'
17
+ import { type SettingsNamespace } from '@deepseek-ai/dsh-settings'
18
+ import { LegacySettingsProvider } from './helpers/legacy-settings/index.ts'
19
+ import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
20
+ import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
21
+ import TokenMeter from '@deepseek-ai/dsh-token-meter'
22
+ import ToolRuntime from '@deepseek-ai/dsh-tools'
23
+ import { afterEach, describe, expect, it } from 'vitest'
24
+ import { apply } from '../src/index.ts'
25
+
26
+ const CORDIS_ORIGINAL = Symbol.for('cordis.original')
27
+ type Traceable = { [CORDIS_ORIGINAL]?: unknown }
28
+
29
+ let ctx: Context | undefined
30
+ let root: string | undefined
31
+
32
+ afterEach(async () => {
33
+ await ctx?.fiber.dispose()
34
+ ctx = undefined
35
+ if (root !== undefined) await rm(root, { recursive: true, force: true })
36
+ root = undefined
37
+ })
38
+
39
+ class MemorySettings extends LegacySettingsProvider {
40
+ readonly writable = true
41
+
42
+ protected load(): Promise<Record<string, unknown>> {
43
+ return Promise.resolve({})
44
+ }
45
+
46
+ protected persist(_ns: SettingsNamespace, _section: Record<string, unknown>): Promise<void> {
47
+ return Promise.resolve()
48
+ }
49
+ }
50
+
51
+ interface CustomSettings {
52
+ profile: string
53
+ custom: {
54
+ history: { trigger: number }
55
+ tailTrim: { enabled: boolean; trigger: number }
56
+ }
57
+ }
58
+
59
+ async function createPresetRoot(): Promise<string> {
60
+ root = await mkdtemp(join(tmpdir(), 'dsh-selector-loader-e2e-'))
61
+ const marker = join(root, 'marker.mjs')
62
+ await writeFile(marker, 'export function apply() {}\n')
63
+ const source = `- id: source-marker\n name: ${JSON.stringify(marker)}\n`
64
+ for (const id of ['standard', 'custom', 'minimal']) {
65
+ const directory = join(root, id)
66
+ await mkdir(directory)
67
+ await writeFile(join(directory, COMPOSITION_FILE), source)
68
+ }
69
+ return root
70
+ }
71
+
72
+ async function harness(): Promise<Context> {
73
+ const presets = await createPresetRoot()
74
+ const runtime = new Context()
75
+ runtime.baseUrl = `${pathToFileURL(presets).href}/`
76
+ await runtime.plugin(Loader).await()
77
+ runtime.loader.builtins.include = Include
78
+ runtime.loader.builtins.group = Group
79
+ await runtime.plugin(LlmRuntime).await()
80
+ await runtime.plugin(SessionStore).await()
81
+ await runtime.plugin(SystemPrompt).await()
82
+ await runtime.plugin(ToolRuntime).await()
83
+ await runtime.plugin(AgentRegistry).await()
84
+ await runtime.plugin(AgentLoop).await()
85
+ await runtime.plugin(CommandRuntime).await()
86
+ await runtime.plugin(SessionProjectionRegistry).await()
87
+ await runtime.plugin(TokenMeter).await()
88
+ await runtime.plugin(MemorySettings).await()
89
+ await runtime.plugin(AgentPresets, {
90
+ default: 'standard',
91
+ roots: [{ path: presets, trust: 'system' }],
92
+ includeShippedRoot: false,
93
+ includeUserRoot: false,
94
+ })
95
+ await runtime.plugin({
96
+ apply: (selectorCtx) => {
97
+ apply(selectorCtx, { presetOverlay: true })
98
+ },
99
+ }).await()
100
+ ctx = runtime
101
+ return runtime
102
+ }
103
+
104
+ async function agentOn(runtime: Context, sessionId: string, preset: string): Promise<Agent> {
105
+ const handle = await runtime.agents.create({
106
+ sessionId: SessionId(sessionId),
107
+ setup: async agentCtx => void await runtime.agentPresets.mount(agentCtx, preset),
108
+ })
109
+ return handle.agent
110
+ }
111
+
112
+ function hasCompressionRetrieve(runtime: Context, agent: Agent): boolean {
113
+ return runtime.tools.get('context_compression_retrieve', scopeOf(agent.ctx)) !== undefined
114
+ }
115
+
116
+ function hasCompactCommand(runtime: Context, agent: Agent): boolean {
117
+ return runtime.commands.list(agent).some(command => command.name === 'compact')
118
+ }
119
+
120
+ function expectCompleteCompressionStack(runtime: Context, agent: Agent): void {
121
+ expect(runtime.agentPresets.serviceFor(agent, 'toolResultPruner')).toBeDefined()
122
+ expect(runtime.agentPresets.serviceFor(agent, 'compaction')).toBeDefined()
123
+ expect(hasCompressionRetrieve(runtime, agent)).toBe(true)
124
+ expect(hasCompactCommand(runtime, agent)).toBe(true)
125
+ }
126
+
127
+ function expectNoCompressionStack(runtime: Context, agent: Agent): void {
128
+ expect(runtime.agentPresets.serviceFor(agent, 'toolResultPruner')).toBeUndefined()
129
+ expect(runtime.agentPresets.serviceFor(agent, 'compaction')).toBeUndefined()
130
+ expect(hasCompressionRetrieve(runtime, agent)).toBe(false)
131
+ expect(hasCompactCommand(runtime, agent)).toBe(false)
132
+ }
133
+
134
+ describe('standalone selector Bundle through the real preset Loader', () => {
135
+ it('mounts the complete stack without changing source preset authoring', async () => {
136
+ const runtime = await harness()
137
+ const source = await runtime.agentPresets.resolve('standard')
138
+ const sourceText = await runtime.agentPresets.read('standard')
139
+
140
+ const agent = await agentOn(runtime, 'selector-loader-standard', 'standard')
141
+
142
+ expectCompleteCompressionStack(runtime, agent)
143
+ expect((await runtime.agentPresets.resolve('standard')).path).toBe(source.path)
144
+ expect(await runtime.agentPresets.read('standard')).toBe(sourceText)
145
+ expect(sourceText).not.toContain('tool-result-pruner')
146
+ })
147
+
148
+ it('keeps compression across preset changes and excludes only exact Minimal', async () => {
149
+ const runtime = await harness()
150
+ const agent = await agentOn(runtime, 'selector-loader-switch', 'standard')
151
+ expectCompleteCompressionStack(runtime, agent)
152
+
153
+ await runtime.agentPresets.recompose(agent.ctx, 'minimal')
154
+ expectNoCompressionStack(runtime, agent)
155
+
156
+ // `custom` deliberately contains the same source rows as Minimal. Its id,
157
+ // not its copied contents, decides the one documented exception.
158
+ await runtime.agentPresets.recompose(agent.ctx, 'custom')
159
+ expectCompleteCompressionStack(runtime, agent)
160
+ })
161
+
162
+ it('gives a child the parent\'s exact compression service instances', async () => {
163
+ const runtime = await harness()
164
+ const parent = await agentOn(runtime, 'selector-loader-parent', 'standard')
165
+ const childHandle = await runtime.agents.create({
166
+ sessionId: SessionId('selector-loader-child'),
167
+ setup: childCtx => void runtime.agentPresets.composeFrom(childCtx, parent.ctx),
168
+ })
169
+ const child = childHandle.agent
170
+
171
+ const parentPruner = runtime.agentPresets.serviceFor(parent, 'toolResultPruner')
172
+ const childPruner = runtime.agentPresets.serviceFor(child, 'toolResultPruner')
173
+ const parentCompaction = runtime.agentPresets.serviceFor(parent, 'compaction')
174
+ const childCompaction = runtime.agentPresets.serviceFor(child, 'compaction')
175
+ expect(parentPruner).toBeDefined()
176
+ expect(parentCompaction).toBeDefined()
177
+ expect(Object.is(
178
+ (childPruner as Traceable)[CORDIS_ORIGINAL],
179
+ (parentPruner as Traceable)[CORDIS_ORIGINAL],
180
+ )).toBe(true)
181
+ expect(Object.is(
182
+ (childCompaction as Traceable)[CORDIS_ORIGINAL],
183
+ (parentCompaction as Traceable)[CORDIS_ORIGINAL],
184
+ )).toBe(true)
185
+ expect(hasCompressionRetrieve(runtime, child)).toBe(true)
186
+ expect(hasCompactCommand(runtime, child)).toBe(true)
187
+ })
188
+
189
+ it('carries the daily Custom defaults on the bundle entry config schema', async () => {
190
+ // 0.1.7: there is no plugin-owned settings row publishing defaults — the
191
+ // volatile `settings` field's schema defaults ARE the daily Custom doc the
192
+ // loader resolves into every composition.
193
+ const settings = (Config({ presetOverlay: true }).settings as unknown as {
194
+ get(): CustomSettings
195
+ }).get()
196
+
197
+ expect(settings.custom.history.trigger).toBe(500_000)
198
+ expect(settings.custom.tailTrim).toEqual({ enabled: false, trigger: 700_000 })
199
+ })
200
+ })
@@ -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.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
+ 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
+ })