demo-code-mode.mjs 987 B

12345678910111213141516171819202122
  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', ['--expose-internals', '--import', 'tsx', 'packages/examples/tui-demo/src/bin.ts', 'examples/tui-agent/code-mode.cordis.yml']],
  10. ['acp', ['--import', 'tsx', 'packages/examples/acp-demo/src/bin.ts', '--config', 'examples/acp-agent/code-mode.cordis.yml']],
  11. ])
  12. const ui = process.argv[2] ?? 'tui'
  13. const args = UIS.get(ui)
  14. if (!args || process.argv.length > 3) {
  15. console.error('usage: pnpm run demo:code-mode [tui|acp]')
  16. process.exit(2)
  17. }
  18. const child = spawn(process.execPath, args, { stdio: 'inherit' })
  19. child.on('exit', (code, signal) => { process.exit(signal !== null ? 1 : code ?? 1) })