Problem
Currently, acpx kimi sessions close <name> only marks a session as `[closed]` in the sessions list but does not delete the session files from `~/.acpx/sessions/`. Over time this leads to:
- Hundreds of orphaned session files accumulating on disk (in our case: 190 closed sessions = ~2.4GB)
- The sessions list shows a cluttered mix of open and closed entries
- No way to bulk-clean closed sessions without manual file deletion
Proposed Solution
Add a `prune` subcommand to `acpx sessions`:
```bash
Prune all closed sessions for current agent/cwd
acpx kimi sessions prune
Dry-run: show what would be deleted
acpx kimi sessions prune --dry-run
Prune sessions closed before a given date
acpx kimi sessions prune --before 2026-03-01
Prune sessions older than N days
acpx kimi sessions prune --older-than 7
Also delete session history files (.stream.ndjson)
acpx kimi sessions prune --include-history
```
Behavior
- Query the sessions list for the current agent
- Filter sessions with status = `[closed]`
- Apply optional date/age filters
- Delete:
- `{session_id}.json` (session metadata)
- `{session_id}.stream.ndjson` and `{session_id}.stream.N.ndjson` (if `--include-history`)
- Print summary: X sessions pruned, Y MB freed
Motivation
- Disk hygiene: sessions can grow large (hundreds of MB per session with long conversations)
- UX: keeps `sessions list` output clean and actionable
- Alternative: implementing file deletion inside `sessions close` is also acceptable, but a separate `prune` command gives users more control
Alternatives Considered
| Approach |
Pros |
Cons |
| `sessions close` also deletes files |
Simple, no new command |
Breaking change if users rely on file persistence |
| `sessions prune` (proposed) |
Granular control, dry-run possible |
Slightly more complex |
| Automatic pruning on close |
Zero maintenance |
May delete data users want to keep |
This is purely a CLI UX improvement; the session state is already tracked in memory so no protocol changes needed.
Problem
Currently,
acpx kimi sessions close <name>only marks a session as `[closed]` in the sessions list but does not delete the session files from `~/.acpx/sessions/`. Over time this leads to:Proposed Solution
Add a `prune` subcommand to `acpx sessions`:
```bash
Prune all closed sessions for current agent/cwd
acpx kimi sessions prune
Dry-run: show what would be deleted
acpx kimi sessions prune --dry-run
Prune sessions closed before a given date
acpx kimi sessions prune --before 2026-03-01
Prune sessions older than N days
acpx kimi sessions prune --older-than 7
Also delete session history files (.stream.ndjson)
acpx kimi sessions prune --include-history
```
Behavior
Motivation
Alternatives Considered
This is purely a CLI UX improvement; the session state is already tracked in memory so no protocol changes needed.