Files
seal-use/src/cli/help.ts
T

1442 lines
62 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { ParsedArgs } from "./types.js";
import { usageError } from "./errors.js";
export interface CommandOptionHelp {
flag: string;
description: string;
}
export interface CommandHelp {
name: string;
aliases?: string[];
group?: string;
summary?: string;
usage: string[];
options?: CommandOptionHelp[];
description?: string;
}
export interface AreaHelp {
area: string;
title: string;
description?: string;
groupOrder?: string[];
commands: CommandHelp[];
}
export const HELP_REGISTRY: AreaHelp[] = [
{
area: "corps",
title: "Enterprise and tenant management",
description: "Manage enterprise configurations, environment modes, test bindings, and syncing.",
groupOrder: ["企业接入", "发现与选择", "企业配置", "测试配对与验证", "Hose 专属能力"],
commands: [
{
name: "list",
group: "发现与选择",
summary: "List configured enterprises sorted by 7-day usage frequency",
usage: ["seal-use corps list [query] [--all] [--limit <n>] [--env <production|test>] [--strict] [--corp <corpId>]"],
options: [
{ flag: "--all", description: "Display all configured enterprises without the default 10-item limit" },
{ flag: "--limit <n>", description: "Maximum number of enterprises to display (defaults to 10)" },
{ flag: "--env <production|test>", description: "Filter enterprises by environment ('production' or 'test')" },
{ flag: "--strict", description: "Use strict exact substring matching instead of default soft fuzzy search" }
]
},
{
name: "search",
aliases: ["find"],
group: "发现与选择",
summary: "Search configured enterprises with intelligent soft fuzzy matching",
usage: ["seal-use corps search <query> [--env <production|test>] [--strict]"],
options: [
{ flag: "--env <production|test>", description: "Filter enterprises by environment ('production' or 'test')" },
{ flag: "--strict", description: "Use strict exact substring matching instead of default soft fuzzy search" }
],
description: "Searches enterprise ID, name, staff ID, domain, tenant slug, environment, or bindings. Uses soft search by default (case-insensitive, Chinese homophones, front/back nasal vowels, initials, typo/missing letter tolerance)."
},
{
name: "get",
aliases: ["show"],
group: "发现与选择",
summary: "Get rich details and configuration of an enterprise",
usage: ["seal-use corps get <corpId>"],
description: "Retrieves complete enterprise details (URLs, tenant slugs, custom headers/cookies, staff IDs, relations, config file path) with sensitive secrets safely redacted."
},
{
name: "current",
group: "发现与选择",
summary: "Show active enterprise in stateful mode",
usage: ["seal-use corps current [--corp <corpId>]"]
},
{
name: "switch",
group: "发现与选择",
summary: "Switch default active enterprise",
usage: ["seal-use corps switch <corpId>"]
},
{
name: "mark",
group: "企业配置",
summary: "Mark enterprise environment as production or test",
usage: ["seal-use corps mark <corpId> --env <production|test> [--confirm]"],
options: [
{ flag: "--env <production|test>", description: "Target environment: 'production' or 'test' (required)" },
{ flag: "--confirm", description: "Confirm the environment update (required)" }
],
description: "Explicitly updates an enterprise's environment tag. Requires --confirm to prevent accidental changes."
},
{
name: "rename",
group: "企业配置",
summary: "Rename an enterprise display name",
usage: ["seal-use corps rename <corpId> --name <newName>"],
options: [
{ flag: "--name <newName>", description: "New human-readable enterprise name (required)" }
],
description: "Safely updates the display name of a configured enterprise without modifying underlying files manually."
},
{
name: "bind-test",
group: "测试配对与验证",
summary: "Bind a production enterprise to a test enterprise (1-to-1 association)",
usage: [
"seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]",
"seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]"
],
options: [
{ flag: "--confirm", description: "Explicitly confirm binding and tag test environment (required)" },
{ flag: "--force", description: "Force re-binding if the production enterprise is already bound" },
{ flag: "--corp <corpId>", description: "Specify production enterprise ID or name" }
],
description: "Establishes a strict 1-to-1 association between a production enterprise and a test enterprise. Automatically marks the test enterprise with environment 'test'."
},
{
name: "unbind-test",
group: "测试配对与验证",
summary: "Unbind a production and test enterprise association",
usage: ["seal-use corps unbind-test [<corpId>] [--confirm]"],
options: [
{ flag: "--confirm", description: "Explicitly confirm unbinding both sides (required)" },
{ flag: "--corp <corpId>", description: "Specify enterprise ID or name" }
],
description: "Removes the 1-to-1 test association from both the production enterprise and the test enterprise."
},
{
name: "sync-test",
group: "测试配对与验证",
summary: "Synchronize rules and preferences from production to test enterprise",
usage: ["seal-use corps sync-test [<prodCorpId>] [--dry-run] [--yes] [--version-name <name>]"],
options: [
{ flag: "--dry-run", description: "Preview sync diff without making network mutations (default)" },
{ flag: "--yes", description: "Execute synchronization and publish new rule version on test enterprise" },
{ flag: "--version-name <name>", description: "Custom version name for published test rule version" },
{ flag: "--corp <corpId>", description: "Specify production enterprise ID or name" }
],
description: "Overwrites test enterprise decision preferences with production preferences, syncs production draft rules to test enterprise, and immediately publishes a new version on the test enterprise. Production rules remain safe in draft state."
},
{
name: "replay-test",
group: "测试配对与验证",
summary: "Replay approval records from production enterprise to bound test enterprise via Webhook",
usage: [
"seal-use corps replay-test [<prodCorpId>] [--record-id <id>] [--sn <sn>] [--limit <n>] [--status <status>] [--webhook <idOrName>] [--sn-suffix <str>] [--dry-run] [--confirm|--yes] [--force]"
],
options: [
{ flag: "<prodCorpId>", description: "Production enterprise ID (default: active enterprise)" },
{ flag: "--record-id <id>", description: "Replay a specific approval run ID" },
{ flag: "--sn <sn>", description: "Replay a specific document SN" },
{ flag: "--limit <n>", description: "Batch replay latest N records from production (default: 1)" },
{ flag: "--status <status>", description: "Filter records by status (e.g. completed, failed, rejected)" },
{ flag: "--webhook <idOrName>", description: "Target Webhook integration on test enterprise" },
{ flag: "--sn-suffix <str>", description: "Optional suffix appended to documentSN" },
{ flag: "--dry-run", description: "Preview payload without sending" },
{ flag: "--confirm, --yes", description: "Confirm live replay and send the payload" },
{ flag: "--force", description: "Allow replay without a bound test enterprise or into a non-test target" }
],
description: "Pulls production approval records from the production enterprise and replays them into the bound test enterprise's Webhook channel for rule verification."
},
{
name: "add-hose-persistent",
group: "企业接入",
summary: "Add a durable Hose/Ekuaibao enterprise configuration",
usage: ["seal-use corps add-hose-persistent --json '{\"name\":\"企业名称\",\"domain\":\"https://app.ekuaibao.com\",\"appKey\":\"...\",\"appSecurity\":\"...\",\"proxyStaffBizId\":\"corpId:staffId\"}'"],
description: "使用长期 Hose OpenAPI 凭据接入企业并持久化配置。"
},
{
name: "add-seal-bearer",
group: "企业接入",
summary: "Add a native Seal enterprise from a Bearer session",
usage: ["seal-use corps add-seal-bearer --json '{\"sealUrl\":\"https://tenant.sealai.cc\",\"token\":\"seal-bearer-token\"}'"],
description: "使用 Seal Bearer Token 接入原生 Seal 企业。"
},
{
name: "add-hose-web-session",
group: "企业接入",
summary: "Import a temporary Hose web session and exchange it for a Seal session",
usage: ["seal-use corps add-hose-web-session --json '{\"baseUrl\":\"https://wx2.ekuaibao.com\",\"corpId\":\"...\",\"staffId\":\"...\",\"accessToken\":\"...\"}'"],
options: [
{ flag: "--name <name>", description: "Optional custom name for the enterprise" },
{ flag: "--domain <url>", description: "Hose web-session base URL (alias: --base-url)" },
{ flag: "--corp-id <id>", description: "Hose corporation ID" },
{ flag: "--staff-id <id>", description: "Hose web-session staff ID (normally discovered automatically)" },
{ flag: "--access-token <token>", description: "Hose web-session accesstoken" },
{ flag: "--overwrite", description: "Overwrite existing enterprise config" },
{ flag: "--dry-run", description: "Exchange and verify the session without saving local config" }
],
description: "将 Agent 从合思后台 cURL 提取出的 accesstoken 保存为 Hose closeToken,并绑定 corpId/staffId;调用 Seal 能力时再经 Hose→Seal SSO 换取短期 Seal Bearer。不提取或持久化 OpenAPI appKey/appSecurity。"
},
{
name: "add-link",
group: "企业接入",
summary: "Import enterprise configuration from a Seal delegation link or Hose assistance link",
usage: [
"seal-use corps add-link <url> [--name <customName>] [--elevate-hose] [--app-key <key>] [--key-id <id>] [--overwrite] [--dry-run]"
],
options: [
{ flag: "--name <name>", description: "Optional custom name for the enterprise" },
{ flag: "--dry-run", description: "Preview link resolution and tenant metadata without saving" },
{ flag: "--elevate-hose", description: "【明确提权】从合思协助链接提取 OpenAPI 密钥并将临时会话升级为长期标准配置" },
{ flag: "--app-key <key>", description: "企业存在多套密钥时,指定使用的 appKey" },
{ flag: "--key-id <id>", description: "企业存在多套密钥时,指定使用的 keyId" },
{ flag: "--overwrite", description: "Overwrite existing enterprise config" }
]
},
{
name: "probe-hose",
group: "Hose 专属能力",
summary: "Probe Hose domains and discover enterprise identity",
usage: ["seal-use corps probe-hose --json '{\"appKey\":\"...\",\"appSecurity\":\"...\",\"domain\":\"https://...\"}'"],
description: "验证合思凭证、探测可用域名并发现企业与角色信息;不写入本地企业配置。"
},
{
name: "hose-staffs",
group: "Hose 专属能力",
summary: "Discover Hose staff candidates by role",
usage: ["seal-use corps hose-staffs --json '{\"appKey\":\"...\",\"appSecurity\":\"...\",\"role\":\"admin\"}'"],
description: "按合思角色查询员工候选;手机号默认脱敏,供 add-hose-persistent 选择管理员。"
},
{
name: "hose-extract-keys",
aliases: ["extract-keys", "extract-key", "extract-hose-keys"],
group: "Hose 专属能力",
summary: "【合思子域提权】从合思协助链接提取 OpenAPI 开发者密钥 (appKey/appSecurity)",
usage: [
"seal-use corps hose-extract-keys <url> [--reveal] [--save] [--app-key <key>] [--key-id <id>] [--name <customName>] [--overwrite]"
],
options: [
{ flag: "--reveal, -r", description: "显式揭示完整 appSecurity 明文(默认脱敏保护)" },
{ flag: "--save", description: "【提权升级】将提取到的合思 OpenAPI 密钥保存为长期标准配置" },
{ flag: "--app-key <key>", description: "存在多套密钥时指定使用的 appKey" },
{ flag: "--key-id <id>", description: "存在多套密钥时指定使用的 keyId" },
{ flag: "--name <name>", description: "Custom enterprise name when saving" },
{ flag: "--overwrite", description: "Overwrite existing enterprise config" }
],
description: "专属于合思 (Hose/合思云/易快报) 子域的能力。利用协助链接中的内部权限读取 OpenAPI 密钥,将临时会话提权为标准开发者凭据。非合思渠道企业不支持。"
},
{
name: "hose-keys",
aliases: ["keys"],
group: "Hose 专属能力",
summary: "【合思子域】查看企业已配置的合思 OpenAPI 密钥,或从协助链接中提取",
usage: [
"seal-use corps hose-keys [<url> | <corpId>] [--reveal] [--save] [--app-key <key>]"
],
options: [
{ flag: "--reveal, -r", description: "显式揭示完整 appSecurity 明文(默认脱敏保护)" },
{ flag: "--save", description: "从协助链接提取并保存为标准配置" },
{ flag: "--app-key <key>", description: "多套密钥时指定目标 appKey" }
]
},
]
},
{
area: "rules",
title: "Approval rules management",
description: "Query, search, version, lint, import, and export approval audit rules.",
commands: [
{
name: "count",
summary: "Count total rules in current enterprise",
usage: ["seal-use rules count [--corp <corpId>]"]
},
{
name: "list",
summary: "List approval rules with optional pagination and summary",
usage: ["seal-use rules list [--summary] [--count] [--limit 20] [--offset 0] [--output-file <path>] [--corp <corpId>]"],
options: [
{ flag: "--summary", description: "Output compact summary fields (code, status, strictness, scope, updatedAt)" },
{ flag: "--limit <n>", description: "Number of rules to fetch (default: 20)" },
{ flag: "--offset <n>", description: "Offset index for pagination" },
{ flag: "--full", description: "Allow large payloads beyond standard size limits" },
{ flag: "--output-file <path>", description: "Write the complete JSON payload to a file" }
]
},
{
name: "clear",
summary: "Clear all draft rules from enterprise",
usage: ["seal-use rules clear [--corp <corpId>] [--dry-run|--yes]"]
},
{
name: "versions",
summary: "List published rule versions",
usage: ["seal-use rules versions [--corp <corpId>]"]
},
{
name: "version",
summary: "Inspect a specific rule version",
usage: ["seal-use rules version <versionId|versionNumber|latest> [--corp <corpId>]"]
},
{
name: "diff",
summary: "Compare two published rule versions by persisted ID or code",
usage: ["seal-use rules diff <fromVersion> <toVersion> [--rule-id <stableRuleId>|--code <code>] [--include-unchanged] [--full] [--corp <corpId>]"],
options: [
{ flag: "--rule-id <id>", description: "Compare only one stable rule ID" },
{ flag: "--code <code>", description: "Compare only one rule code when stable ID mapping is unavailable" },
{ flag: "--include-unchanged", description: "Include unchanged rules in the structured changes list" },
{ flag: "--full", description: "Expand an oversized diff; small diffs are returned in full by default" },
{ flag: "--format unified|json", description: "Return unified diff text together with structured metadata" }
],
description: "Uses locally persisted draft IDs when available and otherwise falls back to code. Output is truncated only when the total diff exceeds the safety limit; use --full to expand it."
},
{
name: "diff-one",
summary: "Inspect one rule change",
usage: ["seal-use rules diff-one <fromVersion> <toVersion> <ruleId> [--full] [--corp <corpId>]"],
description: "Single-rule alias for rules diff; use --code when the published snapshots have no stable ID."
},
{
name: "get",
summary: "Get single rule by rule code or record ID",
usage: [
"seal-use rules get <ruleCode> [--version <number|latest>] [--corp <corpId>]",
"seal-use rules get --record-id <recordId> --runtime-id rule-205 [--corp <corpId>]"
]
},
{
name: "search",
summary: "Search rules by keyword",
usage: ["seal-use rules search <keyword> [--version <versionId|versionNumber|latest>] [--maxResults 20] [--corp <corpId>]"]
},
{
name: "lint",
summary: "Lint rule text or rule file using builtin or custom linter",
usage: ["seal-use rules lint [--file <path>] [--linter <name|path>] [--version <id|num|latest>] [--code <code>] [--rule <ruleId>] [--min-score <score>] [--level all|error|warning] [--summary] [--corp <corpId>]"]
},
{
name: "linters",
summary: "List available official and custom rule linters and directory locations",
usage: ["seal-use rules linters [--corp <corpId>]"]
},
{
name: "pull",
summary: "Export rules to local JSON file",
usage: ["seal-use rules pull [--version <id|num|latest>] [--out <file>] [--corp <corpId>]"]
},
{
name: "push",
summary: "Push rules from local JSON file to enterprise draft space",
usage: ["seal-use rules push --file <path> [--publish] [--version-name <name>] [--dry-run|--yes] [--corp <corpId>]"]
},
{
name: "map",
summary: "Inspect locally synced production/test rule code mappings",
usage: ["seal-use rules map [--version <id|num|latest>] [--code <code>] [--corp <corpId>]"]
}
]
},
{
area: "webhook",
title: "Webhook integrations and material packs",
description: "Manage incoming audit webhooks and upload offline simulation material packs.",
commands: [
{
name: "ready",
summary: "Check readiness of webhook integration and material pack",
usage: ["seal-use webhook ready [<材料包.zip>] [--webhook <idOrName>] [--corp <corpId>]"]
},
{
name: "status",
summary: "Check status of webhook integration",
usage: ["seal-use webhook status [<材料包.zip>] [--corp <corpId>]"]
},
{
name: "list",
summary: "List registered webhook endpoints",
usage: ["seal-use webhook list [--query <text>] [--show-secret] [--corp <corpId>]"]
},
{
name: "get",
aliases: ["find"],
summary: "Get webhook endpoint details",
usage: ["seal-use webhook get|find <idOrName> [--show-secret] [--corp <corpId>]"]
},
{
name: "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>]"]
},
{
name: "update",
summary: "Update an existing webhook endpoint",
usage: ["seal-use webhook update <idOrName> [--name <name>] [--result-url <url>] [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret <secret>|--rotate-secret] [--min-file-size <bytes>] [--max-file-size <bytes>] [--allowed-extensions <.pdf,.xlsx,...>] [--clear-max-file-size] [--dry-run] [--corp <corpId>]"]
},
{
name: "delete",
summary: "Delete a webhook endpoint",
usage: ["seal-use webhook delete <idOrName> [--yes|--dry-run] [--corp <corpId>]"]
},
{
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 --record-ids <id1,id2> [--corp <corpId>]"
],
options: [
{ flag: "<recordId>", description: "Single approval run record ID to export" },
{ flag: "--record-ids <ids>", description: "Comma-separated list of approval run record IDs" },
{ flag: "--limit <n>", description: "Limit number of records to export (default: 10)" },
{ flag: "--status <status>", description: "Filter records by status (e.g. completed, approved)" },
{ flag: "--start-date <YYYY-MM-DD>", description: "Filter records starting from date" },
{ flag: "--end-date <YYYY-MM-DD>", description: "Filter records up to date" },
{ 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: "--corp <corpId>", description: "Source enterprise configuration ID" }
]
},
{
name: "resource-pack preview",
summary: "Inspect and validate a Webhook resource pack ZIP or Excel sheet (alias: pack preview)",
usage: ["seal-use webhook resource-pack preview <资源包.zip|信息表.xlsx> [--min-file-size <bytes>] [--max-file-size <bytes>] [--allowed-extensions <.pdf,.xlsx,...>] [--corp <corpId>]"]
},
{
name: "resource-pack push",
summary: "Upload attachments and push documents from a resource pack ZIP to Webhook (alias: pack push)",
usage: ["seal-use webhook resource-pack push <资源包.zip|信息表.xlsx> [--webhook <idOrName>] [--corp <corpId>]"]
},
{
name: "replay",
usage: [
"seal-use webhook replay <recordId> [--webhook <idOrName>] [--sn-suffix <str>] [--dry-run] [--corp <corpId>]",
"seal-use webhook replay --sn <documentSN> [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>]",
"seal-use webhook replay --limit <n> [--status <status>] [--source-corp <corpId>] [--target-corp <corpId>]"
],
options: [
{ flag: "<recordId>", description: "Approval run record ID to replay" },
{ flag: "--sn <sn>", description: "Lookup approval record by source document SN if recordId not given" },
{ flag: "--limit <n>", description: "Batch replay latest N records from source enterprise" },
{ flag: "--status <status>", description: "Filter records by status (e.g. completed, failed, rejected)" },
{ flag: "--webhook <idOrName>", description: "Target Webhook integration (auto-locks if only one exists)" },
{ flag: "--source-corp <corpId>", description: "Source enterprise where records reside (alias: --prod-corp)" },
{ flag: "--target-corp <corpId>", description: "Target enterprise where records are pushed (alias: --test-corp)" },
{ flag: "--sn-suffix <str>", description: "Optional suffix appended to documentSN and documentId" },
{ flag: "--sn-prefix <str>", description: "Optional prefix prepended to documentSN and documentId" },
{ flag: "--dry-run", description: "Generate and output Webhook payload JSON without sending HTTP request" },
{ flag: "--force", description: "Allow replaying to a production enterprise" }
],
description: "Extracts structured form fields from historical approval records (Webhook or Hose source), sanitizes field types, and pushes documents to the target Webhook channel. Automatically infers 1-to-1 bound test/production enterprise pairs."
}
]
},
{
area: "approval-runs",
title: "Approval runs and audit execution records",
description: "Inspect live and historical AI approval decisions, cited rules, and attachments.",
commands: [
{
name: "summary",
summary: "Daily summary of approval runs",
usage: ["seal-use approval-runs summary [--date YYYY-MM-DD] [--timezone Asia/Shanghai] [--corp <corpId>]"]
},
{
name: "stats",
summary: "Statistical aggregation of approval run metrics",
usage: ["seal-use approval-runs stats [--since 3months] [--dedupe-by sourceDocumentSN|sourceDocumentId|id] [--corp <corpId>]"]
},
{
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>]"]
},
{
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>]"],
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: "--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: "--out <file>", description: "Custom output file path" }
]
},
{
name: "hose-flow",
aliases: ["flow"],
summary: "【合思专属】Get Hose approval flow timeline, staff opinions, and align with AI runs",
usage: ["seal-use approval-runs hose-flow <recordId|SN> [--corp <corpId>]"]
},
{
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] [--limit 20] [--includeBridge true] [--corp <corpId>]"]
},
{
name: "pick",
summary: "Locate single approval run by document SN",
usage: ["seal-use approval-runs pick --sn <documentSN> [--batch <batchId>] [--latest] [--fields recordId,status,aiDecision] [--corp <corpId>]"]
},
{
name: "get",
summary: "Get detailed approval record payload",
usage: ["seal-use approval-runs get <recordId> [--summary] [--fields metadata|document.fields,result.summary] [--full] [--output-file file.json] [--corp <corpId>]"]
},
{
name: "cited-rules",
summary: "Inspect rules cited by AI in an approval decision",
usage: ["seal-use approval-runs cited-rules <recordId> [--corp <corpId>]"]
},
{
name: "document-summary",
summary: "Inspect parsed source document summary",
usage: ["seal-use approval-runs document-summary <recordId> [--corp <corpId>]"]
},
{
name: "attachments",
summary: "Inspect and list attachments for approval run",
usage: [
"seal-use approval-runs attachments <recordId> [--summary] [--corp <corpId>]",
"seal-use approval-runs attachments download <recordId> [--all] [--name <name>] [--out-dir <dir>] [--corp <corpId>]"
]
},
{
name: "result",
summary: "Get decision result for an approval run",
usage: ["seal-use approval-runs result <recordId> [--summary] [--corp <corpId>]"]
},
{
name: "link",
aliases: ["url"],
summary: "Get web console link for an approval run (Seal AI audit result or Hose original document)",
usage: [
"seal-use approval-runs link <recordId> [--corp <corpId>]",
"seal-use approval-runs link <recordId> --auto-login [--expire 7200] [--corp <corpId>]",
"seal-use approval-runs link <recordId> --type hose-document [--corp <corpId>]",
"seal-use approval-runs link --sn <documentSN> [--auto-login] [--corp <corpId>]"
],
options: [
{
flag: "--type <seal-result|hose-document>",
description: "Link type: 'seal-result' (Seal AI audit result page, default) or 'hose-document' (Hose original form)"
},
{
flag: "--auto-login",
description: "Generate auto-login ticketed link (for seal-result type, valid for --expire seconds)"
},
{
flag: "--expire <seconds>",
description: "Auto-login ticket expiration in seconds (default: 7200)"
}
]
},
{
name: "bridge",
summary: "Inspect browser bridge integration payload",
usage: ["seal-use approval-runs bridge [--sourceDocumentSN B26001887] [--corp <corpId>]"]
},
{
name: "replay",
summary: "Replay approval run record into a Webhook integration",
usage: [
"seal-use approval-runs replay <recordId> [--webhook <idOrName>] [--sn-suffix <str>] [--dry-run] [--corp <corpId>]",
"seal-use approval-runs replay --sn <documentSN> [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>]",
"seal-use approval-runs replay --limit <n> [--status <status>] [--source-corp <corpId>] [--target-corp <corpId>]"
],
options: [
{ flag: "<recordId>", description: "Approval run record ID" },
{ flag: "--sn <sn>", description: "Lookup approval record by source document SN" },
{ flag: "--limit <n>", description: "Batch replay latest N records" },
{ flag: "--status <status>", description: "Filter records by status" },
{ flag: "--webhook <idOrName>", description: "Target Webhook integration" },
{ flag: "--source-corp <corpId>", description: "Source enterprise where records reside" },
{ flag: "--target-corp <corpId>", description: "Target enterprise where records are pushed" },
{ flag: "--sn-suffix <str>", description: "Optional suffix appended to documentSN" },
{ flag: "--dry-run", description: "Preview payload without sending" }
]
}
]
},
{
area: "simulation",
title: "Simulation testing engine",
description: "Execute and analyze offline or HoseCloud batch simulations against approval rules.",
commands: [
{
name: "batch-records",
summary: "Fetch records for a simulation batch",
usage: ["seal-use simulation batch-records <batchId> [--corp <corpId>]"]
},
{
name: "create",
summary: "Trigger a new simulation batch",
usage: [
"seal-use simulation create --mode hosecloud --flow-ids \"B26017701,B26022501\" [--wait] [--timeout 10m] [--poll-interval 2s] [--reject-node 财务] [--thinking-depth default|medium|high] [--skip-invoice-generation|--skip-invoice-generation false] [--no-wait] [--corp <corpId>]",
"seal-use simulation create --mode material_pack --package-ids <materialPackageId> [--template-id conference_reimbursement_v1] [--schema-config file.json] [--corp <corpId>]",
"seal-use simulation create --source-system weaver --request-ids \"req-01,req-02\" [--corp <corpId>]"
]
},
{
name: "status",
summary: "Check current progress of a simulation batch",
usage: ["seal-use simulation status <batchId> [--corp <corpId>]"]
},
{
name: "wait",
summary: "Wait synchronously for simulation batch to finish",
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> [--corp <corpId>]"]
},
{
name: "specifications",
summary: "Query simulation specifications",
usage: ["seal-use simulation specifications [--integration <sign-key>] [--corp <corpId>]"]
},
{
name: "approval-definitions",
summary: "Query simulation approval definitions",
usage: ["seal-use simulation approval-definitions [--corp <corpId>]"]
},
{
name: "list",
summary: "List recent simulation batches",
usage: ["seal-use simulation list [--limit 50] [--corp <corpId>]"]
},
{
name: "get",
summary: "Get details for simulation batch",
usage: ["seal-use simulation get <batchId> [--corp <corpId>]"]
},
{
name: "templates",
summary: "List available simulation templates",
usage: ["seal-use simulation templates [--corp <corpId>]"]
},
{
name: "integrations",
summary: "List available simulation integrations",
usage: ["seal-use simulation integrations [--corp <corpId>]"]
},
{
name: "package-upload",
summary: "Upload a simulation material package",
usage: ["seal-use simulation package-upload <材料包.zip> [--corp <corpId>]"]
}
]
},
{
area: "deploy",
title: "Deployment and cloud synchronization",
description: "Manage HoseCloud integration configurations and synchronization.",
commands: [
{
name: "hosecloud requirements",
summary: "Check HoseCloud deployment requirements",
usage: ["seal-use deploy hosecloud requirements [--corp <corpId>]"]
},
{
name: "hosecloud list",
summary: "List HoseCloud deployment targets",
usage: ["seal-use deploy hosecloud list [--corp <corpId>]"]
},
{
name: "hosecloud get",
summary: "Get HoseCloud deployment details",
usage: ["seal-use deploy hosecloud get <sign-key> [--corp <corpId>]"]
},
{
name: "hosecloud status",
summary: "Check HoseCloud deployment status",
usage: ["seal-use deploy hosecloud status [--corp <corpId>]"]
},
{
name: "hosecloud configure",
summary: "Configure HoseCloud deployment settings",
usage: ["seal-use deploy hosecloud configure --json '{...}' [--dry-run] [--corp <corpId>]"]
},
{
name: "hosecloud sync",
summary: "Synchronize HoseCloud rules and definitions",
usage: ["seal-use deploy hosecloud sync <sign-key> [--corp <corpId>]"]
}
]
},
{
area: "preference",
title: "Audit preferences and thinking depth",
description: "Manage AI decision preferences, strictness, and thinking depth policies.",
commands: [
{
name: "get",
summary: "Get current decision preference configuration",
usage: ["seal-use preference get [--corp <corpId>]"]
},
{
name: "decision update",
summary: "Update decision preference rules",
usage: ["seal-use preference decision update --json '{\"explicitApprove\":\"...\"}' [--dry-run] [--corp <corpId>]"]
},
{
name: "thinking-depth set",
summary: "Set default thinking depth",
usage: ["seal-use preference thinking-depth set --default <medium|high> [--dry-run] [--corp <corpId>]"]
},
{
name: "thinking-depth policies list",
summary: "List thinking depth policies",
usage: ["seal-use preference thinking-depth policies list [--corp <corpId>]"]
},
{
name: "thinking-depth policies upsert",
summary: "Upsert a thinking depth policy",
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>]"]
}
]
},
{
area: "config",
title: "CLI and global workspace configuration",
description: "Manage configuration paths, stateful/stateless mode, test directory, and rule linter.",
commands: [
{
name: "paths",
summary: "Display active configuration file and directory paths",
usage: ["seal-use config paths"]
},
{
name: "get",
aliases: ["status"],
summary: "Display current global configuration",
usage: ["seal-use config get"]
},
{
name: "mode",
summary: "Configure stateful or stateless CLI operating mode",
usage: ["seal-use config mode <stateful|stateless> [--corp <corpId>]"]
},
{
name: "test-dir",
aliases: ["test-enterprises-dir"],
summary: "Set or clear global test enterprises directory",
usage: ["seal-use config test-dir [<path>|--clear]"]
},
{
name: "lint",
summary: "Configure automatic rule linter status and thresholds",
usage: ["seal-use config lint [status|enable|disable] [--linter <name|path>] [--min-score <score>]"]
}
]
},
{
area: "auth",
title: "Authentication and session diagnostics",
description: "Diagnose upstream token status and generate provisional assistance links.",
commands: [
{
name: "check",
summary: "Check auth session and platform connectivity",
usage: ["seal-use auth check [--corp <corpId>]"]
},
{
name: "link",
summary: "【Seal 审核后台】生成免密登录/委托访问直达链接",
usage: [
"seal-use auth link [--note <note>] [--corp <corpId>]",
"seal-use auth link --from-link <url> [--note <note>]"
],
options: [
{ flag: "--note <note>", description: "委托授权备注说明(如:演示测试、外部审计)" },
{ flag: "--from-link <url>", description: "直接由合思协助链接换取 Seal 委托直达链接" }
],
description:
"生成访问当前企业 Seal AI 智能审核后台 (https://<tenant>.sealai.cc/delegate) 的免密直达链接。主体作用于 Seal 审核后台。"
},
{
name: "link list",
summary: "【Seal 审核后台】列出当前租户已生效的委托授权令牌 (Delegation Tokens)",
usage: ["seal-use auth link list [--corp <corpId>]"],
description: "查询已在 Seal 平台签发的委托授权记录。若返回 [] 表示当前租户暂无有效委托。"
},
{
name: "link revoke",
summary: "【Seal 审核后台】撤销指定的 Seal 委托授权令牌",
usage: ["seal-use auth link revoke <tokenId> [--corp <corpId>]"]
},
{
name: "hose-link",
summary: "【合思外部主站】生成免密登录/第三方协助入口链接",
usage: ["seal-use auth hose-link [--corp <corpId>] [--expire 7200] [--force]"],
options: [
{ flag: "--expire <seconds>", description: "链接有效时间(秒),默认 7200,支持如 86400(1天)" },
{ flag: "--force, --refresh, -f", description: "强制向合思 OpenAPI 申请全新临时凭证" }
],
description:
"专用于合思 (Hose) 来源企业。向合思申请临时 ticket,生成直达外部合思/易快报主站 (https://app.ekuaibao.com/web/thirdparty.html) 的免密登录链接。若需生成 Seal 自身的审核后台访问链接,请使用 'seal-use auth link'。"
},
{
name: "hose-extract-keys",
aliases: ["extract-keys", "extract-key", "extract-hose-keys"],
summary: "【合思子域提权】从合思协助链接提取 OpenAPI 开发者密钥并可选升级配置",
usage: [
"seal-use auth hose-extract-keys <url> [--reveal] [--save] [--app-key <key>] [--key-id <id>] [--name <customName>] [--overwrite]"
],
options: [
{ flag: "--reveal, -r", description: "显式揭示完整 appSecurity 明文(默认脱敏保护)" },
{ flag: "--save", description: "【提权升级】直接将提取到的合思 OpenAPI 密钥持久化为标准企业配置" },
{ flag: "--app-key <key>", description: "存在多套密钥时指定使用的 appKey" },
{ flag: "--key-id <id>", description: "存在多套密钥时指定使用的 keyId" }
],
description: "专属于合思 (Hose/合思云/易快报) 子域的能力。非合思渠道企业不支持。"
},
{
name: "hose-keys",
aliases: ["keys"],
summary: "【合思子域】查看当前企业已配置的合思 OpenAPI 开发者密钥",
usage: ["seal-use auth hose-keys [--corp <corpId>] [--reveal]"],
options: [
{ flag: "--reveal, -r", description: "显式揭示完整 appSecurity 明文(默认脱敏保护)" }
],
description: "专属于合思 (Hose) 来源企业。原生 Seal 企业不包含 OpenAPI 密钥,不支持此命令。"
}
]
},
{
area: "users",
title: "User administration",
description: "Manage tenant users, phone credentials, and passwords.",
commands: [
{
name: "create",
summary: "Create a new tenant user",
usage: ["seal-use users create --name <name> --phone <phone> [--dept <deptId>] [--corp <corpId>]"]
},
{
name: "search",
summary: "Search tenant users by name or phone",
usage: ["seal-use users search <keyword> [--corp <corpId>]"]
},
{
name: "delegation",
summary: "Create delegation token for a specific user",
usage: ["seal-use users delegation <userIdOrPhone|name> [--note <note>] [--corp <corpId>]"]
},
{
name: "reset-password",
summary: "Reset user password",
usage: ["seal-use users reset-password <userId> [--corp <corpId>]"]
},
{
name: "get",
summary: "Get user details",
usage: ["seal-use users get <userId> [--corp <corpId>]"]
},
{
name: "delete",
summary: "Delete user",
usage: ["seal-use users delete <userId> [--corp <corpId>]"]
}
]
},
{
area: "contacts",
title: "Contacts directory",
description: "Query organizational departments, child hierarchies, and user mappings.",
commands: [
{
name: "departments",
summary: "List organizational departments",
usage: ["seal-use contacts departments [<departmentId>] [--corp <corpId>]"]
},
{
name: "children",
summary: "List child departments",
usage: ["seal-use contacts children <departmentId> [--corp <corpId>]"]
},
{
name: "users",
summary: "List users in department",
usage: ["seal-use contacts users <departmentId> [--corp <corpId>]"]
},
{
name: "sync-time",
summary: "Get latest contacts synchronization time",
usage: ["seal-use contacts sync-time [--corp <corpId>]"]
}
]
},
{
area: "data",
title: "Expense and invoice data records",
description: "Search raw historical expense and invoice data entries.",
commands: [
{
name: "expenses",
summary: "Search raw expense items",
usage: ["seal-use data expenses [--search <text>] [--start-date <ISO|ms>] [--end-date <ISO|ms>] [--offset <n>] [--limit <n>] [--corp <corpId>]"]
},
{
name: "invoices",
summary: "Search raw invoice records",
usage: ["seal-use data invoices [--search <text>] [--start-date <ISO|ms>] [--end-date <ISO|ms>] [--offset <n>] [--limit <n>] [--corp <corpId>]"]
}
]
},
{
area: "llm",
title: "LLM configuration",
description: "Query LLM providers and configuration settings.",
commands: [
{
name: "config",
summary: "Get active LLM configuration",
usage: ["seal-use llm config [--corp <corpId>]"]
},
{
name: "providers",
summary: "List available LLM providers",
usage: ["seal-use llm providers [--corp <corpId>]"]
}
]
},
{
area: "permissions",
title: "Tenant permissions",
description: "Inspect available and configured permissions.",
commands: [
{
name: "available",
summary: "List available permissions",
usage: ["seal-use permissions available [--corp <corpId>]"]
},
{
name: "configs",
summary: "List active permission configurations",
usage: ["seal-use permissions configs [--corp <corpId>]"]
}
]
},
{
area: "billing",
title: "Subscription and billing plans",
description: "Query billing status, feature entitlements, and plan limits.",
commands: [
{
name: "status",
summary: "Query current billing and subscription status",
usage: ["seal-use billing status [--corp <corpId>]"]
},
{
name: "plans",
summary: "Query available billing plans",
usage: ["seal-use billing plans [--corp <corpId>]"]
},
{
name: "features",
summary: "Query billing feature toggles",
usage: ["seal-use billing features [--corp <corpId>]"]
}
]
},
{
area: "analytics",
title: "Audit analytics and insights",
description: "Query high-level audit analytics and insights.",
commands: [
{
name: "insight",
aliases: ["insight-stats", "stats"],
summary: "Query AI audit insights risk-tag statistics and analysis status",
usage: ["seal-use analytics insight [--start-date <ISO>] [--end-date <ISO>] [--limit <n>] [--corp <corpId>]"]
},
{
name: "risks",
aliases: ["risks-by-tag", "tag-risks"],
summary: "Query detailed risks and document citations under a specific risk tag",
usage: ["seal-use analytics risks <tagId> [--start-date <ISO>] [--end-date <ISO>] [--corp <corpId>]"]
},
{
name: "performance",
aliases: ["perf"],
summary: "Query audit performance metrics (accuracy, automation rate) and Sankey flow",
usage: ["seal-use analytics performance [--start-date <ISO|ms>] [--end-date <ISO|ms>] [--corp <corpId>]"]
},
{
name: "analyze",
aliases: ["reanalyze"],
summary: "Trigger on-demand smart insight risk analysis for an approval record",
usage: ["seal-use analytics analyze <recordId> [--corp <corpId>]"]
},
{
name: "export",
aliases: ["report", "download"],
summary: "Export smart insights risk report to high-fidelity Excel workbook",
usage: ["seal-use analytics export [--downloads] [--out <file>] [--start-date <ISO>] [--end-date <ISO>] [--force] [--limit <n>] [--corp <corpId>]"],
options: [
{ flag: "--downloads", description: "Save directly to the user's Downloads directory" },
{ flag: "--out <file>", description: "Custom destination file path" },
{ flag: "--start-date <ISO>", description: "Filter beginning time range" },
{ flag: "--end-date <ISO>", description: "Filter ending time range" },
{ flag: "--force", description: "Force export when time range exceeds 180 days" },
{ flag: "--limit <n>", description: "Maximum risk tags to drill down into" }
]
}
]
},
{
area: "context",
title: "Knowledge context and documents",
description: "Query uploaded knowledge context and documents.",
commands: [
{
name: "",
summary: "Inspect knowledge context documents",
usage: ["seal-use context [--ruleVersion <versionId|versionNumber|latest>] [--documentLimit 50] [--corp <corpId>]"]
}
]
},
{
area: "source",
title: "Data source configurations",
description: "Inspect enterprise source system configuration.",
commands: [
{
name: "config",
summary: "Inspect source configuration",
usage: ["seal-use source config [--corp <corpId>]"]
}
]
},
{
area: "tool",
title: "Direct low-level tool invocation",
description: "Execute individual Seal tools directly.",
commands: [
{
name: "",
summary: "Invoke a tool directly",
usage: ["seal-use tool <toolName> [--corp <corpId>] [--json '{\"key\":\"value\"}']"]
}
]
},
{
area: "tools",
title: "Available tools listing",
description: "List all executable domain tools.",
commands: [
{
name: "list",
summary: "List all available domain tools",
usage: ["seal-use tools list"]
}
]
},
{
area: "update",
title: "CLI self-update and release changelogs",
description: "Check for new releases, perform self-updates, and view changelogs.",
commands: [
{
name: "",
summary: "Update seal-use to latest or target version",
usage: [
"seal-use update [--check] [--force] [--version <v>]",
"seal-use update check",
"seal-use update changelog [--limit <n>]",
"seal-use changelog [--limit <n>]"
]
}
]
},
{
area: "probe",
title: "Enterprise connectivity probe",
description: "Probe upstream Hose and Seal HTTP connectivity and token validity.",
commands: [
{
name: "",
summary: "Run connectivity probe",
usage: ["seal-use probe [<corpId>]"]
}
]
},
{
area: "mcp",
title: "Model Context Protocol (MCP) server",
description: "Run standalone or stdio MCP server for agent harnesses.",
commands: [
{
name: "",
summary: "Run MCP server or output MCP config",
usage: [
"seal-use mcp",
"seal-use mcp config",
"seal-use mcp-config"
]
}
]
},
{
area: "skill",
title: "Agent skill management",
description: "Install, dump, or inspect agent skills.",
commands: [
{
name: "dump",
summary: "Dump embedded skill markdown",
usage: ["seal-use skill dump"]
},
{
name: "install",
summary: "Install skill to active workspace",
usage: ["seal-use skill install [--dir <path>|--local]"]
},
{
name: "status",
summary: "Check skill installation status",
usage: ["seal-use skill status"]
}
]
},
{
area: "http",
title: "HTTP server",
description: "Run interactive HTTP server.",
commands: [
{
name: "",
summary: "Start HTTP daemon",
usage: [
"seal-use http [--port 8787] [--host 127.0.0.1]",
"seal-use serve [--port 8787]"
]
}
]
},
{
area: "service",
title: "Background HTTP service lifecycle",
description: "Start, stop, restart, inspect, and read logs from the standalone seal-use HTTP service daemon.",
commands: [
{
name: "start",
summary: "Start the background service daemon",
usage: ["seal-use service start [--port 8787] [--host 127.0.0.1]"]
},
{
name: "stop",
summary: "Stop the background service daemon",
usage: ["seal-use service stop"]
},
{
name: "restart",
summary: "Restart the background service daemon",
usage: ["seal-use service restart [--port 8787] [--host 127.0.0.1]"]
},
{
name: "status",
summary: "Show service daemon status",
usage: ["seal-use service status"]
},
{
name: "logs",
summary: "Print recent service daemon logs",
usage: ["seal-use service logs [--lines 50]"]
},
{
name: "run",
summary: "Run the service in the foreground",
usage: ["seal-use service run [--port 8787] [--host 127.0.0.1]"]
}
]
},
{
area: "stop",
title: "Stop the background service",
description: "Shortcut for stopping the background seal-use HTTP service daemon.",
commands: [
{
name: "",
summary: "Stop the background service daemon",
usage: ["seal-use stop"]
}
]
},
{
area: "openapi",
title: "OpenAPI specification",
description: "Output embedded OpenAPI JSON specification.",
commands: [
{
name: "",
summary: "Print OpenAPI schema",
usage: ["seal-use openapi"]
}
]
},
{
area: "doctor",
title: "System diagnostic and environment health check",
description: "Inspects runtime executable, filesystem paths, enterprise assets, and embedded specifications without modifying any files.",
commands: [
{
name: "",
summary: "Run complete system diagnostic health check",
usage: ["seal-use doctor [--quiet]"],
options: [
{ flag: "--quiet", description: "Suppress formatted human dashboard on stderr" }
]
},
{
name: "guide",
aliases: ["doc", "knowledge"],
summary: "Read embedded system architecture & directory specification whitepaper",
usage: ["seal-use doctor guide"]
},
{
name: "paths",
aliases: ["dirs"],
summary: "Inspect core filesystem paths and directory health",
usage: ["seal-use doctor paths"]
},
{
name: "tenant",
aliases: ["corp", "enterprise"],
summary: "Inspect tenant-level health contract, auth permissions, AI approval quota, and rules state",
usage: ["seal-use doctor tenant [--corp <corpId>] [--quiet]"],
options: [
{ flag: "--corp <corpId>", description: "Enterprise ID or selector to diagnose" },
{ flag: "--quiet", description: "Suppress formatted dashboard on stderr" }
]
}
]
},
{
area: "test",
title: "Automated test harnesses and rule regression matrix",
description: "Run automated regression tests and decision comparison matrix across paired production and test environments.",
commands: [
{
name: "regression",
aliases: ["regress", "matrix"],
summary: "Run automated rule regression test matrix against paired test enterprise",
usage: ["seal-use test regression [--corp <corpId>] [--samples <N>] [--dry-run] [--fail-on-flips]"],
options: [
{ flag: "--corp <corpId>", description: "Target test enterprise or production parent (must be paired)" },
{ flag: "--samples <N>", description: "Number of historical production runs to replay (default: 10)" },
{ flag: "--dry-run", description: "Preview sample documents and verify quota without executing replayed audits" },
{ flag: "--fail-on-flips", description: "Exit with non-zero code if any decision flip is detected" },
{ flag: "--prod-corp <id>", description: "Explicit production enterprise source for sample documents" },
{ flag: "--test-corp <id>", description: "Explicit test enterprise target for replay" },
{ flag: "--quiet", description: "Suppress formatted summary dashboard on stderr" }
]
}
]
}
];
export function extractHelpRequest(args: ParsedArgs): { isHelp: boolean; target: string[] } {
const hasHelpOption = Boolean(args.options.help || args.options.h);
if (!args.command.length) {
return { isHelp: true, target: [] };
}
if (args.command[0] === "help") {
return { isHelp: true, target: args.command.slice(1) };
}
const helpIndex = args.command.indexOf("help");
if (helpIndex !== -1) {
const target = args.command.filter((_, idx) => idx !== helpIndex);
return { isHelp: true, target };
}
if (hasHelpOption) {
return { isHelp: true, target: [...args.command] };
}
return { isHelp: false, target: [] };
}
export function renderHelp(target: string[] = []): string {
if (!target.length) {
return renderGlobalHelp();
}
const rawArea = target[0];
if (!rawArea) {
return renderGlobalHelp();
}
const rest = target.slice(1);
const areaKey = normalizeArea(rawArea);
const areaEntry = HELP_REGISTRY.find((entry) => entry.area === areaKey);
if (!areaEntry) {
throw usageError(`Unknown command: ${target.join(" ")}. Run 'seal-use help' for available commands.`);
}
if (!rest.length) {
return renderAreaHelp(areaEntry);
}
const actionPath = rest.join(" ").toLowerCase();
const matchedCommand = findCommandInArea(areaEntry, actionPath, rest);
if (!matchedCommand) {
throw usageError(`Unknown ${areaEntry.area} command: ${rest.join(" ")}. Run 'seal-use ${areaEntry.area} --help' for available commands.`);
}
return renderCommandHelp(areaEntry, matchedCommand);
}
function normalizeArea(area: string): string {
const lower = area.toLowerCase();
if (lower === "corp") return "corps";
if (lower === "webhooks") return "webhook";
if (lower === "preferences") return "preference";
if (lower === "changelog") return "update";
if (lower === "serve") return "http";
if (lower === "mcp-config") return "mcp";
if (lower === "server") return "mcp";
return lower;
}
function findCommandInArea(areaEntry: AreaHelp, actionPath: string, rest: string[]): CommandHelp | undefined {
const exact = areaEntry.commands.find((cmd) => {
if (!cmd.name) return false;
if (cmd.name.toLowerCase() === actionPath) return true;
if (cmd.aliases?.some((alias) => alias.toLowerCase() === actionPath)) return true;
return false;
});
if (exact) return exact;
const firstToken = rest[0]?.toLowerCase();
if (!firstToken) return undefined;
const prefixMatch = areaEntry.commands.find((cmd) => {
if (!cmd.name) return false;
if (cmd.name.toLowerCase() === firstToken) return true;
if (cmd.aliases?.some((alias) => alias.toLowerCase() === firstToken)) return true;
return false;
});
return prefixMatch;
}
function renderCommandHelp(areaEntry: AreaHelp, cmd: CommandHelp): string {
const lines: string[] = [];
const cmdTitle = cmd.name ? `seal-use ${areaEntry.area} ${cmd.name}` : `seal-use ${areaEntry.area}`;
const header = cmd.summary ? `${cmdTitle} - ${cmd.summary}` : cmdTitle;
lines.push(header);
lines.push("");
lines.push("Usage:");
for (const usage of cmd.usage) {
lines.push(` ${usage}`);
}
if (cmd.options && cmd.options.length > 0) {
lines.push("");
lines.push("Options:");
const maxFlagLen = Math.max(...cmd.options.map((opt) => opt.flag.length));
for (const opt of cmd.options) {
lines.push(` ${opt.flag.padEnd(maxFlagLen + 2)} ${opt.description}`);
}
}
if (cmd.description) {
lines.push("");
lines.push("Description:");
lines.push(` ${cmd.description}`);
}
return lines.join("\n");
}
function renderAreaHelp(areaEntry: AreaHelp): string {
const lines: string[] = [];
lines.push(`seal-use ${areaEntry.area} - ${areaEntry.title}`);
if (areaEntry.description) {
lines.push(areaEntry.description);
}
lines.push("");
lines.push("Usage:");
const groupedCommands = new Map<string, CommandHelp[]>();
for (const cmd of areaEntry.commands) {
const group = cmd.group ?? "";
const commands = groupedCommands.get(group) ?? [];
commands.push(cmd);
groupedCommands.set(group, commands);
}
const orderedGroups = [
...(areaEntry.groupOrder ?? []),
...[...groupedCommands.keys()].filter((group) => !areaEntry.groupOrder?.includes(group))
];
for (const group of orderedGroups) {
const commands = groupedCommands.get(group);
if (!commands) continue;
if (group) {
lines.push("");
lines.push(`${group}:`);
}
for (const cmd of commands) {
for (const usage of cmd.usage) {
lines.push(` ${usage}`);
}
}
}
if (areaEntry.commands.some((cmd) => cmd.name)) {
lines.push("");
lines.push(`Run 'seal-use ${areaEntry.area} <command> --help' for details on a specific command.`);
}
return lines.join("\n");
}
export function renderGlobalHelp(): string {
const lines: string[] = [];
lines.push("seal-use CLI");
lines.push("");
lines.push("Usage:");
lines.push(" seal-use version");
for (const area of HELP_REGISTRY) {
for (const command of area.commands) {
for (const usage of command.usage) {
lines.push(` ${usage}`);
}
}
}
lines.push("");
lines.push("Run 'seal-use <command> --help' for details on a specific command.");
return lines.join("\n");
}