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.

Worktreeread-onlyidempotentMCP tool

A directory with no agent is one whose row was deleted while cleanup did not run, or one a test left behind. A directory a delete has claimed and not yet taken, through delete_agents, delete_worktrees or the panel, is left out until that delete fails. Sizes are measured in the background a few directories at a time, so a directory the loop has not reached yet carries none. This reads the directories, the agent rows and the stored sizes and runs no git, so it is cheap to call often; read one directory's contents and standing against its base with get_worktree, which also measures it afresh.

Calling it#

curl -X POST http://127.0.0.1:8787/worktree.v1.WorktreeService/ListWorktrees \
  -H 'Content-Type: application/json' \
  -d '{}'

Request#

Empty#

No fields.

Response#

ListWorktreesResponse#

FieldTypeDescription
worktreeslist of Worktree

Every directory under the worktree directories, in no particular order.

dirslist of string

The directories that were walked: the configured one and each workflow's own.

unreadableDirslist of string

Which of those could not be read, so a listing that is short says why.

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.

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.