Skip to content

退出码

Uni-CLI 在 stderr 中同时返回进程退出码和结构化错误 envelope。error.code 表示具体原因,error.suggestion 给出下一条命令。

代码名称含义常见下一步
0success操作完成读取 data
1generic error运行时出现意外错误阅读 envelope 与日志
2usage error命令或参数无效运行 unicli describeunicli help
66empty result请求完成,但没有匹配项调整查询或标识符
69service unavailable需要的服务、provider 或工具当前不可用执行 error.suggestion
75temporary failure出现超时、限流或网络错误按建议等待后重试
77authentication required需要登录或权限运行返回的认证或授权命令
78configuration erroradapter 或本地配置需要调整查看结果中标明的源文件

Shell 示例

bash
if output=$(unicli hackernews top --limit 5 -f json); then
  printf '%s\n' "$output" | jq '.data'
else
  status=$?
  printf 'Uni-CLI exited with %s\n' "$status" >&2
fi

Agent 示例

text
用 -f json 运行命令。
退出码为 0 时读取 data。
退出码为 75 时等待后重试。
其他失败读取 error.code、error.suggestion 和 error.remedy.command。

退出码常量定义在 src/core/envelope.ts

基于 Apache-2.0 许可证发布