2 releases
| new 0.2.1 | Dec 17, 2025 |
|---|---|
| 0.2.0 | Nov 24, 2025 |
#282 in Command line utilities
14KB
203 lines
CleanPkgCache
A Rust CLI tool to clean package cache directories by keeping only the latest 2 versions of each package.
Overview
This tool is designed to clean package cache folders where each subfolder represents a package, and each package folder contains multiple versions. The tool will identify all packages and their versions, then remove older versions while keeping only the latest 2 versions of each package.
Features
- Default Path: Automatically targets
C:\PkgCache\VC17LTCGif no path is specified - Dry Run Mode: Preview what would be deleted without actually deleting files
- Verbose Output: Detailed information about packages and versions found
- Safe Deletion: Only removes directories that are clearly version folders within package directories
- Roo Checkpoint Cleanup: Optional flag to remove outdated MS Roo Code task checkpoints (older than ~2 months)
- Summary Report: Shows how many packages were processed and versions kept/deleted
Installation
- Make sure you have Rust installed on your system
- Clone or download this project
- Build the release version:
cargo build --release - The executable will be available at
target/release/cleanpkgcache.exe
Usage
Basic Usage
# Use default path (C:\PkgCache\VC17LTCG)
cleanpkgcache.exe
# Specify a custom path
cleanpkgcache.exe "C:\Your\Custom\Cache\Path"
Options
# Dry run - see what would be deleted without actually deleting
cleanpkgcache.exe --dry-run
# Verbose output - see detailed information about packages and versions
cleanpkgcache.exe --verbose
# Combine options
cleanpkgcache.exe --dry-run --verbose "C:\Your\Cache\Path"
# Include Roo checkpoint cleanup
cleanpkgcache.exe --clean-roo-checkpoints --dry-run
Command Line Arguments
PATH- Path to the package cache directory (optional, defaults toC:\PkgCache\VC17LTCG)-d, --dry-run- Show what would be deleted without actually deleting-v, --verbose- Show detailed output about packages and versions--clean-roo-checkpoints- Also clean checkpoints under the MS Roo Code and Roo Code Extensiontasksfolders that are older than ~2 months-h, --help- Show help information-V, --version- Show version information
Example Output
Cleaning package cache at: C:\PkgCache\VC17LTCG
Package: SomePackage
Found 5 versions:
1: v1.2.3 (modified: 2023-12-01T10:00:00Z)
2: v1.2.2 (modified: 2023-11-15T14:30:00Z)
3: v1.2.1 (modified: 2023-11-01T09:15:00Z)
4: v1.2.0 (modified: 2023-10-15T16:45:00Z)
5: v1.1.9 (modified: 2023-10-01T11:20:00Z)
Keeping: v1.2.3
Keeping: v1.2.2
Deleting: C:\PkgCache\VC17LTCG\SomePackage\v1.2.1
Deleting: C:\PkgCache\VC17LTCG\SomePackage\v1.2.0
Deleting: C:\PkgCache\VC17LTCG\SomePackage\v1.1.9
Summary:
Packages processed: 1
Versions kept: 2
Versions deleted: 3
How It Works
- Discovery: The tool scans the specified cache directory for package folders
- Version Detection: For each package, it finds all version subdirectories
- Sorting: Versions are sorted by modification time (newest first)
- Cleanup: Keeps the 2 most recent versions and deletes the rest
- Reporting: Provides a summary of the cleanup operation
- Optional Roo Cleanup: When
--clean-roo-checkpointsis passed, the tool also scansC:\Users\zhizha\AppData\Roaming\Code\User\globalStorage\microsoftai.ms-roo-cline\tasksandC:\Users\zhizha\AppData\Roaming\Code\User\globalStorage\rooveterinaryinc.roo-cline\tasks, deletingcheckpointsfolders for tasks older than roughly two months
Safety Features
- Path Validation: Ensures the specified path exists and is a directory
- Dry Run Mode: Allows you to preview changes before applying them
- Error Handling: Graceful handling of permission errors and invalid paths
- Detailed Logging: Clear output about what is being kept and what is being deleted
Requirements
- Windows (designed for Windows paths, but should work on other platforms)
- Rust 1.70+ (for building from source)
License
MIT License
Dependencies
~1–1.7MB
~31K SLoC