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[]; summary?: string; usage: string[]; options?: CommandOptionHelp[]; description?: string; } export interface AreaHelp { area: string; title: string; description?: 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.", commands: [ { name: "list", summary: "List all configured enterprises", usage: ["seal-use corps list [query] [--env ] [--strict] [--corp ]"], options: [ { flag: "--env ", 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"], summary: "Search configured enterprises with intelligent soft fuzzy matching", usage: ["seal-use corps search [--env ] [--strict]"], options: [ { flag: "--env ", 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"], summary: "Get rich details and configuration of an enterprise", usage: ["seal-use corps get "], description: "Retrieves complete enterprise details (URLs, tenant slugs, custom headers/cookies, staff IDs, relations, config file path) with sensitive secrets safely redacted." }, { name: "current", summary: "Show active enterprise in stateful mode", usage: ["seal-use corps current [--corp ]"] }, { name: "switch", summary: "Switch default active enterprise", usage: ["seal-use corps switch "] }, { name: "mark", summary: "Mark enterprise environment as production or test", usage: ["seal-use corps mark --env [--confirm]"], options: [ { flag: "--env ", 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: "bind-test", summary: "Bind a production enterprise to a test enterprise (1-to-1 association)", usage: [ "seal-use corps bind-test [--confirm] [--force]", "seal-use corps bind-test --corp [--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 ", 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", summary: "Unbind a production and test enterprise association", usage: ["seal-use corps unbind-test [] [--confirm]"], options: [ { flag: "--confirm", description: "Explicitly confirm unbinding both sides (required)" }, { flag: "--corp ", 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", summary: "Synchronize rules and preferences from production to test enterprise", usage: ["seal-use corps sync-test [] [--dry-run] [--yes] [--version-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 ", description: "Custom version name for published test rule version" }, { flag: "--corp ", 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", summary: "Replay approval records from production enterprise to bound test enterprise via Webhook", usage: [ "seal-use corps replay-test [] [--record-id ] [--sn ] [--limit ] [--webhook ] [--dry-run]" ], options: [ { flag: "", description: "Production enterprise ID (default: active enterprise)" }, { flag: "--record-id ", description: "Replay a specific approval run ID" }, { flag: "--sn ", description: "Replay a specific document SN" }, { flag: "--limit ", description: "Batch replay latest N records from production (default: 1)" }, { flag: "--status ", description: "Filter records by status (e.g. completed, failed, rejected)" }, { flag: "--webhook ", description: "Target Webhook integration on test enterprise" }, { flag: "--sn-suffix ", description: "Optional suffix appended to documentSN" }, { flag: "--dry-run", description: "Preview payload without sending" } ], 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", summary: "Add a Hose/Ekuaibao enterprise configuration", usage: ["seal-use corps add-hose --json '{\"name\":\"企业名称\",\"domain\":\"https://app.ekuaibao.com\",\"appKey\":\"...\",\"appSecurity\":\"...\",\"proxyStaffBizId\":\"corpId:staffId\"}'"] }, { name: "add-seal", summary: "Add a native Seal enterprise configuration", usage: ["seal-use corps add-seal --json '{\"sealUrl\":\"https://tenant.sealai.cc\",\"token\":\"seal-bearer-token\"}'"] }, { name: "add-link", summary: "Import enterprise configuration from a Hose assistance link", usage: ["seal-use corps add-link [--name ] [--overwrite]"] } ] }, { 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 ]"] }, { name: "list", summary: "List approval rules with optional pagination and summary", usage: ["seal-use rules list [--summary] [--count] [--limit 20] [--offset 0] [--corp ]"], options: [ { flag: "--summary", description: "Output compact summary fields (id, code, strictness, scope)" }, { flag: "--limit ", description: "Number of rules to fetch (default: 20)" }, { flag: "--offset ", description: "Offset index for pagination" }, { flag: "--full", description: "Allow large payloads beyond standard size limits" } ] }, { name: "clear", summary: "Clear all draft rules from enterprise", usage: ["seal-use rules clear [--corp ] [--dry-run|--yes]"] }, { name: "versions", summary: "List published rule versions", usage: ["seal-use rules versions [--corp ]"] }, { name: "version", summary: "Inspect a specific rule version", usage: ["seal-use rules version [--corp ]"] }, { name: "get", summary: "Get single rule by code or record ID", usage: [ "seal-use rules get --corp --version --code '#0038'", "seal-use rules get --corp --record-id --runtime-id rule-205" ] }, { name: "search", summary: "Search rules by keyword", usage: ["seal-use rules search [--version ] [--maxResults 20] [--corp ]"] }, { name: "lint", summary: "Lint rule text or rule file using builtin or custom linter", usage: ["seal-use rules lint [--file ] [--linter ] [--min-score ] [--corp ]"] }, { name: "pull", summary: "Export rules to local JSON file", usage: ["seal-use rules pull [--out ] [--corp ]"] }, { name: "push", summary: "Push rules from local JSON file to enterprise draft space", usage: ["seal-use rules push --file [--mode replace|incremental] [--yes] [--corp ]"] } ] }, { 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 ] [--corp ]"] }, { name: "status", summary: "Check status of webhook integration", usage: ["seal-use webhook status [<材料包.zip>] [--corp ]"] }, { name: "list", summary: "List registered webhook endpoints", usage: ["seal-use webhook list [--query ] [--show-secret] [--corp ]"] }, { name: "get", aliases: ["find"], summary: "Get webhook endpoint details", usage: ["seal-use webhook get|find [--show-secret] [--corp ]"] }, { name: "add", summary: "Register a new webhook endpoint", usage: ["seal-use webhook add --name --result-url [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret ] [--min-file-size 500] [--max-file-size ] [--allowed-extensions <.pdf,.xlsx,...>] [--dry-run] [--corp ]"] }, { name: "update", summary: "Update an existing webhook endpoint", usage: ["seal-use webhook update [--name ] [--result-url ] [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret |--rotate-secret] [--min-file-size ] [--max-file-size ] [--allowed-extensions <.pdf,.xlsx,...>] [--clear-max-file-size] [--dry-run] [--corp ]"] }, { name: "delete", summary: "Delete a webhook endpoint", usage: ["seal-use webhook delete [--yes|--dry-run] [--corp ]"] }, { name: "material-pack preview", summary: "Inspect and validate a material pack ZIP or Excel sheet", usage: ["seal-use webhook material-pack preview <材料包.zip|信息表.xlsx> [--min-file-size ] [--max-file-size ] [--allowed-extensions <.pdf,.xlsx,...>] [--corp ]"] }, { name: "material-pack push", summary: "Upload and push a material pack to webhook endpoint", usage: ["seal-use webhook material-pack push <材料包.zip|信息表.xlsx> [--webhook ] [--corp ]"] }, { name: "replay", usage: [ "seal-use webhook replay [--webhook ] [--sn-suffix ] [--dry-run] [--corp ]", "seal-use webhook replay --sn [--webhook ] [--source-corp ] [--target-corp ]", "seal-use webhook replay --limit [--status ] [--source-corp ] [--target-corp ]" ], options: [ { flag: "", description: "Approval run record ID to replay" }, { flag: "--sn ", description: "Lookup approval record by source document SN if recordId not given" }, { flag: "--limit ", description: "Batch replay latest N records from source enterprise" }, { flag: "--status ", description: "Filter records by status (e.g. completed, failed, rejected)" }, { flag: "--webhook ", description: "Target Webhook integration (auto-locks if only one exists)" }, { flag: "--source-corp ", description: "Source enterprise where records reside (alias: --prod-corp)" }, { flag: "--target-corp ", description: "Target enterprise where records are pushed (alias: --test-corp)" }, { flag: "--sn-suffix ", description: "Optional suffix appended to documentSN and documentId" }, { flag: "--sn-prefix ", 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 ]"] }, { name: "stats", summary: "Statistical aggregation of approval run metrics", usage: ["seal-use approval-runs stats [--since 3months] [--dedupe-by sourceDocumentSN|sourceDocumentId|id] [--corp ]"] }, { name: "count", summary: "Count approval runs filtered by status", usage: ["seal-use approval-runs count [--status APPROVED] [--corp ]"] }, { name: "export", summary: "Export approval run audit records to Excel workbook", usage: ["seal-use approval-runs export [--start ] [--end ] [--limit ] [--downloads] [--out ] [--corp ]"] }, { 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 ]"] }, { name: "pick", summary: "Locate single approval run by document SN", usage: ["seal-use approval-runs pick --sn [--batch ] [--latest] [--fields recordId,status,aiDecision] [--corp ]"] }, { name: "get", summary: "Get detailed approval record payload", usage: ["seal-use approval-runs get [--summary] [--fields metadata|document.fields,result.summary] [--full] [--output-file file.json] [--corp ]"] }, { name: "cited-rules", summary: "Inspect rules cited by AI in an approval decision", usage: ["seal-use approval-runs cited-rules [--corp ]"] }, { name: "document-summary", summary: "Inspect parsed source document summary", usage: ["seal-use approval-runs document-summary [--corp ]"] }, { name: "attachments", summary: "Inspect and list attachments for approval run", usage: [ "seal-use approval-runs attachments [--summary] [--corp ]", "seal-use approval-runs attachments download [--all] [--name ] [--out-dir ] [--corp ]" ] }, { name: "result", summary: "Get decision result for an approval run", usage: ["seal-use approval-runs result [--summary] [--corp ]"] }, { name: "url", summary: "Get web console URL for approval run (default deep link, or --sso for auto-login link)", usage: [ "seal-use approval-runs url [--corp ]", "seal-use approval-runs url --sso [--expire 7200] [--corp ]", "seal-use approval-runs url --sn [--sso] [--corp ]", "seal-use approval-runs url [--corp ]" ] }, { name: "bridge", summary: "Inspect browser bridge integration payload", usage: ["seal-use approval-runs bridge [--sourceDocumentSN B26001887] [--corp ]"] }, { name: "replay", summary: "Replay approval run record into a Webhook integration", usage: [ "seal-use approval-runs replay [--webhook ] [--sn-suffix ] [--dry-run] [--corp ]", "seal-use approval-runs replay --sn [--webhook ] [--source-corp ] [--target-corp ]", "seal-use approval-runs replay --limit [--status ] [--source-corp ] [--target-corp ]" ], options: [ { flag: "", description: "Approval run record ID" }, { flag: "--sn ", description: "Lookup approval record by source document SN" }, { flag: "--limit ", description: "Batch replay latest N records" }, { flag: "--status ", description: "Filter records by status" }, { flag: "--webhook ", description: "Target Webhook integration" }, { flag: "--source-corp ", description: "Source enterprise where records reside" }, { flag: "--target-corp ", description: "Target enterprise where records are pushed" }, { flag: "--sn-suffix ", 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 [--corp ]"] }, { name: "create", summary: "Trigger a new simulation batch", usage: [ "seal-use simulation create --mode hosecloud --flow-ids \"B26017701,B26022501\" [--reject-node 财务] [--thinking-depth default|medium|high] [--skip-invoice-generation|--skip-invoice-generation false] [--no-wait] [--corp ]", "seal-use simulation create --mode material_pack --package-ids [--template-id conference_reimbursement_v1] [--schema-config file.json] [--corp ]", "seal-use simulation create --source-system weaver --request-ids \"req-01,req-02\" [--corp ]" ] }, { name: "status", summary: "Check current progress of a simulation batch", usage: ["seal-use simulation status [--corp ]"] }, { name: "wait", summary: "Wait synchronously for simulation batch to finish", usage: ["seal-use simulation wait [--timeout 10m] [--poll-interval 2s] [--corp ]"] }, { name: "clean", summary: "Clean simulation batch records", usage: ["seal-use simulation clean [--corp ]"] }, { name: "specifications", summary: "Query simulation specifications", usage: ["seal-use simulation specifications [--integration ] [--corp ]"] }, { name: "approval-definitions", summary: "Query simulation approval definitions", usage: ["seal-use simulation approval-definitions [--corp ]"] }, { name: "list", summary: "List recent simulation batches", usage: ["seal-use simulation list [--limit 50] [--corp ]"] }, { name: "get", summary: "Get details for simulation batch", usage: ["seal-use simulation get [--corp ]"] }, { name: "templates", summary: "List available simulation templates", usage: ["seal-use simulation templates [--corp ]"] }, { name: "integrations", summary: "List available simulation integrations", usage: ["seal-use simulation integrations [--corp ]"] }, { name: "package-upload", summary: "Upload a simulation material package", usage: ["seal-use simulation package-upload <材料包.zip> [--corp ]"] } ] }, { 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 ]"] }, { name: "hosecloud list", summary: "List HoseCloud deployment targets", usage: ["seal-use deploy hosecloud list [--corp ]"] }, { name: "hosecloud get", summary: "Get HoseCloud deployment details", usage: ["seal-use deploy hosecloud get [--corp ]"] }, { name: "hosecloud status", summary: "Check HoseCloud deployment status", usage: ["seal-use deploy hosecloud status [--corp ]"] }, { name: "hosecloud configure", summary: "Configure HoseCloud deployment settings", usage: ["seal-use deploy hosecloud configure --json '{...}' [--dry-run] [--corp ]"] }, { name: "hosecloud sync", summary: "Synchronize HoseCloud rules and definitions", usage: ["seal-use deploy hosecloud sync [--corp ]"] } ] }, { 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 ]"] }, { name: "decision update", summary: "Update decision preference rules", usage: ["seal-use preference decision update --json '{\"explicitApprove\":\"...\"}' [--dry-run] [--corp ]"] }, { name: "thinking-depth set", summary: "Set default thinking depth", usage: ["seal-use preference thinking-depth set --default [--dry-run] [--corp ]"] }, { name: "thinking-depth policies list", summary: "List thinking depth policies", usage: ["seal-use preference thinking-depth policies list [--corp ]"] }, { name: "thinking-depth policies upsert", summary: "Upsert a thinking depth policy", usage: ["seal-use preference thinking-depth policies upsert --json '{...}' [--dry-run] [--corp ]"] }, { name: "thinking-depth policies remove", summary: "Remove a thinking depth policy", usage: ["seal-use preference thinking-depth policies remove [--dry-run] [--corp ]"] } ] }, { 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 [--corp ]"] }, { name: "test-dir", aliases: ["test-enterprises-dir"], summary: "Set or clear global test enterprises directory", usage: ["seal-use config test-dir [|--clear]"] }, { name: "lint", summary: "Configure automatic rule linter status and thresholds", usage: ["seal-use config lint [status|enable|disable] [--linter ] [--min-score ]"] } ] }, { area: "auth", title: "Authentication and session diagnostics", description: "Diagnose upstream token status and generate provisional assistance links.", commands: [ { name: "diagnose", summary: "Diagnose auth session and platform connectivity", usage: ["seal-use auth diagnose [--corp ]"] }, { name: "hose-link", summary: "Generate Hose third-party assistance link", usage: ["seal-use auth hose-link [--corp ] [--expire 7200]"] } ] }, { area: "delegation", title: "Delegation tokens", description: "Manage Seal user delegation tokens and temporary access credentials.", commands: [ { name: "list", summary: "List active delegation tokens", usage: ["seal-use delegation list [--corp ]"] }, { name: "create", summary: "Create a new delegation token", usage: [ "seal-use delegation create [--note ] [--from-link ] [--corp ]" ] }, { name: "revoke", summary: "Revoke an existing delegation token", usage: ["seal-use delegation revoke [--corp ]"] } ] }, { 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 --phone [--dept ] [--corp ]"] }, { name: "search", summary: "Search tenant users by name or phone", usage: ["seal-use users search [--corp ]"] }, { name: "delegation", summary: "Create delegation token for a specific user", usage: ["seal-use users delegation [--note ] [--corp ]"] }, { name: "reset-password", summary: "Reset user password", usage: ["seal-use users reset-password [--corp ]"] }, { name: "get", summary: "Get user details", usage: ["seal-use users get [--corp ]"] }, { name: "delete", summary: "Delete user", usage: ["seal-use users delete [--corp ]"] } ] }, { 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 [] [--corp ]"] }, { name: "children", summary: "List child departments", usage: ["seal-use contacts children [--corp ]"] }, { name: "users", summary: "List users in department", usage: ["seal-use contacts users [--corp ]"] }, { name: "sync-time", summary: "Get latest contacts synchronization time", usage: ["seal-use contacts sync-time [--corp ]"] } ] }, { 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 ] [--start-date ] [--end-date ] [--offset ] [--limit ] [--corp ]"] }, { name: "invoices", summary: "Search raw invoice records", usage: ["seal-use data invoices [--search ] [--start-date ] [--end-date ] [--offset ] [--limit ] [--corp ]"] } ] }, { 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 ]"] }, { name: "providers", summary: "List available LLM providers", usage: ["seal-use llm providers [--corp ]"] } ] }, { area: "permissions", title: "Tenant permissions", description: "Inspect available and configured permissions.", commands: [ { name: "available", summary: "List available permissions", usage: ["seal-use permissions available [--corp ]"] }, { name: "configs", summary: "List active permission configurations", usage: ["seal-use permissions configs [--corp ]"] } ] }, { 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 ]"] }, { name: "plans", summary: "Query available billing plans", usage: ["seal-use billing plans [--corp ]"] }, { name: "features", summary: "Query billing feature toggles", usage: ["seal-use billing features [--corp ]"] } ] }, { area: "analytics", title: "Audit analytics and insights", description: "Query high-level audit analytics and insights.", commands: [ { name: "insight", summary: "Query AI audit insights and trends", usage: ["seal-use analytics insight [--start-date ] [--end-date ] [--limit ] [--corp ]"] } ] }, { 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 ] [--documentLimit 50] [--corp ]"] } ] }, { 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 ]"] } ] }, { 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 [--corp ] [--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 ]", "seal-use update check", "seal-use update changelog [--limit ]", "seal-use changelog [--limit ]" ] } ] }, { 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 []"] } ] }, { 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 |--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"] } ] } ]; 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:"); for (const cmd of areaEntry.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} --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 --help' for details on a specific command."); return lines.join("\n"); }