term-clean
term-clean is a terminal TUI (Text User Interface) cleanup tool designed specifically for macOS users. It helps you easily manage, analyze, and clean up packages installed by various package managers (brew, npm, pnpm, yarn, pip).
π― Why Term-Clean?
Term-Clean is built for you if youβve ever faced these scenarios:
"I have low disk space, but I donβt know whatβs taking up space..."
π Term-Clean visualizes disk usage, helping you instantly spot large, unused packages.
"Iβm afraid uninstalling ffmpeg will break my other tools..."
π‘οΈ With recursive dependency analysis and safe uninstall preview, youβll always know the impact before you act.
"I followed a tutorial, installed 20 packages, and now Iβm afraid to touch them..."β¦
term-clean
term-clean is a terminal TUI (Text User Interface) cleanup tool designed specifically for macOS users. It helps you easily manage, analyze, and clean up packages installed by various package managers (brew, npm, pnpm, yarn, pip).
π― Why Term-Clean?
Term-Clean is built for you if youβve ever faced these scenarios:
"I have low disk space, but I donβt know whatβs taking up space..."
π Term-Clean visualizes disk usage, helping you instantly spot large, unused packages.
"Iβm afraid uninstalling ffmpeg will break my other tools..."
π‘οΈ With recursive dependency analysis and safe uninstall preview, youβll always know the impact before you act.
"I followed a tutorial, installed 20 packages, and now Iβm afraid to touch them..."
π Say goodbye to "dependency anxiety". Term-Clean clarifies what each package does and who needs it.
π Core Features
- π¦ Multi-Manager Support: One-stop management for Homebrew (Formulae & Casks), npm, pnpm, yarn, and pip.
- π Smart Scanning & Analysis: Automatically detects all installed packages and analyzes their disk usage.
- π³ Dependency Tracing: Built-in recursive dependency tree algorithm clearly shows the reference relationships between packages.
- β οΈ Safe Uninstall Preview: Before executing uninstallation, the system provides a secondary confirmation and displays affected dependencies to prevent accidental deletion of critical system components.
- β¨οΈ Keyboard-First Interaction: Built with Ink and React, providing a smooth TUI automatic experience.
- π Real-time Statistics: Real-time calculation of the total size of selected packages and the disk space that can be freed.
- π Auto Update Detection: Automatically checks for available updates for all packages in the background, with visual indicators.
- ποΈ Package Monitoring: Watch specific packages for updates and track their version changes over time.
- β‘ One-Click Upgrade: Upgrade selected packages to their latest versions with a single keystroke.
- π€ Smart Sorting: Sort packages by name, size, or installation date with visual indicators.
- π Real-time Search: Quickly filter packages with incremental search functionality.
- β¨ Batch Operations: Select all, invert selection, and batch monitoring for efficient package management.
π Quick Start
Installation
You can install it globally via npm:
npm install -g term-clean
(Note: The code is currently in the development phase. You can clone the repository and run npm link for testing)
Usage
Interactive Mode (TUI)
Run the command directly to enter the interactive interface:
term-clean
Once in the interface, you can use the following shortcuts:
Navigation & Selection
β/β: Move up and down in the package list.Tab/Shift+Tab: Switch between different package manager tabs (brew, npm, pip, etc.).Space: Check/uncheck packages.Enter: View detailed information for the highlighted package.
Package Operations
p: Preview mode - View detailed information about selected packages and uninstall impact analysis.u: Quick uninstall - Uninstall selected packages with confirmation (skips preview).g: Upgrade selected packages to their latest versions.w: Toggle watch status for the highlighted package (monitor for updates).W: Batch watch - Add all selected packages to the watch list.v: Toggle update check for the highlighted package.
Batch Operations
a: Select/deselect all packages in the current view.i: Invert selection.
Sorting & Filtering
s: Cycle through sort options (name β size β date)./: Enter search mode to filter packages by name.Esc(in search mode): Exit search and clear filter.
System
r: Refresh scanning results.q: Exit the application.c(in preview mode): Confirm and execute uninstallation.
π¨ Visual Indicators
The interface uses intuitive icons to help you understand package status at a glance:
- ποΈ - Package is being watched for updates
- π - Update available (shows current version β latest version)
- β²/βΌ - Sort direction indicator (ascending/descending)
- β - Selected package
- β - Unselected package
π Smart Features
Automatic Update Detection: Term-Clean silently checks for package updates in the background. When updates are available, packages are marked with π and show the version upgrade path (e.g., 1.0.0 β 1.0.1).
Package Monitoring: Add frequently-used packages to your watch list with w. Watched packages are highlighted and their update status is tracked across sessions.
Intelligent Sorting: Press s to cycle through different sorting methods:
- Name (A-Z or Z-A)
- Size (largest/smallest first)
- Installation Date (newest/oldest first)
Search & Filter: Press / to enter search mode and type to filter packages in real-time. The search is case-insensitive and matches package names.
Command Line Mode (CLI)
You can also use traditional command-line arguments:
# Filter only specific package managers
term-clean -m brew
# Start in debug mode (view detailed logs)
term-clean --debug
π οΈ Development & Testing
If you wish to participate in development or run the project locally:
Prerequisites
- Node.js (v18+ recommended)
- npm / pnpm / yarn
Local Setup
- Clone the repository
- Install dependencies:
npm install - Run in development mode:
npm run dev - Build the project:
npm run build - Run the built program:
node dist/cli.js
Testing
The project uses vitest for unit testing:
# Run all tests
npm test
# Run unit tests
npm run test:unit
ποΈ Architecture
The project adopts a layered architecture, ensuring good extensibility and maintainability:
- Managers (Adapter Layer): Unifies query and uninstall interfaces for different package managers (e.g.,
BrewPackageManager,NpmPackageManager). - Services (Business Logic Layer): Handles package scanning (
PackageScannerService) and cleaning processes (PackageCleanerService). - Stores (State Management): Uses
zustandto manage global reactive state (e.g., selected packages, list data). - Components (UI Layer): A React component library built on
ink, responsible for TUI rendering.
π Roadmap
Completed β
- Multi-package manager adapter implementation
- Recursive dependency analysis algorithm
- Core TUI interface and keyboard interaction
- Uninstall preview and risk warning
- Automatic update detection for all packages
- Package monitoring and watch list
- One-click package upgrade functionality
- Smart sorting (by name, size, installation date)
- Real-time search and filtering
- Batch operations (select all, invert, batch watch)
- Optimized async loading with silent background updates
In Progress π§
- Export cleanup logs to file
- Package usage frequency tracking (smart identification of long-unused packages)
- Enhanced regex filtering
- Graphical visualization of dependency trees
- Configuration file support for persistent settings
- Plugin system for custom package managers
π License
This project is open-sourced under the MIT License.
π€ Contribution
Issues and Pull Requests are welcome! If you find this tool useful, please give it a βοΈ.