dsh-context-compression-improved 0.6.3 → 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.
- package/.agents-stash-064.patch +39 -0
- package/CHANGELOG.ja.md +42 -0
- package/CHANGELOG.ko.md +38 -0
- package/CHANGELOG.md +46 -0
- package/CHANGELOG.zh.md +38 -0
- package/README.ja.md +2 -2
- package/README.ko.md +2 -2
- package/README.md +5 -3
- package/README.zh.md +2 -2
- package/_dsh_devdeps.json +50 -0
- package/_verify064/package/package.json +162 -0
- package/_verify064/package/packages/selector/src/client/index.ts +232 -0
- package/package.json +50 -49
- package/packages/selector/dsh.plugin.json +16 -16
- package/packages/selector/lib/client.js +2 -1
- package/packages/selector/lib/style.css +46 -46
- package/packages/selector/package.json +114 -114
- package/packages/selector/src/client/index.ts +213 -225
- package/packages/selector/src/client/scope-face.ts +24 -24
- package/packages/selector/src/index.ts +0 -1
- package/packages/selector/src/pruner.ts +0 -1
- package/packages/selector/tests/custom-contract.client.spec.ts +222 -222
- package/packages/selector/tests/helpers/legacy-namespace.ts +8 -4
- package/packages/selector/tests/helpers/legacy-settings/index.ts +15 -0
- package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +41 -0
- package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +647 -0
- package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +78 -0
- package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +234 -0
- package/packages/selector/tests/host-preset-overlay.host.spec.ts +3 -5
- package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +200 -206
- package/packages/selector/tests/public/package-contract.client.spec.ts +78 -78
- package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +230 -233
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2731 -2727
- package/packages/selector/tests/settings-seat.client.spec.ts +165 -165
- package/packages/selector/tests/standing-generation.host.spec.ts +724 -704
- package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +18 -2
- package/packages/selector/tests/support/ui-primitives.tsx +34 -34
- package/pnpm-workspace.yaml +1 -1
- package/scripts/packed-install-e2e.mjs +6 -6
- 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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
runtime.
|
|
82
|
-
await runtime.plugin(
|
|
83
|
-
runtime.
|
|
84
|
-
runtime.
|
|
85
|
-
await runtime.plugin(
|
|
86
|
-
await runtime.plugin(
|
|
87
|
-
await runtime.plugin(
|
|
88
|
-
await runtime.plugin(
|
|
89
|
-
await runtime.plugin(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
await runtime.plugin(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
expect(runtime.agentPresets.serviceFor(agent, '
|
|
129
|
-
expect(
|
|
130
|
-
expect(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
await runtime
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
expect(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
)).toBe(true)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
+
})
|