agent-cleandrive 0.0.0-stage → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +357 -2
- package/bin/cleandrive.js +280 -0
- package/config.example.json +35 -0
- package/docs/offload-strategy.md +132 -0
- package/lib/actions.js +263 -0
- package/lib/archives.js +242 -0
- package/lib/catalog.js +222 -0
- package/lib/offload.js +534 -0
- package/lib/projects.js +114 -0
- package/lib/scan.js +236 -0
- package/lib/server.js +261 -0
- package/lib/util.js +134 -0
- package/package.json +60 -4
- package/ui/index.html +521 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Martin Kaiser
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,358 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# 🧹 agent-cleandrive
|
|
4
|
+
|
|
5
|
+
<img src="media/illustration.jpg" width="420" alt="A small robot sorts the clutter spilling out of a laptop into labelled crates (caches, cables, boxes, containers) while a cart carries a crate along a dashed path to a home server">
|
|
6
|
+
|
|
7
|
+
### The disk cleaner your AI agent can't misuse.
|
|
8
|
+
|
|
9
|
+
**Your agent proposes the cleanup, you approve it, and the tool enforces the rules: a project can never be deleted, only archived and verified.**
|
|
10
|
+
Scan → sort by risk → approve → clean caches, archive projects to your own drive with checksum
|
|
11
|
+
verification, or offload big videos iCloud-style. Works with Claude Code, Codex, Cursor, or no agent at all.
|
|
12
|
+
|
|
13
|
+
<sub>Built for, and on, an 8 GB MacBook Air that runs several Claude Code sessions a day.</sub>
|
|
14
|
+
|
|
15
|
+
[](https://github.com/kaiser-data/agent-cleandrive/actions/workflows/test.yml)
|
|
16
|
+
[](https://www.npmjs.com/package/agent-cleandrive)
|
|
17
|
+

|
|
18
|
+

|
|
19
|
+
 
|
|
20
|
+

|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
<br>
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
> **Try it in 60 seconds** (read-only until you approve something):
|
|
30
|
+
> ```bash
|
|
31
|
+
> npx agent-cleandrive scan # ~1–3 min, nothing is changed
|
|
32
|
+
> npx agent-cleandrive serve # dashboard → http://localhost:4499
|
|
33
|
+
> ```
|
|
34
|
+
> Or in Claude Code: `/plugin install cleandrive --marketplace kaiser-data/agent-cleandrive`, then ask *"my disk is full, what can I clean?"*
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Why this exists
|
|
39
|
+
|
|
40
|
+
Mac disk cleaners fall into two camps. **Dumb** ones blindly wipe `~/Library/Caches` and hope.
|
|
41
|
+
**Dangerous** ones offer "free up 200 GB" in one click and take last week's project with it.
|
|
42
|
+
|
|
43
|
+
agent-cleandrive starts from one hard rule: **nothing is deleted unless it can be regenerated, or has
|
|
44
|
+
been verified on another disk first.** Caches can go, because apps rebuild them. Projects can only
|
|
45
|
+
leave the machine by being copied to your drive and checksum-verified before the local copy is
|
|
46
|
+
removed. Paths you never want touched, such as your Claude Code history, are **hard-locked** and
|
|
47
|
+
refused even when someone forges the action.
|
|
48
|
+
|
|
49
|
+
| Without it | With agent-cleandrive |
|
|
50
|
+
|---|---|
|
|
51
|
+
| "Free up 40 GB?" — and you don't know what's in it | Every item has a category, a risk level and a reason |
|
|
52
|
+
| Deleting a project is one `rm -rf` away | Projects can't be `rm`-ed at all, only archived and verified |
|
|
53
|
+
| Old videos are either on the Mac or gone | `offload` leaves a `.cloud` placeholder; `fetch` restores it byte-for-byte |
|
|
54
|
+
| `df` says 56% full while macOS says the disk is full | Real APFS capacity: `used / (used + available)` |
|
|
55
|
+
| The disk fills up again and you don't know why | Field-tested list of where the space actually goes ([below](#field-notes-where-the-space-actually-went)) |
|
|
56
|
+
|
|
57
|
+
### Built on an 8 GB Mac
|
|
58
|
+
|
|
59
|
+
I'm [Martin Kaiser](https://github.com/kaiser-data). I do agent-heavy development, with several Claude
|
|
60
|
+
Code sessions, MCP servers, a browser and a local model, on a **base M2 MacBook Air: 8 GB RAM,
|
|
61
|
+
228 GB disk**. That's a deliberate choice. Small hardware forces lean habits, and lean habits make
|
|
62
|
+
agent work cheaper wherever it runs.
|
|
63
|
+
|
|
64
|
+
The catch is that on a small Mac, **memory and disk are one problem.** With 8 GB, macOS swaps hard;
|
|
65
|
+
on a normal workday swap sits around **7.9 of 8 GB**, and those swap files live in the same APFS
|
|
66
|
+
container as your files. Each `npm install` or `uv sync` an agent runs adds gigabytes of
|
|
67
|
+
dependencies. So the disk fills from two sides, and when free space runs out, swap has nowhere to
|
|
68
|
+
grow and the whole machine stalls.
|
|
69
|
+
|
|
70
|
+
agent-cleandrive is how I keep that machine usable without buying a bigger one. It makes the disk side
|
|
71
|
+
predictable: dependency churn gets cleaned often and safely, finished projects move to a drive
|
|
72
|
+
on my tailnet, and big videos become placeholders. Free space stays free, so swap has room. It
|
|
73
|
+
manages disk only; it doesn't touch RAM or running processes.
|
|
74
|
+
|
|
75
|
+
<table>
|
|
76
|
+
<tr>
|
|
77
|
+
<td width="50%" valign="top"><b>Light</b><br><img src="media/dashboard-light.png" alt="Dashboard in light mode: capacity bar, category breakdown, item table with approve buttons"></td>
|
|
78
|
+
<td width="50%" valign="top"><b>Dark</b><br><img src="media/dashboard-dark.png" alt="Dashboard in dark mode"></td>
|
|
79
|
+
</tr>
|
|
80
|
+
</table>
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Install
|
|
85
|
+
|
|
86
|
+
| Way | Command | Config & data live in |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| **Claude Code plugin** | `/plugin install cleandrive --marketplace kaiser-data/agent-cleandrive` | `~/.config/cleandrive/` |
|
|
89
|
+
| **npm** | `npm i -g agent-cleandrive` → command `cleandrive` (or `npx agent-cleandrive …`) | `~/.config/cleandrive/` |
|
|
90
|
+
| **git clone** | `git clone https://github.com/kaiser-data/agent-cleandrive && cd agent-cleandrive && cp config.example.json config.json` | the repo (`config.json`, `data/`) |
|
|
91
|
+
|
|
92
|
+
Needs macOS and Node ≥ 20 (Linux support is next on the roadmap). **No dependencies:** pure Node stdlib plus the system's `du`, `rsync`
|
|
93
|
+
and `ssh`. On first run it writes a default `config.json`. Point `projectRoots` at your
|
|
94
|
+
code folders and, if you want archiving, set `remote`.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## How it works
|
|
99
|
+
|
|
100
|
+
1. **Scan.** `cleandrive scan` sizes caches, package caches, `node_modules`, projects, app data,
|
|
101
|
+
apps (with last-used date) and models, then writes `data/latest.json`.
|
|
102
|
+
2. **Plan.** Each item gets a category, which fixes what is allowed. You approve items in the
|
|
103
|
+
dashboard or with `cleandrive approve <id>`.
|
|
104
|
+
3. **Preview.** `cleandrive execute --dry-run` shows exactly what will happen.
|
|
105
|
+
4. **Execute.** In the dashboard you type `FREE`; in the CLI you run `cleandrive execute`. Every
|
|
106
|
+
step is logged to `data/actions.log`.
|
|
107
|
+
|
|
108
|
+
| Category | Risk | What it allows | Example |
|
|
109
|
+
|---|---|---|---|
|
|
110
|
+
| `pkgcache` | low | official clean (npm/uv/brew/pnpm/bun), or rm | *`~/.npm` — 935 MB* |
|
|
111
|
+
| `cache` | low | rm, the app rebuilds it | *`~/Library/Caches/com.spotify.client`* |
|
|
112
|
+
| `node_modules` | low | rm, reinstall per project | *`~/code/old-app/node_modules`* |
|
|
113
|
+
| `projects` | medium | archive / archive+rm / keep, **never a bare rm** | *a repo untouched for 60+ days* |
|
|
114
|
+
| `appdata` | review | rm only after you mark it reviewed | *`~/Library/Application Support/Slack`* |
|
|
115
|
+
| `models` | review | rm after review, or via the owning tool | *`~/.ollama`* |
|
|
116
|
+
| `apps` | manual | never deleted, shown with size and last-used date | *an 800 MB app unopened for 5 months* |
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## The safety model
|
|
121
|
+
|
|
122
|
+
This is the reason the tool exists. Every rule is enforced in the executor, not just in the UI,
|
|
123
|
+
and **[covered by tests](test/safety.test.mjs)** that run against a fake `$HOME`.
|
|
124
|
+
|
|
125
|
+
- **Allowlist by construction.** Only paths that came out of the scan are actionable; forged plan
|
|
126
|
+
entries are ignored.
|
|
127
|
+
- **`rm` is category-gated.** It works only for `pkgcache`, `cache`, `node_modules`, and for
|
|
128
|
+
`appdata`/`models` after an explicit review. A project can leave only via `archive+rm`.
|
|
129
|
+
- **Archive, verify, then delete.** `rsync -aH` to the remote, then a second `rsync -c` checksum
|
|
130
|
+
pass. The local copy goes only if that pass reports zero content differences.
|
|
131
|
+
- **The drive must really be there.** Before every archive or offload, the tool checks over SSH
|
|
132
|
+
that `remote.path` sits on the expected drive (`remote.uuid`), not on an empty mount point on the
|
|
133
|
+
remote's system disk, and that there is room for the item + 5%.
|
|
134
|
+
- **Protected paths are hard-locked.** `config.protected` entries are flagged 🔒, forced to `keep`,
|
|
135
|
+
and refused at execution. The default protects `~/.claude`, `~/.claude-mem` and the Claude
|
|
136
|
+
desktop app's data. `config.extraCaches` can carve out exact regenerable subpaths, and only those.
|
|
137
|
+
- **Protected roots.** `~`, `~/Documents`, `~/Desktop`, `~/Downloads`, `~/Pictures`, `~/Library`
|
|
138
|
+
are refused as direct targets, whatever the plan says.
|
|
139
|
+
- **Local only.** The dashboard binds to `127.0.0.1`. There is no cloud, no account and no telemetry.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Offload: iCloud-style, to your own drive
|
|
144
|
+
|
|
145
|
+
Big idle files, mostly videos, move to your remote drive. A small `<name>.cloud` placeholder stays
|
|
146
|
+
on the Mac, and `fetch` brings the file back byte-for-byte. Nothing runs in the background, on
|
|
147
|
+
either machine.
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
cleandrive offload-candidates # read-only: big idle media, duplicates first
|
|
151
|
+
cleandrive offload ~/Movies/talk.mov --dry-run
|
|
152
|
+
cleandrive offload ~/Movies/talk.mov # → talk.mov.cloud (1 KB)
|
|
153
|
+
cleandrive fetch ~/Movies/talk.mov.cloud # → talk.mov, sha256-verified
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The local file is unlinked only after the **remote sha256 equals the local hash** and the file is
|
|
157
|
+
**unchanged since hashing**. Symlinks, hard links, open files (`lsof`), `~/Library`, `.git`,
|
|
158
|
+
`node_modules`, photo and media libraries, protected paths and pins are refused. Storage is
|
|
159
|
+
content-addressed, so duplicates are stored once and re-offloading a fetched file uploads nothing.
|
|
160
|
+
The design is in [`docs/offload-strategy.md`](docs/offload-strategy.md).
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Any agent can drive it
|
|
165
|
+
|
|
166
|
+
The CLI speaks `--json` and the state is plain files, so any coding agent can run the whole loop.
|
|
167
|
+
The safety gates live in the executor, not in the prompt: **an agent that misreads the plan still
|
|
168
|
+
cannot delete a project or a protected path.**
|
|
169
|
+
|
|
170
|
+
- **Claude Code:** install the plugin. Its [skill](skills/cleandrive/SKILL.md) teaches the workflow: read the scan, propose a plan grouped by risk, act only on the items you confirm.
|
|
171
|
+
- **Codex, Cursor, Gemini CLI, others:** paste this into the agent's instructions (`AGENTS.md`, rules file):
|
|
172
|
+
|
|
173
|
+
> To free disk space, use the `cleandrive` CLI. Run `cleandrive state --json`, propose a plan grouped by category with sizes, and wait for my confirmation of specific items. Then `cleandrive approve <ids>`, show `cleandrive execute --dry-run`, and run `cleandrive execute` only after I say yes. Never delete files by hand that cleandrive refuses.
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
cleandrive state --json # items: {id, path, kb, category, suggest, note}
|
|
177
|
+
cleandrive approve <id…> --action=archive+rm
|
|
178
|
+
cleandrive execute --dry-run # Claude shows you this first
|
|
179
|
+
cleandrive execute # only after you say yes
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
> *"Here are 33 GB of package caches and 14 GB of `node_modules`, all regenerable. Clean them?
|
|
183
|
+
> And 3 projects untouched since spring, 21 GB. Archive and verify them to your drive first?"*
|
|
184
|
+
|
|
185
|
+
agent-cleandrive was itself built in Claude Code sessions. That is why protecting agent history is a
|
|
186
|
+
default: **the tool knows what it must never delete.**
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Field notes: where the space actually went
|
|
191
|
+
|
|
192
|
+
Lessons from running agent-cleandrive on an 8 GB / 228 GB MacBook Air under daily agent workloads,
|
|
193
|
+
which kept hitting 98% full (Sept–Nov 2026).
|
|
194
|
+
These shaped the code and the [skill](skills/cleandrive/SKILL.md).
|
|
195
|
+
|
|
196
|
+
| What we saw | What it taught us |
|
|
197
|
+
|---|---|
|
|
198
|
+
| `df` reported 56% while macOS said the disk was full | APFS volumes share one container. Real capacity is `used / (used + available)`. |
|
|
199
|
+
| A scan ran for over an hour at 0% CPU | `du` blocks forever on other apps' privacy-protected containers. Every `du` now has a timeout, and unreadable paths are listed in `scan.blocked`. |
|
|
200
|
+
| Swap stood at 7.9 of 8 GB on a normal workday | On an 8 GB Mac, swap is part of disk usage. Keep several GB free, or the machine stalls before the disk is technically full. |
|
|
201
|
+
| Roughly 100 GB of "used" space never appeared in any scan | macOS privacy (TCC) hides Downloads, Documents, Desktop, Mail and Trash from the terminal. Grant **Full Disk Access** or the numbers stay low. |
|
|
202
|
+
| 36 GB came back within five days of a cleanup | Most likely not a leak but dependency churn: `node_modules`, `.venv` and package caches regrow with every install. Clean them often; they are low-risk. |
|
|
203
|
+
| Aerial wallpaper videos regrew to 5.9 GB in two days | Switching the wallpaper is not enough. The **screen saver and lock screen** also download Aerials. |
|
|
204
|
+
| A Claude Code plugin cache held 17 old versions, most ~800 MB each (9.6 GB) | Tool and plugin caches keep old versions side by side. Keep the active one (check its manifest); the rest is dead weight. |
|
|
205
|
+
| "Archive OK", but the files landed on the remote's boot disk | The USB drive wasn't mounted, so the mount point was just an empty folder. Archives now check the drive's UUID first. |
|
|
206
|
+
| The USB drive didn't mount after a reboot | `x-systemd.device-timeout=10` in fstab is too short for a spinning HDD. Use 90 s. |
|
|
207
|
+
| SSH to the Tailscale short name timed out | The `100.x` IP worked. Use the IP as `remote.host` if the name is flaky. |
|
|
208
|
+
| `rsync --info=progress2` failed on the Mac | macOS ships openrsync ("2.6.9 compatible"). Use portable flags only. |
|
|
209
|
+
| Checksum verification flagged unchanged files | ext4 can't represent macOS symlink permissions. Ignore metadata-only diffs; still fail on any content, size or missing-file change. |
|
|
210
|
+
| A cache `rm` failed halfway | The browser was still running. Quit the app first, then re-approve the item. |
|
|
211
|
+
| `approve $IDS` recorded a single bogus id | zsh doesn't word-split `$IDS`. Pass ids as `$(cat ids.txt)`. |
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## CLI reference
|
|
216
|
+
|
|
217
|
+
| Command | What it does |
|
|
218
|
+
|---|---|
|
|
219
|
+
| `scan [--json]` | Rescan, categorize, write `data/latest.json` |
|
|
220
|
+
| `state [--json]` | Current scan and plan, with item ids and project activity |
|
|
221
|
+
| `archives [search] [--json]` | Search recorded project archives |
|
|
222
|
+
| `restore <id\|receipt.json> [--dry-run]` | Verify and restore a project to an absent original path |
|
|
223
|
+
| `serve` | Dashboard at `http://localhost:4499` |
|
|
224
|
+
| `approve <id…> [--action=rm\|clean\|archive\|archive+rm]` | Approve items |
|
|
225
|
+
| `skip <id…>` · `review <id…>` | Skip items · mark reviewed (unlocks rm for `appdata`/`models`) |
|
|
226
|
+
| `execute [--dry-run]` | Run all approved actions |
|
|
227
|
+
| `remote-test` | SSH reachability, drive mounted, free space |
|
|
228
|
+
| `offload-dryrun` | Pre-flight the approved archive items (drive mounted, room) without copying |
|
|
229
|
+
| `offload-candidates [--min=200] [--days=30]` | Big idle media and duplicates (read-only) |
|
|
230
|
+
| `offload <file\|dir…> [--dry-run]` | Verified upload, leaves `<name>.cloud` |
|
|
231
|
+
| `fetch <file\|stub\|dir…> [--dry-run]` | Restore offloaded files, sha256-verified |
|
|
232
|
+
| `offloaded` · `offload-verify` · `pin <path>` | List · re-hash every remote copy · keep a path local |
|
|
233
|
+
| `catalog [search] \| sync \| stats` | SQLite index of archives and offloads (needs Node ≥ 22.13; everything else runs on Node 20) |
|
|
234
|
+
|
|
235
|
+
## Remote drive setup
|
|
236
|
+
|
|
237
|
+
1. Attach a drive to any Linux machine you can SSH into: a Raspberry Pi, a Jetson, a NAS, an old
|
|
238
|
+
laptop. Tailscale makes it reachable from anywhere without opening ports.
|
|
239
|
+
2. Set `remote.host`, `remote.user`, `remote.path` and, ideally, `remote.uuid` (from `findmnt -n -o UUID -T <path>`) in `config.json`, or in the dashboard's remote card. `remote.path` may contain only letters, digits and `._/+@%=,-` (no spaces): it is passed to the remote shell unquoted, which keeps the stock macOS `rsync` working.
|
|
240
|
+
3. Run `cleandrive remote-test`. It must report the drive as mounted.
|
|
241
|
+
|
|
242
|
+
New project archives use unique version directories. Their receipts retain the original Mac path
|
|
243
|
+
and restore instructions; use `cleandrive archives` to find them.
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Architecture
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
bin/cleandrive.js CLI + agent connector (every command scriptable, --json where useful)
|
|
251
|
+
lib/scan.js scanner: categories, sizes, staleness, app last-used, blocked paths
|
|
252
|
+
lib/actions.js executor: validation gates, rm/clean/archive, checksum verify, audit log
|
|
253
|
+
lib/offload.js offload/fetch: content-addressed remote store, .cloud stubs, scrub
|
|
254
|
+
lib/server.js zero-dependency HTTP API + static host, 127.0.0.1 only
|
|
255
|
+
lib/util.js process runner with timeouts, atomic JSON writes, config resolution
|
|
256
|
+
ui/index.html single-file dashboard (colorblind-safe palette, light/dark)
|
|
257
|
+
skills/cleandrive/ Claude Code skill shipped with the plugin
|
|
258
|
+
test/ safety-model tests (node:test, fake $HOME)
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Development
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
npm test # 49 tests, ~1 s, never touches your real home folder
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Roadmap** ([PLAN.md](PLAN.md)): **Linux support** (XDG caches, Docker images, journald, snap revisions) · MCP server for non-CLI agents · item lifecycle and checkbox selection in the dashboard ·
|
|
268
|
+
"free up X GB" goal mode · known space-hog catalog · coverage bar (what the scan can't see) ·
|
|
269
|
+
recursive project discovery and stale subfolders · scan speed.
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
<div align="center">
|
|
274
|
+
|
|
275
|
+
MIT licensed · built by [Martin Kaiser](https://github.com/kaiser-data) with [Claude Code](https://claude.com/claude-code), on 8 GB of RAM
|
|
276
|
+
|
|
277
|
+
**Clean without fear.**
|
|
278
|
+
|
|
279
|
+
</div>
|
|
280
|
+
|
|
281
|
+
### Project activity and discoverable archives
|
|
282
|
+
|
|
283
|
+
A scan now discovers projects inside grouping folders, stopping at project markers
|
|
284
|
+
such as `.git`, `package.json`, and `pyproject.toml`. `projectDepth` defaults to 3.
|
|
285
|
+
Loose files remain visible as a grouping folder's remaining content; grouping
|
|
286
|
+
folders themselves cannot be approved for cleanup. Project sizes exclude separately
|
|
287
|
+
listed dependencies, while archive space checks use the full project size.
|
|
288
|
+
|
|
289
|
+
Activity evidence includes meaningful source edits, Git commits, dirty/untracked
|
|
290
|
+
work, and Spotlight last-opened information when available. Generated directories
|
|
291
|
+
such as `node_modules`, `.venv`, `.git`, and build output do not establish activity.
|
|
292
|
+
They are still included in an archive. Missing Spotlight metadata is shown as
|
|
293
|
+
unavailable; failed source/Git inspection yields **unknown**, never inactive.
|
|
294
|
+
Scans inspect at most 100,000 entries per project and default to a 15-second
|
|
295
|
+
inspection budget (`evidenceTimeoutSec`). These are observations, not proof that a
|
|
296
|
+
project is unused.
|
|
297
|
+
|
|
298
|
+
Defaults are **recent (<30 days)**, **review (30–89 days)**, and **archive candidate
|
|
299
|
+
(90+ days)**. An explicit existing `staleDays` overrides the archive threshold.
|
|
300
|
+
Dirty/untracked work and unclassified folders need manual review. `cleandrive pin
|
|
301
|
+
<project>` keeps the project local; unpin explicitly before approving removal.
|
|
302
|
+
Pinning a descendant also prevents removal of its ancestor.
|
|
303
|
+
|
|
304
|
+
Every new project archive has a unique directory on the configured remote:
|
|
305
|
+
`<remote.path>/archives/<id>/payload`. Earlier versions are never overwritten.
|
|
306
|
+
The catalog is stored in `data/archives/` under cleandrive's config/data directory;
|
|
307
|
+
the remote version contains its own `receipt.json`. An archive-and-remove action
|
|
308
|
+
also leaves `<project>.cleandrive-archive.json` beside the former project location.
|
|
309
|
+
Receipts preserve the original path, exact remote location, content hash,
|
|
310
|
+
verification date, and restore instructions.
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
cleandrive archives # list project archives
|
|
314
|
+
cleandrive archives hackathon --json # search for a project
|
|
315
|
+
cleandrive restore <archive-id> --dry-run
|
|
316
|
+
cleandrive restore <archive-id>
|
|
317
|
+
# If the local catalog was lost, use the sibling or remote receipt:
|
|
318
|
+
cleandrive restore /path/project.cleandrive-archive.json
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Restore downloads into a temporary sibling, checks the remote contents and receipt
|
|
322
|
+
hash, and publishes only to an absent original path. An existing destination,
|
|
323
|
+
including an empty directory or dangling symlink, is refused. The original parent
|
|
324
|
+
must exist. Failed staging remains available at the path printed in the error.
|
|
325
|
+
Restoring never deletes the remote version. These receipts are explicit recovery
|
|
326
|
+
instructions, not Finder placeholders that download automatically. Old archives
|
|
327
|
+
without receipts remain on the remote but are not inferred into the new catalog.
|
|
328
|
+
|
|
329
|
+
Keep a project quiescent during archive-and-remove: close its editors, development
|
|
330
|
+
servers, and other processes. Open-file checks, source fingerprints, drive identity,
|
|
331
|
+
checksums, and successful receipt writes gate local removal. These checks are not
|
|
332
|
+
an atomic filesystem snapshot. External/absolute symlinks require review and are
|
|
333
|
+
refused; a linked Git worktree cannot be removed because its external metadata is
|
|
334
|
+
not self-contained. Remote storage is expected to be Linux, including `sync -f`
|
|
335
|
+
for flushing receipt and payload writes before local removal.
|
|
336
|
+
|
|
337
|
+
An interrupted process may leave `data/archives.lock`. Check that its recorded PID
|
|
338
|
+
is no longer running and review the archive receipts before removing the stale
|
|
339
|
+
lock. `removal-interrupted` or `removal-failed` means inspect both copies; do not
|
|
340
|
+
assume the remaining local directory is complete.
|
|
341
|
+
|
|
342
|
+
### Archive storage versus backup
|
|
343
|
+
|
|
344
|
+
**Transfer verified** means the archive matched when copied. **Independent backup:
|
|
345
|
+
unknown** means cleandrive has not verified a second copy on another storage device.
|
|
346
|
+
A second directory on the same remote drive is not an independent backup. The dashboard and
|
|
347
|
+
CLI keep these facts separate; they do not claim that an old archive is currently
|
|
348
|
+
healthy without another verification.
|
|
349
|
+
|
|
350
|
+
Recommended workflow: back up active Mac work with versioned snapshots; copy a
|
|
351
|
+
finished project to the remote drive with `archive`; back that drive up to a separate
|
|
352
|
+
physical disk or offsite destination and test recovery; only then approve local
|
|
353
|
+
removal. Each new `archive+rm` makes another version, so ensure your independent
|
|
354
|
+
backup covers the same contents before removal. This release does not enforce
|
|
355
|
+
that second-copy policy or schedule backups. Keep the catalog, receipts, and
|
|
356
|
+
configuration in your independent backup as well. A reasonable starting retention
|
|
357
|
+
policy is 7 daily, 4 weekly, and 12 monthly snapshots, with monthly integrity checks
|
|
358
|
+
and test restores.
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// cleandrive — scan disk, plan cleanup, clean caches, archive to remote over SSH/Tailscale.
|
|
3
|
+
// This CLI is also the Claude Code connector: every command supports --json where useful.
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { listArchives, restoreArchive } from '../lib/archives.js';
|
|
6
|
+
import { DATA_DIR, readJson, fmtGB, loadConfig, loadCatalog } from '../lib/util.js';
|
|
7
|
+
import { runScan, CATEGORIES } from '../lib/scan.js';
|
|
8
|
+
import { serve } from '../lib/server.js';
|
|
9
|
+
import { loadPlan, setPlanItem, approvedItems, executeItem, testRemote, archive, actionRefusal, scanItem } from '../lib/actions.js';
|
|
10
|
+
import { offloadPaths, fetchPaths, listOffloaded, findCandidates, verifyRemote, setPin } from '../lib/offload.js';
|
|
11
|
+
|
|
12
|
+
const [, , cmd, ...args] = process.argv;
|
|
13
|
+
const flag = (f) => args.includes(f);
|
|
14
|
+
const num = (name, dflt) => { const a = args.find((x) => x.startsWith(`--${name}=`)); return a ? Number(a.split('=')[1]) : dflt; };
|
|
15
|
+
const positional = () => args.filter((a) => !a.startsWith('--'));
|
|
16
|
+
const out = (d) => process.stderr.write(d);
|
|
17
|
+
|
|
18
|
+
function latest() {
|
|
19
|
+
const scan = readJson(path.join(DATA_DIR, 'latest.json'));
|
|
20
|
+
if (!scan) {
|
|
21
|
+
console.error('no scan yet — run: cleandrive scan');
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
return scan;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function printState() {
|
|
28
|
+
const scan = latest();
|
|
29
|
+
const plan = loadPlan();
|
|
30
|
+
if (flag('--json')) {
|
|
31
|
+
console.log(JSON.stringify({ scan, plan }, null, 2));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const d = scan.disk;
|
|
35
|
+
console.log(`scan: ${scan.ts}`);
|
|
36
|
+
console.log(`disk: ${fmtGB(d.usedKB)} used of ${fmtGB(d.sizeKB)} (${d.pct}%), ${fmtGB(d.availKB)} free\n`);
|
|
37
|
+
if (scan.blocked?.length) {
|
|
38
|
+
const timedOut = scan.blocked.filter((b) => /timed out/.test(b.reason));
|
|
39
|
+
const partial = scan.blocked.length - timedOut.length;
|
|
40
|
+
for (const b of timedOut) console.log(`⚠ not measured: ${b.path.replace(process.env.HOME, '~')} — ${b.reason}`);
|
|
41
|
+
if (partial) console.log(`ℹ ${partial} folder(s) partly unreadable (macOS privacy). Sizes may be low; grant your terminal Full Disk Access for full numbers.`);
|
|
42
|
+
console.log('');
|
|
43
|
+
}
|
|
44
|
+
for (const [key, meta] of Object.entries(CATEGORIES)) {
|
|
45
|
+
const items = scan.items.filter((i) => i.category === key);
|
|
46
|
+
if (!items.length) continue;
|
|
47
|
+
const total = items.reduce((s, i) => s + i.kb, 0);
|
|
48
|
+
console.log(`## ${meta.label} — ${fmtGB(total)} (risk: ${meta.risk})`);
|
|
49
|
+
for (const i of items.slice(0, 15)) {
|
|
50
|
+
const st = plan.items[i.id]?.status || '·';
|
|
51
|
+
console.log(` [${st.padEnd(8)}] ${i.id} ${fmtGB(i.kb).padStart(8)} ${i.suggest.padEnd(10)} ${i.path.replace(process.env.HOME, '~')}`);
|
|
52
|
+
if (i.activity) console.log(` ${i.note}`);
|
|
53
|
+
}
|
|
54
|
+
if (items.length > 15) console.log(` … ${items.length - 15} more`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
switch (cmd) {
|
|
59
|
+
case 'archives': {
|
|
60
|
+
const records = listArchives(positional().join(' '));
|
|
61
|
+
if (flag('--json')) console.log(JSON.stringify(records, null, 2));
|
|
62
|
+
else {
|
|
63
|
+
console.log(`${records.length} project archive(s); independent backup status is unknown`);
|
|
64
|
+
for (const r of records) {
|
|
65
|
+
console.log(`${r.id} ${r.state} ${fmtGB(r.bytes / 1024)} ${r.originalPath}`);
|
|
66
|
+
console.log(` ${r.remote.host}:${r.remotePath}`);
|
|
67
|
+
console.log(` transfer ${r.verification.status} ${r.verification.checkedAt}; restore: cleandrive restore ${r.id}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
case 'restore': {
|
|
73
|
+
const [ref] = positional();
|
|
74
|
+
if (!ref) { console.error('usage: cleandrive restore <archive-id|receipt.json> [--dry-run]'); process.exitCode = 2; break; }
|
|
75
|
+
try {
|
|
76
|
+
const result = await restoreArchive(ref, { dryRun: flag('--dry-run'), onData: out });
|
|
77
|
+
console.log(result.output);
|
|
78
|
+
} catch (e) { console.error(e.message); process.exitCode = 1; }
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
case 'scan': {
|
|
83
|
+
console.error('scanning…');
|
|
84
|
+
const scan = await runScan((s) => console.error(' ' + s));
|
|
85
|
+
if (flag('--json')) console.log(JSON.stringify(scan, null, 2));
|
|
86
|
+
else console.log(`done: ${scan.items.length} items, disk at ${scan.disk.pct}%`);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case 'state':
|
|
90
|
+
printState();
|
|
91
|
+
break;
|
|
92
|
+
case 'serve':
|
|
93
|
+
serve();
|
|
94
|
+
break;
|
|
95
|
+
case 'approve': {
|
|
96
|
+
const ids = args.filter((a) => !a.startsWith('--'));
|
|
97
|
+
const action = (args.find((a) => a.startsWith('--action=')) || '').split('=')[1];
|
|
98
|
+
const plan = loadPlan();
|
|
99
|
+
for (const id of ids) {
|
|
100
|
+
const it = scanItem(id);
|
|
101
|
+
if (!it) { console.log(`✗ ${id}: not in the current scan`); process.exitCode = 1; continue; }
|
|
102
|
+
const why = actionRefusal({ ...it, reviewed: plan.items[id]?.reviewed === true }, action || it.suggest);
|
|
103
|
+
if (why) { console.log(`✗ refused ${id} (${it.path}): ${why}`); process.exitCode = 1; continue; }
|
|
104
|
+
setPlanItem(id, { status: 'approved', ...(action && { action }) });
|
|
105
|
+
console.log(`approved ${id}${action ? ' → ' + action : ''}`);
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case 'skip':
|
|
110
|
+
for (const id of args.filter((a) => !a.startsWith('--'))) {
|
|
111
|
+
setPlanItem(id, { status: 'skipped' });
|
|
112
|
+
console.log(`skipped ${id}`);
|
|
113
|
+
}
|
|
114
|
+
break;
|
|
115
|
+
case 'review':
|
|
116
|
+
for (const id of args.filter((a) => !a.startsWith('--'))) {
|
|
117
|
+
setPlanItem(id, { status: 'reviewed', reviewed: true });
|
|
118
|
+
console.log(`reviewed ${id}`);
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
case 'execute': {
|
|
122
|
+
const items = approvedItems();
|
|
123
|
+
if (!items.length) { console.log('nothing approved'); break; }
|
|
124
|
+
const dry = flag('--dry-run');
|
|
125
|
+
for (const item of items) {
|
|
126
|
+
const why = actionRefusal(item);
|
|
127
|
+
if (dry) {
|
|
128
|
+
console.log(why ? `[dry-run] ✗ refused ${item.plannedAction}: ${item.path} — ${why}`
|
|
129
|
+
: `[dry-run] would ${item.plannedAction}: ${item.path} (${fmtGB(item.kb)})`);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
console.log(`▶ ${item.plannedAction}: ${item.path} (${fmtGB(item.kb)})`);
|
|
133
|
+
try {
|
|
134
|
+
const r = await executeItem(item, { onData: (d) => process.stderr.write(d) });
|
|
135
|
+
console.log(r.ok ? ' ✓ done' : ` ✗ failed: ${r.output.split('\n').pop()}`);
|
|
136
|
+
if (!r.ok) process.exitCode = 1;
|
|
137
|
+
} catch (e) {
|
|
138
|
+
console.log(` ✗ refused: ${e.message}`);
|
|
139
|
+
process.exitCode = 1;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
case 'offload-dryrun': {
|
|
145
|
+
const items = approvedItems().filter((i) => (i.plannedAction || '').startsWith('archive'));
|
|
146
|
+
for (const item of items) {
|
|
147
|
+
console.log(`dry-run: ${item.path}`);
|
|
148
|
+
const r = await archive(item, { dryRun: true, removeLocal: item.plannedAction === 'archive+rm', onData: (d) => process.stderr.write(d) });
|
|
149
|
+
console.log(r.ok ? ' ✓ ok' : ` ✗ ${r.output}`);
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case 'offload': {
|
|
154
|
+
const ps = positional();
|
|
155
|
+
if (!ps.length) { console.error('usage: cleandrive offload <file|dir…> [--dry-run] [--min=MB]'); process.exit(2); }
|
|
156
|
+
const r = await offloadPaths(ps, { dryRun: flag('--dry-run'), minMB: num('min', 50), onData: out });
|
|
157
|
+
const ok = r.filter((x) => x.ok);
|
|
158
|
+
console.log(`${flag('--dry-run') ? 'dry-run: ' : ''}${ok.length}/${r.length} ok, ${fmtGB(ok.reduce((s, x) => s + (x.size || 0), 0) / 1024)}`);
|
|
159
|
+
process.exit(r.every((x) => x.ok) ? 0 : 1);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case 'fetch': {
|
|
163
|
+
const ps = positional();
|
|
164
|
+
if (!ps.length) { console.error('usage: cleandrive fetch <file|file.cloud|dir…> [--dry-run]'); process.exit(2); }
|
|
165
|
+
const r = await fetchPaths(ps, { dryRun: flag('--dry-run'), onData: out });
|
|
166
|
+
console.log(`${flag('--dry-run') ? 'dry-run: ' : ''}${r.filter((x) => x.ok).length}/${r.length} ok`);
|
|
167
|
+
process.exit(r.every((x) => x.ok) ? 0 : 1);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
case 'offloaded': {
|
|
171
|
+
const l = listOffloaded();
|
|
172
|
+
if (flag('--json')) { console.log(JSON.stringify(l, null, 2)); break; }
|
|
173
|
+
const off = l.files.filter((f) => f.state === 'offloaded');
|
|
174
|
+
console.log(`offloaded: ${off.length} files, ${fmtGB(off.reduce((s, f) => s + f.size, 0) / 1024)} on the remote`);
|
|
175
|
+
for (const f of l.files) console.log(` [${f.state.padEnd(9)}] ${fmtGB(f.size / 1024).padStart(8)} ${f.path.replace(process.env.HOME, '~')}`);
|
|
176
|
+
if (l.pins.length) console.log(`pinned (keep local): ${l.pins.map((p) => p.replace(process.env.HOME, '~')).join(', ')}`);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case 'offload-candidates': {
|
|
180
|
+
const r = await findCandidates({ minMB: num('min', 200), days: num('days', 30), allTypes: flag('--all-types'), dupes: !flag('--no-dupes'), onData: out });
|
|
181
|
+
if (flag('--json')) { console.log(JSON.stringify(r, null, 2)); break; }
|
|
182
|
+
const tot = r.candidates.reduce((s, c) => s + c.kb, 0);
|
|
183
|
+
console.log(`${r.candidates.length} candidates, ${fmtGB(tot)} (≥${r.minMB} MB, idle ≥${r.days}d)`);
|
|
184
|
+
for (const c of r.candidates.slice(0, 40)) {
|
|
185
|
+
console.log(` ${fmtGB(c.kb).padStart(8)} ${String(c.idleDays).padStart(4)}d ${c.path.replace(process.env.HOME, '~')}${c.duplicateOf ? ` ⧉ duplicate of ${c.duplicateOf.replace(process.env.HOME, '~')}` : ''}`);
|
|
186
|
+
}
|
|
187
|
+
if (r.unreadable) console.log(`⚠ ${r.unreadable} paths not readable (macOS privacy / Full Disk Access)`);
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
case 'offload-verify': {
|
|
191
|
+
const r = await verifyRemote({ onData: out });
|
|
192
|
+
console.log(r.bad.length ? `✗ ${r.bad.length} of ${r.checked} remote copies bad` : `✓ all ${r.checked} remote copies verified`);
|
|
193
|
+
process.exit(r.bad.length ? 1 : 0);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
case 'pin':
|
|
197
|
+
case 'unpin':
|
|
198
|
+
for (const p of positional()) console.log(`${cmd === 'pin' ? 'pinned' : 'unpinned'} ${setPin(p, cmd === 'pin')}`);
|
|
199
|
+
break;
|
|
200
|
+
case 'remote-test': {
|
|
201
|
+
const r = await testRemote();
|
|
202
|
+
console.log((r.ok ? '✓ ' : '✗ ') + r.msg);
|
|
203
|
+
process.exit(r.ok ? 0 : 1);
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
case 'catalog': {
|
|
207
|
+
// node:sqlite needs Node >= 22.13; the rest of the CLI must keep working without it.
|
|
208
|
+
const C = await loadCatalog();
|
|
209
|
+
if (!C) { console.error(`catalog needs Node >= 22.13 (node:sqlite); this is Node ${process.versions.node}`); process.exit(1); }
|
|
210
|
+
const { all: catalogAll, search: catalogSearch, stats: catalogStats, sync: catalogSync, syncRemote: catalogSyncRemote, closeDb } = C;
|
|
211
|
+
const sub = positional()[0];
|
|
212
|
+
if (sub === 'sync') {
|
|
213
|
+
const local = catalogSync({ onData: out });
|
|
214
|
+
if (flag('--remote')) {
|
|
215
|
+
const remote = await catalogSyncRemote({ onData: out });
|
|
216
|
+
console.log(`sync done: ${local.added + remote.added} added, ${local.updated} updated`);
|
|
217
|
+
} else {
|
|
218
|
+
console.log(`sync done: ${local.added} added, ${local.updated} updated`);
|
|
219
|
+
}
|
|
220
|
+
} else if (sub === 'stats') {
|
|
221
|
+
const s = catalogStats();
|
|
222
|
+
if (flag('--json')) { console.log(JSON.stringify(s, null, 2)); break; }
|
|
223
|
+
console.log(`catalog: ${s.total.n} items, ${fmtGB(s.total.bytes / 1024)} total`);
|
|
224
|
+
console.log(`\nby type:`);
|
|
225
|
+
for (const r of s.byType) console.log(` ${r.type.padEnd(10)} ${String(r.n).padStart(4)} items ${fmtGB(r.bytes / 1024).padStart(8)}`);
|
|
226
|
+
console.log(`\nby state:`);
|
|
227
|
+
for (const r of s.byState) console.log(` ${r.state.padEnd(18)} ${String(r.n).padStart(4)} items ${fmtGB(r.bytes / 1024).padStart(8)}`);
|
|
228
|
+
console.log(`\non remote: ${s.onRemote.n} items, ${fmtGB(s.onRemote.bytes / 1024)}`);
|
|
229
|
+
} else {
|
|
230
|
+
const query = positional().join(' ');
|
|
231
|
+
const items = query ? catalogSearch(query) : catalogAll(
|
|
232
|
+
Object.fromEntries([['type', '--type'], ['state', '--state']].map(
|
|
233
|
+
([k, f]) => [k, (args.find((a) => a.startsWith(f + '=')) || '').split('=')[1] || '']
|
|
234
|
+
).filter(([, v]) => v))
|
|
235
|
+
);
|
|
236
|
+
if (flag('--json')) { console.log(JSON.stringify(items, null, 2)); break; }
|
|
237
|
+
if (!items.length) { console.log('catalog empty — run: cleandrive catalog sync'); break; }
|
|
238
|
+
if (flag('--compact')) {
|
|
239
|
+
for (const it of items) console.log(`${it.local_path.replace(process.env.HOME, '~')}\t${fmtGB(it.size_bytes / 1024)}\t${it.state}\t${it.type}`);
|
|
240
|
+
} else {
|
|
241
|
+
console.log(`${items.length} item(s) on the remote drive:\n`);
|
|
242
|
+
for (const it of items) {
|
|
243
|
+
const lp = it.local_path.replace(process.env.HOME, '~');
|
|
244
|
+
console.log(` [${it.type.padEnd(7)}] ${it.state.padEnd(18)} ${fmtGB(it.size_bytes / 1024).padStart(8)} ${lp}`);
|
|
245
|
+
console.log(` ${it.remote_host}:${it.remote_path}`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
closeDb();
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
default:
|
|
253
|
+
console.log(`cleandrive — disk cleanup planner & executor
|
|
254
|
+
|
|
255
|
+
usage:
|
|
256
|
+
cleandrive scan [--json] scan disk, categorize, write data/latest.json
|
|
257
|
+
cleandrive archives [search] [--json] search verified project archive records
|
|
258
|
+
cleandrive restore <id|receipt.json> [--dry-run] restore a project without overwriting
|
|
259
|
+
cleandrive state [--json] show latest scan + plan status
|
|
260
|
+
cleandrive serve start dashboard on http://localhost:${loadConfig().port || 4499}
|
|
261
|
+
cleandrive approve <id…> [--action=rm|clean|archive|archive+rm]
|
|
262
|
+
cleandrive skip <id…>
|
|
263
|
+
cleandrive review <id…> mark reviewed (unlocks rm for appdata/models)
|
|
264
|
+
cleandrive execute [--dry-run] run all approved actions
|
|
265
|
+
cleandrive offload-dryrun pre-flight approved archive items (drive, room)
|
|
266
|
+
cleandrive remote-test check SSH reachability of configured remote
|
|
267
|
+
|
|
268
|
+
offload (iCloud-style switch to the remote drive, see docs/offload-strategy.md):
|
|
269
|
+
cleandrive offload <file|dir…> [--dry-run] [--min=MB] verified upload, leaves <name>.cloud
|
|
270
|
+
cleandrive fetch <file|stub|dir…> [--dry-run] verified download, removes the stub
|
|
271
|
+
cleandrive offloaded [--json] what is offloaded / back local
|
|
272
|
+
cleandrive offload-candidates [--min=200] [--days=30] [--all-types] [--no-dupes] [--json]
|
|
273
|
+
cleandrive offload-verify re-hash remote copies (scrub)
|
|
274
|
+
cleandrive pin|unpin <path…> keep local / never propose
|
|
275
|
+
|
|
276
|
+
catalog (SQLite index of everything on the remote drive; Node >= 22.13):
|
|
277
|
+
cleandrive catalog [search] [--type=offload|archive] [--state=…] [--json]
|
|
278
|
+
cleandrive catalog sync [--remote] rebuild from local JSON + optionally pull remote manifest
|
|
279
|
+
cleandrive catalog stats [--json] summary: items by type, state, total size`);
|
|
280
|
+
}
|