Add --dry-run mutation previews across remaining mutating commands
Close the AGENTS.md "Safety Guardrail & Mutation Preview" coverage gap: every remote-mutating command now supports --dry-run returning structured JSON with preview: true, without executing the mutation. - Domain capabilities gain an optional dryRun param and preview handlers: sealUserCreate/ResetPassword/Delete/Activate/DelegationCreate, sealDelegationRevoke, sealApprovalRuleCreate/Update/Delete/ VersionPublish, sealSimulationBatchClean, sealInsightRecordAnalyze. Previews reuse the shared mutationPreview() diff shape; reads (GET) are allowed to build the before/after, writes never fire. - CLI wiring: users create/delegation/reset-password/delete, rules create/update/delete/publish, simulation delete, analytics analyze, auth link revoke pass dryRun; dry-run bypasses the --yes gate (webhook delete pattern); corps mark previews the local config tag change without writing it. - Shared dryRunOption() helper in parser.ts; help registry documents --dry-run on all covered commands; cli-protocol.md §3 example list updated; cli.md and embedded skill regenerated. - New src/cli/commands/dry-run-gates.test.ts pins the contract: preview JSON on stdout, zero mutating requests (GET-only where reads are needed), config untouched for local previews. Local user-config writes (corps switch/rename, config mode/test-dir/ lint) stay outside this contract: they are reversible local edits with no upstream effect.
This commit is contained in:
1 parent
245ec33d1a
commit
ffb9820822
16 files changed
+515
-86
No files matched your search
@@ -13,7 +13,7 @@ import {
|
||||
import type { CorpEnvironment } from "../../../core/config/types.js";
|
||||
import { selectCorp } from "../../helpers.js";
|
||||
import { confirmationRequired, usageError } from "../../../core/errors.js";
|
||||
import { booleanOption, numberOption, stringOption } from "../../parser.js";
|
||||
import { booleanOption, dryRunOption, numberOption, stringOption } from "../../parser.js";
|
||||
import { printJson } from "../../printer.js";
|
||||
import type { ParsedArgs } from "../../types.js";
|
||||
import { formatSafeSourceDetail, resolveCorpSealUrl } from "./shared.js";
|
||||
@@ -167,6 +167,20 @@ export async function handleCorpOverview(
|
||||
throw usageError("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");
|
||||
}
|
||||
|
||||
const dryRun = dryRunOption(args);
|
||||
if (dryRun) {
|
||||
printJson({
|
||||
preview: true,
|
||||
dryRun: true,
|
||||
mutation: "corps mark",
|
||||
corpId: corp.id,
|
||||
corpName: corp.name,
|
||||
changesDiff: { before: corp.environment ?? undefined, after: targetEnv },
|
||||
note: "环境标签影响同步与重放安全守卫;去掉 --dry-run 并加 --confirm 才会实际写入。"
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
const confirmed = booleanOption(args.options.confirm) === true || booleanOption(args.options.yes) === true;
|
||||
if (!confirmed) {
|
||||
throw confirmationRequired(
|
||||
|
||||
Reference in new issue
Block a user