From 71845c35e7516cd49f718c268c95a9158d8d6283 Mon Sep 17 00:00:00 2001 From: yunyingk <128617637+yunyingk@users.noreply.github.com> Date: Tue, 10 Nov 2026 19:16:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(cli):=20=E4=B8=8D=E5=86=8D=E5=9C=A8?= =?UTF-8?q?=E5=B8=AE=E5=8A=A9=E4=B8=8E=E6=96=87=E6=A1=A3=E4=B8=AD=E6=9A=B4?= =?UTF-8?q?=E9=9C=B2=E5=B7=B2=E9=80=80=E5=BD=B9=E7=9A=84=20--flow=20?= =?UTF-8?q?=E6=8B=BC=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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 `。 - approval-run-lightweight.md:同步修正,并补上原生合思流程时间线的入口。 - 运行时:冲突报错改为只列调用方实际传入的标志,不再主动广播退役拼写。 - naming-charter:新增裸 `--flow` 的边界守卫。原有 LEGACY_SURFACE_TOKENS 是子串匹配,无法表达这个概念(`--flow-id`、 `--flow-ids`、`--flow-concurrency` 都是规范参数),这正是该泄漏存活 八个版本的根因。 --- .../seal-use/references/approval-run-lightweight.md | 2 +- src/cli/commands/approval-runs.test.ts | 3 +++ src/cli/commands/approval-runs.ts | 11 +++++++++-- src/cli/help.ts | 2 +- src/cli/naming-charter.test.ts | 10 ++++++++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/skills/seal-use/references/approval-run-lightweight.md b/skills/seal-use/references/approval-run-lightweight.md index 1d91994..6fd9ff5 100644 --- a/skills/seal-use/references/approval-run-lightweight.md +++ b/skills/seal-use/references/approval-run-lightweight.md @@ -76,7 +76,7 @@ seal-use approval-runs get --raw-json --full --corp - `--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 `,不要从审核详情接口取。写入文件时 stdout 仅返回文件路径和字节数的 JSON 回执,原生响应保存在文件中。 - 不把兜底入口作为默认查询,也不将大段原生 JSON 直接贴给用户;Agent 可按需读取文件中的特定字段。 ## Understand The Case First diff --git a/src/cli/commands/approval-runs.test.ts b/src/cli/commands/approval-runs.test.ts index 8705618..6fdb8d8 100644 --- a/src/cli/commands/approval-runs.test.ts +++ b/src/cli/commands/approval-runs.test.ts @@ -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) }) diff --git a/src/cli/commands/approval-runs.ts b/src/cli/commands/approval-runs.ts index cb552a9..597a288 100644 --- a/src/cli/commands/approval-runs.ts +++ b/src/cli/commands/approval-runs.ts @@ -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( diff --git a/src/cli/help.ts b/src/cli/help.ts index 4da0cbf..38c6829 100644 --- a/src/cli/help.ts +++ b/src/cli/help.ts @@ -578,7 +578,7 @@ export const HELP_REGISTRY: AreaHelp[] = [ summary: "Get detailed approval record payload", usage: ["seal-use approval-runs get [--summary] [--fields metadata|document.fields,result.summary] [--raw-json] [--full] [--output-file file.json] [--corp ]"], 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 `" }, { flag: "--full", description: "Bypass the shared 200,000-byte stdout size guard; this does not change payload structure" }, { flag: "--output-file ", description: "Write the complete JSON payload to a file, bypassing the stdout size guard" } ] diff --git a/src/cli/naming-charter.test.ts b/src/cli/naming-charter.test.ts index 728e7ca..123a391 100644 --- a/src/cli/naming-charter.test.ts +++ b/src/cli/naming-charter.test.ts @@ -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", () => {