Worktree

WorktreeService reads and clears the directories komrad cut for its agents.

worktree.v1.WorktreeService

  • list_worktrees#

    List every worktree directory komrad holds, under the configured worktrees directory and each workflow's own, with the repository it was cut from, its branch, whether git can still read it, the agent it was made for, the other agents working in it, the disk it takes as it was last measured, and when it was last active.

  • get_worktree#

    Read one worktree directory: its size and its top-level entries with theirs, biggest first, walked for the call and recorded so list_worktrees carries the fresh number, what is uncommitted, the base it is measured against with how far ahead and behind it stands and how many of its commits the base already holds whole, whether deleting its agent would keep the branch, and the commits since the base.

  • remove_unowned_worktrees#

    Remove worktree directories no agent answers for, which delete_agents cannot reach: a directory under the worktrees directories whose agent row is gone, or whose row is in AGENT_STATE_FAILED_TO_CLEANUP because git can no longer read the registration.

  • delete_worktrees#

    Queue one background job that deletes worktree directories, each by the path its row decides.