demo-code-mode.mjs 1.3 KB

1234567891011121314151617181920212223242526272829
  1. /**
  2. * Boot the Code Mode demo under the UI named on the command line:
  3. * `pnpm run demo:code-mode [repl|acp]`, default `repl`. Code Mode is the
  4. * point — the UI is just the surface it happens to wear: each UI boots its
  5. * base example through that example's `code-mode.cordis.yml` overlay
  6. * (include ./cordis.yml, flip `tools.mode` to `code`, insert the
  7. * worker-thread code runtime). Both need DEEPSEEK_API_KEY (repo-root .env
  8. * works). Anything else on the command line is a misconfiguration and
  9. * fails loud with usage.
  10. */
  11. import { spawn } from 'node:child_process'
  12. // Each UI's node invocation, verbatim what its base demo script runs plus
  13. // the overlay config (the stdio bin keeps --expose-internals for the cordis
  14. // Loader's HMR path).
  15. const UIS = new Map([
  16. ['repl', ['--expose-internals', '--import', 'tsx', 'packages/ui/stdio-agent/src/bin.ts', 'examples/coding-agent/code-mode.cordis.yml']],
  17. ['acp', ['--import', 'tsx', 'packages/ui/acp-agent/src/bin.ts', 'examples/acp-agent/code-mode.cordis.yml']],
  18. ])
  19. const ui = process.argv[2] ?? 'repl'
  20. const args = UIS.get(ui)
  21. if (!args || process.argv.length > 3) {
  22. console.error('usage: pnpm run demo:code-mode [repl|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) })