Commit 12610e0
committed
feat: add list_sessions top-level function
Ports listSessions() from the TypeScript SDK as a filesystem-reading
implementation (not a CLI passthrough). Scans ~/.claude/projects/ for
.jsonl session files and extracts metadata via stat + head/tail reads
without full JSONL parsing.
- Add SDKSessionInfo dataclass to types.py (session_id, summary,
last_modified, file_size, custom_title, first_prompt, git_branch, cwd)
- Add _internal/sessions.py with path sanitization, JSON field
extraction, first-prompt parsing, and git worktree detection
- Export list_sessions() and SDKSessionInfo from __init__.py
- Filter sidechain sessions and empty metadata-only sessions
(no '(session)' placeholder fallback)
- Support include_worktrees option (default True) to scan all
git worktree paths for a project
- 38 tests covering helpers and integration scenarios1 parent a58d3ab commit 12610e0
4 files changed
Lines changed: 1254 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| |||
378 | 380 | | |
379 | 381 | | |
380 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
381 | 386 | | |
382 | 387 | | |
383 | 388 | | |
| |||
0 commit comments