Enforce cross-domain naming charter with silent legacy aliases
Unify the visible command surface on one canonical spelling per semantic concept while keeping every legacy spelling working as a silent parser/dispatcher alias (per .agents/rules/cli-protocol.md §6): - Fix silent-ignore accept-set gaps: webhook resource-pack export now reads --out/--output-file and --downloads/--download; approval-runs and webhook read canonical --start-date/--end-date; webhook secret reveal accepts --reveal/-r alongside legacy --show-secret. - Add kebab-case parser registrations for camel-only flags (human-result, manual-approval-status, include-bridge, rule-version, document-limit, context-lines, source-document-sn/-id, simulation-batch-id) and read them in rules/documents search, context, approval-runs list/summary/ bridge/export. - Retire verbs on the visible surface only: webhook create (add), simulation delete (clean), preference thinking-depth policies delete (remove); dispatch keeps both. Runtime nextAction suggestions and doctor knowledge switch to canonical spellings. - Add src/cli/naming-charter.test.ts: help surface must be lowercase kebab-case and free of retired tokens; canonical/legacy spellings must both parse; P0 accept-sets pinned. - Document the charter in .agents/rules/cli-protocol.md §7; sync AGENTS.md, README, and skills/references docs; regenerate cli.md and embedded skill artifacts.
This commit is contained in:
1 parent
5d703cec38
commit
245ec33d1a
21 files changed
+298
-110
No files matched your search
+1
-1
@@ -68,7 +68,7 @@ describe("CLI version & help handling", () => {
|
||||
expect(result.stdout).toContain("seal-use users search <keyword>");
|
||||
expect(result.stdout).toContain("seal-use users delegation <userIdOrPhone|name>");
|
||||
expect(result.stdout).toContain("seal-use webhook get|find <idOrName>");
|
||||
expect(result.stdout).toContain("seal-use webhook add --name <name> --result-url <url>");
|
||||
expect(result.stdout).toContain("seal-use webhook create --name <name> --result-url <url>");
|
||||
expect(result.stdout).toContain("seal-use corps add-link <url>");
|
||||
expect(result.stdout).toContain("seal-use auth link [--note <note>] [--expire <duration>] [--corp <corpId>]");
|
||||
expect(result.stdout).toContain("[--secret <secret>|--rotate-secret]");
|
||||
|
||||
@@ -34,14 +34,17 @@ export async function handleApprovalRunsCommand(
|
||||
date: stringOption(args.options.date),
|
||||
timezone: stringOption(args.options.timezone),
|
||||
limit: numberOption(args.options.limit),
|
||||
startDate: stringOption(args.options.startDate),
|
||||
endDate: stringOption(args.options.endDate),
|
||||
startDate: stringOption(args.options["start-date"]) ?? stringOption(args.options.startDate),
|
||||
endDate: stringOption(args.options["end-date"]) ?? stringOption(args.options.endDate),
|
||||
status: stringOption(args.options.status),
|
||||
taskMode: stringOption(args.options.taskMode),
|
||||
manualApprovalStatus: stringOption(args.options.manualApprovalStatus),
|
||||
sourceDocumentSN: stringOption(args.options.sourceDocumentSN),
|
||||
sourceDocumentId: stringOption(args.options.sourceDocumentId),
|
||||
humanResult: stringOption(args.options.humanResult),
|
||||
taskMode: stringOption(args.options.taskMode) ?? stringOption(args.options["task-mode"]),
|
||||
manualApprovalStatus:
|
||||
stringOption(args.options["manual-approval-status"]) ?? stringOption(args.options.manualApprovalStatus),
|
||||
sourceDocumentSN:
|
||||
stringOption(args.options["source-document-sn"]) ?? stringOption(args.options.sourceDocumentSN),
|
||||
sourceDocumentId:
|
||||
stringOption(args.options["source-document-id"]) ?? stringOption(args.options.sourceDocumentId),
|
||||
humanResult: stringOption(args.options["human-result"]) ?? stringOption(args.options.humanResult),
|
||||
query: stringOption(args.options.query)
|
||||
}
|
||||
);
|
||||
@@ -80,10 +83,12 @@ export async function handleApprovalRunsCommand(
|
||||
|
||||
if (action === "count") {
|
||||
const rawStart =
|
||||
stringOption(args.options["start-date"]) ??
|
||||
stringOption(args.options.start) ??
|
||||
stringOption(args.options.startDate) ??
|
||||
stringOption(args.options.since);
|
||||
const rawEnd =
|
||||
stringOption(args.options["end-date"]) ??
|
||||
stringOption(args.options.end) ??
|
||||
stringOption(args.options.endDate);
|
||||
|
||||
@@ -113,21 +118,27 @@ export async function handleApprovalRunsCommand(
|
||||
limit: numberOption(args.options.limit),
|
||||
offset: numberOption(args.options.offset),
|
||||
startDate:
|
||||
stringOption(args.options["start-date"]) ??
|
||||
stringOption(args.options.startDate) ??
|
||||
stringOption(args.options.start) ??
|
||||
stringOption(args.options.since),
|
||||
endDate:
|
||||
stringOption(args.options["end-date"]) ??
|
||||
stringOption(args.options.endDate) ??
|
||||
stringOption(args.options.end),
|
||||
status: stringOption(args.options.status),
|
||||
taskMode: stringOption(args.options.taskMode),
|
||||
manualApprovalStatus: stringOption(args.options.manualApprovalStatus),
|
||||
sourceDocumentSN: stringOption(args.options.sourceDocumentSN),
|
||||
sourceDocumentId: stringOption(args.options.sourceDocumentId),
|
||||
humanResult: stringOption(args.options.humanResult),
|
||||
taskMode: stringOption(args.options.taskMode) ?? stringOption(args.options["task-mode"]),
|
||||
manualApprovalStatus:
|
||||
stringOption(args.options["manual-approval-status"]) ?? stringOption(args.options.manualApprovalStatus),
|
||||
sourceDocumentSN:
|
||||
stringOption(args.options["source-document-sn"]) ?? stringOption(args.options.sourceDocumentSN),
|
||||
sourceDocumentId:
|
||||
stringOption(args.options["source-document-id"]) ?? stringOption(args.options.sourceDocumentId),
|
||||
humanResult: stringOption(args.options["human-result"]) ?? stringOption(args.options.humanResult),
|
||||
hasExtraRisk: booleanOption(args.options["has-extra-risk"]) ?? booleanOption(args.options.hasExtraRisk),
|
||||
query: stringOption(args.options.query),
|
||||
includeBridge: booleanOption(args.options.includeBridge)
|
||||
includeBridge:
|
||||
booleanOption(args.options["include-bridge"]) ?? booleanOption(args.options.includeBridge)
|
||||
},
|
||||
outputOptions(args.options)
|
||||
);
|
||||
@@ -140,10 +151,13 @@ export async function handleApprovalRunsCommand(
|
||||
client,
|
||||
corp,
|
||||
{
|
||||
recordId: stringOption(args.options.recordId),
|
||||
sourceDocumentSN: stringOption(args.options.sourceDocumentSN),
|
||||
sourceDocumentId: stringOption(args.options.sourceDocumentId),
|
||||
simulationBatchId: stringOption(args.options.simulationBatchId),
|
||||
recordId: stringOption(args.options.recordId) ?? stringOption(args.options["record-id"]),
|
||||
sourceDocumentSN:
|
||||
stringOption(args.options["source-document-sn"]) ?? stringOption(args.options.sourceDocumentSN),
|
||||
sourceDocumentId:
|
||||
stringOption(args.options["source-document-id"]) ?? stringOption(args.options.sourceDocumentId),
|
||||
simulationBatchId:
|
||||
stringOption(args.options["simulation-batch-id"]) ?? stringOption(args.options.simulationBatchId),
|
||||
limit: numberOption(args.options.limit)
|
||||
},
|
||||
outputOptions(args.options)
|
||||
@@ -418,12 +432,15 @@ export async function handleApprovalRunsCommand(
|
||||
manualApprovalStatus:
|
||||
stringOption(args.options["manual-status"]) ??
|
||||
stringOption(args.options.manualStatus) ??
|
||||
stringOption(args.options["manual-approval-status"]) ??
|
||||
stringOption(args.options.manualApprovalStatus),
|
||||
includeCompletedOnly:
|
||||
booleanOption(args.options["completed-only"]) ?? booleanOption(args.options.completedOnly),
|
||||
outputFile:
|
||||
stringOption(args.options.out) ??
|
||||
stringOption(args.options["output-file"]) ??
|
||||
stringOption(args.options.output) ??
|
||||
stringOption(args.options.outputFile) ??
|
||||
stringOption(args.options.file),
|
||||
toDownloads:
|
||||
booleanOption(args.options["to-downloads"]) ??
|
||||
|
||||
@@ -15,8 +15,8 @@ export async function handleContextCommand(
|
||||
client,
|
||||
corp,
|
||||
{
|
||||
documentLimit: numberOption(args.options.documentLimit),
|
||||
...ruleVersionContextOptions(stringOption(args.options.ruleVersion))
|
||||
documentLimit: numberOption(args.options["document-limit"]) ?? numberOption(args.options.documentLimit),
|
||||
...ruleVersionContextOptions(stringOption(args.options["rule-version"]) ?? stringOption(args.options.ruleVersion))
|
||||
},
|
||||
outputOptions(args.options)
|
||||
);
|
||||
|
||||
@@ -113,7 +113,7 @@ export async function handleDocumentsCommand(
|
||||
if (action === "search") {
|
||||
const keyword = maybeName ?? stringOption(args.options.query);
|
||||
if (!keyword) {
|
||||
throw usageError("Usage: seal-use documents search <keyword> [--maxResults 20] [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use documents search <keyword> [--max-results 20] [--corp <corpId>]");
|
||||
}
|
||||
await runCapability(
|
||||
"sealApprovalSearch",
|
||||
@@ -122,8 +122,8 @@ export async function handleDocumentsCommand(
|
||||
{
|
||||
keywords: [keyword],
|
||||
areas: ["documents"],
|
||||
maxResults: numberOption(args.options.maxResults),
|
||||
contextLines: numberOption(args.options.contextLines),
|
||||
maxResults: numberOption(args.options["max-results"]) ?? numberOption(args.options.maxResults),
|
||||
contextLines: numberOption(args.options["context-lines"]) ?? numberOption(args.options.contextLines),
|
||||
refresh: booleanOption(args.options.refresh),
|
||||
snippetOnly: booleanOption(args.options.snippetOnly) ?? booleanOption(args.options["snippet-only"]),
|
||||
maxChars: numberOption(args.options.maxChars) ?? numberOption(args.options["max-chars"]),
|
||||
|
||||
@@ -301,7 +301,7 @@ export async function handleRulesCommand(
|
||||
|
||||
if (action === "search") {
|
||||
const keyword = maybeName ?? stringOption(args.options.query);
|
||||
if (!keyword) throw usageError("Usage: seal-use rules search <keyword> [--version <number|latest>] [--maxResults 20] [--corp <corpId>]");
|
||||
if (!keyword) throw usageError("Usage: seal-use rules search <keyword> [--version <number|latest>] [--max-results 20] [--corp <corpId>]");
|
||||
await runCapability(
|
||||
"sealApprovalSearch",
|
||||
client!,
|
||||
@@ -309,8 +309,8 @@ export async function handleRulesCommand(
|
||||
{
|
||||
keywords: [keyword],
|
||||
areas: ["rules"],
|
||||
maxResults: numberOption(args.options.maxResults),
|
||||
contextLines: numberOption(args.options.contextLines),
|
||||
maxResults: numberOption(args.options["max-results"]) ?? numberOption(args.options.maxResults),
|
||||
contextLines: numberOption(args.options["context-lines"]) ?? numberOption(args.options.contextLines),
|
||||
refresh: booleanOption(args.options.refresh),
|
||||
snippetOnly: booleanOption(args.options.snippetOnly) ?? booleanOption(args.options["snippet-only"]),
|
||||
maxChars: numberOption(args.options.maxChars) ?? numberOption(args.options["max-chars"]),
|
||||
|
||||
@@ -156,7 +156,7 @@ describe("simulation local search", () => {
|
||||
});
|
||||
|
||||
describe("simulation command confirmation gates", () => {
|
||||
test("simulation clean refuses without --yes and never reaches the API", async () => {
|
||||
test("simulation clean (legacy alias) refuses without --yes and never reaches the API", async () => {
|
||||
setupMockEnv();
|
||||
const mutations = trackMutationRequests();
|
||||
|
||||
@@ -165,7 +165,7 @@ describe("simulation command confirmation gates", () => {
|
||||
expect(result.isError).toBe(true);
|
||||
expect(result.exitCode).toBe(10);
|
||||
expect(result.stderr).toContain("Refusing to delete simulation batch 'batch-123' without --yes.");
|
||||
expect(result.stderr).toContain("seal-use simulation clean batch-123");
|
||||
expect(result.stderr).toContain("seal-use simulation delete batch-123");
|
||||
expect(mutations).toEqual([]);
|
||||
});
|
||||
|
||||
|
||||
@@ -172,12 +172,12 @@ 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 clean <batchId> --yes");
|
||||
if (!batchId) throw usageError("Usage: seal-use simulation delete <batchId> --yes");
|
||||
const confirmed = booleanOption(args.options.yes) === true || booleanOption(args.options.confirm) === true;
|
||||
if (!confirmed) {
|
||||
throw confirmationRequired(
|
||||
`Refusing to delete simulation batch '${batchId}' without --yes.`,
|
||||
`seal-use simulation clean ${batchId} --corp ${corp.id} --yes`
|
||||
`seal-use simulation delete ${batchId} --corp ${corp.id} --yes`
|
||||
);
|
||||
}
|
||||
await runCapability("sealSimulationBatchClean", client, corp, { batchId }, outputOptions(args.options));
|
||||
|
||||
@@ -280,6 +280,7 @@ export async function handleWebhookCommand(
|
||||
? false
|
||||
: booleanOption(args.options.attachments) !== false;
|
||||
const outputFile =
|
||||
stringOption(args.options.out) ??
|
||||
stringOption(args.options.output) ??
|
||||
stringOption(args.options.outputFile) ??
|
||||
stringOption(args.options["output-file"]) ??
|
||||
@@ -287,7 +288,11 @@ export async function handleWebhookCommand(
|
||||
stringOption(args.options.file) ??
|
||||
(args.command[3]?.endsWith(".zip") ? args.command[3] : undefined);
|
||||
const toDownloads =
|
||||
booleanOption(args.options.toDownloads) ?? booleanOption(args.options["to-downloads"]) ?? false;
|
||||
booleanOption(args.options.downloads) ??
|
||||
booleanOption(args.options.download) ??
|
||||
booleanOption(args.options.toDownloads) ??
|
||||
booleanOption(args.options["to-downloads"]) ??
|
||||
false;
|
||||
|
||||
const result = await exportApprovalRunsToResourcePack(client, corp, {
|
||||
recordId,
|
||||
@@ -338,7 +343,7 @@ export async function handleWebhookCommand(
|
||||
throw new CliError(
|
||||
"当前租户未配置任何 Webhook 集成通道。",
|
||||
1,
|
||||
`seal-use webhook add --name <name> --result-url <url> --corp ${corp.id}`
|
||||
`seal-use webhook create --name <name> --result-url <url> --corp ${corp.id}`
|
||||
);
|
||||
}
|
||||
const result = await pushMaterialPack(input.fileBuffer, input.fileName, {
|
||||
@@ -368,7 +373,7 @@ export async function handleWebhookCommand(
|
||||
|
||||
if (action === "get" || action === "find") {
|
||||
const selector = maybeName ?? stringOption(args.options.selector) ?? stringOption(args.options.id);
|
||||
if (!selector) throw usageError("Usage: seal-use webhook get <idOrName> [--show-secret]");
|
||||
if (!selector) throw usageError("Usage: seal-use webhook get <idOrName> [--reveal]");
|
||||
await runCapability(
|
||||
"sealWebhookGet",
|
||||
client,
|
||||
@@ -390,7 +395,7 @@ export async function handleWebhookCommand(
|
||||
stringOption(args.options.outgoingResultWebhook) ??
|
||||
stringOption(args.options["outgoing-result-webhook"]);
|
||||
if (!name || !outgoingResultWebhook) {
|
||||
throw usageError("Usage: seal-use webhook add --name <name> --result-url <url> [--mode assisted|semi_automatic|fully_automatic]");
|
||||
throw usageError("Usage: seal-use webhook create --name <name> --result-url <url> [--mode assisted|semi_automatic|fully_automatic]");
|
||||
}
|
||||
const autoApprovalRate = webhookRateOption(args.options);
|
||||
const materialPackFilePolicy = materialPackFilePolicyOptions(args.options);
|
||||
|
||||
@@ -73,7 +73,7 @@ describe("renderHelp", () => {
|
||||
const help = renderHelp([]);
|
||||
expect(help).toContain("seal-use CLI");
|
||||
expect(help).toContain("seal-use corps list");
|
||||
expect(help).toContain("seal-use webhook add");
|
||||
expect(help).toContain("seal-use webhook create");
|
||||
});
|
||||
|
||||
test("renders focused area help without polluting with other domains", () => {
|
||||
@@ -248,8 +248,8 @@ describe("CLI help execution for domain commands", () => {
|
||||
const result = await runCli(["approval-runs", "--help"]);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.stdout).toContain("approval-runs count [--status APPROVED] [--start <YYYY-MM-DD|ms>] [--end <YYYY-MM-DD|ms>]");
|
||||
expect(result.stdout).toContain("approval-runs export [--sn <SN1,SN2>] [--start <YYYY-MM-DD|ms>] [--end <YYYY-MM-DD|ms>] [--force] [--status <status>] [--manual-status <status>] [--completed-only]");
|
||||
expect(result.stdout).toContain("approval-runs count [--status APPROVED] [--start-date <YYYY-MM-DD|ms>] [--end-date <YYYY-MM-DD|ms>]");
|
||||
expect(result.stdout).toContain("approval-runs export [--sn <SN1,SN2>] [--start-date <YYYY-MM-DD|ms>] [--end-date <YYYY-MM-DD|ms>] [--force] [--status <status>] [--manual-status <status>] [--completed-only]");
|
||||
});
|
||||
|
||||
test("analytics export --help prints force parameter usage", async () => {
|
||||
|
||||
+28
-25
@@ -284,7 +284,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "search",
|
||||
summary: "Search rules by keyword (defaults to current draft; pass --version latest for latest published version)",
|
||||
usage: ["seal-use rules search <keyword> [--version <number|latest>] [--maxResults 20] [--corp <corpId>]"]
|
||||
usage: ["seal-use rules search <keyword> [--version <number|latest>] [--max-results 20] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "create",
|
||||
@@ -386,18 +386,19 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "list",
|
||||
summary: "List registered webhook endpoints",
|
||||
usage: ["seal-use webhook list [--query <text>] [--show-secret] [--corp <corpId>]"]
|
||||
usage: ["seal-use webhook list [--query <text>] [--reveal] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "get",
|
||||
aliases: ["find"],
|
||||
summary: "Get webhook endpoint details",
|
||||
usage: ["seal-use webhook get|find <idOrName> [--show-secret] [--corp <corpId>]"]
|
||||
usage: ["seal-use webhook get|find <idOrName> [--reveal] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "add",
|
||||
name: "create",
|
||||
aliases: ["add"],
|
||||
summary: "Register a new webhook endpoint",
|
||||
usage: ["seal-use webhook add --name <name> --result-url <url> [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret <secret>] [--min-file-size 500] [--max-file-size <bytes>] [--allowed-extensions <.pdf,.xlsx,...>] [--dry-run] [--corp <corpId>]"]
|
||||
usage: ["seal-use webhook create --name <name> --result-url <url> [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret <secret>] [--min-file-size 500] [--max-file-size <bytes>] [--allowed-extensions <.pdf,.xlsx,...>] [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "update",
|
||||
@@ -413,8 +414,8 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
name: "resource-pack export",
|
||||
summary: "Export online approval records to a local Webhook resource pack ZIP (alias: pack export)",
|
||||
usage: [
|
||||
"seal-use webhook resource-pack export [--limit <n>] [--status <status>] [--output <file.zip>] [--to-downloads] [--corp <corpId>]",
|
||||
"seal-use webhook resource-pack export <recordId> [--output <file.zip>] [--corp <corpId>]",
|
||||
"seal-use webhook resource-pack export [--limit <n>] [--status <status>] [--out <file.zip>] [--downloads] [--corp <corpId>]",
|
||||
"seal-use webhook resource-pack export <recordId> [--out <file.zip>] [--corp <corpId>]",
|
||||
"seal-use webhook resource-pack export --record-ids <id1,id2> [--corp <corpId>]"
|
||||
],
|
||||
options: [
|
||||
@@ -427,8 +428,8 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{ flag: "--doc-id-prefix <str>", description: "Optional prefix prepended to exported documentId/meetingId" },
|
||||
{ flag: "--doc-id-suffix <str>", description: "Optional suffix appended to exported documentId/meetingId" },
|
||||
{ flag: "--no-attachments", description: "Skip downloading and packaging attachments" },
|
||||
{ flag: "-o, --output <file.zip>", description: "Target ZIP file path" },
|
||||
{ flag: "--to-downloads", description: "Save directly to ~/Downloads" },
|
||||
{ flag: "-o, --out <file.zip>", description: "Target ZIP file path" },
|
||||
{ flag: "--downloads", description: "Save directly to ~/Downloads" },
|
||||
{ flag: "--corp <corpId>", description: "Source enterprise configuration ID" }
|
||||
]
|
||||
},
|
||||
@@ -475,7 +476,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "summary",
|
||||
summary: "Daily summary of approval runs",
|
||||
usage: ["seal-use approval-runs summary [--date YYYY-MM-DD] [--timezone Asia/Shanghai] [--corp <corpId>]"]
|
||||
usage: ["seal-use approval-runs summary [--date <YYYY-MM-DD>] [--timezone Asia/Shanghai] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "stats",
|
||||
@@ -485,23 +486,23 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "count",
|
||||
summary: "Count approval runs filtered by status or time range",
|
||||
usage: ["seal-use approval-runs count [--status APPROVED] [--start <YYYY-MM-DD|ms>] [--end <YYYY-MM-DD|ms>] [--corp <corpId>]"]
|
||||
usage: ["seal-use approval-runs count [--status APPROVED] [--start-date <YYYY-MM-DD|ms>] [--end-date <YYYY-MM-DD|ms>] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "export",
|
||||
summary: "Export approval run audit records to Excel workbook. Add --with-flow to include E人工行为 / E人工意见 columns (requires Hose Open API; adds ~30s for large batches).",
|
||||
usage: ["seal-use approval-runs export [--sn <SN1,SN2>] [--start <YYYY-MM-DD|ms>] [--end <YYYY-MM-DD|ms>] [--force] [--status <status>] [--manual-status <status>] [--completed-only] [--limit <n>] [--downloads|--to-downloads] [--with-flow] [--out <file>] [--corp <corpId>]"],
|
||||
usage: ["seal-use approval-runs export [--sn <SN1,SN2>] [--start-date <YYYY-MM-DD|ms>] [--end-date <YYYY-MM-DD|ms>] [--force] [--status <status>] [--manual-status <status>] [--completed-only] [--limit <n>] [--downloads] [--with-flow] [--out <file>] [--corp <corpId>]"],
|
||||
options: [
|
||||
{ flag: "--sn, --sns <SNs>", description: "Target specific document SNs (comma-separated, e.g. B26002307,B26002144); fast indexed search bypassing full pagination" },
|
||||
{ flag: "--with-flow", description: "Enrich export with Hose human actions and opinions in E人工行为 / E人工意见 columns (rejection 2-B, mid-flow modifications, action emojis)" },
|
||||
{ flag: "--start <date>", description: "Filter records by start date (YYYY-MM-DD or ms timestamp)" },
|
||||
{ flag: "--end <date>", description: "Filter records by end date (YYYY-MM-DD or ms timestamp)" },
|
||||
{ flag: "--start-date <date>", description: "Filter records by start date (YYYY-MM-DD or ms timestamp)" },
|
||||
{ flag: "--end-date <date>", description: "Filter records by end date (YYYY-MM-DD or ms timestamp)" },
|
||||
{ flag: "--force", description: "Force export when time range exceeds 180 days" },
|
||||
{ flag: "--status <status>", description: "Filter by system status (e.g. completed, processing)" },
|
||||
{ flag: "--manual-status <status>", description: "Filter by manual approval status (e.g. APPROVED, TERMINATED)" },
|
||||
{ flag: "--completed-only", description: "Only export completed approval runs" },
|
||||
{ flag: "--limit <n>", description: "Maximum number of records to export" },
|
||||
{ flag: "--downloads, --to-downloads", description: "Save exported workbook directly to user's ~/Downloads directory" },
|
||||
{ flag: "--downloads", description: "Save exported workbook directly to user's ~/Downloads directory" },
|
||||
{ flag: "--out <file>", description: "Custom output file path" }
|
||||
]
|
||||
},
|
||||
@@ -515,7 +516,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
name: "list",
|
||||
aliases: ["search"],
|
||||
summary: "Search approval records by keyword, dates, or decision status",
|
||||
usage: ["seal-use approval-runs list|search [--query text] [--humanResult 驳回] [--manualApprovalStatus TERMINATED] [--startDate ms] [--endDate ms] [--has-extra-risk] [--limit 20] [--includeBridge true] [--corp <corpId>]"],
|
||||
usage: ["seal-use approval-runs list|search [--query text] [--human-result 驳回] [--manual-approval-status TERMINATED] [--start-date <ms>] [--end-date <ms>] [--has-extra-risk] [--limit 20] [--include-bridge] [--corp <corpId>]"],
|
||||
options: [
|
||||
{ flag: "--has-extra-risk", description: "Filter the fetched page to records with warning/error in result.otherFindings; info is excluded. Includes extraRisks with titles, levels and descriptions." },
|
||||
{ flag: "--limit <n>", description: "Records to scan before local filtering (default 50, maximum 100); no automatic pagination to fill matches" },
|
||||
@@ -597,7 +598,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "bridge",
|
||||
summary: "Inspect browser bridge integration payload",
|
||||
usage: ["seal-use approval-runs bridge [--sourceDocumentSN B26001887] [--corp <corpId>]"]
|
||||
usage: ["seal-use approval-runs bridge [--source-document-sn B26001887] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "replay",
|
||||
@@ -799,9 +800,10 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
usage: ["seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "clean",
|
||||
summary: "Clean simulation batch records",
|
||||
usage: ["seal-use simulation clean <batchId> --yes [--corp <corpId>]"]
|
||||
name: "delete",
|
||||
aliases: ["clean"],
|
||||
summary: "Delete simulation batch records",
|
||||
usage: ["seal-use simulation delete <batchId> --yes [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "specifications",
|
||||
@@ -987,9 +989,10 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
usage: ["seal-use preference thinking-depth policies upsert --json '{...}' [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "thinking-depth policies remove",
|
||||
summary: "Remove a thinking depth policy",
|
||||
usage: ["seal-use preference thinking-depth policies remove <policyId> [--dry-run] [--corp <corpId>]"]
|
||||
name: "thinking-depth policies delete",
|
||||
aliases: ["thinking-depth policies remove"],
|
||||
summary: "Delete a thinking depth policy",
|
||||
usage: ["seal-use preference thinking-depth policies delete <policyId> [--dry-run] [--corp <corpId>]"]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1342,7 +1345,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "",
|
||||
summary: "Inspect knowledge context documents",
|
||||
usage: ["seal-use context [--ruleVersion <versionId|versionNumber|latest>] [--documentLimit 50] [--corp <corpId>]"]
|
||||
usage: ["seal-use context [--rule-version <versionId|versionNumber|latest>] [--document-limit 50] [--corp <corpId>]"]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1376,7 +1379,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "search",
|
||||
summary: "Search approval knowledge documents by keyword",
|
||||
usage: ["seal-use documents search <keyword> [--maxResults 20] [--corp <corpId>]"]
|
||||
usage: ["seal-use documents search <keyword> [--max-results 20] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "create",
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { HELP_REGISTRY } from "./help.js";
|
||||
import { parseArgs } from "./parser.js";
|
||||
|
||||
/**
|
||||
* Naming charter guard (.agents/rules/cli-protocol.md "Naming Charter").
|
||||
*
|
||||
* The visible surface (help registry, mirrored into the skill docs) must present
|
||||
* one canonical spelling per concept; legacy spellings keep working as silent
|
||||
* dispatcher/parser aliases but must never appear in documentation. This test
|
||||
* fails when a camelCase flag or a retired verb/flag leaks back onto the
|
||||
* visible surface, or when a canonical flag loses its parser registration.
|
||||
*/
|
||||
|
||||
const LEGACY_SURFACE_TOKENS = [
|
||||
"--to-downloads",
|
||||
"--show-secret",
|
||||
"--maxResults",
|
||||
"--maxRuns",
|
||||
"--humanResult",
|
||||
"--manualApprovalStatus",
|
||||
"--startDate",
|
||||
"--endDate",
|
||||
"--includeBridge",
|
||||
"--ruleVersion",
|
||||
"--documentLimit"
|
||||
];
|
||||
|
||||
const VALUE_FLAG_PAIRS: Array<[kebab: string, legacyCamel: string]> = [
|
||||
["--start-date", "--startDate"],
|
||||
["--end-date", "--endDate"],
|
||||
["--max-results", "--maxResults"],
|
||||
["--human-result", "--humanResult"],
|
||||
["--manual-approval-status", "--manualApprovalStatus"],
|
||||
["--rule-version", "--ruleVersion"],
|
||||
["--document-limit", "--documentLimit"],
|
||||
["--context-lines", "--contextLines"],
|
||||
["--source-document-sn", "--sourceDocumentSN"],
|
||||
["--source-document-id", "--sourceDocumentId"]
|
||||
];
|
||||
|
||||
const BOOLEAN_FLAG_CANONICAL = ["--downloads", "--include-bridge", "--reveal"];
|
||||
|
||||
function collectSurfaceFlags(): string[] {
|
||||
const flags: string[] = [];
|
||||
const scan = (text: string) => {
|
||||
// Strip <placeholder> segments first: values like <YYYY-MM-DD|ms> contain
|
||||
// dash-led uppercase fragments that are not flags.
|
||||
for (const match of text.replace(/<[^>]*>/g, " ").matchAll(/--?[A-Za-z][A-Za-z0-9-]*/g)) {
|
||||
flags.push(match[0]);
|
||||
}
|
||||
};
|
||||
for (const area of HELP_REGISTRY) {
|
||||
for (const command of area.commands) {
|
||||
for (const usage of command.usage) {
|
||||
scan(usage);
|
||||
}
|
||||
for (const option of command.options ?? []) {
|
||||
scan(option.flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
describe("naming charter: visible help surface", () => {
|
||||
test("documents only lowercase kebab-case flags", () => {
|
||||
const offenders = collectSurfaceFlags().filter((flag) => /[A-Z]/.test(flag));
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
|
||||
test("never documents retired flag spellings", () => {
|
||||
const serialized = JSON.stringify(HELP_REGISTRY);
|
||||
const offenders = LEGACY_SURFACE_TOKENS.filter((token) => serialized.includes(token));
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("naming charter: parser accepts canonical and legacy spellings", () => {
|
||||
test("kebab canonical and camel legacy value flags both parse", () => {
|
||||
for (const [kebab, legacy] of VALUE_FLAG_PAIRS) {
|
||||
const canonical = parseArgs(["x", kebab, "v"]);
|
||||
const legacyArgs = parseArgs(["x", legacy, "v"]);
|
||||
expect(canonical.options[kebab.slice(2)]).toBe("v");
|
||||
expect(legacyArgs.options[legacy.slice(2)]).toBe("v");
|
||||
}
|
||||
});
|
||||
|
||||
test("canonical boolean flags parse without a value", () => {
|
||||
for (const flag of BOOLEAN_FLAG_CANONICAL) {
|
||||
const parsed = parseArgs(["x", flag]);
|
||||
expect(parsed.options[flag.slice(2)]).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("naming charter: canonical accept-sets are wired in commands", () => {
|
||||
const read = (path: string) => readFileSync(fileURLToPath(new URL(path, import.meta.url)), "utf8");
|
||||
|
||||
test("webhook resource-pack export reads --out and --downloads (no silent ignore)", () => {
|
||||
const source = read("./commands/webhook.ts");
|
||||
expect(source).toContain("stringOption(args.options.out) ??");
|
||||
expect(source).toContain("booleanOption(args.options.downloads) ??");
|
||||
expect(source).toContain("booleanOption(args.options.download) ??");
|
||||
});
|
||||
|
||||
test("webhook secret reveal accepts --reveal alongside legacy --show-secret", () => {
|
||||
const source = read("./parser.ts");
|
||||
expect(source).toContain("booleanOption(options.reveal)");
|
||||
expect(source).toContain('booleanOption(options["show-secret"])');
|
||||
});
|
||||
|
||||
test("approval-runs reads canonical --start-date/--end-date everywhere", () => {
|
||||
const source = read("./commands/approval-runs.ts");
|
||||
const startDateReads = source.match(/args\.options\["start-date"\]/g)?.length ?? 0;
|
||||
const endDateReads = source.match(/args\.options\["end-date"\]/g)?.length ?? 0;
|
||||
expect(startDateReads).toBeGreaterThanOrEqual(3);
|
||||
expect(endDateReads).toBeGreaterThanOrEqual(3);
|
||||
});
|
||||
});
|
||||
+14
-9
@@ -30,7 +30,7 @@ export const BOOLEAN_FLAGS = new Set([
|
||||
"download", "downloads", "dry-run", "dryRun", "elevate-hose", "enabled",
|
||||
"exclude-deleted", "extract", "extract-expenses", "extractExpenses", "fail-on-flips", "flow", "force", "full", "glossary", "has-input", "has-output", "help",
|
||||
"has-extra-risk", "hasExtraRisk", "hose", "hose-outbound", "hose-sso", "hoseOutbound", "hoseSso", "include-deleted", "include-io-preview", "include-simulation", "include-unchanged",
|
||||
"includeBridge", "includeSimulation", "includeUnchanged", "local", "no-attachments", "no-flow", "no-glossary",
|
||||
"include-bridge", "includeBridge", "includeSimulation", "includeUnchanged", "local", "no-attachments", "no-flow", "no-glossary",
|
||||
"no-wait", "noWait", "outbound", "overwrite", "plain", "publish", "quiet",
|
||||
"r", "raw-json", "rawJson", "recode", "refresh", "refresh-if-missing", "reveal", "rotate-secret", "rotateSecret",
|
||||
"save", "silent", "silent-save", "simulation", "skip-expense-extraction", "skip-extract", "skip-invoice-generation",
|
||||
@@ -47,17 +47,17 @@ export const VALUE_FLAGS = new Set([
|
||||
"access-token", "accessToken", "action", "add-approver-ids", "addApproverIds", "ai", "ai-accuracy", "aiAccuracy", "app-key", "app-security", "appKey", "appSecurity",
|
||||
"base-url", "batch", "batch-id", "batchId", "both", "both-accurate", "bothAccurate", "business-codes", "businessCodes",
|
||||
"channel", "chrome", "code", "comment", "concurrency", "confirm-code", "confirmCode", "content", "content-file", "content-hints", "content-type", "contentFile",
|
||||
"content-format", "contentFormat", "contentType", "context-chars", "contextLines", "corp", "corp-id", "corpId", "corporation-id", "corporationId", "date",
|
||||
"content-format", "contentFormat", "contentType", "context-chars", "context-lines", "contextLines", "corp", "corp-id", "corpId", "corporation-id", "corporationId", "date",
|
||||
"dedupe-by", "dedupeBy", "default", "departmentId", "dept", "desc",
|
||||
"description", "description-file", "descriptionFile", "dir", "doc-id-prefix", "doc-id-suffix",
|
||||
"docIdPrefix", "docIdSuffix", "document-id", "document-sn", "document-sns", "document-type",
|
||||
"documentId", "documentLimit", "documentSn", "documentType", "domain", "enable",
|
||||
"documentId", "document-limit", "documentLimit", "documentSn", "documentType", "domain", "enable",
|
||||
"end", "end-date", "end-time", "endDate", "endTime", "env",
|
||||
"environment", "expire", "expires-in", "expiresIn", "fields", "file", "file-id", "file-name", "flow-concurrency",
|
||||
"flow-id", "flow-ids", "flow-status-list", "flowId", "flowIds", "flowStatusList", "format", "from",
|
||||
"from-link", "host", "human", "human-accuracy", "humanAccuracy", "humanResult", "id", "input", "integration",
|
||||
"from-link", "host", "human", "human-accuracy", "humanAccuracy", "human-result", "humanResult", "id", "input", "integration",
|
||||
"json", "json-path", "key-id", "keyId", "keyword", "ledger", "level", "limit",
|
||||
"lines", "link", "linter", "manual-status", "manualApprovalStatus", "manualStatus",
|
||||
"lines", "link", "linter", "manual-approval-status", "manual-status", "manualApprovalStatus", "manualStatus",
|
||||
"max-chars", "max-preview-chars", "maxChars", "maxResults", "max-results", "message-id", "messageId", "metadata", "metadata-key", "min-score", "minScore", "mode",
|
||||
"max-runs", "max-scan", "maxScan",
|
||||
"month",
|
||||
@@ -70,11 +70,11 @@ export const VALUE_FLAGS = new Set([
|
||||
"reviewed-by", "reviewedBy",
|
||||
"report-id",
|
||||
"repo", "request-ids", "requestIds", "resubmit-method", "resubmitMethod", "result-url", "resultUrl", "reuse-window",
|
||||
"reuseWindow", "rule", "rule-hints", "rule-id", "ruleId", "ruleVersion", "runtime-id",
|
||||
"reuseWindow", "rule", "rule-hints", "rule-id", "ruleId", "rule-version", "ruleVersion", "runtime-id",
|
||||
"runtimeId", "samples", "scenarios", "schema-config", "schemaConfig", "scope",
|
||||
"sealUrl", "search", "secret", "selector", "session-id", "sign-key", "signKey",
|
||||
"simulationBatchId", "since", "sn", "sn-prefix", "sn-suffix", "snPrefix",
|
||||
"snSuffix", "sns", "source-corp", "source-system", "sourceCorp", "sourceDocumentId",
|
||||
"simulation-batch-id", "simulationBatchId", "since", "sn", "sn-prefix", "sn-suffix", "snPrefix",
|
||||
"snSuffix", "sns", "source-corp", "source-document-id", "source-document-sn", "source-system", "sourceCorp", "sourceDocumentId",
|
||||
"sourceDocumentSN", "sourceSystem", "staff-id", "staff-name", "staff-phone", "staffId",
|
||||
"staffName", "staffPhone", "start", "start-date", "start-time", "startDate",
|
||||
"startTime", "state", "status", "strictness", "tag", "tag-id",
|
||||
@@ -360,7 +360,12 @@ export function webhookRateOption(options: Record<string, string | boolean>): nu
|
||||
}
|
||||
|
||||
export function webhookShowSecretOption(options: Record<string, string | boolean>): boolean | undefined {
|
||||
return booleanOption(options.showSecret) ?? booleanOption(options["show-secret"]);
|
||||
return (
|
||||
booleanOption(options.reveal) ??
|
||||
booleanOption(options.r) ??
|
||||
booleanOption(options.showSecret) ??
|
||||
booleanOption(options["show-secret"])
|
||||
);
|
||||
}
|
||||
|
||||
export function materialPackFilePolicyOptions(
|
||||
|
||||
@@ -157,12 +157,12 @@ export const EMBEDDED_DOMAIN_CAPABILITIES: DomainCapabilitySpec[] = [
|
||||
{
|
||||
domain: "simulation (模拟演练)",
|
||||
summary: "合思单据指定、材料包导入、飞书/泛微三方审批定义演练、批次轮询等待与数据清理",
|
||||
primaryCommands: ["simulation create", "simulation status", "simulation wait", "simulation clean"]
|
||||
primaryCommands: ["simulation create", "simulation status", "simulation wait", "simulation delete"]
|
||||
},
|
||||
{
|
||||
domain: "webhook (通道与重放)",
|
||||
summary: "Webhook 回调通道配置、材料包校验推送、线上单据向 Webhook 通道测试重放",
|
||||
primaryCommands: ["webhook list", "webhook add", "webhook replay", "webhook material-pack push"]
|
||||
primaryCommands: ["webhook list", "webhook create", "webhook replay", "webhook material-pack push"]
|
||||
},
|
||||
{
|
||||
domain: "deploy (费控集成)",
|
||||
|
||||
@@ -401,7 +401,7 @@ describe("Webhook material pack", () => {
|
||||
const res = await checkWebhookReadiness(client, mockCorp)
|
||||
expect(res.ready).toBe(false)
|
||||
expect(res.activeWebhooks).toHaveLength(0)
|
||||
expect(res.nextAction).toContain("seal-use webhook add")
|
||||
expect(res.nextAction).toContain("seal-use webhook create")
|
||||
})
|
||||
|
||||
test("checkWebhookReadiness flags not ready when auth fails", async () => {
|
||||
|
||||
@@ -121,7 +121,7 @@ export async function checkWebhookReadiness(
|
||||
nextAction = `seal-use auth diagnose${corpFlag}`;
|
||||
} else if (activeWebhooks.length === 0) {
|
||||
statusMessage = "当前企业尚未配置任何 Webhook 集成通道";
|
||||
nextAction = `seal-use webhook add --name "默认入站通道" --result-url "https://your-domain.com/callback"${corpFlag}`;
|
||||
nextAction = `seal-use webhook create --name "默认入站通道" --result-url "https://your-domain.com/callback"${corpFlag}`;
|
||||
} else if (materialPack && !materialPack.valid) {
|
||||
statusMessage = `资源包预检失败: ${materialPack.errors?.join("; ")}`;
|
||||
nextAction = `seal-use webhook resource-pack preview ${materialPack.filePath}${corpFlag}`;
|
||||
|
||||
Reference in new issue
Block a user