feat(tui): session resume — /resume command, exit hint, and dsh --resume <id>
Squashes feat/tui-resume-command, fix/tui-resume-desc, and feat/tui-resume-flag.
This commit is contained in:
@@ -5,6 +5,7 @@ The `dsh` command-line entry, following the `apps/` assembly tier proposed by th
|
||||
The TUI surface:
|
||||
|
||||
- boots the shipped default config (`examples/tui-agent/cordis.yml`) or an explicit config argument, through [`dsh-app-boot`](../../packages/ui/app-boot/README.md);
|
||||
- resumes a persisted session with `dsh --resume <session-id>` — the form the TUI prints on exit and lists under `/resume`; the flag sets `RESUME_SESSION_ID` before 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 `cordis` toolset can read and modify it;
|
||||
- applies the personal overlay from `~/.config/dsh` (see [app-boot's Personal config](../../packages/ui/app-boot/README.md#personal-config)): `.env` fills environment gaps (ambient > project `.env` > personal `.env`), `config.yaml` patches the booted tree.
|
||||
|
||||
@@ -18,12 +18,19 @@ import {
|
||||
installFailLoud,
|
||||
loadEnv,
|
||||
loadPersonalPatches,
|
||||
parseResumeArg,
|
||||
resolveConfigPath,
|
||||
resolvePersonalConfigDir,
|
||||
} from '@deepseek-ai/dsh-app-boot'
|
||||
|
||||
const NAME = 'dsh'
|
||||
|
||||
// The env var the shipped tui-agent config reads (`resumeSessionId: !!js
|
||||
// process.env.RESUME_SESSION_ID`) to rehydrate a persisted session. The
|
||||
// `--resume <id>` flag is CLI sugar that sets it before boot, so the printed
|
||||
// `dsh --resume <id>` exit hint runs back through this same intake.
|
||||
const RESUME_SESSION_ID_ENV = 'RESUME_SESSION_ID'
|
||||
|
||||
// Both the source tree (apps/cli/src) and the bundled bin (apps/cli/lib) sit
|
||||
// one directory under apps/cli, so the shipped default config resolves with
|
||||
// the same relative hop from either artifact.
|
||||
@@ -38,7 +45,8 @@ const SOURCE_ROOT = fileURLToPath(new URL('../../..', import.meta.url))
|
||||
the tui-agent PTY smoke drives this path end to end, personal overlay included */
|
||||
/**
|
||||
* Run the interactive TUI from the invoking directory.
|
||||
* @param argv - arguments after the subcommand dispatch; `argv[0]` may name a
|
||||
* @param argv - arguments after the subcommand dispatch; a `--resume <id>` flag
|
||||
* resumes that persisted session, and the first non-flag argument may name a
|
||||
* config to boot instead of the shipped default.
|
||||
*/
|
||||
export async function runTui(argv: string[]): Promise<void> {
|
||||
@@ -53,7 +61,11 @@ export async function runTui(argv: string[]): Promise<void> {
|
||||
// The bin already loaded the invoking directory's .env; the personal .env
|
||||
// only fills what is still unset (process.loadEnvFile never overrides).
|
||||
loadEnv(NAME, resolvePersonalConfigDir())
|
||||
const ctx = await boot(NAME, resolveConfigPath(argv[0] ?? DEFAULT_CONFIG, undefined), loadPersonalPatches(NAME))
|
||||
// An explicit `--resume` flag beats any ambient RESUME_SESSION_ID, so set it
|
||||
// after loadEnv and before boot reads it through the config's `!!js`.
|
||||
const { resumeSessionId, rest } = parseResumeArg(argv)
|
||||
if (resumeSessionId !== undefined) process.env[RESUME_SESSION_ID_ENV] = resumeSessionId
|
||||
const ctx = await boot(NAME, resolveConfigPath(rest[0] ?? DEFAULT_CONFIG, undefined), loadPersonalPatches(NAME))
|
||||
addHarnessSourceSection(ctx, SOURCE_ROOT)
|
||||
}
|
||||
/* v8 ignore stop */
|
||||
|
||||
Reference in New Issue
Block a user