Files
apes-sidebar/tests/dsh-baseline.spec.ts
T
Menghuan1918 795beabe22 chore(dsh): adapt to DSH 0.2.3-alpha.2 and drop pre-0.2.3 compatibility
Raise the whole baseline to the alpha line and stop carrying code that only
exists for older hosts (no runtime compatibility layer, per AGENTS §4):

- peers/engines: 14 DSH peers and engines.dsh -> 0.2.3-alpha.2, Cordis ->
  4.2.0-alpha.1, group/include 1.2.0-alpha.1, schemastery 3.20.0-alpha.1;
  dev pins and CI/e2e/install scripts move with them; plugin version
  0.34.0-alpha.0.
- admission: DSH 0.2.3 deleted `requestRejection`, so only the injected
  `connection.authentication` provider can call `admit`; the legacy branch
  and the direct-admit fallback are gone and the fence fails loudly.
- directory events: the projection authority is `workspace-root/change`;
  the side-chat cwd stamp emits it and the worktree scan no longer reads
  the retired `working-directory/change`.
- llm types: `@deepseek-ai/dsh-llm` no longer exports `./brand`, so
  MessageId comes from `./types`.
- client anchors: only `[data-slot="main.conversation"]`; the alpha.1
  `conversation` key is retired. `webServer.getOrigin` is called directly.

Gates: peers check, typecheck, lint, test (366 files / 4615 passed),
build, check:consumer-types.
2026-11-25 01:03:57 +08:00

58 lines
3.0 KiB
TypeScript

/**
* Host baseline contract: package DSH peers/dev pins, standalone installers,
* e2e fallback/version check and CI must move together, without floating CLI tags.
*/
import { readFileSync } from 'node:fs'
import { describe, expect, it } from 'vitest'
const baseline = '0.2.3-alpha.2'
/** The host runtime the mount lane and the standalone installers pin. It follows
* `package.json#engines.dsh`, which is stricter than the peer floor: the plugin
* installs on this line or newer, so every place that actually runs it moves. */
const hostBaseline = '0.2.3-alpha.2'
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
const bash = readFileSync(new URL('../scripts/install.sh', import.meta.url), 'utf8')
const powershell = readFileSync(new URL('../scripts/install.ps1', import.meta.url), 'utf8')
const e2e = readFileSync(new URL('../scripts/e2e-common.sh', import.meta.url), 'utf8')
const ci = readFileSync(new URL('../.github/workflows/ci.yml', import.meta.url), 'utf8')
describe('DSH host baseline', () => {
it('keeps all DSH package peers and dev pins on the exact baseline', () => {
for (const [section, prefix] of [['peerDependencies', '^'], ['devDependencies', '']] as const) {
const entries = Object.entries(pkg[section]).filter(([name]) => name.startsWith('@deepseek-ai/dsh-'))
expect(entries.length, section).toBeGreaterThan(0)
for (const [name, version] of entries) {
expect(version, `${section}.${name}`).toBe(`${prefix}${baseline}`)
}
}
})
it('does not publish or depend on the retired invariant companion', () => {
expect(pkg.exports).not.toHaveProperty('./invariant')
expect(pkg.files).not.toContain('lib/invariant.js')
for (const section of ['peerDependencies', 'devDependencies', 'dependencies']) {
expect(pkg[section]).not.toHaveProperty('@deepseek-ai/dsh-invariants')
}
})
it('pins both standalone installer npx fallbacks', () => {
expect(bash).toContain(`printf 'npx -y --package @deepseek-ai/dsh@${hostBaseline} dsh'`)
expect(powershell).toContain(`$cliArgs = @('-y', '--package', '@deepseek-ai/dsh@${hostBaseline}', 'dsh', 'plugin'`)
for (const source of [bash, powershell]) {
expect(source).not.toMatch(/^\s*(?:source|\.)\s+[^\r\n]*e2e-common/m)
}
})
it('pins the e2e fallback and expected version to the same baseline', () => {
expect(e2e).toContain('DSH_NPX_SPEC="${DSH_NPX_SPEC:-@deepseek-ai/dsh@' + hostBaseline + '}"')
expect(e2e).toContain('expected="${DSH_EXPECT_VERSION:-' + hostBaseline + '}"')
})
it.each(['\n', '\r\n'])('pins CI with its heap budget and peer resolution intact (%j)', (eol) => {
// Git may check out YAML as CRLF on Windows; the contract is the same.
const source = ci.replace(/\r?\n/g, eol)
expect(source).toContain(`NODE_OPTIONS: --max-old-space-size=4096${eol} run: npm install -g @deepseek-ai/dsh@${hostBaseline}${eol}`)
expect(source).not.toMatch(/^\s*run:.*--legacy-peer-deps/m)
})
})