fix(cli): 不再在帮助与文档中暴露已退役的 --flow 拼写

`approval-runs get --flow` 至今仍是 `approval-runs hose-flow` 的静默遗留
别名:解析器的布尔标志白名单里还留着它,命令实现里也仍在转发。但 CLI
协议第 6 节要求兼容拼写只能停留在实现层,不得出现在 help、Skill、
references、README 或正常运行时提示中。

问题在于这条规矩被自己的文档破了:`get --help` 中 `--raw-json` 的描述写着
"incompatible with --summary, --fields and --flow",references 里同一句话也
照抄了一遍。用户只要撞上一次参数冲突,就会被 CLI 主动教一遍退役拼写。

- help:`--raw-json` 描述去掉 `--flow`,改为指向规范命令
  `approval-runs hose-flow <recordId|SN>`。
- approval-run-lightweight.md:同步修正,并补上原生合思流程时间线的入口。
- 运行时:冲突报错改为只列调用方实际传入的标志,不再主动广播退役拼写。
- naming-charter:新增裸 `--flow` 的边界守卫。原有
  LEGACY_SURFACE_TOKENS 是子串匹配,无法表达这个概念(`--flow-id`、
  `--flow-ids`、`--flow-concurrency` 都是规范参数),这正是该泄漏存活
  八个版本的根因。
This commit is contained in:
yunyingk committed 2026-11-10 19:47:43 +08:00
1 parent 8ecadbb124
commit 71845c35e7
5 files changed
+24 -4

No files matched your search

@@ -76,7 +76,7 @@ seal-use approval-runs get <recordId> --raw-json --full --corp <corpId>
- `--raw-json` 保留上游响应的 JSON 结构(包括 `data` 包装、嵌套内容、新字段及上游同名字段),绕过审核记录的业务 schema 校验,不额外添加或覆盖字段。它仍只调用同一条只读审核详情接口,沿用企业认证和 HTTP 错误处理。
- 该模式解析并重新序列化 JSON,缩进等文本格式可能变化,不是 HTTP 响应的字节级副本。上游未返回的内容不会补查;无效 JSON、网络错误或 HTTP 失败仍按原协议报错。
- 输出不会静默截断。共享的 stdout 大小保护超过 200,000 字节时返回退出码 12;`--full` 或 `--output-file` 可输出完整内容。`--full` 只控制大小保护,不会绕过字段校验,也不会撤销 `--summary/--fields`。
- `--raw-json` 不能与 `--summary`、`--fields` 或 `--flow` 同用;这些参数会改写结构或切换接口,CLI 会以退出码 2 明确拒绝。写入文件时 stdout 仅返回文件路径和字节数的 JSON 回执,原生响应保存在文件中。
- `--raw-json` 不能与 `--summary` 或 `--fields` 同用;这两个参数会改写返回结构,CLI 会以退出码 2 明确拒绝。需要合思原生审批流时间线时,用 `seal-use approval-runs hose-flow <recordId|SN>`,不要从审核详情接口取。写入文件时 stdout 仅返回文件路径和字节数的 JSON 回执,原生响应保存在文件中。
- 不把兜底入口作为默认查询,也不将大段原生 JSON 直接贴给用户;Agent 可按需读取文件中的特定字段。
## Understand The Case First
+3
View File
@@ -102,6 +102,9 @@ describe("approval run native JSON fallback", () => {
expect(result.exitCode).toBe(2)
expect(result.stdout).toBe("")
expect(result.stderr).toContain("--raw-json cannot be combined")
// The message names only what the caller actually passed, so the retired
// `--flow` spelling is never advertised to anyone who did not use it.
expect(result.stderr).toContain(flags[0]!)
}
expect(requests).toHaveLength(0)
})
+9 -2
View File
@@ -190,8 +190,15 @@ export async function handleApprovalRunsCommand(
const recordId = args.command[2];
if (!recordId) throw new Error("Missing approval run recordId");
const rawJson = booleanOption(args.options["raw-json"]) ?? booleanOption(args.options.rawJson);
if (rawJson && (booleanOption(args.options.flow) || booleanOption(args.options.summary) || stringOption(args.options.fields) !== undefined)) {
throw usageError("--raw-json cannot be combined with --flow, --summary or --fields");
if (rawJson) {
// Name only the flags the caller actually passed: legacy spellings stay
// implementation-only and must not be advertised to everyone else.
const conflicts = [
booleanOption(args.options.flow) ? "--flow" : undefined,
booleanOption(args.options.summary) ? "--summary" : undefined,
stringOption(args.options.fields) !== undefined ? "--fields" : undefined
].filter((flag): flag is string => flag !== undefined);
if (conflicts.length) throw usageError(`--raw-json cannot be combined with ${conflicts.join(", ")}`);
}
if (booleanOption(args.options.flow)) {
await runCapability(
+1 -1
View File
@@ -578,7 +578,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
summary: "Get detailed approval record payload",
usage: ["seal-use approval-runs get <recordId> [--summary] [--fields metadata|document.fields,result.summary] [--raw-json] [--full] [--output-file file.json] [--corp <corpId>]"],
options: [
{ flag: "--raw-json", description: "Compatibility fallback: return the upstream JSON response including its envelope and unknown fields, without business-schema validation or derived fields; incompatible with --summary, --fields and --flow" },
{ flag: "--raw-json", description: "Compatibility fallback: return the upstream JSON response including its envelope and unknown fields, without business-schema validation or derived fields; incompatible with --summary and --fields. Native Hose flow timeline lives in `seal-use approval-runs hose-flow <recordId|SN>`" },
{ flag: "--full", description: "Bypass the shared 200,000-byte stdout size guard; this does not change payload structure" },
{ flag: "--output-file <path>", description: "Write the complete JSON payload to a file, bypassing the stdout size guard" }
]
+10
View File
@@ -76,6 +76,16 @@ describe("naming charter: visible help surface", () => {
const offenders = LEGACY_SURFACE_TOKENS.filter((token) => serialized.includes(token));
expect(offenders).toEqual([]);
});
test("never documents the retired bare flow switch", () => {
// `--flow` on `approval-runs get` is a silent legacy alias for
// `approval-runs hose-flow`, so the visible surface must not name it.
// LEGACY_SURFACE_TOKENS matches by substring and cannot express this:
// `--flow-id`, `--flow-ids` and `--flow-concurrency` are canonical.
const serialized = JSON.stringify(HELP_REGISTRY);
const offenders = serialized.match(/--flow(?![A-Za-z0-9-])/g) ?? [];
expect(offenders).toEqual([]);
});
});
describe("naming charter: parser accepts canonical and legacy spellings", () => {