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:
@@ -592,11 +592,14 @@ for (const info of sessions) {
|
||||
console.log(`${info.id}: ${info.firstMessage} (${info.messageCount} messages)`);
|
||||
}
|
||||
|
||||
// Custom agentDir for sessions
|
||||
// Custom session directory (no cwd encoding)
|
||||
const customDir = "/path/to/my-sessions";
|
||||
const { session } = await createAgentSession({
|
||||
agentDir: "/custom/agent",
|
||||
sessionManager: SessionManager.create(process.cwd(), "/custom/agent"),
|
||||
sessionManager: SessionManager.create(process.cwd(), customDir),
|
||||
});
|
||||
// Also works with list and continueRecent:
|
||||
// SessionManager.list(process.cwd(), customDir);
|
||||
// SessionManager.continueRecent(process.cwd(), customDir);
|
||||
```
|
||||
|
||||
> See [examples/sdk/11-sessions.ts](../examples/sdk/11-sessions.ts)
|
||||
|
||||
Reference in New Issue
Block a user