demo-code-mode.mjs 988 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * Boot the TUI or ACP Code Mode overlay, defaulting to TUI. Each overlay
  3. * includes its base example, selects Code Mode, and adds the worker runtime.
  4. * All require a DeepSeek API key; unsupported arguments fail with usage.
  5. */
  6. import { spawn } from 'node:child_process'
  7. // Each UI's node invocation matches its base demo script plus the overlay config.
  8. const UIS = new Map([
  9. ['tui', [
  10. '--import',
  11. 'tsx/esm',
  12. 'apps/cli/src/bin.ts',
  13. '--config',
  14. 'examples/tui-agent/code-mode.cordis.yml',
  15. ]],
  16. ['acp', ['--import', 'tsx', 'packages/examples/acp-demo/src/bin.ts', '--config', 'examples/acp-agent/code-mode.cordis.yml']],
  17. ])
  18. const ui = process.argv[2] ?? 'tui'
  19. const args = UIS.get(ui)
  20. if (!args || process.argv.length > 3) {
  21. console.error('usage: pnpm run demo:code-mode [tui|acp]')
  22. process.exit(2)
  23. }
  24. const child = spawn(process.execPath, args, { stdio: 'inherit' })
  25. child.on('exit', (code, signal) => { process.exit(signal !== null ? 1 : code ?? 1) })