Remove the --deps, --json and --no-gh modes, the upstream-remote PR lookup,
the zombie bookkeeping in the process scan, the size column and the
force/safe branch deletion split. Trash goes into a mkdtemp slot and the
background delete removes whole trash directories, so leftovers need no
separate scan. Idle time now comes from the worktree HEAD reflog.
Treat a PR as merged when its head SHA is the worktree HEAD, so a
squash-merged worktree is removed after its remote branch is pruned.
The process check is Linux only; elsewhere the script only reports.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
When origin and upstream both answer for a branch, keep OPEN over
MERGED over CLOSED instead of the last reply. Name --deps trash by the
directory's relative path plus a counter, so two dist directories in
one worktree do not collide.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Look up PRs in the upstream remote as well, so a fork's open PRs are
seen. Count processes that hide their cwd and say so in the report;
zombies and sshd children cannot hold a worktree open, so they do not
block removal. Put --deps trash next to the worktree and discover
leftover trash in the usual worktree parents, not only next to listed
worktrees. Continue the background delete past a failed path. Mention
locked worktrees in the README.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Rename a removed worktree into a sibling .worktree-trash directory and
prune the git entry, then delete the trash in a detached process.
Removing a worktree with 250k files drops from ~17 s to under a second
of blocking time. Look up PR states concurrently and skip the size
measurement in --yes mode, so the scan at Codespace start stays around
one second regardless of the number of worktrees. A re-check of the
tree right before the rename keeps work that appeared since the report.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Give the cleanup call in post-start.mjs a deadline so a stalled git or
gh call cannot delay the agent worker. Cap each gh lookup inside the
script; a timed-out lookup keeps the worktree.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Keep a worktree when the PR lookup fails instead of treating it as
having no PR. Drop the --force retry on removal: git re-checks that the
tree is clean, and ignored build outputs never block removal. Count the
cleaner's own cwd as in use. Run the cleanup before the agent worker
starts. Continue past a failed directory in --deps mode. Document that
--deps needs --yes.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Add `pnpm worktree:clean`. It lists the git worktrees of the repository
with the reason each one is kept or removed. With `--yes` it removes the
worktrees that are clean, fully on a remote, not in use, and whose PR is
merged or closed or that idled past a threshold with no open PR.
Codespaces run it from post-start.mjs at each container start.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>