Skip to content

JSON Output

Most Graft repository commands have a JSON form. Use it for app UIs, automation, tests, and integrations that need structured state.

CLI commands use --json:

Terminal window
graft status --json
graft diff --json --rows HEAD~1 HEAD data.sqlite

The SQLite extension does not expose repository JSON PRAGMAs. Embedded applications should invoke the CLI control plane and decode its JSON response.

Many JSON responses include:

FieldMeaning
current_headCurrent commit id when available.
current_branchCurrent branch name when HEAD points to a branch.
operationOperation name for mutation responses.

Detached or uninitialized repositories may omit position fields.

Path entries are the primary app-facing unit.

FieldMeaning
pathRepository-relative path.
kindsqlite_database, text_file, or binary_file.
storagesqlite_snapshot, inline, or external.
changeadded, modified, or deleted when available.
index_statusStaged status in status output.
worktree_statusUnstaged status in status output.
codeGit-like two-character status code.
conflictedWhether the path has unresolved conflict stages.

Use kind to choose UI controls. Use storage to decide whether bytes are inline, snapshot-backed, or external-payload-backed.

Terminal window
graft status --json

Important fields:

FieldMeaning
pathsOne entry per changed path.
countsCounts for staged, unstaged, and conflicted paths.
has_unstaged_changesTrue when the worktree has unstaged changes.
has_staged_changesTrue when the index has staged changes.
has_conflictsTrue when there are unresolved conflicts.
work_in_progressTrue when any staged, unstaged, conflict, or merge state exists.
staged_changesLower-level staged changes.
unstaged_changesLower-level unstaged changes.

Prefer work_in_progress when deciding whether an app can safely switch, pull, or close a review flow.

Terminal window
graft diff --json
graft diff --json --rows HEAD~1 HEAD data.sqlite

Top-level paths summarizes changed repository paths. SQLite database entries can also include row-level payloads when --rows is present.

Useful database fields include:

FieldMeaning
row_diff_availableWhether row diff detail is present.
logical_statusCoarse row-diff interpretation.
capabilitiesSQLite surfaces Graft interpreted.
limitationsSQLite surfaces that need caveats.
tablesTable-level row changes when available.

Each table entry includes columns, changes, and, for declared-primary-key tables, primary_key_columns. A row change uses rowid for an ordinary rowid table or key for a WITHOUT ROWID table:

{
"name": "docs",
"primary_key_columns": ["space_id", "id"],
"changes": [
{
"op": "update",
"key": { "space_id": "space-1", "id": "doc-1" },
"old_values": ["space-1", "doc-1", "before"],
"values": ["space-1", "doc-1", "after"]
}
]
}

Primary-key JSON preserves identity types. BLOB key parts use an explicit marker such as { "$blob": "00ff" }; the same key object can be passed to graft resolve --row.

Terminal window
graft conflicts --json

Conflict output is intended for merge review UIs. It can include path rollups, index stages, row merge analysis, schema conflicts, row conflicts, opaque changes, and blocked reasons.

Common fields:

FieldMeaning
availableWhether row-level analysis is available for a database conflict.
can_auto_mergeWhether the plan can be applied automatically.
blocked_reasonsWhy auto-merge is blocked.
row_conflictsRowid, declared-primary-key, or semantic-key conflicts.
schema_conflictsSchema conflict detail.
opaque_changesUnsupported or opaque SQLite surfaces.
apply_policySQL apply and validation policy.
Terminal window
graft ls-files --json --details
graft payload status --json HEAD
graft payload fetch --json --remote origin HEAD
graft payload prune --json

Use these for file browsers and offline availability panels.

ls-files --details can include object ids, content hashes, and local external payload presence. Payload commands include present, missing, invalid, fetched, candidate, pruned, and byte-count summaries depending on the operation.

Applications should prefer high-level fields such as paths, kind, storage, current_head, current_branch, work_in_progress, and documented conflict fields. Avoid depending on debug-only fields, storage LSNs, or internal object serialization details.