Skip to main content

Module json_api

Module json_api 

Source
Expand description

Stable, machine-readable JSON surface shared by the --format=json CLI flags (issue #38, phase 1) and the daemon’s JSON-RPC methods (phase 2).

The DTOs here are deliberately decoupled from the internal crate::worktree::WorktreeInfo / crate::doctor::DoctorReport types. Those structs carry TUI-runtime baggage (loaded GitHub issue / PR state, cached branch age as a Duration, the BranchLink graph) whose shape churns as the TUI evolves. Pinning the documented schema (see docs/schema/) to a dedicated set of Serialize DTOs means a refactor of WorktreeInfo can’t silently break a downstream editor plugin. Conversions are one-directional (From<&Internal>); the JSON surface is output-only.

Key convention: snake_case, matching the hand-built print_status_json in crate::cli.

Structs§

JsonCheck
One diagnostic check, the stable projection of crate::doctor::Check.
JsonDoctorReport
A full doctor run, carrying the per-check list plus the aggregate severity and the process exit_code (0/1/2) so a consumer doesn’t have to re-derive them.
JsonPath
The { name, path, branch } triple returned by gwm path --format=json.
JsonStatus
Working-tree + upstream status, the stable projection of BranchStatus.
JsonWorktree
One worktree as exposed to scripting / editor integrations. Mirrors the columns of gwm list plus the machine-only fields a consumer needs (absolute path, raw age_seconds, linked issue/PR numbers).

Functions§

check_status_str
Stable lowercase string for a CheckStatus, used as the status field of JsonCheck and the severity of JsonDoctorReport.
worktrees
Build the stable JSON worktree list for repo. Shared by gwm list --format=json and the daemon’s list RPC method so both surfaces stay byte-identical.