Expand description
Worktree cleanup for finished runs: blyte clean, on review, and at dispatch.
Structs§
- Clean
Context - Context for cleaning a repository, caching metadata to avoid redundant git calls and disk reads.
- Clean
Repo Stats - GitWorktree
Info - RefEntry
Enums§
Constants§
- DEFAULT_
SESSION_ IDLE_ DAYS - Default idle threshold in days for session worktrees.
Functions§
- check_
removable - Evaluates whether a worktree is removable according to the clean rules.
- check_
session_ worktree_ removable - Evaluates whether a session worktree is removable.
- clean_
on_ review - Removes a run’s worktree on review after recording the verdict under the same rules.
Removes the worktree only when the rules allow it now (e.g. redone, or work already merged);
otherwise prints nothing extra beyond the verdict line, except for accepted/fixed prints
worktree .wt/<id> kept until wip/<id> is merged. - clean_
repo - Cleans one repository.
- clean_
repo_ with_ options - Cleans one repository with configurable session worktree idle threshold and process cwd list.
- dir_
size - Recursively computes directory size in bytes without following symlinks.
- display_
worktree_ path - Formats a worktree path for display and for git CLI commands:
relative to
rootif insiderootor a sibling (same parent directory); otherwise absolute. - find_
blyte_ worktrees - Lists all
.wt/<id>directories that have a corresponding.wt/<id>.start.json. - find_
default_ branch - Identifies the default branch (origin/HEAD’s target, else main, else master).
- find_
merged_ followup - Finds a follow-up run that makes
<id>merged. - find_
repo_ root - Finds the root repository (resolving the main checkout if inside a linked worktree).
- format_
size - Formats byte count into human-readable representation: e.g. “812 MB”, “12.3 GB”.
- get_
branch_ tip - Returns the commit SHA at the tip of
branch_nameif it exists. - has_
dispatched_ runs - Returns true if
<wt_path>/.wt/contains any*.start.jsonfile. - has_
uncommitted_ changes - Checks whether a worktree has uncommitted changes via
git status --porcelain. - has_
wt_ component - Returns true if any path component is
.wt. - is_
branch_ merged - Checks whether a branch’s work is on the default branch when any of:
- is_
branch_ merged_ with_ extra_ targets - Checks whether a branch’s work is on the default branch or any of the extra target refs.
- is_
branch_ merged_ with_ targets - Checks whether a branch’s work is on the default branch or any of the extra target refs.
- is_
commit_ merged - Checks whether a commit’s work is on the default branch when any of:
- is_
commit_ merged_ with_ targets - Checks whether a commit’s work is on the default branch or any of the extra target refs.
- is_
linked_ worktree - Returns true if
rootis a linked worktree (its git-dir differs from its git-common-dir). - is_
pid_ alive - Checks whether a process with the given PID is alive.
- is_
research - Checks whether a run is a research run from its start file.
- is_
session_ worktree - Returns true if
wt_pathis a session worktree ofroot: - is_
worktree_ clean - Checks whether a worktree’s working tree is clean:
git status --porcelainlists nothing other than.DS_Storefiles, at any depth. - is_
worktree_ idle - Returns whether
indexandHEADin the worktree’s git admin directory (git -C <wt> rev-parse --absolute-git-dir) are both more thanidle_daysdays old. Errors name what could not be read. - is_
worktree_ in_ use - Returns true if any process working directory in
cwdsiswt_pathor a subdirectory of it. Compares canonical paths. - list_
all_ run_ ids - Lists all run IDs that have a corresponding
.wt/<id>.start.json. - list_
running_ process_ cwds - Lists the current working directories of all running processes via
lsof -a -d cwd -Fn. - parse_
lsof_ cwd_ output - Parses
lsof -a -d cwd -Fnoutput into a list of working directory paths. - parse_
worktree_ list - Parses git worktrees from
git worktree list --porcelain. - read_
run_ base - Reads
basefrom.wt/<id>.start.jsonif present. - read_
start_ record - Reads
.wt/<id>.start.jsonfrom disk now. - remove_
finished_ run - Removes a finished run
<id>when its work is merged (or it made no changes) and its worktree has no uncommitted changes. - report_
other_ worktrees - Inspects other worktrees (excluding main checkout, linked-worktree roots,
and blyte’s
.wt/<id>runs), and reports any that are both merged and clean. Never deletes them. - resolve_
base_ targets - Resolves candidate git refs for a run’s base branch.
Returns (display_name, targets) if
baseis a branch name that resolves. Returns None ifbaseis not a branch name (e.g. HEAD, commit id, wip/ branch) or if none of the candidate refs resolve in git. - run
- Runs the
blyte cleancommand. - spawn_
background_ clean - Starts
blyte clean --quiet [--skip <ID>]in the background without waiting for it.