fix(approval): keep dry-run paths free of remote and local mutations

This commit is contained in:
gitea committed 2026-10-20 17:50:06 +08:00
1 parent fac81b08e8
commit ae2a1a9d60
5 files changed
+231 -184

No files matched your search

+7
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bun
import { isDryRun, mutationPreview } from "./cli/mutation.js";
import { parseArgs, stringOption, booleanOption, isJsonRequested } from "./cli/parser.js";
import { cliErrorResult } from "./cli/runner.js";
import { printHelp, printJson, redactSensitiveText } from "./cli/printer.js";
@@ -48,6 +49,12 @@ async function runAiProCliOnce(rawArgs: string[]): Promise<{ stdout: string; std
});
const corp = runtime.selectedCorp;
const previewPositional = parsed.positional || [];
const previewCommand = (previewPositional[0] || "help").toLowerCase();
const mutating = ["init", "start", "bind", "mount", "review", "eval", "evaluate", "decide", "approve", "reject"].includes(previewCommand) || (["points", "clauses"].includes(previewCommand) && previewPositional.length >= 3);
if (mutating && isDryRun(parsed, runtime)) {
return mutationPreview({ ...parsed, raw: ["aipro", ...rawArgs] }, runtime, "预览 AI PRO 审批操作", stringOption(parsed.options, ["run", "r", "code", "sn", "id", "target"]) || previewPositional[1] || "未指定", { action: previewCommand, corpId: corp?.corpId || corp?.id, apply: booleanOption(parsed.options, ["apply", "execute", "run", "do"]) });
}
const repo = new ApprovalRepository();
const service = new ApprovalService(repo);
let cachedSession: Awaited<ReturnType<typeof getSessionClientForRuntime>> | undefined;