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
@@ -5,6 +5,7 @@ import { confirmationRequired, usageError, validationError } from "../../core/er
|
||||
import { runCapability, runCapabilityResult } from "../helpers.js";
|
||||
import {
|
||||
booleanOption,
|
||||
dryRunOption,
|
||||
jsonObject,
|
||||
numberOption,
|
||||
splitOption,
|
||||
@@ -172,15 +173,22 @@ export async function handleSimulationCommand(
|
||||
|
||||
if (action === "clean" || action === "delete") {
|
||||
const batchId = maybeName ?? stringOption(args.options.batchId) ?? stringOption(args.options["batch-id"]);
|
||||
if (!batchId) throw usageError("Usage: seal-use simulation delete <batchId> --yes");
|
||||
if (!batchId) throw usageError("Usage: seal-use simulation delete <batchId> [--dry-run] --yes");
|
||||
const confirmed = booleanOption(args.options.yes) === true || booleanOption(args.options.confirm) === true;
|
||||
if (!confirmed) {
|
||||
const dryRun = dryRunOption(args);
|
||||
if (!confirmed && !dryRun) {
|
||||
throw confirmationRequired(
|
||||
`Refusing to delete simulation batch '${batchId}' without --yes.`,
|
||||
`seal-use simulation delete ${batchId} --corp ${corp.id} --yes`
|
||||
);
|
||||
}
|
||||
await runCapability("sealSimulationBatchClean", client, corp, { batchId }, outputOptions(args.options));
|
||||
await runCapability(
|
||||
"sealSimulationBatchClean",
|
||||
client,
|
||||
corp,
|
||||
{ batchId, dryRun },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user