mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-08-29 04:26:38 +00:00
89 lines
3.5 KiB
TypeScript
89 lines
3.5 KiB
TypeScript
/**
|
|
* The verify-cordis-config metadata contract: `disabled` is the one entry
|
|
* metadata field whose `!!js` expression the Loader interpolates; every other
|
|
* metadata field must stay static, and a disabled expression must parse.
|
|
*/
|
|
|
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
bundleManifestPaths,
|
|
bundlePluginDependencyErrors,
|
|
metadataExpressionErrors,
|
|
} from './verify-cordis-config.ts'
|
|
|
|
describe('verify-cordis-config metadata expressions', () => {
|
|
it('accepts a disabled !!js expression', () => {
|
|
const problems = metadataExpressionErrors(
|
|
{ id: 'tool-bash', name: '@deepseek-ai/dsh-tool-bash', disabled: { __jsExpr: "process.platform === 'win32'" } },
|
|
'[0]',
|
|
)
|
|
expect(problems).toEqual([])
|
|
})
|
|
|
|
it('rejects an expression in a static metadata field', () => {
|
|
const problems = metadataExpressionErrors({ id: { __jsExpr: 'process.platform' }, name: 'pkg' }, '[0]')
|
|
expect(problems).toContain('[0].id: !!js is not interpolated here')
|
|
})
|
|
|
|
it('rejects an expression nested below disabled (only the field itself interpolates)', () => {
|
|
const problems = metadataExpressionErrors(
|
|
{ id: 'tool-bash', name: 'pkg', disabled: { when: { __jsExpr: 'process.platform' } } },
|
|
'[0]',
|
|
)
|
|
expect(problems).toContain('[0].disabled.when: !!js is not interpolated here')
|
|
})
|
|
|
|
it('rejects a disabled expression that does not parse (the loader would fail the boot)', () => {
|
|
const problems = metadataExpressionErrors(
|
|
{ id: 'tool-bash', name: 'pkg', disabled: { __jsExpr: 'process.platform ===' } },
|
|
'[0]',
|
|
)
|
|
expect(problems.some(problem => problem.includes('[0].disabled: disabled expression does not parse'))).toBe(true)
|
|
})
|
|
})
|
|
|
|
describe('workspace Bundle discovery and product dependency closures', () => {
|
|
it('discovers a Bundle outside packages/bundle from its manifest declaration', () => {
|
|
const fixture = mkdtempSync(join(tmpdir(), 'dsh-bundle-discovery-'))
|
|
try {
|
|
const bundleDir = join(fixture, 'packages/subagent/example')
|
|
const plainDir = join(fixture, 'packages/bundle/plain')
|
|
mkdirSync(bundleDir, { recursive: true })
|
|
mkdirSync(plainDir, { recursive: true })
|
|
writeFileSync(join(bundleDir, 'package.json'), JSON.stringify({
|
|
name: '@deepseek-ai/dsh-subagent-example',
|
|
dsh: { bundle: { patch: './cordis.patch.yml' } },
|
|
}))
|
|
writeFileSync(join(plainDir, 'package.json'), JSON.stringify({
|
|
name: '@deepseek-ai/dsh-plain',
|
|
}))
|
|
|
|
expect(bundleManifestPaths(fixture)).toEqual([
|
|
'packages/subagent/example/package.json',
|
|
])
|
|
} finally {
|
|
rmSync(fixture, { recursive: true, force: true })
|
|
}
|
|
})
|
|
|
|
it('allows a Bundle to mount itself but rejects an undeclared plugin package', () => {
|
|
const manifestPath = 'packages/subagent/example/package.json'
|
|
const file = 'packages/subagent/example/cordis.patch.yml'
|
|
const manifest = {
|
|
name: '@deepseek-ai/dsh-subagent-example',
|
|
dependencies: {},
|
|
}
|
|
const self = { file, name: '@deepseek-ai/dsh-subagent-example' }
|
|
expect(bundlePluginDependencyErrors(manifestPath, manifest, [self])).toEqual([])
|
|
expect(bundlePluginDependencyErrors(manifestPath, manifest, [
|
|
self,
|
|
{ file, name: '@deepseek-ai/dsh-missing-plugin' },
|
|
])).toEqual([
|
|
`${file}: @deepseek-ai/dsh-missing-plugin must be declared in ${manifestPath} dependencies`,
|
|
])
|
|
})
|
|
})
|