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
@@ -3,7 +3,7 @@ import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { exportInsightReportToExcel } from "../../domains/seal/insight/export.js";
|
||||
import { runCapability } from "../helpers.js";
|
||||
import { booleanOption, numberOption, stringOption } from "../parser.js";
|
||||
import { booleanOption, dryRunOption, numberOption, stringOption } from "../parser.js";
|
||||
import { outputOptions, printJson } from "../printer.js";
|
||||
import type { ParsedArgs } from "../types.js";
|
||||
|
||||
@@ -72,7 +72,8 @@ export async function handleAnalyticsCommand(
|
||||
client,
|
||||
corp,
|
||||
{
|
||||
recordId
|
||||
recordId,
|
||||
dryRun: dryRunOption(args)
|
||||
},
|
||||
outputOptions(args.options)
|
||||
);
|
||||
|
||||
@@ -15,6 +15,7 @@ import { createDelegation, getMe } from "../../domains/seal/api.js";
|
||||
import { resolveHoseLinkIdentity, resolveSealLinkIdentity, summarizeSealLinkIdentity } from "../../domains/seal/enterprise/assist-identity.js";
|
||||
import {
|
||||
booleanOption,
|
||||
dryRunOption,
|
||||
parseDelegationExpireHours,
|
||||
parseHoseExpireSeconds,
|
||||
stringOption
|
||||
@@ -99,8 +100,14 @@ export async function handleAuthCommand(action: string | undefined, corp: CorpCo
|
||||
|
||||
if (subAction === "revoke") {
|
||||
const tokenId = args.command[3] ?? stringOption(args.options.tokenId) ?? stringOption(args.options.id);
|
||||
if (!tokenId) throw usageError("Usage: seal-use auth link revoke <tokenId>");
|
||||
await runCapability("sealDelegationRevoke", client, corp, { tokenId }, outputOptions(args.options));
|
||||
if (!tokenId) throw usageError("Usage: seal-use auth link revoke <tokenId> [--dry-run]");
|
||||
await runCapability(
|
||||
"sealDelegationRevoke",
|
||||
client,
|
||||
corp,
|
||||
{ tokenId, dryRun: dryRunOption(args) },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
import { afterEach, describe, expect, test } from "bun:test";
|
||||
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { runCli } from "../runner.js";
|
||||
|
||||
/**
|
||||
* Mutation-preview (`--dry-run`) gates for commands that previously mutated
|
||||
* without a preview path (AGENTS.md "Safety Guardrail & Mutation Preview").
|
||||
* Every dry-run must return structured JSON with `preview: true` on stdout and
|
||||
* never issue a mutating HTTP request — reads (GET) are allowed for building
|
||||
* the before/after diff.
|
||||
*/
|
||||
|
||||
const ORIGINAL_ENV = {
|
||||
enterprises: process.env.SEAL_USE_ENTERPRISES_DIR,
|
||||
config: process.env.SEAL_USE_CONFIG_FILE,
|
||||
tokenStore: process.env.SEAL_USE_TOKEN_STORE,
|
||||
usageFile: process.env.SEAL_USE_USAGE_FILE
|
||||
};
|
||||
const ORIGINAL_FETCH = globalThis.fetch;
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
afterEach(() => {
|
||||
restoreEnv("SEAL_USE_ENTERPRISES_DIR", ORIGINAL_ENV.enterprises);
|
||||
restoreEnv("SEAL_USE_CONFIG_FILE", ORIGINAL_ENV.config);
|
||||
restoreEnv("SEAL_USE_TOKEN_STORE", ORIGINAL_ENV.tokenStore);
|
||||
restoreEnv("SEAL_USE_USAGE_FILE", ORIGINAL_ENV.usageFile);
|
||||
globalThis.fetch = ORIGINAL_FETCH;
|
||||
|
||||
for (const dir of tempDirs.splice(0)) {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
function restoreEnv(name: string, value: string | undefined) {
|
||||
if (value === undefined) delete process.env[name];
|
||||
else process.env[name] = value;
|
||||
}
|
||||
|
||||
function setupMockEnv() {
|
||||
const root = mkdtempSync(join(tmpdir(), "seal-use-dry-run-"));
|
||||
const enterprises = join(root, "enterprises");
|
||||
tempDirs.push(root);
|
||||
process.env.SEAL_USE_ENTERPRISES_DIR = enterprises;
|
||||
process.env.SEAL_USE_CONFIG_FILE = join(root, "config.json");
|
||||
process.env.SEAL_USE_TOKEN_STORE = join(root, "tokens.json");
|
||||
process.env.SEAL_USE_USAGE_FILE = join(root, "usage.json");
|
||||
mkdirSync(enterprises, { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(enterprises, "dry-run-corp.json"),
|
||||
JSON.stringify(
|
||||
{
|
||||
id: "dry-run-corp",
|
||||
name: "Dry Run Corp",
|
||||
environment: "test",
|
||||
seal: {
|
||||
url: "https://dry-run-corp.sealai.cc",
|
||||
endpoints: { approvalStylePreferences: "api/v1/agent/ai-approval/config" }
|
||||
},
|
||||
source: { type: "seal", token: "mock-token", sealUrl: "https://dry-run-corp.sealai.cc" }
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(root, "config.json"),
|
||||
JSON.stringify({ defaultCorpId: "dry-run-corp", stateful: true }, null, 2)
|
||||
);
|
||||
return { root, enterprises };
|
||||
}
|
||||
|
||||
/** Records `METHOD url` per request and answers every call with a generic 200. */
|
||||
function trackRequests() {
|
||||
const requests: string[] = [];
|
||||
globalThis.fetch = (async (input: RequestInfo | URL) => {
|
||||
const url = typeof input === "string"
|
||||
? input
|
||||
: input instanceof URL
|
||||
? input.toString()
|
||||
: input.url;
|
||||
const method = typeof input === "object" && "method" in input ? input.method : "GET";
|
||||
requests.push(`${method} ${url}`);
|
||||
return new Response(JSON.stringify({ data: {} }), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" }
|
||||
});
|
||||
}) as typeof fetch;
|
||||
return requests;
|
||||
}
|
||||
|
||||
describe("mutation preview (--dry-run) gates", () => {
|
||||
test("users create --dry-run previews without any network call", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["users", "create", "--name", "张三", "--phone", "13300001111", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"dryRun": true');
|
||||
expect(requests).toEqual([]);
|
||||
});
|
||||
|
||||
test("users delete --dry-run bypasses --yes and issues no mutating request", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["users", "delete", "user-123", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(requests.every((entry) => entry.startsWith("GET "))).toBe(true);
|
||||
});
|
||||
|
||||
test("rules create --dry-run previews the rule payload without any network call", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli([
|
||||
"rules", "create", "--description", "测试规则", "--scope", "general", "--dry-run"
|
||||
]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"mutation": "sealApprovalRuleCreate"');
|
||||
expect(requests).toEqual([]);
|
||||
});
|
||||
|
||||
test("rules delete --dry-run bypasses --yes and issues no mutating request", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["rules", "delete", "0025", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"deleted": 0');
|
||||
expect(requests.every((entry) => entry.startsWith("GET "))).toBe(true);
|
||||
});
|
||||
|
||||
test("rules publish --dry-run previews draft scale without publishing", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["rules", "publish", "v-test", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"published": false');
|
||||
expect(requests.every((entry) => entry.startsWith("GET "))).toBe(true);
|
||||
});
|
||||
|
||||
test("simulation delete --dry-run bypasses --yes and issues no mutating request", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["simulation", "delete", "batch-42", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"cleaned": 0');
|
||||
expect(requests.every((entry) => entry.startsWith("GET "))).toBe(true);
|
||||
});
|
||||
|
||||
test("analytics analyze --dry-run previews without triggering server-side analysis", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["analytics", "analyze", "record-77", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"triggered": false');
|
||||
expect(requests).toEqual([]);
|
||||
});
|
||||
|
||||
test("auth link revoke --dry-run previews without revoking", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["auth", "link", "revoke", "token-1", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(requests.every((entry) => entry.startsWith("GET "))).toBe(true);
|
||||
});
|
||||
|
||||
test("corps mark --dry-run previews the tag change without writing config", async () => {
|
||||
const { enterprises } = setupMockEnv();
|
||||
trackRequests();
|
||||
|
||||
const result = await runCli(["corps", "mark", "dry-run-corp", "--env", "production", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"after": "production"');
|
||||
|
||||
const config = JSON.parse(readFileSync(join(enterprises, "dry-run-corp.json"), "utf8"));
|
||||
expect(config.environment).toBe("test");
|
||||
});
|
||||
});
|
||||
@@ -12,6 +12,7 @@ import { runCapability, runCapabilityResult } from "../helpers.js";
|
||||
import { confirmationRequired, validationError, usageError } from "../../core/errors.js";
|
||||
import {
|
||||
booleanOption,
|
||||
dryRunOption,
|
||||
jsonObject,
|
||||
numberOption,
|
||||
parseRuleVersionSelector,
|
||||
@@ -220,7 +221,7 @@ export async function handleRulesCommand(
|
||||
"sealApprovalRuleCreate",
|
||||
client!,
|
||||
corp,
|
||||
{ description, scope, strictness },
|
||||
{ description, scope, strictness, dryRun: dryRunOption(args) },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
@@ -246,7 +247,7 @@ export async function handleRulesCommand(
|
||||
"sealApprovalRuleUpdate",
|
||||
client!,
|
||||
corp,
|
||||
{ ruleId, description, scope, strictness },
|
||||
{ ruleId, description, scope, strictness, dryRun: dryRunOption(args) },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
@@ -259,10 +260,11 @@ export async function handleRulesCommand(
|
||||
stringOption(args.options["rule-id"]) ??
|
||||
stringOption(args.options.code);
|
||||
if (!ruleId) {
|
||||
throw usageError("Usage: seal-use rules delete <code> --yes [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use rules delete <code> [--dry-run] --yes [--corp <corpId>]");
|
||||
}
|
||||
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 rule '${ruleId}' without --yes.`,
|
||||
`seal-use rules delete ${ruleId} --corp ${corp.id} --yes`
|
||||
@@ -272,7 +274,7 @@ export async function handleRulesCommand(
|
||||
"sealApprovalRuleDelete",
|
||||
client!,
|
||||
corp,
|
||||
{ ruleId },
|
||||
{ ruleId, dryRun },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
@@ -287,13 +289,13 @@ export async function handleRulesCommand(
|
||||
stringOption(args.options.name) ??
|
||||
(typeof payload.versionName === "string" ? payload.versionName : undefined);
|
||||
if (!versionName) {
|
||||
throw usageError("Usage: seal-use rules publish <versionName> [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use rules publish <versionName> [--dry-run] [--corp <corpId>]");
|
||||
}
|
||||
await runCapability(
|
||||
"sealApprovalRuleVersionPublish",
|
||||
client!,
|
||||
corp,
|
||||
{ versionName },
|
||||
{ versionName, dryRun: dryRunOption(args) },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+18
-10
@@ -2,7 +2,7 @@ import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { confirmationRequired, usageError } from "../../core/errors.js";
|
||||
import { runCapability } from "../helpers.js";
|
||||
import { booleanOption, parseDelegationExpireHours, stringOption } from "../parser.js";
|
||||
import { booleanOption, dryRunOption, parseDelegationExpireHours, stringOption } from "../parser.js";
|
||||
import { outputOptions } from "../printer.js";
|
||||
import type { ParsedArgs } from "../types.js";
|
||||
|
||||
@@ -16,24 +16,31 @@ export async function handleUsersCommand(
|
||||
if (action === "create") {
|
||||
const name = stringOption(args.options.name) ?? maybeName;
|
||||
const phone = stringOption(args.options.phone);
|
||||
if (!name || !phone) throw usageError("Usage: seal-use users create --name <name> --phone <phone> [--dept <deptId>]");
|
||||
if (!name || !phone) throw usageError("Usage: seal-use users create --name <name> --phone <phone> [--dept <deptId>] [--dry-run]");
|
||||
const deptId = stringOption(args.options.dept) ?? stringOption(args.options.departmentId);
|
||||
const departmentIds = deptId ? [deptId] : undefined;
|
||||
await runCapability("sealUserCreate", client, corp, { name, phone, departmentIds }, outputOptions(args.options));
|
||||
await runCapability(
|
||||
"sealUserCreate",
|
||||
client,
|
||||
corp,
|
||||
{ name, phone, departmentIds, dryRun: dryRunOption(args) },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === "reset-password") {
|
||||
const userId = maybeName ?? stringOption(args.options.userId);
|
||||
if (!userId) throw usageError("Usage: seal-use users reset-password <userId> --yes");
|
||||
if (!userId) throw usageError("Usage: seal-use users reset-password <userId> [--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 reset password of user '${userId}' without --yes.`,
|
||||
`seal-use users reset-password ${userId} --corp ${corp.id} --yes`
|
||||
);
|
||||
}
|
||||
await runCapability("sealUserResetPassword", client, corp, { userId }, outputOptions(args.options));
|
||||
await runCapability("sealUserResetPassword", client, corp, { userId, dryRun }, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,15 +59,16 @@ export async function handleUsersCommand(
|
||||
|
||||
if (action === "delete") {
|
||||
const userId = maybeName ?? stringOption(args.options.userId);
|
||||
if (!userId) throw usageError("Usage: seal-use users delete <userId> --yes");
|
||||
if (!userId) throw usageError("Usage: seal-use users delete <userId> [--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 user '${userId}' without --yes.`,
|
||||
`seal-use users delete ${userId} --corp ${corp.id} --yes`
|
||||
);
|
||||
}
|
||||
await runCapability("sealUserDelete", client, corp, { userId }, outputOptions(args.options));
|
||||
await runCapability("sealUserDelete", client, corp, { userId, dryRun }, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,7 +89,7 @@ export async function handleUsersCommand(
|
||||
"sealUserDelegationCreate",
|
||||
client,
|
||||
corp,
|
||||
{ userIdOrPhone, note, expiresInHours },
|
||||
{ userIdOrPhone, note, expiresInHours, dryRun: dryRunOption(args) },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
|
||||
+15
-13
@@ -80,9 +80,10 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
name: "mark",
|
||||
group: "企业配置",
|
||||
summary: "Mark enterprise environment as production or test",
|
||||
usage: ["seal-use corps mark <corpId> --env <production|test> [--confirm]"],
|
||||
usage: ["seal-use corps mark <corpId> --env <production|test> [--dry-run] [--confirm]"],
|
||||
options: [
|
||||
{ flag: "--env <production|test>", description: "Target environment: 'production' or 'test' (required)" },
|
||||
{ flag: "--dry-run", description: "Preview the environment tag change without writing local config" },
|
||||
{ flag: "--confirm", description: "Confirm the environment update (required)" }
|
||||
],
|
||||
description: "Explicitly updates an enterprise's environment tag. Requires --confirm to prevent accidental changes."
|
||||
@@ -289,22 +290,22 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "create",
|
||||
summary: "Create a new draft approval rule",
|
||||
usage: ["seal-use rules create --description <text> --scope <scope> [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--description-file <path>] [--corp <corpId>]"]
|
||||
usage: ["seal-use rules create --description <text> --scope <scope> [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--description-file <path>] [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "update",
|
||||
summary: "Update a draft approval rule by code",
|
||||
usage: ["seal-use rules update <code> [--description <text>|--description-file <path>] [--scope <scope>] [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--corp <corpId>]"]
|
||||
usage: ["seal-use rules update <code> [--description <text>|--description-file <path>] [--scope <scope>] [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "delete",
|
||||
summary: "Delete a draft approval rule by code",
|
||||
usage: ["seal-use rules delete <code> --yes [--corp <corpId>]"]
|
||||
usage: ["seal-use rules delete <code> [--dry-run] --yes [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "publish",
|
||||
summary: "Publish current draft rules as a new formal version",
|
||||
usage: ["seal-use rules publish <versionName> [--corp <corpId>]"]
|
||||
usage: ["seal-use rules publish <versionName> [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "versions",
|
||||
@@ -803,7 +804,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
name: "delete",
|
||||
aliases: ["clean"],
|
||||
summary: "Delete simulation batch records",
|
||||
usage: ["seal-use simulation delete <batchId> --yes [--corp <corpId>]"]
|
||||
usage: ["seal-use simulation delete <batchId> [--dry-run] --yes [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "specifications",
|
||||
@@ -1064,7 +1065,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "link revoke",
|
||||
summary: "【Seal 审核后台】撤销指定的 Seal 委托授权令牌",
|
||||
usage: ["seal-use auth link revoke <tokenId> [--corp <corpId>]"]
|
||||
usage: ["seal-use auth link revoke <tokenId> [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "hose-link",
|
||||
@@ -1123,7 +1124,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "create",
|
||||
summary: "Create a new tenant user",
|
||||
usage: ["seal-use users create --name <name> --phone <phone> [--dept <deptId>] [--corp <corpId>]"]
|
||||
usage: ["seal-use users create --name <name> --phone <phone> [--dept <deptId>] [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "search",
|
||||
@@ -1133,16 +1134,17 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "delegation",
|
||||
summary: "Create delegation token for a specific user",
|
||||
usage: ["seal-use users delegation <userIdOrPhone|name> [--note <note>] [--expire <duration>] [--corp <corpId>]"],
|
||||
usage: ["seal-use users delegation <userIdOrPhone|name> [--note <note>] [--expire <duration>] [--dry-run] [--corp <corpId>]"],
|
||||
options: [
|
||||
{ flag: "--note <note>", description: "委托授权备注说明" },
|
||||
{ flag: "--expire, --expires-in <duration>", description: "委托授权有效期,推荐 '7d' 或 '24h'(最大 7 天,兼容秒数并自动向下取整)" }
|
||||
{ flag: "--expire, --expires-in <duration>", description: "委托授权有效期,推荐 '7d' 或 '24h'(最大 7 天,兼容秒数并自动向下取整)" },
|
||||
{ flag: "--dry-run", description: "Preview the delegation parameters without minting a token" }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "reset-password",
|
||||
summary: "Reset user password",
|
||||
usage: ["seal-use users reset-password <userId> --yes [--corp <corpId>]"]
|
||||
usage: ["seal-use users reset-password <userId> [--dry-run] --yes [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "get",
|
||||
@@ -1152,7 +1154,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "delete",
|
||||
summary: "Delete user",
|
||||
usage: ["seal-use users delete <userId> --yes [--corp <corpId>]"]
|
||||
usage: ["seal-use users delete <userId> [--dry-run] --yes [--corp <corpId>]"]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1319,7 +1321,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
name: "analyze",
|
||||
aliases: ["reanalyze"],
|
||||
summary: "Trigger on-demand smart insight risk analysis for an approval record",
|
||||
usage: ["seal-use analytics analyze <recordId> [--corp <corpId>]"]
|
||||
usage: ["seal-use analytics analyze <recordId> [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "export",
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user