fix(cli): 统一生产环境确认协议与预览行为

- 新增 src/cli/production.ts:--allow-prod 为唯一生产覆盖参数,
  --allow-production / --force 仅作兼容别名;JSON 阻断统一为
  PROD_OVERRIDE_REQUIRED,并携带 nextAction 与 details.operation
- workflow test 与 workflow nodes grant 统一提示文案、错误结构与
  nextAction 生成;workflow test 的 JSON 阻断不再返回空 stdout
- 预览 --dry-run 始终放行,实际执行才要求覆盖参数;nodes grant
  参数校验前置,缺少节点类型时不再先报生产阻断
- 两个命令的成功结果统一携带 productionOverride / productionWarning
- corps tag 将企业从 prod 降级为 test/demo 时输出显著警告
- 同步 CLI 帮助、CLI/workflow README 与 Skill;补充对应单测

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
giteaandClaude committed 2026-11-18 16:44:57 +08:00
1 parent 038aca10fb
commit 5be2bd5432
16 files changed
+575 -127

No files matched your search

+22 -9
View File
@@ -45,21 +45,34 @@ export function requireMutationConfirmation(
throw new MutationConfirmationRequired(operation, nextAction);
}
/**
* 基于当前原始参数构造「确认执行」命令,并补齐缺失的附加参数。
* 所有命令的 nextAction 都走这里,避免各自拼接造成格式漂移。
*/
export function buildConfirmedCommand(parsed: CliParsedArgs, extraArgs: string[] = []): string {
const strip = new Set([
"--dry-run", "--dryRun", "--dryrun",
"--yes", "-y", "--confirm", "--force-write", "--forceWrite",
]);
const args = (parsed.raw ?? []).filter((arg) => !strip.has(arg));
const isAiPro = args[0] === "hose-aipro" || args[0] === "aipro";
const cleanArgs =
args[0] === "hose-aipro" || args[0] === "hose-use" || args[0] === "aipro"
? args.slice(1)
: args;
const extra = extraArgs.filter((arg) => arg && !cleanArgs.includes(arg));
return `${isAiPro ? "hose-aipro" : "hose-use"} ${[...cleanArgs, ...extra].join(" ")} --yes`;
}
export function mutationPreview(
parsed: CliParsedArgs,
runtime: CliRuntime,
operation: string,
target: string,
changes: Record<string, unknown>
changes: Record<string, unknown>,
options: { extraArgs?: string[] } = {}
): CliResult {
const confirmedArgs = parsed.raw.filter((arg) => !["--dry-run", "--dryRun", "--dryrun"].includes(arg));
const isAiPro = confirmedArgs[0] === "hose-aipro" || confirmedArgs[0] === "aipro";
const binaryPrefix = isAiPro ? "hose-aipro" : "hose-use";
const cleanArgs =
confirmedArgs[0] === "hose-aipro" || confirmedArgs[0] === "hose-use" || confirmedArgs[0] === "aipro"
? confirmedArgs.slice(1)
: confirmedArgs;
const nextAction = `${binaryPrefix} ${cleanArgs.join(" ")} --yes`;
const nextAction = buildConfirmedCommand(parsed, options.extraArgs);
const payload = {
dryRun: true,
operation,