feat(coding-agent): Add --session-dir flag for custom session directory

- Add --session-dir CLI flag to specify custom session directory
- SessionManager API: second param of create(), continueRecent(), list(), open()
  changed from agentDir to sessionDir (direct directory, no cwd encoding)
- When omitted, uses default (~/.pi/agent/sessions/<encoded-cwd>/)
- --session now derives sessionDir from file's parent if --session-dir not provided
- list() validates session header before processing files
- Closes #313

Co-authored-by: scutifer <scutifer@users.noreply.github.com>
This commit is contained in:
Mario Zechner 2025-12-25 20:27:31 +01:00
parent 4edfff41a7
commit 911963e777
8 changed files with 106 additions and 48 deletions

View file

@ -23,6 +23,7 @@ export interface Args {
mode?: Mode;
noSession?: boolean;
session?: string;
sessionDir?: string;
models?: string[];
tools?: ToolName[];
hooks?: string[];
@ -78,6 +79,8 @@ export function parseArgs(args: string[]): Args {
result.noSession = true;
} else if (arg === "--session" && i + 1 < args.length) {
result.session = args[++i];
} else if (arg === "--session-dir" && i + 1 < args.length) {
result.sessionDir = args[++i];
} else if (arg === "--models" && i + 1 < args.length) {
result.models = args[++i].split(",").map((s) => s.trim());
} else if (arg === "--tools" && i + 1 < args.length) {
@ -153,6 +156,7 @@ ${chalk.bold("Options:")}
--continue, -c Continue previous session
--resume, -r Select a session to resume
--session <path> Use specific session file
--session-dir <dir> Directory for session storage and lookup
--no-session Don't save session (ephemeral)
--models <patterns> Comma-separated model patterns for quick cycling with Ctrl+P
--tools <tools> Comma-separated list of tools to enable (default: read,bash,edit,write)