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.

Worktreeread-onlyidempotentMCP tool

The base is read as the clone last fetched it unless fetch is set, which asks origin first. A directory whose registration git cannot read answers with the entries alone.

Calling it#

curl -X POST http://127.0.0.1:8787/worktree.v1.WorktreeService/GetWorktree \
  -H 'Content-Type: application/json' \
  -d '{
  "dir": "<dir>"
}'

Request#

GetWorktreeRequest#

FieldTypeDescription
dirstring

The directory to read, as list_worktrees spelled it.

required

fetchbool

Whether to fetch the base from origin before measuring against it, which is a network round trip; left off, the base is whatever the clone last fetched.

Response#

GetWorktreeResponse#

FieldTypeDescription
worktreeWorktree

The directory as list_worktrees reports it.

sizeBytesint64

The disk the directory takes, in bytes, walked for this call.

entrieslist of Entry

The top-level entries with the disk each takes, biggest first, from the same walk.

modifiedlist of string

The paths git tracks that differ from HEAD.

untrackedlist of string

The paths git neither tracks nor ignores.

baseRefstring

The ref the branch is measured against, which is the workflow's base branch as the clone holds it, empty when the repository cannot be read or the clone does not hold the base, in which case nothing below is measured.

baseErrorstring

Why the base could not be named, when base_ref is empty for that reason.

aheadint32

How many of the branch's commits the base does not hold.

behindint32

How many of the base's commits the branch does not hold.

landedCommitsint32

How many of the branch's own commits the base already holds whole, which is what a squash merge leaves behind.

sequenceInProgressbool

Whether a merge, a rebase or a cherry-pick is part-way through.

keepsBranchbool

Whether deleting the agent would keep the branch, which cleanup does for an adopted branch and for one whose commits are on no other ref.

commitslist of Commit

The branch's commits the base does not hold, newest first, at most fifty.

Types#

Worktree#

FieldTypeDescription
dirstring

The directory, absolute.

repoDirstring

The repository the worktree was cut from, read off the directory's own .git file, which for a registration git can no longer read is where the repository used to be.

branchstring

The branch the directory's HEAD names, empty when it is detached or the registration cannot be read.

readablebool

Whether the gitdir the .git file names is still there, without which git will not answer for the directory.

agentWorktreeAgent

The agent the directory was made for, unset when no row answers for it.

occupantslist of WorktreeAgent

The other agents working in this directory, which hold none of their own.

sizeBytesint64

The disk the directory takes, in bytes, as it was last measured in the background or by get_worktree: blocks rather than length, a hard linked file counted once. Unset until it has been measured, and while the last walk failed.

measuredAtstring

When the size was last measured, or last failed to be, in RFC 3339. Unset until the background loop has reached the directory.

sizeErrorstring

Why the last walk failed, empty when it did not.

lastActiveAtstring

When the directory was last active, in RFC 3339: the later of its agent's last state change and its archiving when an agent answers for it, else when git last wrote the directory's .git file, else the directory's own modification time.

fateWorktreeFate

Which delete path the directory takes.

Entry#

FieldTypeDescription
pathstring

The path, relative to the directory.

sizeBytesint64

The disk it takes, in bytes, counted through for a directory: blocks rather than length, with a file that is hard linked counted once.

dirbool

Whether it is a directory.

Commit#

FieldTypeDescription
shastring

The commit's hash.

subjectstring

The first line of its message.

committedAtstring

When it was committed, in RFC 3339.

WorktreeAgent#

FieldTypeDescription
idstring

The agent's id.

namestring

What the panel lists it as.

stateAgentState

The agent's state, as the agents listing carries it.

archivedAtstring

When the agent was put away, in RFC 3339, unset while it is live.

adoptedbool

Whether the branch was somebody's before the agent was put on it, which cleanup never deletes.

WorktreeFate#

WorktreeFate is which delete path a directory takes.

ValueDescription
WORKTREE_FATE_UNOWNED

Nothing answers for the directory, which the remover takes.

WORKTREE_FATE_ARCHIVED

The directory's agent is put away, which the agent delete takes.

WORKTREE_FATE_LIVE

The directory's agent is running, which nothing takes.

AgentState#

AgentState is what the panel last decided an agent was doing, read off the tail of its pane.

ValueDescription
AGENT_STATE_IDLE

The pane is at rest with nothing typed.

AGENT_STATE_THINKING

The CLI is working on a turn.

AGENT_STATE_WAITING

The CLI is blocked on a human answering a selection.

AGENT_STATE_SETTING_UP

The agent is being launched and has no pane to read yet.

AGENT_STATE_FAILED_TO_CREATE

The launch failed, which retry_agent is for.

AGENT_STATE_FAILED_TO_CLEANUP

A delete failed to take the worktree down, and the reason is on the row.

AGENT_STATE_UNCERTAIN

The pane could be read but its tail decided nothing.