demo-code-mode.mjs 1.0 KB

1234567891011121314151617181920212223242526272829
  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. '--experimental-transform-types',
  11. '--import',
  12. './scripts/tspath-loader.ts',
  13. 'apps/cli/src/bin.ts',
  14. '--config',
  15. 'examples/tui-agent/code-mode.cordis.yml',
  16. ]],
  17. ['acp', ['--import', 'tsx', 'packages/examples/acp-demo/src/bin.ts', '--config', 'examples/acp-agent/code-mode.cordis.yml']],
  18. ])
  19. const ui = process.argv[2] ?? 'tui'
  20. const args = UIS.get(ui)
  21. if (!args || process.argv.length > 3) {
  22. console.error('usage: pnpm run demo:code-mode [tui|acp]')
  23. process.exit(2)
  24. }
  25. const child = spawn(process.execPath, args, { stdio: 'inherit' })
  26. child.on('exit', (code, signal) => { process.exit(signal !== null ? 1 : code ?? 1) })