Skip to content

disktree-cli: the scan, findings and removal guards without a window - #32

Open
NakliTechie wants to merge 3 commits into
tobi:mainfrom
NakliTechie:headless-cli
Open

NakliTechie wants to merge 3 commits into
tobi:mainfrom
NakliTechie:headless-cli

Conversation

@NakliTechie

Copy link
Copy Markdown

Disk cleanup is becoming agent work, and disktree already knows it: its review screen hands the marked list to a coding agent, and "Agent scratch" is one of its categories. This PR adds the other direction: an agent can ask disktree what fills a disk, and remove only through disktree's own guards.

Three commits, each reviewable on its own:

  1. core: move git state into disktree-core. git.rs moves from the app to core, unchanged, so a checkout's changes, stashes and unpushed commits can be read without a window. No behaviour change.
  2. insights: model weights, stale archives, and .worktrees. Worth a look now lists two things a developer machine forgets. The panel labels both "check for a copy", not "safe to delete".
    • Weights: a directory holding .safetensors, .gguf, .ggml, .ckpt, .pt, .pth, .onnx or .tflite directly. A .bin counts only beside a config.json, the Hugging Face shape. Only the weight files are counted.
    • Stale archive: an archive or disk image untouched for 30 days. Synced folders are skipped, since an old archive there is a backup.
    • .worktrees is treated like worktrees.
  3. disktree-cli. Three commands, each printing JSON:
    disktree-cli scan [PATH] [--store DIR]... [--limit N]
    disktree-cli check --root ROOT PATH...
    disktree-cli trash --root ROOT PATH...
    
    • Each finding carries a tier. regenerable is space a tool or build writes again. judge is space that may be the only copy. Worktree findings include each checkout's git state.
    • --store names a directory kept on purpose, such as a model store. Findings inside it are left out. A weight file elsewhere with the same name and size is reported as a copy of the one in the store.
    • --root is required for check and trash, as the scanned root is the consent boundary in the window. trash is the only way it removes anything. There is no permanent mode.

The one new dependency is serde_json, in the CLI crate only.

Checks

  • cargo xtask lint: clean on Rust 1.98.1.
  • cargo xtask test: 173 passed, 0 failed. That includes 5 new insights tests and 3 CLI tests: a store match, guard refusals, and --root required.
  • On an M-series Mac: disktree-cli scan ~/Code took 22 s for 1.63M files, 206 GB.
  • check refused home, the scanned root, and a path under /private.
  • trash moved a test directory to the macOS Trash.
  • Not run: Linux and Windows. The CLI adds no platform code apart from a cfg(unix) block size, with a len() fallback elsewhere.

README gains a "Without a window" section. AGENTS.md's map gains git.rs and the CLI.

Happy to split this into three PRs, or to drop the CLI and keep only the findings, if that fits the project better.

🤖 Generated with Claude Code

Chirag Patnaik and others added 3 commits September 26, 2026 15:03
What git knows about a checkout (changes, stashes, unpushed commits) is
the question to ask before removing one, whether from the window or from
a script. Moving it next to removal.rs lets code without a window ask it
too. No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Worth a look listed only space known to come back. The largest things a
developer machine forgets are often not that: checkpoints and adapters
left in a project, and archives downloaded, unpacked and left. Both are
now findings, labelled so the panel says to check for a copy rather
than suggesting they are safe.

- Weights: a directory holding .safetensors, .gguf, .ggml, .ckpt, .pt,
  .pth, .onnx or .tflite directly; .bin only beside a config.json, the
  Hugging Face shape. Only the weight files are counted.
- Stale archive: an archive or disk image untouched for 30 days, outside
  a synced folder, where an old archive is a backup.
- .worktrees counts as agent worktrees, like worktrees.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An agent asked what fills a disk reaches for find and du. This prints
what the window shows as JSON instead: totals, free space and Worth a
look, each finding with a tier (regenerable or judge) and, for
worktrees, what git says about each checkout.

check and trash take --root and run removal::plan, the same guards the
review screen uses. trash is the only way it removes anything.

--store names a directory kept on purpose, such as a model store: its
contents are not findings, and a weight file elsewhere with the same
name and size as one in it is reported as a copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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