2026-07-09 12:16:37 +08:00
|
|
|
/**
|
2026-07-20 19:26:04 +08:00
|
|
|
* Boot the TUI or ACP Code Mode overlay, defaulting to TUI. Each overlay
|
2026-07-13 23:27:00 +08:00
|
|
|
* includes its base example, selects Code Mode, and adds the worker runtime.
|
2026-07-19 01:09:20 +08:00
|
|
|
* All require a DeepSeek API key; unsupported arguments fail with usage.
|
2026-07-09 12:16:37 +08:00
|
|
|
*/
|
|
|
|
|
import { spawn } from 'node:child_process'
|
|
|
|
|
|
2026-07-20 19:26:04 +08:00
|
|
|
// Each UI's node invocation matches its base demo script plus the overlay config.
|
2026-07-09 12:16:37 +08:00
|
|
|
const UIS = new Map([
|
refactor(cli): unify the arg grammar — one program, --config flag, real web subcommand
Drop the bare `dsh <config>` positional in favor of a `--config <path>` flag.
Without a root positional, `web` can be a real Commander subcommand in one
program instead of the reserved-first-token dispatch to a second parser, so
`dsh --help` lists every mode natively (no hand-pasted command text) and the
second parser + reserved-token machinery are gone.
Grammar:
dsh TUI (shipped tree + ~/.dsh overlay)
dsh --config <path> TUI, alternate tree (demos/tests only)
dsh --resume <id> TUI, resume a session
dsh -p "task" headless one-shot
dsh web [--host --port --dev]
`dsh` is the product front door with no positional; `--config` exists only so
demo:cordis, demo:code-mode, and the keyless PTY smokes can point the shipped
bin at an example tree. Those three sites and the /resume re-exec argv move to
`--config <path>`. The `-p` + `--config`/`--resume` mode-mixing guard and the
cordis.yml-owns-host/port-default fix are preserved.
Agent Note + Chinese pair, README, tui.ts docs updated. All 13 PTY smokes
(including code-mode via --config and the exec-replace resume handoff) green.
2026-07-25 15:47:55 +08:00
|
|
|
['tui', ['--import', 'tsx', 'apps/cli/src/bin.ts', '--config', 'examples/tui-agent/code-mode.cordis.yml']],
|
2026-07-15 15:57:57 +08:00
|
|
|
['acp', ['--import', 'tsx', 'packages/examples/acp-demo/src/bin.ts', '--config', 'examples/acp-agent/code-mode.cordis.yml']],
|
2026-07-09 12:16:37 +08:00
|
|
|
])
|
|
|
|
|
|
2026-07-20 19:26:04 +08:00
|
|
|
const ui = process.argv[2] ?? 'tui'
|
2026-07-09 12:16:37 +08:00
|
|
|
const args = UIS.get(ui)
|
|
|
|
|
if (!args || process.argv.length > 3) {
|
2026-07-20 19:26:04 +08:00
|
|
|
console.error('usage: pnpm run demo:code-mode [tui|acp]')
|
2026-07-09 12:16:37 +08:00
|
|
|
process.exit(2)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const child = spawn(process.execPath, args, { stdio: 'inherit' })
|
|
|
|
|
child.on('exit', (code, signal) => { process.exit(signal !== null ? 1 : code ?? 1) })
|