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

+1 -1
View File
@@ -14,7 +14,7 @@
- `errors.ts`:`classifyCliError` 按 `EkbError` 子类与状态码映射退出码与恢复建议。
带结构化元数据的 `EkbError.details` 会保留在 JSON 错误中,例如工作流主保存已完成但元数据刷新失败时的 `remoteSaved` 和服务端版本;普通错误输出不变。
- `mutation.ts`:写操作统一防护(确认/dry-run 语义),边界由 `mutation-boundaries.test.ts` 强制。
- `生产环境安全阻断 (Production Safeguard)`:对带副作用的敏感命令,在正式生产企业 (`env === "prod"`) 执行时触发硬阻断。`workflow test` 需显式带 `--force` 确认生产风险;`workflow nodes grant` 需显式带 `--allow-prod`,并继续遵守 `--dry-run`/`--yes` 两阶段确认。自省命令(`corps list`、`corps current`、`context`、`probe`)显式输出环境标识,并提供 `corps tag` 标记与 `corps list --test/--prod` 筛选。
- `生产环境确认 (Production Safeguard)`:`src/cli/production.ts` 统一策略。正式生产企业 (`env === "prod"`) 执行敏感命令时,只要求显式追加 `--allow-prod` 表明操作者已知晓目标为生产企业,不禁止功能;`--force` 保留为兼容别名。预览 (`--dry-run`) 始终放行,不要求覆盖参数;实际执行仍遵守 `--dry-run`/`--yes` 两阶段确认。阻断统一返回文本提示或 JSON 错误 `PROD_OVERRIDE_REQUIRED`(含 `nextAction` 与 `details.operation`)。自省命令(`corps list`、`corps current`、`context`、`probe`)显式输出环境标识,并提供 `corps tag` 标记与 `corps list --test/--prod` 筛选。
- `helpers.ts`:横切运行时助手(`initCorpRuntime` / `requireSelectedCorp` / `getSessionClientForRuntime`)。
- `service.ts`:常驻守护进程管理(安装/启停/状态)。
- `help.ts`:帮助文本组织。