Skip to content

Worktree teardown + git-status across CLI, MCP, and portal #430

@dotdevdotdev

Description

@dotdevdotdev

Goal

Make the full worktree lifecycle drivable from MCP without dropping to the shell, and give the portal/MCP read-only git awareness of worktrees (the portal provides worktree UI but had no way to know a worktree's state).

Previously: MCP could create (session_create) and kill the tmux session (session_kill), but session_kill leaves the worktree + branch on disk. Full teardown (agentwire worktree --remove) was CLI-only, and nothing — CLI, MCP, or portal — could report a worktree's git status.

Scope

  • In: read-only git status (dirty/ahead/behind/pushed, local git only — no network, no gh), worktree teardown exposed to MCP, portal route + sidebar badges.
  • Out: MCP committing/pushing/PR'ing. By design there is no write verb — commit/push/PR stays the agent's job (the worktree-session role instructs it).

Approach

SSOT preserved: every layer routes through the one CLI worktree command. Portal and MCP are thin wrappers (run_agentwire_cmd), no parallel git logic.

  • CLI: worktree_status(path) helper; worktree --status <name>; git status folded into worktree --list --json.
  • MCP: worktree_list, worktree_status (read-only), worktree_remove (teardown: kill session + tmux, force-remove worktree + branch, unregister).
  • Portal: GET /api/worktrees.
  • Frontend: git badges on worktree session cards.

Verification

End-to-end: real-flow worktree reads unpushed until pushed; dirty detection; teardown removes worktree; MCP tools register; live portal route returns the git field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions