The README was the last file still describing the old project
Twenty-six commits went into main this week and not one of them touched README.md, which sounds like restraint and is actually a bug: every commit made the code more honest about Windows while the first file a stranger reads kept saying the opposite. It opened with "macOS 磁盘清理与系统监控工具" as if the platform layer shipped last month were a fork, and the crate map still described squid-platform as "macOS 实现(App 清单、残留匹配、卷);Linux/Windows 占位" — the same document that two sections later listed a working Windows registry adapter, an IFileOperation recycle bin, thirty cleaning rules and a real machine that had deleted files into it and restored them. A README that contradicts itself is worse than a thin one, because the reader has to guess which half is out of date, and the confident-looking half (the crate map, the feature table) is exactly the half that is stale. So this rewrites the stale claims and leaves the author's structure and tone alone. squid-platform now says three implementations, and names what only Windows has: the shell's recycle bin, console size and glyph-width probing, process termination. The cleaning-rule count stops implying one number for every platform — thirty-nine is macOS, thirty is windows.toml, and printing 39 above a Windows install is a promise the rules directory does not keep. Uninstall says where an app comes from on each platform, because "bundle id" means nothing to a reader whose machine answers with a registry key, and the paths section now says that on Windows config, rules and ledger all live under %APPDATA%\squid and that the ledger records no physical path there — the Recycle Bin keeps the files, so undo hands the restore to Explorer rather than renaming anything itself. Item 7 of the safety model got the same correction from the other direction, since it used to promise "记录每条的废纸篓目标路径" unconditionally. Two features the interface grew and the README never learned about. `x` joins the key table: on the three file panels it is `d`, on the system panel it stops the process under the cursor behind a dialog that repeats the sample rather than the pid. That deserves a safety-model line as much as a key-table line, because "the cleaner can also stop things" is the sentence a reader should meet next to the list of processes it refuses to touch — squid itself, pid 0/1, Windows' System Idle and pid 4, and csrss/smss/wininit/services/lsass/winlogon, an elevated squid genuinely can open those for termination, which is the entire reason for six names. svchost stays off the list on purpose, and the message now says so rather than leaving the omission to be rediscovered as a bug report. The Windows console paragraph records what the last two days of frame captures taught: legacy conhost hands the process a window wider than the buffer behind it, cp936 charges two cells for glyphs ratatui budgets one, and both lies arrive as the same 花屏 — so the interface re-measures the size every beat and prices each glyph before drawing it, and the command line deliberately buys the pessimistic code-page answer instead of measuring, because measuring writes a character onto whatever is on screen. SQUID_SYMBOL_CELLS and SQUID_CONSOLE_TRACE join the environment table; they existed, they saved the port, they were undocumented. On the verification claim I did the opposite of what the week's momentum suggested. The old line read "已在 Windows 10(1909)真机验证", and the machine at 192.168.2.92 was set up as a Windows 11 box, so the tempting edit was to write "Windows 10 与 11 均已真机验证". Nothing in the repo supports that. Every hardware check ever captured from that machine prints `Windows 10 Pro (build 18363)`, and os_version reads ProductName, DisplayVersion and CurrentBuildNumber straight out of the registry — there is no code path by which a Windows 11 install produces 18363. Either the box is not Windows 11 or its registry disagrees with whoever installed it; the README states what the instrument reported and the roadmap carries "Windows 11 真机复验" as pending, so the claim will be earned by a doctor run on a machine that says 22000 or newer, not asserted because it is plausible. The remaining edits are smaller truths: release artifacts are Apple-only, so the download section now says Windows builds from source rather than sending readers after a nonexistent .tar.gz; the roadmap's Windows row picks up process stopping, the highlight-that-survives-paging and the menu-that-stops-being- overpainted fixes, and the "顶住 512 字节写入不变" settle condition that replaced "seen twice" as the definition of a finished frame; "Linux/Windows 冒烟测试" narrows to Linux, since Windows has a better instrument than a smoke test now — capture on the real ConPTY, replay through pyte, measure the borders — and the 开发与测试 section shows how to run it, including --selftest, which is what keeps the judge honest.main
parent
5515bab2d9
commit
b129c6bc43
63
README.md
63
README.md
|
|
@ -1,6 +1,6 @@
|
|||
# squid
|
||||
|
||||
macOS 磁盘清理与系统监控工具:清理缓存与系统垃圾、卸载 App 并连带清掉残留、深度清理构建产物、
|
||||
macOS / Windows 磁盘清理与系统监控工具:清理缓存与系统垃圾、卸载 App 并连带清掉残留、深度清理构建产物、
|
||||
分析磁盘占用、实时监控资源。命令行与内置 TUI 共用同一套引擎,产物是一个静态二进制,
|
||||
不装后台进程、不写 shell 配置、不需要 root。
|
||||
|
||||
|
|
@ -8,20 +8,21 @@ macOS 磁盘清理与系统监控工具:清理缓存与系统垃圾、卸载 A
|
|||
|
||||
| 能力 | 说明 | 入口 |
|
||||
| --- | --- | --- |
|
||||
| 清理 | 39 条内置规则:应用缓存、浏览器缓存、日志与崩溃报告、Xcode DerivedData、废纸篓等 | `squid clean` |
|
||||
| 卸载 | 按名称或 bundle id 定位 App,本体与散落的偏好、缓存、容器一起进入删除计划 | `squid uninstall` |
|
||||
| 清理 | 内置规则 macOS 39 条 / Windows 30 条:应用与浏览器缓存、日志与崩溃报告、Xcode DerivedData、Windows Update 残留、废纸篓 / 回收站等 | `squid clean` |
|
||||
| 卸载 | 按名称定位 App(macOS 扫 `/Applications` 与 bundle id,Windows 读注册表卸载表),本体与散落的偏好、缓存、容器 / AppData 残留一起进入删除计划 | `squid uninstall` |
|
||||
| 深度清理 | `node_modules` 等项目构建产物、磁盘镜像、陈旧安装包与下载 | `squid purge` |
|
||||
| 存储分析 | 体积树与最大文件,可逐层下钻 | `squid analyze`、`state` 存储面板 |
|
||||
| 系统监控 | CPU / 内存 / 网络 / 磁盘 / 电池 / 温度 / 进程 | `squid status`、`state` 系统面板 |
|
||||
| 系统监控 | CPU / 内存 / 网络 / 磁盘 / 电池 / 温度 / 进程,并可结束选中的进程 | `squid status`、`state` 系统面板 |
|
||||
| 历史与撤销 | 每次真实删除写一条 JSON 账本,可将仍在废纸篓 / 回收站里的文件原样放回 | `squid history`、`squid undo` |
|
||||
|
||||
- 语言:Rust 1.80+,workspace 由 7 个 crate 组成
|
||||
- 界面:中英双语文案,跟随系统语言;真彩色 / 256 色 / 无色三档自动适配
|
||||
- 结构:命令行与 TUI 共用同一套扫描与删除通道,行为、确认、账本完全一致
|
||||
- 平台:macOS 完整支持;Windows 10 / 11 用同一个构建,已在 Windows 10(1909)真机验证
|
||||
(回收站删除与还原、中英文 TUI 在 legacy conhost + cp936 下的排版:界面启动时自己量一次
|
||||
「一个字形在这里占几格」,被收两格就整屏改用 ASCII 边框,不再叠成花屏);
|
||||
UAC 提权与 Linux 见[路线图](#路线图)
|
||||
- 平台:macOS 完整支持;Windows 10 / 11 用同一个构建,已在局域网真机跑通(那台机器自报
|
||||
`Windows 10 Pro (build 18363)`):回收站真实删除与还原、按名称卸载并带走 AppData 残留、系统面板结束进程,
|
||||
中英文 TUI 在 legacy conhost + cp936 下的排版由判据守着而不是靠肉眼——界面启动时自己量一次
|
||||
「一个字形在这里占几格」,被收两格就整屏改用 ASCII 边框,不再叠成花屏;
|
||||
UAC 提权、Windows 11 复验与 Linux 见[路线图](#路线图)
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -51,7 +52,8 @@ PREFIX=~/.local/bin ./scripts/install.sh # 免 sudo,装进指定目录
|
|||
|
||||
### 预编译包
|
||||
|
||||
发布产物是通用二进制(arm64 + x86_64)的 tar.gz,附带 sha256:
|
||||
发布产物是通用二进制(arm64 + x86_64)的 tar.gz,附带 sha256;发布脚本目前只出 Apple 产物,
|
||||
Windows 需从源码构建(`cargo build --release --target x86_64-pc-windows-msvc`):
|
||||
|
||||
```bash
|
||||
curl -LO https://github.com/nexdev/squid/releases/download/v0.1.0/squid-0.1.0-universal-apple-darwin.tar.gz
|
||||
|
|
@ -114,7 +116,7 @@ squid state # 进入 TUI
|
|||
| 命令 | 作用 | 常用参数 |
|
||||
| --- | --- | --- |
|
||||
| `clean` | 按规则清理缓存、日志、浏览器与开发者垃圾、崩溃报告、废纸篓等 | `--dry-run` `-y` `--categories <a,b>` `--orphans` `--min-age <天>` `--user-only` `--trash` `--permanent` |
|
||||
| `uninstall [NAME]` | 按名称或 bundle id 定位 App,生成并执行「本体 + 残留」计划 | `--list` `--dry-run` `-y` `--trash` `--permanent` `--json` |
|
||||
| `uninstall [NAME]` | 按名称定位 App(Windows 取注册表卸载表),生成并执行「本体 + 残留」计划 | `--list` `--dry-run` `-y` `--trash` `--permanent` `--json` |
|
||||
| `purge [PATHS…]` | 深度清理:项目构建目录、磁盘镜像、安装包、陈旧下载 | `--dry-run` `-y` `--all` `--min-age <天>` `--json` |
|
||||
| `state` | 打开 TUI:清理 / 卸载 / 深度清理 / 存储 / 系统 / 历史 | — |
|
||||
| `status` | 系统快照,适合脚本与 cron | `--processes <n>` |
|
||||
|
|
@ -143,6 +145,7 @@ squid state # 进入 TUI
|
|||
| `s` | 扫描当前面板 |
|
||||
| `a` | 全选 / 全不选 |
|
||||
| `d` | 清理已勾选内容 |
|
||||
| `x` | 系统面板:结束光标所在的进程(先弹确认框,复述 pid / CPU / 内存并说明「它不会有机会保存任何内容」);其余面板与 `d` 等价 |
|
||||
| `m` | 废纸篓 ⇄ 永久删除 |
|
||||
| `u` | 还原上一次废纸篓会话 |
|
||||
| `f` | 卸载面板:筛选应用列表(`esc` 清空筛选、`enter` 保留);存储面板:列出当前目录最大的文件 |
|
||||
|
|
@ -163,6 +166,14 @@ iTerm、WezTerm、Ghostty、VS Code、`TERM` 含 `truecolor`)时按设计的 R
|
|||
`NO_COLOR` 或 `TERM=dumb` 时完全不发颜色。三档下选中、勾选、进度都由反白 / 加粗 / `●○` / `█░`
|
||||
表达,不依赖颜色。`SQUID_TRUECOLOR=always|never` 强制指定档位。
|
||||
|
||||
**Windows 控制台**:legacy conhost 进备用屏时换掉的只是「正在显示的那块缓冲区」,进程手里的窗口比真实
|
||||
存在的格子更宽;cp936 码页又把 `─│·…↑↓✓` 这批 East Asian Ambiguous 字形收两格,而排版按一格算。
|
||||
两种偏差最后长成同一种花屏,所以界面每一拍重新量一次尺寸(只有真的变了才擦屏重画),并在启动时
|
||||
逐字符量一次字形的价格(往屏幕上写一个字符再擦掉),付不起的字符整屏换成 ASCII 边框。
|
||||
命令行不当这个测量的客人——测量要动它正显示的东西——它按码页取悲观值,代价是被误伤的机器上少一个
|
||||
`█`、多一个 `#`。`SQUID_SYMBOL_CELLS=1|2` 强制指定价格,`SQUID_CONSOLE_TRACE=<文件>` 把控制台自报的
|
||||
几组数字写进文件留证。
|
||||
|
||||
**语言**:中英双语,判定顺序为配置文件 `language` → `SQUID_LANG` → `LC_ALL` → `LC_MESSAGES` →
|
||||
`LANG` → macOS 系统偏好(`AppleLocale`/`AppleLanguages`)→ 英文;`C`/`POSIX`/空值视为无信息继续下探。
|
||||
`squid doctor` 与 TUI 的 `?` 面板都会打印最终生效的语言与配色档位及其来源。
|
||||
|
|
@ -171,14 +182,15 @@ iTerm、WezTerm、Ghostty、VS Code、`TERM` 含 `truecolor`)时按设计的 R
|
|||
|
||||
前提:**可以清理一个 245 GB 的系统盘,但不能毁掉其中的任何用户文件。**
|
||||
|
||||
1. **默认进废纸篓**:`DeleteMode::Trash` 为默认,`--permanent` 才执行 `unlink`;卸载计划包含 App 本体;`squid undo` 原样放回。
|
||||
1. **默认进废纸篓 / 回收站**:`DeleteMode::Trash` 为默认,`--permanent` 才执行 `unlink`;卸载计划包含 App 本体;`squid undo` 原样放回。
|
||||
2. **`--dry-run` everywhere**:任何删除命令都能只看不动。
|
||||
3. **非交互环境需显式确认**:stdin 不是 TTY 时,缺少 `-y/--yes` 直接拒绝执行删除。
|
||||
4. **删除时二次校验**:执行前对每条重新做安全检查、白名单检查与锚点校验;嵌套子项先于父项处理,避免重复计数与 `ENOENT`。
|
||||
5. **硬性禁区**:`squid_core::safety::SafetyPolicy` 内置 `HARD_DENY`(`/`、`/usr`、`/System`、`/Library`、`/Applications`、`/private/var/folders` …)与 `DENY_EXACT`(`~/Library`、`~/Documents`、`~/.ssh`、`~/.aws` … 只允许删子项);递归删除要求位于允许锚点之下至少 `min_depth = 1` 层,且永不跟随符号链接。
|
||||
6. **规则自带刹车**:`protect` 白名单、`min_age_days`、`needs_admin`、`skip_if_running`(进程运行时不提出删除其虚拟磁盘)、`risky`(默认不勾选并提示复核)。
|
||||
7. **删除账本与 `undo`**:每次真实删除写一个 JSON 会话,记录每条的废纸篓目标路径。
|
||||
7. **删除账本与 `undo`**:每次真实删除写一个 JSON 会话,记录每条的废纸篓目标路径;Windows 的回收站自己保管文件,账本只记「它进了回收站」,还原因此在资源管理器里完成。
|
||||
8. **白名单**:`squid whitelist add '~/Library/Caches/com.apple.Safari'` 之后,任何规则与面板都不会再选中该路径。
|
||||
9. **结束进程也有禁区**:不结束 squid 自己,不结束机器的第一个进程(unix 的 pid 0/1、Windows 的 System Idle 与 pid 4),Windows 上另封 `csrss` / `smss` / `wininit` / `services` / `lsass` / `winlogon`——提权后的进程确实能打开它们,代价是一次回车换来一台重启的机器。确认框交给执行方的是采样而不是 pid,动手前重新读一次;名单里故意没有 `svchost`,因为机器活得过它。
|
||||
|
||||
## 路径规划
|
||||
|
||||
|
|
@ -194,7 +206,10 @@ iTerm、WezTerm、Ghostty、VS Code、`TERM` 含 `truecolor`)时按设计的 R
|
|||
| 内置规则 | 编译进二进制的 `crates/squid-rules/rules/*.toml` | `disabled_rules` |
|
||||
|
||||
Linux 下配置与状态目录遵循 XDG(`$XDG_CONFIG_HOME/squid`、`$XDG_STATE_HOME/squid`,回落到
|
||||
`~/.config/squid`、`~/.local/state/squid`)。`squid doctor` 会打印实际生效的配置与账本路径。
|
||||
`~/.config/squid`、`~/.local/state/squid`);Windows 下配置、规则与账本都在 `%APPDATA%\squid\`
|
||||
(`config.toml`、`rules\*.toml`、`history\<会话>.json`),删除去向是回收站——回收站自己保管文件,
|
||||
账本因此不记物理路径,`squid undo` 在 Windows 上把还原交给资源管理器的回收站。
|
||||
`squid doctor` 会打印实际生效的配置与账本路径。
|
||||
|
||||
squid 只在上述位置写入,扫描过程全程只读。
|
||||
|
||||
|
|
@ -228,6 +243,8 @@ purge_roots = ["~/code", "~/Projects", "~/Desktop"]
|
|||
| `SQUID_STATE_DIR` | 覆盖状态目录(历史账本所在地) |
|
||||
| `SQUID_TRUECOLOR` | `always` / `never` 强制指定配色能力,跳过自动探测 |
|
||||
| `SQUID_LANG` | `zh` / `en` 强制界面语言,等价于 `squid --lang` |
|
||||
| `SQUID_SYMBOL_CELLS` | `1` / `2` 强制指定「一个歧义字形占几格」,覆盖对控制台的实测(Windows 排版排查) |
|
||||
| `SQUID_CONSOLE_TRACE` | 把控制台自报的尺寸与字形价格写进指定文件,留证据用 |
|
||||
| `NO_COLOR` | 存在即关闭全部颜色输出 |
|
||||
|
||||
### 自定义规则
|
||||
|
|
@ -256,7 +273,8 @@ note = "MyApp 会自动重建这些缓存。"
|
|||
```
|
||||
crates/
|
||||
├── squid-core 模型、字节格式化、路径、安全策略、设置、删除账本、进度/取消
|
||||
├── squid-platform Platform trait + macOS 实现(App 清单、残留匹配、卷);Linux/Windows 占位
|
||||
├── squid-platform Platform trait 与 macOS / Linux / Windows 三套实现:App 清单、残留匹配、卷、
|
||||
│ 回收站(Windows 走 shell 的 `IFileOperation`)、进程终止、控制台尺寸与字形宽度探测
|
||||
├── squid-rules TOML 规则引擎:模式展开、锚点、保护列表、年龄与风险标记
|
||||
├── squid-stats sysinfo 采样器、趋势、电池、uptime
|
||||
├── squid-engine clean / uninstall / purge / analyze 四个引擎 + 唯一的删除通道 delete
|
||||
|
|
@ -284,6 +302,19 @@ python3 scripts/tui_smoke.py # menu / menu-mono / uninstall
|
|||
python3 scripts/tui_smoke.py uninstall # 只跑连续卸载
|
||||
```
|
||||
|
||||
Windows 上没有 pty 可以 fork,界面排版改由「抓帧 → 复放 → 量框」守护:`win-tui-capture.sh` 让真机的
|
||||
ConPTY 收到什么就原样存什么、抓回本地,`tui-frame-check.py` 用 pyte 把它复放成画面再逐帧量边框——
|
||||
一幅画面要顶住 512 字节的写入不变才算画稳,半帧不许下判词:
|
||||
|
||||
```bash
|
||||
python3 scripts/tui-frame-check.py --selftest # 先证明判据本身没坏
|
||||
python3 scripts/tui-frame-check.py /tmp/squid-win-tui.bin # 再判那一帧
|
||||
TUI_REUSE=1 TUI_OUT=/tmp/x.bin ./scripts/win-tui-capture.sh # 只重算旧帧,不连真机
|
||||
```
|
||||
|
||||
真机侧的构建与测试由 `scripts/win-sync.sh` 同步源码后跑 `scripts/win-check.ps1`
|
||||
(test / clippy / release build,产物在 `C:\dev\target`)。
|
||||
|
||||
删除相关的测试用例只在 `~/Library/Caches/squid-delete-test-*` 临时目录内操作,
|
||||
并通过 `SQUID_STATE_DIR` 将账本写入临时目录,不会触碰真实用户数据。
|
||||
|
||||
|
|
@ -304,9 +335,9 @@ Homebrew formula 的校验和。
|
|||
| --- | --- | --- |
|
||||
| macOS | 完整实现(规则、App 残留、卷、卸载钩子)| Developer ID 签名与公证流水线 |
|
||||
| Linux | `squid-platform/src/linux.rs` 已实现 `.desktop` / Flatpak / Snap 应用清单与 XDG 残留目录 | `rules/linux.toml`、真机验证 |
|
||||
| Windows | 平台层已实现:注册表卸载表(HKLM 64/32 位 + HKCU)、AppData 残留目录、卷枚举、回收站(`IFileOperation`);安全层按 Windows 语义比较路径(大小写不敏感、盘符根/`$Recycle.Bin` 等硬封禁);内置 30 条清理规则(临时文件、WER 崩溃报告、浏览器/Shell/开发缓存、Windows.old 等);CI 每次提交做 MSVC 目标交叉编译检查;已在局域网内的真机验证通过:回收站真实删除(按卷核算字节数、可在资源管理器里还原)、`undo` 的措辞与行为、`--json` 输出只含一份 JSON、TUI 的排版由判据守住而不是靠肉眼:`win-tui-capture.sh` 把真机 ConPTY 吐出的原始 ANSI 抓回本地用 pyte 复放,`tui-frame-check.py` 逐帧问「右边框落在第几列」,`--selftest` 先证明判据本身没坏 | UAC 提权、长路径 manifest、winget 发布 |
|
||||
| Windows | 平台层已实现:注册表卸载表(HKLM 64/32 位 + HKCU)、AppData 残留目录、卷枚举、回收站(`IFileOperation`)、强制结束进程(附关键进程名单);安全层按 Windows 语义比较路径(大小写不敏感、盘符根/`$Recycle.Bin` 等硬封禁);内置 30 条清理规则(临时文件、WER 崩溃报告、浏览器/Shell/开发缓存、Windows.old 等);CI 每次提交做 MSVC 目标交叉编译检查;已在局域网内的真机验证通过:回收站真实删除(按卷核算字节数、可在资源管理器里还原)、`undo` 的措辞与行为、`--json` 输出只含一份 JSON、系统面板结束进程(确认框复述采样、动手前重读 pid)、列表翻页后高亮不再丢失、动态信息不再压住左侧菜单;TUI 的排版由判据守住而不是靠肉眼:`win-tui-capture.sh` 把真机 ConPTY 吐出的原始 ANSI 抓回本地用 pyte 复放,`tui-frame-check.py` 逐帧问「右边框落在第几列」,并以「顶住 512 字节写入不变」为画稳条件,`--selftest` 先证明判据本身没坏 | UAC 提权、长路径 manifest、Windows 11 真机复验、winget 发布 |
|
||||
|
||||
其他:规则贡献流程与规则覆盖度基准、TUI 主题自定义、Linux/Windows 冒烟测试。
|
||||
其他:规则贡献流程与规则覆盖度基准、TUI 主题自定义、Linux 冒烟测试(Windows 已有抓帧复放判据)。
|
||||
|
||||
## 许可证
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue