8000 feat(state): take back the disk, and say goodbye by dominikwozniak · Pull Request #72 · dominikwozniak/dw-mc · GitHub
[go: up one dir, main page]

Skip to content

feat(state): take back the disk, and say goodbye - #72

Merged
dominikwozniak merged 2 commits into
mainfrom
feat/71-cleanup-and-uninstall
Sep 17, 2026
Merged

dominikwozniak merged 2 commits into
mainfrom
feat/71-cleanup-and-uninstall

Conversation

@dominikwozniak
Copy link
Copy Markdown
Owner

dw-mc keeps 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 remove runs 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 a fix or resolve session 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 prints pnpm remove -g dw-mc as 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 names git cuts against.
  • src/adapters/git.ts — holding answers 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/718
  • src/domain/cleanup.test.ts — 8 new cases: what a plan takes, the clone a session keeps, the review worktree of a repository whose clone stays
  • src/cli/uninstall.test.ts — 7 new cases, one per way a worktree holds work and one for --force
  • by hand: node dist/bin.js cleanup --yes against 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 --yes took the state directory and named the configuration file it did not touch

Risk

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 cleanup is the next run, which clones again.

🤖 Generated with Claude Code

dominikwozniak and others added 2 commits September 17, 2026 21:36
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>
@dominikwozniak
dominikwozniak merged commit d7b37fe into main Sep 17, 2026
1 check passed
@dominikwozniak
dominikwozniak deleted the feat/71-cleanup-and-uninstall branch September 17, 2026 19:39
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.

feat(state): reclaim what the tool wrote, and remove it on the way out

1 participant

0