Skip to content

feat(cleaner): built-in Cleaner plugin to free disk space safely (CLI, TUI, desktop, MCP) - #82

Merged
ralyodio merged 2 commits into
mainfrom
feat/cleaner-plugin
Nov 11, 2026
Merged

ralyodio merged 2 commits into
mainfrom
feat/cleaner-plugin

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

What

A built-in Cleaner plugin (cleaner, CLI alias diskpush clean), enabled by default, that frees disk space intelligently on this machine or on any server DiskPush can ssh to.

The heart of it is the analysis:

  • What is using and growing the disk: every filesystem's free space, the biggest directories (one bounded du -d 1 per root, falling back to parallel per-folder du with a timeout each, so one huge tree shows as ? instead of stalling the scan), the processes writing right now (per-process /proc/<pid>/io write_bytes deltas, mapped to docker container names), and growth since the last report (a snapshot per target in the plugin's settings).
  • Every finding classified and explained: safe (regenerable), safe-if-idle (removable only because the guards prove nobody uses it), or needs-a-human (databases, backups, docker volumes, stopped containers, media: reported with a command to look closer, never deleted). Each item carries its reason and a suggested command.
  • Ranked by bytes freed per unit of risk into a plan.

Then, only on an explicit apply (CLI --apply, MCP apply: true, desktop confirm dialog), it removes the chosen safe-class items, re-checking every guard on the target at the moment of deletion.

Categories

  • caches: npm, pnpm (store prune), yarn, bun, uv, pip, cargo registry, go build cache; skipped while the tool runs
  • docker: docker builder prune -f, docker image prune -a -f --filter until=72h; volumes and containers never touched
  • logs: journald vacuum to a cap, gzip of rotated logs nobody has open (root or --sudo, otherwise listed with the command)
  • build: node_modules/.next/target/dist/... only next to a project marker, git-ignored, whole repo idle N days (default 3), no live process cwd/exe inside it, not referenced by a linked command, crontab, cron.d, systemd unit or a running container's bind mount
  • partials: *.partial/*.part/*.crdownload untouched 24 h and not open

Safety

  • Dry run by default everywhere; the analysis writes no scratch files (works on a 100% full disk).
  • Commands come from a fixed table keyed by id, paths are shell-quoted, option values validated.
  • Apply re-verifies each item on the target; anything that became busy is skipped with the reason.
  • A lock (in $XDG_RUNTIME_DIR) means two cleans never overlap; --min-free-gb N does nothing while N GB are free and stops once they are (cron-safe; diskpush clean cron prints the line).
  • Desktop: the renderer only ever sends a report id plus item ids from a report the main process produced, never a path.
  • Cancelling kills the whole local process group (the du/find children too).

Surfaces (one core: packages/plugin-cleaner)

  • CLI: diskpush clean report [TARGET], diskpush clean [TARGET] [--apply] [--only ...] [--idle-days N] [--min-free-gb N] [--roots ...] [--sudo] [--json], clean targets, clean cron
  • MCP: diskpush clean mcp (stdio): clean_targets, clean_report, clean_apply
  • TUI / desktop file panes: a / right-click on a folder: "Disk report: what can be freed here"
  • Desktop: new Cleaner tab (target, categories, analysis, tick + confirm, results)
  • Site: homepage Cleaner section, docs/cleaner.md (also in the site docs and llms.txt)
  • API: scanTarget, applyClean, listTargets exported from @diskpush/plugin-cleaner

Also: clean is a reserved plugin id, the cleaner is in the release manifests and gets the strict ThreatCrush plugin scan.

Tests

packages/plugin-cleaner/src/cleaner.test.ts runs the real scan and apply programs in a real shell against a fixture home (docker, npm, journalctl, crontab, pgrep shimmed on PATH): an idle repo, an active repo, a repo with a live process inside, a repo named by a crontab line, committed dist, a node_modules outside any project, old and fresh .partial files, a rotated log. It asserts the dry run deletes nothing, apply deletes exactly the eligible set, category filtering, re-verification at delete time, the lock, threshold mode, the MCP dry-run, and quoting. Plus CLI alias tests, desktop contract and helper tests.

Local results (Node 24, this branch): full suite 959 tests, 958 passed in the full run; the one failure (mediaanalyzer ffmpeg sampling, 5 s timeout) passes alone (21/21), the box was at load average 82. pnpm -r typecheck clean. Cleaner suite 15/15.

Desktop Cleaner tab screenshotted in both themes (static renderer export + stubbed preload bridge): report, ranked plan, kept-and-why, needs-a-human with commands, confirm dialog.

🤖 Generated with Claude Code

…, TUI, desktop, MCP)

A new built-in plugin, enabled by default, that analyses what is using and
growing a disk (filesystems, biggest directories, live writers from /proc io
deltas, growth since the last report), classifies every finding as safe,
safe-if-idle or needs-a-human with the reason, ranks them by bytes freed per
unit of risk, and removes only safe-class items on an explicit apply,
re-checking every guard on the target at deletion time.

Runs locally or on any known server over ssh (POSIX sh fed on stdin, no
scratch files, so it works on a full disk). Surfaces: `diskpush clean`
(report, run, targets, cron, mcp), a TUI/desktop folder action, the desktop
Cleaner tab, an MCP server, docs and a homepage section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@socket-security

socket-security Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​profullstack/​footer@​0.2.6 ⏵ 0.6.1987 +10100100 +197 +3100

View full report

…e du -d 1 pass per root; cancel kills the whole process group

Found by a real read-only report on a 1.8 TB box: per-child du with a 20 s
budget left the biggest folders as '?', the case that matters most. A du
that runs out of time has already printed every subfolder it finished, so
their sum is a true lower bound. Roots are sized in one bounded pass and only
the unfinished children are sized one by one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ralyodio

Copy link
Copy Markdown
Contributor Author

Merging on local evidence: the org's Actions runners are jammed (this PR's CI and ThreatCrush runs are still queued).

Local, Node 24.22.2, branch head c8e5b63:

  • pnpm test: 75 files, 960/960 passed
  • pnpm -r typecheck: clean
  • threatcrush scan packages/plugin-cleaner --deps --fail-on critical,high,medium (0.13.76): no security issues
  • Cleaner suite: 16/16 (real scan/apply programs against a fixture home with shimmed docker/npm/journalctl/crontab)
  • A real read-only diskpush clean report on a 1.8 TB Linux box at load ~80: exit 0, 11.7 min, nothing deleted; it found the lower-bound sizing gap fixed in c8e5b63
  • Desktop Cleaner tab rendered from the static renderer export with a stubbed bridge, dark + light + confirm dialog, no page errors

@ralyodio
ralyodio merged commit 773c9f5 into main Nov 11, 2026
6 checks passed
@sh1pt-actions-fleet
sh1pt-actions-fleet Bot deleted the feat/cleaner-plugin branch November 11, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant