Skip to content

API Reference parrot.sdd.scripts.worktree_status

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.sdd.scripts.worktree_status

View source

Discover SDD worktrees and report their task state and health.

Read-only: never writes files or runs mutating git commands. CLI: python -m scripts.sdd.worktree_status [--json] Library: from scripts.sdd.worktree_status import discover_worktree_reports

Alias LEGACY_WORKTREE_ROOT

Re-exported from parrot.sdd.config.LEGACY_WORKTREE_ROOT.

Class ReconciledFeature

A feature's task state after dev/worktree reconciliation.

Fields:

Field Type Default Description
feature_slug str
feature_id str | None None
spec str | None None
index_path str | None None
worktree_branch str | None None
worktree_path str | None None
worktree_ahead bool False
worktree_stale bool False
dev_closed bool False
worktree_only bool False
tasks list[ReconciledTask]

Class ReconciledTask

One task after merging the dev-branch index with a worktree index.

Attributes:

Attribute Type Description
source Literal['dev', 'worktree']

Attribute TaskStatus

Class WorktreeHealth

Health signals for a single worktree.

Fields:

Field Type Default Description
dirty_count int 0
unpushed_count int 0
live_process_count int 0
dirty_unknown bool False
unpushed_unknown bool False

Class WorktreeReport

Complete worktree state for one feature.

Fields:

Field Type Default Description
feature_slug str
feature_id str | None None
flow_type Literal['feature', 'hotfix', 'non-sdd', 'legacy']
worktree_path str
branch str
base_branch str 'dev'
health WorktreeHealth
tasks list[WorktreeTaskStatus]
index_found bool True
ready_for_done bool False

Class WorktreeTaskStatus

Per-task status as seen from a worktree's index.

Attributes:

Attribute Type Description
completed_at str | None

Function discover_worktree_reports

Main entry point: discover all SDD worktrees and their task state.

  1. Parse git worktree list --porcelain.
  2. Also scan the resolved worktree root for orphan directories (not in porcelain).
  3. For each SDD branch, parse slug/id, read worktree index, check health.
  4. Compute ready_for_done.

discover_worktree_reports(repo_root: Path) -> list[WorktreeReport]

Parameter Type Default Description
repo_root Path

Returns: list[WorktreeReport]

Function main

CLI entry point.

--json prints list[WorktreeReport]; plain prints a table. --reconcile switches both outputs to list[ReconciledFeature], the dev-index/worktree merge the /sdd-status task board consumes.

main(argv: Sequence[str] | None = None) -> int

Parameter Type Default Description
argv Sequence[str] | None None

Returns: int

Function reconcile_feature

Merge one feature's dev-branch index with its worktree index.

The worktree may only advance a task (pending → in-progress → terminal); a lower-ranked worktree status is ignored and marks the worktree stale instead. Tasks that exist only in the worktree index are appended (they were generated inside the worktree and never merged).

reconcile_feature(dev_index: dict | None, report: WorktreeReport | None) -> ReconciledFeature

Parameter Type Default Description
dev_index dict | None The parsed sdd/tasks/index/<slug>.json from the current branch, or None when the feature exists only in a worktree.
report WorktreeReport | None The worktree report for the same feature, or None.

Returns: ReconciledFeature — The reconciled feature, carrying per-task provenance and the worktree_ahead / worktree_stale / dev_closed flags the task board uses for labelling.

Function reconcile_reports

Reconcile every per-spec index on this branch with its worktree, if any.

Features whose work only ever existed inside a worktree (no index on the current branch) are appended so the task board can surface them too.

reconcile_reports(repo_root: Path, reports: list[WorktreeReport]) -> list[ReconciledFeature]

Parameter Type Default Description
repo_root Path The primary checkout's root.
reports list[WorktreeReport] Worktree reports from :func:discover_worktree_reports.

Returns: list[ReconciledFeature] — class:ReconciledFeature per dev index, plus one per worktree-only feature, in index-filename order.

Alias worktree_root

Re-exported from parrot.sdd.config.worktree_root.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally