From 74b227c2b0af2895c5a4a3d486b8c40bc07628c4 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 17 Jul 2026 04:18:31 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=B6=E6=95=9B=20workflow=20?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E9=BB=98=E8=AE=A4=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/src/cli.ts | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/scripts/src/cli.ts b/scripts/src/cli.ts index 322541e..6e7e60b 100644 --- a/scripts/src/cli.ts +++ b/scripts/src/cli.ts @@ -106,6 +106,34 @@ function emit(value: Record, json: boolean): void { } } +export function summarizeWorkflowStatus(value: Record): Record { + const result = record(value.result); + const summary: Record = { + target: value.target, + transport: value.transport, + ok: value.ok, + workflowId: value.workflowId, + runId: value.runId, + state: value.state, + terminal: value.terminal, + error: value.error, + }; + if (result) { + summary.resultOk = result.ok; + summary.resultStatus = result.status; + summary.refreshedAt = result.refreshedAt; + summary.window = result.window; + summary.groupCount = Array.isArray(result.groups) ? result.groups.length : null; + summary.accountCount = Array.isArray(result.accounts) ? result.accounts.length : null; + summary.resultFieldCount = Object.keys(result).length; + summary.disclosure = "add --json for the complete workflow result"; + } else if (value.result !== null && value.result !== undefined) { + summary.resultType = Array.isArray(value.result) ? "array" : typeof value.result; + summary.disclosure = "add --json for the complete workflow result"; + } + return summary; +} + function appCommand(parsed: Parsed, config: ReturnType): AppCommand | Record { const [group, action] = parsed.command; if (group === "backend" && action === "check") return { kind: "backend.check" }; @@ -236,7 +264,8 @@ export async function runCli(args: string[]): Promise { if (!target) throw new Error(`runtime.cliTargets.${targetId} does not exist`); if (parsed.overApi && target.mode !== "http") throw new Error(`--over-api requires an http target; ${targetId} is ${target.mode}`); const result = target.mode === "embedded" ? await embedded(parsed, config, target) : await remote(parsed, config, target); - emit({ target: targetId, transport: target.mode === "embedded" ? "local-dispatcher" : "http", ...result as Record }, parsed.json); + const output = { target: targetId, transport: target.mode === "embedded" ? "local-dispatcher" : "http", ...result as Record }; + emit(parsed.command.join(" ") === "workflow status" && !parsed.json ? summarizeWorkflowStatus(output) : output, parsed.json); } catch (error) { emit({ ok: false, error: error instanceof Error ? error.message : String(error), valuesPrinted: false }, wantsJson); process.exitCode = 1;