demo-code-mode.mjs 1.2 KB

123456789101112131415161718192021222324252627
  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: `repl` starts the
  5. * stdio REPL over examples/code-agent, `acp` starts the ACP server over
  6. * examples/acp-agent's code-mode overlay. Both need DEEPSEEK_API_KEY
  7. * (repo-root .env works). Anything else on the command line is a
  8. * misconfiguration and fails loud with usage.
  9. */
  10. import { spawn } from 'node:child_process'
  11. // Each UI's node invocation, verbatim what its standalone demo script ran
  12. // (the stdio bin keeps --expose-internals for the cordis Loader's HMR path).
  13. const UIS = new Map([
  14. ['repl', ['--expose-internals', '--import', 'tsx', 'packages/ui/stdio-agent/src/bin.ts', 'examples/code-agent/cordis.yml']],
  15. ['acp', ['--import', 'tsx', 'packages/ui/acp-agent/src/bin.ts', 'examples/acp-agent/code-mode.cordis.yml']],
  16. ])
  17. const ui = process.argv[2] ?? 'repl'
  18. const args = UIS.get(ui)
  19. if (!args || process.argv.length > 3) {
  20. console.error('usage: pnpm run demo:code-mode [repl|acp]')
  21. process.exit(2)
  22. }
  23. const child = spawn(process.execPath, args, { stdio: 'inherit' })
  24. child.on('exit', (code, signal) => { process.exit(signal !== null ? 1 : code ?? 1) })