|
| 1 | +--- |
| 2 | +name: mole |
| 3 | +description: "Drive the Mole CLI (`mo`) safely from an agent: which command answers which question, the machine-readable surfaces (analyze --json, history --json, the dry-run path list), and the rules that keep an automated run from deleting something the user wanted. Read before running any `mo` command on a user's Mac." |
| 4 | +--- |
| 5 | + |
| 6 | +# Using Mole from an agent |
| 7 | + |
| 8 | +Mole (`mo`) cleans, uninstalls, analyzes, optimizes, and monitors a Mac. It is |
| 9 | +a real deletion tool operating on someone's live machine, so the way an agent |
| 10 | +uses it differs from the way a human does: never guess, never let a TUI decide, |
| 11 | +and never let a destructive command run without the user having seen the list. |
| 12 | + |
| 13 | +## The rules |
| 14 | + |
| 15 | +1. **Preview before you delete. Always.** Every destructive command takes |
| 16 | + `--dry-run`. Run it, read the result, show the user what would go, and only |
| 17 | + then offer the real run. An agent that runs `mo clean` before `mo clean |
| 18 | + --dry-run` has skipped the only step the user can veto. |
| 19 | +2. **The user runs the destructive command, not you**, unless they explicitly |
| 20 | + asked you to do it in the current turn. "Clean my Mac" is such an ask; |
| 21 | + "why is my disk full" is not. |
| 22 | +3. **Never parse the TUI.** `mo status` and the interactive `mo analyze` are |
| 23 | + full-screen Go programs whose output is drawn, not printed. Piping them |
| 24 | + produces escape-code soup. Use the JSON surfaces below. |
| 25 | +4. **Never invent flags.** The command surface is small and listed here; if |
| 26 | + something is not on this page, run `mo <command> --help` and read it, do not |
| 27 | + assume a `--yes` or `--force` exists. |
| 28 | +5. **Protection is a whitelist, not an argument.** If the user wants a cache |
| 29 | + kept, the answer is `mo clean --whitelist`, not a hand-rolled `find`. Never |
| 30 | + work around Mole's safety layer with raw `rm`. |
| 31 | + |
| 32 | +## What answers which question |
| 33 | + |
| 34 | +| The user asks | Command | |
| 35 | +|---|---| |
| 36 | +| "What is eating my disk?" | `mo analyze --json` (whole disk) or `mo analyze <path> --json` | |
| 37 | +| "Free up space" | `mo clean --dry-run`, review, then `mo clean` | |
| 38 | +| "Remove this app completely" | `mo uninstall --dry-run` then `mo uninstall` | |
| 39 | +| "My Mac feels slow" / caches look broken | `mo optimize --dry-run` then `mo optimize` | |
| 40 | +| "Clean up my old projects" | `mo purge --dry-run` then `mo purge` | |
| 41 | +| "Get rid of downloaded installers" | `mo installer --dry-run` then `mo installer` | |
| 42 | +| "What did Mole delete?" | `mo history --json --limit 20` | |
| 43 | +| Live CPU / memory / network | `mo status` (hand it to the user; it is a TUI) | |
| 44 | + |
| 45 | +## Machine-readable surfaces |
| 46 | + |
| 47 | +These three are the entire agent-facing API. Everything else is for humans. |
| 48 | + |
| 49 | +**Disk usage.** `mo analyze --json` prints one JSON object: `path`, `overview`, |
| 50 | +and `entries[]` of `{name, path, size, is_dir, insight}`. `size` is bytes. |
| 51 | +`insight: true` marks an entry Mole considers noteworthy (a large iOS backup, a |
| 52 | +runaway cache). Pass a path to scope it: `mo analyze ~/Library --json`. |
| 53 | + |
| 54 | +**Cleanup history.** `mo history --json [--limit N]` (N is 1-200) prints |
| 55 | +`logs` (paths of the operations and deletions logs) plus `sessions[]` with |
| 56 | +`command`, `started_at`, `items`, `size`, and an `actions` breakdown of |
| 57 | +removed / trashed / skipped / failed. This is how you answer "did Mole delete |
| 58 | +my file" without guessing: the deletions log has the paths. |
| 59 | + |
| 60 | +**The dry-run path list.** `mo clean --dry-run` prints a summary to the |
| 61 | +terminal and writes every candidate path to `~/.config/mole/clean-list.txt`. |
| 62 | +Read that file, not the terminal output, when you need to reason about or show |
| 63 | +the user exactly what a real run would remove. This list is clean-only: `mo |
| 64 | +purge --dry-run` and `mo installer --dry-run` print their candidates to the |
| 65 | +terminal and write no file. |
| 66 | + |
| 67 | +## Command notes worth knowing |
| 68 | + |
| 69 | +- `mo clean` also sweeps leftovers from apps the user already deleted. It does |
| 70 | + not touch installed apps; that is `mo uninstall`. |
| 71 | +- `mo clean --external <path>` cleans macOS metadata off an external volume. |
| 72 | +- `mo purge` removes rebuildable project artifacts (`target/`, `build/`, |
| 73 | + `dist/`, `.next/`). It deliberately does not touch anything that needs a |
| 74 | + network to restore (`node_modules/`, `Pods/`, `venv/`), so a purge is always |
| 75 | + recoverable with a local rebuild. `mo purge --paths` configures which |
| 76 | + directories are scanned; `--include-empty` shows zero-size candidates. |
| 77 | +- `mo optimize` refreshes caches and system services. It is the one destructive |
| 78 | + command whose effects are not "files disappear", so say what it will do |
| 79 | + before running it. |
| 80 | +- `mo update` self-updates; `mo update --nightly` installs unreleased `main`. |
| 81 | + Do not run either on a user's behalf without being asked. |
| 82 | +- `--debug` on any command prints the detailed operation log. Reach for it when |
| 83 | + a command silently did nothing; do not leave it on in normal use. |
| 84 | + |
| 85 | +## When something goes wrong |
| 86 | + |
| 87 | +**`mo clean` deletions are permanent by default.** Cache cleanup removes files |
| 88 | +rather than moving them to the Trash, so there is usually nothing to restore. |
| 89 | +That is exactly why rule 1 exists: the dry-run is the undo. `mo uninstall` is |
| 90 | +the exception: it routes the app and its leftovers through the Trash, so an |
| 91 | +uninstalled app is recoverable until the Trash is emptied. |
| 92 | + |
| 93 | +What you do have is a record. `mo history --json` names the deletions log, and |
| 94 | +every deletion is one tab-separated line in it: timestamp, mode, size, status, |
| 95 | +path. So when a user asks "did Mole take my file", read the log and answer with |
| 96 | +the actual line instead of guessing. Then add the path to the whitelist (`mo |
| 97 | +clean --whitelist`) so the next run leaves it alone. |
0 commit comments