Merge pull request #282 from yunyingk/mac15/fix-retired-flow-switch
fix(cli): 停止在用户可见面上宣传已退役的 --flow 拼写
This commit is contained in:
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
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
@@ -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
@@ -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" }
|
||||
]
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in new issue
Block a user