Replace the dsh CLI's three hand-rolled parsing idioms (raw argv[0]/includes dispatch in bin.ts, per-mode node:util parseArgs in headless.ts/web.ts, and the bespoke parseResumeArg scanner in dsh-app-boot) with a single Commander adapter in apps/cli/src/args.ts. parseDshArgs resolves argv into a discriminated DshInvocation union; bin.ts switches on the mode and dynamic-imports the chosen module, which now consumes already-parsed values. - web is a real subcommand; --host uses choices and --port an argParser range check, moving validation into the parser. - --resume rejects empty and repeated forms; --prompt rejects empty; a config positional after --prompt and a root flag placed before web fail loud. - adds --help/--version; removes parseResumeArg from dsh-app-boot. - new apps/cli/tests/args.spec.ts (apps/*/tests added to vitest include, apps/cli/tests to tsconfig.host.json); the tui-agent keyless PTY smoke covers bin.ts dispatch end to end unchanged.
2.5 KiB
@deepseek-ai/dsh
The dsh command-line entry follows the apps/ assembly tier: apps/* are product assemblies over packages/* libraries. Plain dsh [config.yml] boots the interactive TUI coding agent, dsh -p "task" runs one headless turn, and dsh web serves the browser UI.
Argv is parsed once through a Commander adapter (src/args.ts) that resolves the invocation into a single mode; src/bin.ts switches on that mode and dynamic-imports only the chosen mode's module. dsh --help and dsh web --help render usage, dsh --version prints this app's version, and an unknown option or an invalid --host/--port/--resume value fails loud (stderr, exit 1) instead of misrouting.
The TUI surface:
- boots the shipped default config (
examples/tui-agent/cordis.yml) or an explicit config argument, throughdsh-app-boot; - resumes a persisted session with
dsh --resume <session-id>— the form the TUI prints on exit and lists under/resume; the flag setsRESUME_SESSION_IDbefore boot so the shipped config rehydrates that session, and a missing or unreadable id fails loud and exits nonzero; - treats the invoking directory as the workspace — sessions, relative paths, and workspace instructions resolve from the cwd;
- tells the agent where its own source lives: after boot it adds a prompt section naming this harness checkout, resolved from the launcher's real path so it holds under a PATH symlink and an arbitrary cwd, so the self-referential
cordistoolset can read and modify it; - applies the personal overlay from
~/.dsh(see app-boot's Personal config):.envfills environment gaps (ambient > project.env> personal.env),config.yamlpatches the booted tree.
The Web surface treats its invoking directory as the default project and loads applicable AGENTS.md/CLAUDE.md instructions into each agent-loop request prefix with a 65,536-byte render budget.
Install (developer machine)
Symlink the source-running launcher onto your PATH; it resolves the checkout through its own real path, so code changes apply on the next launch with no build step:
ln -sf "$(pwd)/bin/dsh" ~/.local/bin/dsh
pnpm run demo:tui runs the same entry from the repo root. The built form (lib/bin.js, via pnpm run build) needs node --expose-internals for the shipped config's HMR entry, exactly like the demo bins.