Skip to content

WorktreeManager

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/libs/agent-core/src/tools/worktree-manager.ts

Methods

MethodSignatureReturns
isGitRepoisGitRepo()boolean
createcreate(name: string)WorktreeInfo
removeremove(name: string)void
listlist()WorktreeInfo[]
diffdiff(name: string)string
hasChangeshasChanges(name: string)boolean
activeCountactiveCount()number
pruneStalepruneStale()number

Where it refuses work

  • WorktreeManager stops the work with Error when !this.isGitRepo() — “WorktreeManager: not a git repository”.
  • WorktreeManager stops the work with Error when this.activeCount() >= this.maxWorktrees.
  • WorktreeManager stops the work with an early return when !branch, in 2 places.
  • WorktreeManager stops the work with an early return when this.branchExists(expected).
  • WorktreeManager stops the work with an early return when lines.length > 0 && lines[0].
  • WorktreeManager stops the work with an early return when this.branchExists('main').

When something fails

  • WorktreeManager handles failure in 12 places: it turns it into a return value in 6, discards it silently in 4, and logs it and continues in 2. A failure discarded silently leaves no trace for whoever debugs this later.

Was this page helpful?

Download as PDF