opencode
opencode copied to clipboard
feat(cli): add snapshot management commands
Summary
The Snapshot directory can get very large. This is a simple command to delete it. Its a known issue Also relevent to #1126 #6845 #5617 #3182 #3176
This adds a new snapshot command to manage project snapshot directories with list and clear subcommands.
Changes
-
New command:
opencode snapshot-
opencode snapshot list- Lists all projects with snapshot sizes, sorted by size -
opencode snapshot clear [project-id]- Clears specific snapshot -
opencode snapshot clear- Clears all snapshots
-
-
Features:
- Displays project ID, name, size, and last updated date
- Safety features:
--dry-runflag, confirmation prompts by default -
--forceflag to skip confirmation - Clear specific project or all projects
- Error handling for missing projects
- Success feedback showing space freed
Motivation
Snapshot directories can grow large . Users need a way to:
- See which projects have snapshots and their sizes
- Clean up old or unnecessary snapshots to free disk space
- Manage snapshots per project
I have 8.1 GB across 14 projects.
Testing
# List all snapshots
opencode snapshot list
# Preview what would be deleted (dry-run)
opencode snapshot clear --dry-run
# Clear specific project
opencode snapshot clear <project-id>
# Clear all with confirmation
opencode snapshot clear
# Clear all without confirmation
opencode snapshot clear --force
Code Style
- Follows project style guide (single functions, no destructuring, no else, const only)
- Minimal changes: 2 lines in index.ts + new command file (260 lines)
- All typechecks pass