- Match seal-use repository layout with .agents/rules and skills.json - Ensure no .agent singular directory or symlink exists - Set trigger: 'manual' on all rules to prevent automatic prompt injection - Track .agents/ in git by updating .gitignore
27 lines
1.4 KiB
Markdown
27 lines
1.4 KiB
Markdown
---
|
||
description: "CLI stdout/stderr stream contract, volume explosion protection, and exit codes for hose-use commands"
|
||
globs: "src/cli/**/*.ts"
|
||
trigger: "manual"
|
||
---
|
||
|
||
# CLI 输出流协议与退出码规范
|
||
|
||
在实现或重构 `src/cli/` 下的命令行交互时:
|
||
|
||
1. **机器解析通道 (`stdout`)**:
|
||
- 数据类命令在 `--json` 模式下,`stdout` 必须仅输出纯净、可解析的 JSON 结构体;
|
||
- 严禁将调试日志、进度动画、交互式提示语输出到 `stdout`,确保下游脚本和 Agent Harness 能够直接可靠解析。
|
||
|
||
2. **诊断与引导通道 (`stderr`)**:
|
||
- 运行时警告、网络诊断信息以及下一步操作引导(如 `下一步: hose-use ...`)统一写入 `stderr`。
|
||
|
||
3. **大报文体积保护(Volume Explosion Protection)**:
|
||
- 默认受 200KB 体积防爆限制,防止海量单据明细一次性撑爆上下文;
|
||
- 提示并支持通过 `--limit` 分页、`--output-file / -o` 直接落盘至本地文件,或通过 `--mine` 筛选关键子集。
|
||
|
||
4. **退出码规范**:
|
||
- 正常执行成功退出码为 `0`;
|
||
- 语法错误、参数缺失、上游 API 报错退出码为非 0(如 `1`);
|
||
- 写操作未确认拦截退出码为 `10`(`MutationConfirmationRequired`);
|
||
- 不要在领域代码深处直接调用 `process.exit()`,应抛出带有结构化语义的错误,由外层统一捕获和分配退出码。
|