# JSON 输出契约 `--format json`(默认)下,成功与错误的信封结构不同: 成功信封写入 **stdout**(退出码 0): ```json { "ok": true, "identity": "user", "data": { "guid": "..." }, "meta": { "count": 1 } } ``` 错误信封写入 **stderr**(退出码非 0): ```json { "ok": false, "identity": "user", "error": { "type": "authorization", "subtype": "missing_scope", "code": 99991679, "message": "...", "hint": "...", "missing_scopes": ["..."] } } ``` **判断成功必须用 `ok == true`(或进程退出码 0),不要用 `code == 0`**:成功信封没有顶层 `code` / `msg` 字段,`code` 只出现在错误信封的 `error` 内,含义是上游 OpenAPI 的 numeric code。按 OpenAPI 老格式 `{"code": 0, "msg": "ok"}` 判断会把所有成功调用误判为失败;封装写入类命令(如 `task +create`)时尤其危险,误判会绕过幂等逻辑导致重复创建。