Repository navigation
feat: check only the named paths in clean --item and add clean --json - #76
Merged
Merged
Conversation
clean --item rescanned the whole --path scope before keeping the named artifacts, taking ~28s on a home directory. The scan now carries the item paths in its context: the project walk enters only the directories leading to them, only they are sized, and brew's dry-run runs only for the Homebrew item, so a single item is checked in about a second with the same result. clean --json (with --yes) prints each item's result and the trashed and freed totals; errors before deleting stay on stderr as text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
clean --itemchecks only the named paths. Before, it rescanned the whole--pathscope (default~) and then kept the named artifacts. The scan now carries the item paths in its context:brew cleanup --dry-run(13 s on the author's machine) runs only when an item is the Homebrew item.clean --json(needs--yes). It prints each item'sresult(trashed/freed/failed, orwould_clean/would_failwith--dry-run) and error, plustrashed_size/freed_size, the--yesgate'sskippeditems, andvendor_cleanups. Errors before deleting stay on stderr as text with exit 1, as in text mode.Why
The status-pane mod lists
scan --jsonresults and deletes withclean --item <path>... --yes. That call took about 28 s, and its result could not be parsed.Measured on a real home with
--dry-run(nothing deleted), old → new:--itemnode_modules~/.npmnode_modules+~/.cache/uv(13 GB, pre-delete check)~/Library/Caches/Homebrew(brew's own dry-run)The text output was byte-identical in every case.
Tests
internal/scanner/items_test.goruns a limited scan for every directory of a fixture and checks that the result at that path equals the full scan's. The fixture covers a nested project, an any-depth rule, a hidden ancestor, a pruned pnpm store, an artifact inside an artifact, global/HF/Homebrew caches and a stubbed brew. Breaking the hidden-dir rule or skipping item sizing makes it fail. A second test checks that brew's dry-run runs only for the Homebrew item.internal/cli/clean_test.gochecksclean --jsonper-item results and totals with no other stdout, the dry-run withskipped, and the requirement for--yes.Docs
docs/SPEC.md§ clean: a new--jsonexample; a new--itemparagraph on checking only the named paths; a new#### JSON (--json)subsection; Flow step 1.docs/ARCHITECTURE.md§ Scanner Design: a new Limited scan paragraph (thescanner.WithItemscontract).plugins/devclean/skills/devclean/SKILL.md: clean commands use--json; the scope note no longer says the rescan is slow; failures and the report now read from the JSON fields.🤖 Generated with Claude Code