From d7a90cf0e64b18506268808a023bb3dde8ebfc30 Mon Sep 17 00:00:00 2001 From: vp275 Date: Fri, 13 Mar 2026 07:51:29 +0530 Subject: [PATCH] Add --continue / -c flag to resume the most recent session Uses the existing SessionManager.continueRecent() from the Pi SDK to load the most recent session for the current working directory. Mirrors the --continue flag already available in the base Pi CLI. --- src/cli.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index 31d8e788f..6d1737c9a 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -24,6 +24,7 @@ import { shouldRunOnboarding, runOnboarding } from './onboarding.js' interface CliFlags { mode?: 'text' | 'json' | 'rpc' print?: boolean + continue?: boolean noSession?: boolean model?: string extensions: string[] @@ -42,6 +43,8 @@ function parseCliArgs(argv: string[]): CliFlags { if (m === 'text' || m === 'json' || m === 'rpc') flags.mode = m } else if (arg === '--print' || arg === '-p') { flags.print = true + } else if (arg === '--continue' || arg === '-c') { + flags.continue = true } else if (arg === '--no-session') { flags.noSession = true } else if (arg === '--model' && i + 1 < args.length) { @@ -61,6 +64,7 @@ function parseCliArgs(argv: string[]): CliFlags { process.stdout.write('Options:\n') process.stdout.write(' --mode Output mode (default: interactive)\n') process.stdout.write(' --print, -p Single-shot print mode\n') + process.stdout.write(' --continue, -c Resume the most recent session\n') process.stdout.write(' --model Override model (e.g. claude-opus-4-6)\n') process.stdout.write(' --no-session Disable session persistence\n') process.stdout.write(' --extension Load additional extension\n') @@ -239,7 +243,9 @@ if (existsSync(sessionsDir)) { } } -const sessionManager = SessionManager.create(cwd, projectSessionsDir) +const sessionManager = cliFlags.continue + ? SessionManager.continueRecent(cwd, projectSessionsDir) + : SessionManager.create(cwd, projectSessionsDir) initResources(agentDir) const resourceLoader = buildResourceLoader(agentDir)