Expand description
Output rendering and exit codes.
Exit-code table — process status only; the JSON body carries the
stable UPPER_SNAKE_CASE code under code:
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Generic error (IO, engine init, parse) |
| 2 | Usage / invalid arguments (emitted by clap) |
| 3 | Not found (entity / mem / resource missing) |
| 4 | Hash mismatch (optimistic-lock violation) |
| 5 | Validation error (schema, relation type, etc.) |
In --json mode, errors emit the documented {code, message, details} envelope — same shape agents consume over MCP — to
stdout, so the documented memstead <sub> … --json | jq -r .code
recipe retrieves the typed code on the error path without a 2>&1
redirect (success responses already go to stdout; the structured
error joins them there). The human-facing markdown error path
(no --json) stays on stderr and begins memstead: ERROR [<CODE>]: <message> so consumers reading only the text channel recover the
typed code with one regex.
Enums§
- Error
Stream - Which standard stream a rendered CLI error is written to.
- Exit
Kind - Exit-code kind for CLI errors.
Functions§
- print_
cli_ error - Print a typed CLI error in the documented surface shape, routed per
render_cli_error: the structured--jsonenvelope to stdout, the human markdown form to stderr. The exit code (set by the caller fromExitKind) signals failure independently of the stream. - print_
json - Print a serializable value as pretty JSON to stdout.
- print_
markdown - Print markdown (or JSON when requested) to stdout.
- render_
cli_ error - Decide the target stream and serialized line for a CLI error. Pure —
the routing decision is unit-testable without capturing process
streams. Under
--jsonthe{code, message, details}envelope goes to stdout so the documentedmemstead <sub> … --json | jq -r .coderecipe works on the error path (a stdout-only pipe); the human markdown form goes to stderr.codeis the stableUPPER_SNAKE_CASEtoken (matching the wire envelope agents see over MCP);detailscarries the structured recovery payload under thedetailskey.