README.md
1 # disk-cleanup 2 3 Auto-tracks and cleans up ephemeral files created during Hermes Agent 4 sessions — test scripts, temp outputs, cron logs, stale chrome profiles. 5 Scoped strictly to `$HERMES_HOME` and `/tmp/hermes-*`. 6 7 Originally contributed by [@LVT382009](https://github.com/LVT382009) as a 8 skill in PR #12212. Ported to the plugin system so the behaviour runs 9 automatically via `post_tool_call` and `on_session_end` hooks — the agent 10 never needs to remember to call a tool. 11 12 ## How it works 13 14 | Hook | Behaviour | 15 |---|---| 16 | `post_tool_call` | When `write_file` / `terminal` / `patch` creates a file matching `test_*`, `tmp_*`, or `*.test.*` inside `HERMES_HOME`, track it silently as `test` / `temp` / `cron-output`. | 17 | `on_session_end` | If any test files were auto-tracked during this turn, run `quick` cleanup (no prompts). | 18 19 Deletion rules (same as the original PR): 20 21 | Category | Threshold | Confirmation | 22 |---|---|---| 23 | `test` | every session end | Never | 24 | `temp` | >7 days since tracked | Never | 25 | `cron-output` | >14 days since tracked | Never | 26 | empty dirs under HERMES_HOME | always | Never | 27 | `research` | >30 days, beyond 10 newest | Always (deep only) | 28 | `chrome-profile` | >14 days since tracked | Always (deep only) | 29 | files >500 MB | never auto | Always (deep only) | 30 31 ## Slash command 32 33 ``` 34 /disk-cleanup status # breakdown + top-10 largest 35 /disk-cleanup dry-run # preview without deleting 36 /disk-cleanup quick # run safe cleanup now 37 /disk-cleanup deep # quick + list items needing prompt 38 /disk-cleanup track <path> <category> # manual tracking 39 /disk-cleanup forget <path> # stop tracking 40 ``` 41 42 ## Safety 43 44 - `is_safe_path()` rejects anything outside `HERMES_HOME` or `/tmp/hermes-*` 45 - Windows mounts (`/mnt/c` etc.) are rejected 46 - The state directory `$HERMES_HOME/disk-cleanup/` is itself excluded 47 - `$HERMES_HOME/logs/`, `memories/`, `sessions/`, `skills/`, `plugins/`, 48 and config files are never tracked 49 - Backup/restore is scoped to `tracked.json` — the plugin never touches 50 agent logs 51 - Atomic writes: `.tmp` → backup → rename