noggin

Response envelope

Every structured noggin response — CLI --json output, MCP tool responses, VS Code language-model tool responses — is wrapped in the same canonical envelope so a single consumer can target all three surfaces.

Success

{
  "status": "ok",
  "envelopeVersion": 3,
  "verb": "push",            // command that produced this payload
  "data": { ... }            // verb-specific (CurrentTreeView, DeleteResult, ...)
}

Error

Written to stderr; the process exits with error.exitCode.

{
  "status": "error",
  "envelopeVersion": 3,
  "verb": "push",
  "error": {
    "code": "title-required",
    "message": "push: title required (--title or positional)",
    "exitCode": 2
  }
}

Versioning

envelopeVersion versions the wrapper shape (and the per-verb payloads inside data). It is distinct from the on-disk document's schemaVersion (see Document schema) — the two revision numbers rev independently:

Default pruning

Inside data, a small whitelist of fields whose value matches their declared default is omitted to keep payloads focused. A consumer that doesn't see one of these fields should treat it as the default:

FieldOmitted when
parentKeynull (item is a root)
donefalse (item is still open)
notes[] (no notes)
activePathnull (no active item)
activeKeynull (no active item)
descendantCount0 (in DeleteResult)
viewnull (delete left the tree empty)

Everything else is always present, including the envelope itself (status, envelopeVersion, verb, data / error).

Verb-specific payloads

For per-verb examples with real CLI output, see the verb demo page.

Error codes

error.code is a short, stable string identifying the failure mode. The set of codes is documented as NogginErrorCode in the API reference. Codes additions are non-breaking; treat unknown codes as fallback errors and don't exhaustively switch on the union.

Exit codes

error.exitCode mirrors the CLI process exit code:

CodeMeaning
0Success — no error envelope
1Runtime / state error (item not found, open descendants, cycle, etc.)
2Usage / parse / invalid input (missing title, unknown flag, bad path syntax)

Why an envelope at all