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:
gitea committed 2026-10-24 22:08:37 +08:00
1 parent 245ec33d1a
commit ffb9820822
16 files changed
+515 -86

No files matched your search

+5
View File
@@ -368,6 +368,11 @@ export function webhookShowSecretOption(options: Record<string, string | boolean
);
}
/** Shared `--dry-run` read for mutation-preview gates (charter: one canonical spelling). */
export function dryRunOption(args: ParsedArgs): boolean | undefined {
return booleanOption(args.options["dry-run"]) ?? booleanOption(args.options.dryRun);
}
export function materialPackFilePolicyOptions(
options: Record<string, string | boolean>
): MaterialPackFilePolicyPatch | undefined {