App UI From JSON
Graft CLI commands expose JSON output so applications do not have to scrape terminal text. Use JSON for status badges, change review screens, merge conflict flows, sync progress, and payload cache views.
Status Panel
Section titled “Status Panel”graft status --jsonUseful fields:
| Field | Meaning |
|---|---|
current_head | Current commit id when available. |
current_branch | Current branch name when available. |
work_in_progress | True when there are staged, unstaged, conflicted, or merge-state changes. |
counts | Staged, unstaged, and conflicted path counts. |
paths | One entry per changed path with kind, storage, status, and Git-like code. |
staged_changes | Lower-level staged change entries. |
unstaged_changes | Lower-level unstaged change entries. |
Use paths for most app tables. Use the lower-level arrays only when you need
separate staged and unstaged detail.
File Inventory
Section titled “File Inventory”graft ls-files --jsongraft ls-files --json --detailsgraft ls-files --json --stagegraft ls-files --json --othersUse --details for artifact hashes and payload presence, --stage for raw
index stages during conflicts, and --others for addable untracked paths.
Review Diffs
Section titled “Review Diffs”graft diff --jsongraft diff --json --rows HEAD~1 HEAD data.sqliteUse the top-level paths array as the navigation model. Use SQLite row payloads
inside database entries for detail panes.
Merge UI
Section titled “Merge UI”graft conflicts --jsongraft resolve --json --theirs --row docs 42 data.sqliteRender different controls by path type:
| Path type | Suggested UI |
|---|---|
| SQLite database | Row/schema conflict review with row-level accept controls. |
| Text file | Side picker or manual editor. |
| Binary or external file | Ours/theirs/manual replacement controls. |
Payload UI
Section titled “Payload UI”graft payload status --json HEADgraft payload fetch --json --remote origin HEADgraft payload prune --jsonShow present, missing, invalid, fetched, and pruned byte counts. For file browsers, combine this with:
graft ls-files --json --detailsSync UI
Section titled “Sync UI”graft remote list --jsongraft fetch --json origin maingraft pull --json origin maingraft push --json origin mainSync JSON includes current repository position and operation-specific outcomes.
After a non-fast-forward pull, the repository may enter merge state; follow with
status --json and conflicts --json.
Rule Of Thumb
Section titled “Rule Of Thumb”Use human output for terminals. Use JSON output for applications. The JSON surface carries stable concepts such as path kind, storage strategy, current branch, current head, conflict state, and payload presence.