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_
session_ worktree_ removable_ with_ ctx - 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.
- clean_
surfaces - Returns one line per thing removed (or, with dry_run, that would be removed).
- 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_
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_
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_
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_
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. - run
- Runs the
blyte cleancommand. - run_
process_ alive - spawn_
background_ clean - Starts
blyte clean --quiet [--skip <ID>]in the background without waiting for it.