tw93/Mole
GitHub: tw93/Mole
一款 macOS 一体化系统维护工具,通过命令行提供深度清理、智能卸载、磁盘分析与实时监控。
Stars: 47438 | Forks: 1448
## 功能
- **一体化工具包**:将 CleanMyMac、AppCleaner、DaisyDisk 和 iStat Menus 整合到 **单个二进制文件** 中
- **深度清理**:清除缓存、日志、浏览器残留文件以及孤立的应用数据,**回收数 GB 空间**
- **智能卸载器**:卸载应用及其启动代理、偏好设置和 **隐藏残留**
- **磁盘洞察**:可视化使用情况,查找大文件,**重建缓存**,并刷新系统服务
- **实时监控**:显示实时的 CPU、GPU、内存、磁盘和网络统计信息
## 快速开始
**通过 Homebrew 安装**
```
brew install mole
```
**或通过脚本安装**
```
# 可选参数:-s latest 用于主分支代码,-s 1.17.0 用于特定版本
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bash
```
**运行**
```
mo # Interactive menu
mo clean # Deep cleanup + already-uninstalled app leftovers
mo uninstall # Remove installed apps + their leftovers
mo optimize # Refresh caches & services
mo analyze # Visual disk explorer (or 'mo analyse')
mo status # Live system health dashboard
mo purge # Clean project build artifacts
mo installer # Find and remove installer files
mo touchid # Configure Touch ID for sudo
mo completion # Set up shell tab completion
mo update # Update Mole
mo update --nightly # Update to latest unreleased main build, script install only
mo remove # Remove Mole from system
mo --help # Show help
mo --version # Show installed version
```
**安全预览**
```
mo clean --dry-run
mo uninstall --dry-run
mo purge --dry-run
# 也适用于:optimize, installer, remove, completion, touchid enable
mo clean --dry-run --debug # Preview + detailed logs
mo optimize --whitelist # Manage protected optimization rules
mo clean --whitelist # Manage protected caches
mo purge --paths # Configure project scan directories
mo analyze /Volumes # Analyze external drives only
```
## 安全与可靠性设计
Mole 是一个本地系统维护工具,部分命令会执行具有破坏性的本地操作。
Mole 采用安全优先的默认设置:路径验证、受保护目录规则、保守的清理边界,以及对高风险操作进行明确确认。当风险或不确定性较高时,Mole 会跳过、拒绝或要求更强的确认,而不是扩大删除范围。
`mo analyze` 更适合临时清理,因为它通过 Finder 将文件移至废纸篓,而不是直接删除。
请查阅 [SECURITY.md](SECURITY.md) 和 [SECURITY_AUDIT.md](SECURITY_AUDIT.md) 获取报告指南、安全边界和当前限制。
## 提示
## 详细功能介绍
### 深度系统清理
```
$ mo clean
Scanning cache directories...
✓ User app cache 45.2GB
✓ Browser cache (Chrome, Safari, Firefox) 10.5GB
✓ Developer tools (Xcode, Node.js, npm) 23.3GB
✓ System logs and temp files 3.8GB
✓ App-specific cache (Spotify, Dropbox, Slack) 8.4GB
✓ Trash 12.3GB
====================================================================
Space freed: 95.5GB | Free space now: 223.5GB
====================================================================
```
注意:在 `mo clean` -> 开发者工具 中,Mole 会移除未使用的 CoreSimulator `Volumes/Cryptex` 条目并跳过 `IN_USE` 项目。
### 智能应用卸载
```
$ mo uninstall
Select Apps to Remove
═══════════════════════════
▶ ☑ Photoshop 2024 (4.2G) | Old
☐ IntelliJ IDEA (2.8G) | Recent
☐ Premiere Pro (3.4G) | Recent
Uninstalling: Photoshop 2024
✓ Removed application
✓ Cleaned 52 related files across 12 locations
- Application Support, Caches, Preferences
- Logs, WebKit storage, Cookies
- Extensions, Plugins, Launch daemons
Note: On macOS 15 and later, Local Network permission entries can outlive app removal. Mole warns when an uninstalled app declares Local Network usage, but it does not auto-reset `/Volumes/Data/Library/Preferences/com.apple.networkextension*.plist` because that reset is global and requires Recovery mode.
====================================================================
Space freed: 12.8GB
====================================================================
```
### 系统优化
```
$ mo optimize
System: 5/32 GB RAM | 333/460 GB Disk (72%) | Uptime 6d
✓ Rebuild system databases and clear caches
✓ Reset network services
✓ Refresh Finder and Dock
✓ Clean diagnostic and crash logs
✓ Remove swap files and restart dynamic pager
✓ Rebuild launch services and spotlight index
====================================================================
System optimization completed
====================================================================
Use `mo optimize --whitelist` to exclude specific optimizations.
```
### 磁盘空间分析器
```
$ mo analyze
Analyze Disk ~/Documents | Total: 156.8GB
▶ 1. ███████████████████ 48.2% | 📁 Library 75.4GB >6mo
2. ██████████░░░░░░░░░ 22.1% | 📁 Downloads 34.6GB
3. ████░░░░░░░░░░░░░░░ 14.3% | 📁 Movies 22.4GB
4. ███░░░░░░░░░░░░░░░░ 10.8% | 📁 Documents 16.9GB
5. ██░░░░░░░░░░░░░░░░░ 5.2% | 📄 backup_2023.zip 8.2GB
↑↓←→ Navigate | O Open | F Show | ⌫ Delete | L Large files | Q Quit
```
### 实时系统状态
带有健康评分、硬件信息和性能指标的实时仪表盘。
```
$ mo status
Mole Status Health ● 92 MacBook Pro · M4 Pro · 32GB · macOS 14.5
⚙ CPU ▦ Memory
Total ████████████░░░░░░░ 45.2% Used ███████████░░░░░░░ 58.4%
Load 0.82 / 1.05 / 1.23 (8 cores) Total 14.2 / 24.0 GB
Core 1 ███████████████░░░░ 78.3% Free ████████░░░░░░░░░░ 41.6%
Core 2 ████████████░░░░░░░ 62.1% Avail 9.8 GB
▤ Disk ⚡ Power
Used █████████████░░░░░░ 67.2% Level ██████████████████ 100%
Free 156.3 GB Status Charged
Read ▮▯▯▯▯ 2.1 MB/s Health Normal · 423 cycles
Write ▮▮▮▯▯ 18.3 MB/s Temp 58°C · 1200 RPM
⇅ Network ▶ Processes
Down ▁▁█▂▁▁▁▁▁▁▁▁▇▆▅▂ 0.54 MB/s Code ▮▮▮▮▯ 42.1%
Up ▄▄▄▃▃▃▄▆▆▇█▁▁▁▁▁ 0.02 MB/s Chrome ▮▮▮▯▯ 28.3%
Proxy HTTP · 192.168.1.100 Terminal ▮▯▯▯▯ 12.5%
```
健康评分基于 CPU、内存、磁盘、温度和 I/O 负载,并设有颜色编码范围。
快捷键:在 `mo status` 中,按下 `k` 切换猫咪显示并保存偏好设置,按下 `q` 退出。
启用后,`mo status` 会为长时间处于配置 CPU 阈值之上的进程显示一个只读警告横幅。可使用 `--proc-cpu-threshold`、`--proc-cpu-window` 或 `--proc-cpu-alerts=false` 进行调整或禁用。
#### 机器可读输出
`mo analyze` 和 `mo status` 均支持用于脚本和自动化的 `--json` 标志。
`mo status` 还会自动检测其输出是否被管道重定向(非终端),并自动切换到 JSON 格式。
```
# 磁盘分析(JSON 格式)
$ mo analyze --json ~/Documents
{
"path": "/Users/you/Documents",
"overview": false,
"entries": [
{ "name": "Library", "path": "...", "size": 80939438080, "is_dir": true },
...
],
"large_files": [
{ "name": "backup.zip", "path": "...", "size": 8796093022 }
],
"total_size": 168393441280,
"total_files": 42187
}
# 系统状态(JSON 格式)
$ mo status --json
{
"host": "MacBook-Pro",
"health_score": 92,
"cpu": { "usage": 45.2, "logical_cpu": 8, ... },
"memory": { "total": 25769803776, "used": 15049334784, "used_percent": 58.4 },
"disks": [ ... ],
"uptime": "3d 12h 45m",
...
}
# 通过管道传输时自动检测 JSON
$ mo status | jq '.health_score'
92
```
### 项目构件清理
清理旧的构建构件,如 `node_modules`、`target`、`.build`、`build` 和 `dist`,以释放磁盘空间。
```
mo purge
Select Categories to Clean - 18.5GB (8 selected)
➤ ● my-react-app 3.2GB | node_modules
● old-project 2.8GB | node_modules
● rust-app 4.1GB | target
● next-blog 1.9GB | node_modules
○ current-work 856MB | node_modules | Recent
● django-api 2.3GB | venv
● vue-dashboard 1.7GB | node_modules
● backend-service 2.5GB | node_modules
```
### 安装程序清理
查找并删除 Downloads、Desktop、Homebrew 缓存、iCloud 和 Mail 中的大型安装文件。每个文件都会标注其来源。
```
mo installer
Select Installers to Remove - 3.8GB (5 selected)
➤ ● Photoshop_2024.dmg 1.2GB | Downloads
● IntelliJ_IDEA.dmg 850.6MB | Downloads
● Illustrator_Setup.pkg 920.4MB | Downloads
● PyCharm_Pro.dmg 640.5MB | Homebrew
● Acrobat_Reader.dmg 220.4MB | Downloads
○ AppCode_Legacy.zip 410.6MB | Downloads
```
## 快速启动器
从 Raycast 或 Alfred 启动 Mole 命令:
```
curl -fsSL https://raw.githubusercontent.com/tw93/Mole/main/scripts/setup-quick-launchers.sh | bash
```
添加 5 个命令:`Mole Clean`、`Mole Uninstall`、`Mole Optimize`、`Mole Analyze`、`Mole Status`。
### Raycast 设置
运行脚本后,请完成以下步骤:
1. 打开 Raycast 设置(⌘ + ,)
2. 进入 **Extensions** → **Script Commands**
3. 点击 **"Add Script Directory"**(或 **"+"**)
4. 添加路径:`~/Library/Application Support/Raycast/script-commands`
5. 在 Raycast 中搜索:**"Reload Script Directories"** 并运行
6. 完成!现在可以在 Raycast 中搜索 `Mole Clean` 或 `clean`、`Mole Optimize` 或 `Mole Status` 来使用这些命令
### 终端检测
Mole 会自动检测你使用的终端应用。iTerm2 存在已知兼容性问题。我们强烈推荐使用 [Kaku](https://github.com/tw93/Kaku)。其他不错的选择包括 Alacritty、kitty、WezTerm 和 Warp。如需覆盖,请设置 `MO_LAUNCHER_APP=`。
## 支持
- 如果 Mole 对你有帮助,[分享它](https://twitter.com/intent/tweet?url=https://github.com/tw93/Mole&text=Mole%20-%20Deep%20clean%20and%20optimize%20your%20Mac.) 给朋友或给它一颗星。
- 有想法或发现 Bug?请提交 issue 或 PR,欢迎贡献你的最佳 AI 模型。
- 我有两只猫,TangYuan 和 Coke。如果你认为 Mole 给你的生活带来乐趣,可以请它们吃 罐头 🥩。
## 许可证
MIT 许可证。自由使用 Mole 并参与贡献。
自定义扫描路径
运行 `mo purge --paths` 配置扫描目录,或直接编辑 `~/.config/mole/purge_paths`: ``` ~/Documents/MyProjects ~/Work/ClientA ~/Work/ClientB ``` 配置自定义路径后,Mole 仅扫描这些目录。否则,它将使用默认路径,如 `~/Projects`、`~/GitHub` 和 `~/dev`。标签:Cutter, Mac清理, Shell补全, WSL, 免费开源, 垃圾清理, 威胁情报, 工具箱, 应用安全, 开发者工具, 性能监控, 批量测试, 智能卸载, 磁盘分析, 系统优化, 系统清理, 系统维护, 缓存清理, 跨平台工具