Add exit codes 13 and 14 for config validation and safety blocks

The classifier only matched English usage wording, so every Chinese-language
usage error, every enterprise-selection failure, and every Zod/SyntaxError
fell through to exit 1 ("upstream failure"), while environment safety guards
were reported as exit 2 or 1. Add two semantic codes:

- 13 (validationError): well-formed command, unusable value — missing --corp,
  unparseable enterprise JSON, missing required parameter, ambiguous webhook
  channel selection.
- 14 (safetyBlocked): the target environment forbids the action — replaying
  into production, regression outside a test tenant.

classifyCliError now recognises Chinese usage wording, enterprise-selection
phrasing, local file problems, Zod issue lists (structural, not textual) and
SyntaxError; English Usage:/Unknown-command stays 2, domain failures and
quality gates stay 1. Docs (AGENTS, cli-protocol, skill cli.md) and the exit
code assertions follow.
This commit is contained in:
gitea committed 2026-09-29 22:04:12 +08:00
1 parent 5f4906758e
commit 66eb81f3d1
12 files changed
+177 -134

No files matched your search

+3 -1
View File
@@ -387,7 +387,9 @@ describe("seal-use webhook replay CLI", () => {
"--dry-run"
]);
expect(blockedResult.isError).toBe(true);
expect(blockedResult.exitCode).toBe(1);
// 14: safety block — the target environment forbids the action, not the
// shape of the command line.
expect(blockedResult.exitCode).toBe(14);
expect(blockedResult.stderr).toContain("标记为生产正式环境");
// With --force
+3 -3
View File
@@ -6,7 +6,7 @@ import { existsSync } from "node:fs";
import { runTool, selectCorp } from "../helpers.js";
import * as api from "../../domains/seal/api.js";
import { findWebhookIntegration } from "../../domains/seal/api.js";
import type { ApprovalRun, WebhookIntegration } from "../../domains/seal/types.js";
import type { WebhookIntegration } from "../../domains/seal/types.js";
import {
executeApprovalRunsReplay,
resolveReplayCorpPair,
@@ -31,7 +31,7 @@ import {
import { outputOptions, printJson } from "../printer.js";
import type { ParsedArgs } from "../types.js";
import type { MaterialPackFilePolicyPatch } from "../../domains/seal/material-pack/policy.js";
import { CliError, confirmationRequired, usageError } from "../errors.js";
import { CliError, confirmationRequired, usageError, validationError } from "../errors.js";
export async function handleWebhookResourcePackPreview(
filePath: string,
@@ -295,7 +295,7 @@ export async function handleWebhookCommand(
console.error(`👉 自动锁定唯一可用 Webhook 通道: ${integration.name} (${integration.id})`);
} else if (integrations.length > 1) {
const options = integrations.map((i) => `"${i.name}" (${i.id})`).join(", ");
throw new Error(`当前租户存在多个 Webhook 通道 [${options}],请通过 --webhook <idOrName> 指定目标通道。`);
throw validationError(`当前租户存在多个 Webhook 通道 [${options}],请通过 --webhook <idOrName> 指定目标通道。`);
} else {
throw new CliError(
"当前租户未配置任何 Webhook 集成通道。",