Repository navigation
feat(state): take back the disk, and say goodbye - #72
Merged
Merged
Conversation
The tool writes a configuration file and a state directory outside its own package, and removing the package takes neither: verified by running it, no uninstall script of any name runs on a removal, so a tool that writes outside node_modules has to clean up after itself. cleanup takes back what the tool rebuilds by itself, the bare clones and the worktrees a review run left behind, and stops at a clone a session stands on, because that session's history lives inside it. uninstall takes the whole state directory, the configuration file where asked, and prints the one step it cannot take. Neither takes a worktree that still holds work of mine, asked offline so a machine with no network is never told its commits are gone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <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.
dw-mckeeps a configuration file and a state directory outside its own package, and the state directory grows a bare clone per repository and a worktree per run. Removing the package takes the binary and leaves every byte of that where it is: verified by running it,pnpm removeruns no uninstall script of any name, so nothing but the tool itself can take its own footprint back. It now does, in two commands, because reclaiming disk and leaving the machine are two different intentions.Closes #71.
What changes
src/cli/cleanup.ts— lists the bare clones and the review worktrees with their weight, takes them on confirmation, and leaves a clone standing where afixorresolvesession stands on it, pruning that clone's stale worktree records instead.src/cli/uninstall.ts— takes the whole state directory, the configuration file under--config, and printspnpm remove -g dw-mcas the one step it cannot take. A session worktree holding uncommitted changes or a commit the pull request's head does not have stops it until--force.src/adapters/store.ts— reads the state directory as directories rather than keys: the clones, the checkouts and the records, each weighed; discards a directory and the ones its removal left empty. It also owns the layout namesgitcuts against.src/adapters/git.ts—holdinganswers what a standing session worktree still holds without fetching, so a machine that is offline is never told its commits are gone; a clone that cannot say where the pull request points holds the worktree rather than letting it through.Test plan
pnpm check— pass, 718/718src/domain/cleanup.test.ts— 8 new cases: what a plan takes, the clone a session keeps, the review worktree of a repository whose clone stayssrc/cli/uninstall.test.ts— 7 new cases, one per way a worktree holds work and one for--forcenode dist/bin.js cleanup --yesagainst a laid-out state directory took the clone and the review worktree, kept the record and the standing fix session's clone, and left no empty directories behind;node dist/bin.js uninstall --yestook the state directory and named the configuration file it did not touchRisk
Both commands remove directories, which no reflog brings back. What each takes is printed with its weight before it is taken, the confirmation starts on no, and the one thing that cannot be rebuilt — a session worktree's uncommitted changes or unpushed commits — is checked offline and stops the command. The way back from a mistaken
cleanupis the next run, which clones again.🤖 Generated with Claude Code