base.spec.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * The bundle's substance is its patch file: the `dsh.bundle.patch` manifest
  3. * field must name a real, parseable patch list.
  4. */
  5. import { readFileSync } from 'node:fs'
  6. import { fileURLToPath } from 'node:url'
  7. import { resolve } from 'node:path'
  8. import { describe, expect, it } from 'vitest'
  9. import * as yaml from 'js-yaml'
  10. import { entryListSchema } from '@deepseek-ai/cordis-plugin-include'
  11. describe('dsh-base bundle', () => {
  12. it('declares a parseable patch list through the dsh.bundle.patch manifest field', () => {
  13. const root = fileURLToPath(new URL('..', import.meta.url))
  14. const manifest = JSON.parse(
  15. readFileSync(resolve(root, 'package.json'), 'utf8'),
  16. ) as {
  17. dependencies?: Record<string, string>
  18. dsh?: { bundle?: { patch?: string } }
  19. }
  20. expect(manifest.dsh?.bundle?.patch).toBe('./cordis.patch.yml')
  21. const parsed = yaml.load(
  22. readFileSync(resolve(root, manifest.dsh!.bundle!.patch!), 'utf8'),
  23. { schema: entryListSchema },
  24. )
  25. expect(Array.isArray(parsed)).toBe(true)
  26. // The base layer is one insert list over the empty profile root.
  27. const rows = (parsed as { insert?: { id?: string }[] }[]).flatMap(
  28. patch => patch.insert ?? [],
  29. )
  30. expect(rows.length).toBeGreaterThan(50)
  31. expect(rows.some(row => row.id === 'agent-loop')).toBe(true)
  32. expect(rows.filter(row => row.id === 'subagent-codex')).toHaveLength(1)
  33. expect(rows.filter(row => row.id === 'subagent-claude-code')).toHaveLength(1)
  34. expect(manifest.dependencies).toMatchObject({
  35. '@deepseek-ai/dsh-subagent-codex': 'workspace:^',
  36. '@deepseek-ai/dsh-subagent-claude-code': 'workspace:^',
  37. })
  38. })
  39. it('ships the Windows platform layer as the confined pwsh roster over the ACL runner chain', () => {
  40. const root = fileURLToPath(new URL('..', import.meta.url))
  41. const parsed = yaml.load(
  42. readFileSync(resolve(root, 'windows.cordis.patch.yml'), 'utf8'),
  43. { schema: entryListSchema },
  44. ) as {
  45. id?: string
  46. disabled?: boolean
  47. insert?: { id?: string; name?: string }[]
  48. config?: { policy?: string }
  49. }[]
  50. const disables = parsed
  51. .filter(patch => patch.disabled === true)
  52. .map(patch => patch.id)
  53. // Only the POSIX bash stack is disabled: the Windows roster confines the
  54. // pwsh executor through the ACL runner chain, so the sandbox/policy rows,
  55. // the permission switcher, fs-sandbox, and the approval service all stay
  56. // enabled exactly as on POSIX — only the shell is swapped.
  57. expect(disables).toEqual(['bash-sandbox', 'tool-bash'])
  58. const inserted = parsed
  59. .flatMap(patch => patch.insert ?? [])
  60. .map(row => row.id)
  61. expect(inserted).toEqual(['pwsh-sandbox', 'tool-pwsh'])
  62. // The patch no longer touches the permission/approval surface at all.
  63. expect(parsed.find(patch => patch.id === 'approval')).toBeUndefined()
  64. expect(parsed.find(patch => patch.id === 'permission')).toBeUndefined()
  65. expect(parsed.find(patch => patch.id === 'sandbox')).toBeUndefined()
  66. expect(parsed.find(patch => patch.id === 'sandbox-policy')).toBeUndefined()
  67. expect(parsed.find(patch => patch.id === 'fs-sandbox')).toBeUndefined()
  68. })
  69. })