Merge pull request #264 from yunyingk/mac15/naming-consistency-charter
Enforce naming charter and complete --dry-run preview coverage
This commit is contained in:
31 files changed
+809
-192
No files matched your search
@@ -46,7 +46,7 @@ When developing or refactoring CLI commands under `src/cli/`:
|
||||
|
||||
## 3. High-Risk Mutation & Preview Contract (`--dry-run`)
|
||||
|
||||
- All potentially destructive or state-mutating commands (e.g. `rules push`, `rules clear`, `corps sync-test`, `preference update`, `webhook add/update/delete`) **MUST** support `--dry-run`.
|
||||
- All potentially destructive or state-mutating commands (e.g. `rules push/clear/create/update/delete/publish`, `corps sync-test`, `corps mark`, `preference update`, `users create/delete/reset-password/delegation`, `simulation delete`, `analytics analyze`, `auth link revoke`, `webhook create/update/delete`) **MUST** support `--dry-run`.
|
||||
- **Preview Output**:
|
||||
- When `--dry-run` is present, the command performs read-only discovery, simulates the mutation, and returns structured JSON with:
|
||||
```json
|
||||
@@ -92,3 +92,39 @@ When developing or refactoring CLI commands under `src/cli/`:
|
||||
- Compatibility command spellings and options may remain accepted for existing scripts, but they are implementation-only.
|
||||
- Do not expose them in help, Skill, references, README guidance, generated suggestions, or normal runtime notices.
|
||||
- Agent-generated commands and all new documentation MUST use the current canonical spelling.
|
||||
|
||||
## 7. Naming Charter (跨域命名宪章)
|
||||
|
||||
同一语义操作在不同业务域必须使用同一个词。命名决策顺序:语义类别 → 宪章词表 → 旧名一律转为静默 alias(见 §6)。允许域内风格化命名(如 `rules pull/push` 的 git 配对隐喻),前提是该域 help summary 写明其导出/导入语义,形成可见桥接。横切概念一览:
|
||||
|
||||
### 7.1 子命令动词词表
|
||||
|
||||
| 语义 | Canonical | 静默兼容 / 备注 |
|
||||
| :--- | :--- | :--- |
|
||||
| 分页列表 | `list` | 关键字过滤用 `--query`/`--search` flag |
|
||||
| 读单条 | `get` | |
|
||||
| 关键字检索 | `search` | `search` 是 `list` 别名的场景仅限历史兼容(approval-runs) |
|
||||
| 计数 | `count` | |
|
||||
| 创建 | `create` | `add` 退役为 alias |
|
||||
| 更新 | `update` | |
|
||||
| 删除 | `delete` | 批量语义在 summary/usage 说明;`clean`/`clear`/`remove` 退役为 alias |
|
||||
| 导出/下载 | `export` | `rules pull` 是该域 canonical 名,summary 必须写明 Export 语义 |
|
||||
| 上传/导入 | `push` / `import` | |
|
||||
| 重放 | `replay` | |
|
||||
|
||||
### 7.2 横切 Flag 词表
|
||||
|
||||
| 语义 | Canonical | 静默兼容拼写 |
|
||||
| :--- | :--- | :--- |
|
||||
| 写入本地文件 | `--out` | `--output`、`-o`、`--output-file`、`--outputFile` |
|
||||
| 存到 ~/Downloads | `--downloads` | `--download`、`--to-downloads`、`--toDownloads` |
|
||||
| 明文揭示密钥 | `--reveal`(短名 `-r`) | `--show-secret` |
|
||||
| 时间范围 | `--start-date` / `--end-date` | `--start`/`--end`、`--startDate`/`--endDate`;`--since`/`--until` 仅用于 simulation 的相对时间窗 |
|
||||
| 列表页大小 | `--limit` | `--max-results` 仅用于 search 命中数 |
|
||||
| 本地扫描上限 | `--max-scan` | |
|
||||
|
||||
### 7.3 机械约束
|
||||
|
||||
- Flag 一律 lowercase kebab-case;camelCase 拼写只作为静默兼容,永不出现在 help/Skill/README(`src/cli/naming-charter.test.ts` 强制)。
|
||||
- 每个横切 flag 的 canonical 拼写在所有同类命令中必须被实际读取;accept-set 不齐 = 静默忽略 bug(宪章测试有专项回归)。
|
||||
- 新命令落地时实现可以双收新旧拼写,但 help 注册表只写 canonical;旧名退役永远走 alias,不做硬切断。
|
||||
@@ -35,7 +35,7 @@ Prefer small domain functions over broad utility modules.
|
||||
- **Documented exception — document-output commands**: `seal-use --help` / `seal-use help <area>` (`src/cli/printer.ts`), `seal-use doctor guide` (`src/cli/commands/doctor.ts`), and `seal-use skill dump` (`src/cli/commands/skill.ts`) intentionally write Markdown to `stdout`, because their output *is* the payload the caller redirects or reads (e.g. `seal-use doctor guide > guide.md`, `seal-use skill dump > SKILL.md`). Never add a new prose-on-stdout command outside this list: return structured JSON and put the readable rendering on `stderr` instead. `src/probe.ts` is a local developer probe script rather than a `bin` entry point, so its `[probe] …` lines are outside this contract.
|
||||
- **Guidance & Diagnostic Channel (`stderr`)**: Use `stderr` for runtime logs, network probing status, self-healing notifications, and explicit **Next-Step Command Suggestions** (e.g. `👉 Next action: seal-use deploy hosecloud sync <signKey>`).
|
||||
- **Performance Contract & SWR Architecture**: Read-only discovery and version commands (`seal-use version`, `seal-use doctor`, `seal-use corps list`) MUST execute in under 70ms wall clock (Bun startup alone is ~7ms; runner dispatch uses lazy `await import()` per command area, so the version path never loads the Excel/zip tool chain). Never block on external network I/O during routine invocations. Use the Stale-While-Revalidate (SWR) pattern: read local cache from `~/.config/seal-use/*.json` synchronously (<0.2ms), and refresh stale/missing data via detached, unref'd child processes (`triggerBackgroundUpdateCheck`, `unref()`).
|
||||
- **Safety Guardrail & Mutation Preview (`--dry-run`)**: All potentially destructive or state-mutating commands (e.g. `rules push/clear`, `corps sync-test`, `preference update`, `webhook add/update`) MUST support `--dry-run` returning structured JSON previews with `preview: true` and a clean diff, without executing mutations. Live execution requires explicit `--yes` or `--confirm`.
|
||||
- **Safety Guardrail & Mutation Preview (`--dry-run`)**: All potentially destructive or state-mutating commands (e.g. `rules push/clear`, `corps sync-test`, `preference update`, `webhook create/update`) MUST support `--dry-run` returning structured JSON previews with `preview: true` and a clean diff, without executing mutations. Live execution requires explicit `--yes` or `--confirm`.
|
||||
- **Exit Code Contract**:
|
||||
- `0`: Successful execution.
|
||||
- `1`: Upstream API failure or domain business block (including quality gates such as a lint score below threshold).
|
||||
|
||||
@@ -288,7 +288,7 @@ When `_langfuseTraceId` exists, downstream tools should fetch the trace directly
|
||||
- Do not print diagnostic text to stdout from the MCP server. MCP uses stdout as the protocol stream; use stderr for server diagnostics.
|
||||
- Keep the MCP exported surface to the `seal_use` (read-only) and `seal_use_write` (mutating) pair; command knowledge belongs in this skill and its focused references.
|
||||
- Prefer CLI or script processing for large tool responses. For daily approval questions, call `seal-use approval-runs summary --corp <corpId> ...` instead of reading long `approval-runs search` output manually.
|
||||
- Keep broad search tools compact by default. Add explicit opt-in flags such as `includeBridge` for verbose fields that are useful only in deeper debugging.
|
||||
- Keep broad search tools compact by default. Add explicit opt-in flags such as `include-bridge` for verbose fields that are useful only in deeper debugging.
|
||||
- When Seal API timestamp filters are uncertain, filter again in tool code by `createdAt` and explicit timezone before presenting date-based answers.
|
||||
|
||||
## Release & Publishing
|
||||
|
||||
@@ -44,7 +44,7 @@ seal-use corps search <query> [--env <production|test>] [--strict]
|
||||
seal-use corps get <corpId>
|
||||
seal-use corps current [--corp <corpId>]
|
||||
seal-use corps switch <corpId>
|
||||
seal-use corps mark <corpId> --env <production|test> [--confirm]
|
||||
seal-use corps mark <corpId> --env <production|test> [--dry-run] [--confirm]
|
||||
seal-use corps rename <corpId> --name <newName>
|
||||
seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]
|
||||
seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]
|
||||
@@ -62,11 +62,11 @@ seal-use corps hose-keys [<url> | <corpId>] [--reveal] [--save] [--app-key <key>
|
||||
seal-use rules count [--version <number|latest>] [--corp <corpId>]
|
||||
seal-use rules list [--version <number|latest>] [--summary] [--limit 20] [--offset 0] [--output-file <path>] [--corp <corpId>]
|
||||
seal-use rules get <code> [--version <number|latest>] [--record-id <recordId>] [--corp <corpId>]
|
||||
seal-use rules search <keyword> [--version <number|latest>] [--maxResults 20] [--corp <corpId>]
|
||||
seal-use rules create --description <text> --scope <scope> [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--description-file <path>] [--corp <corpId>]
|
||||
seal-use rules update <code> [--description <text>|--description-file <path>] [--scope <scope>] [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--corp <corpId>]
|
||||
seal-use rules delete <code> --yes [--corp <corpId>]
|
||||
seal-use rules publish <versionName> [--corp <corpId>]
|
||||
seal-use rules search <keyword> [--version <number|latest>] [--max-results 20] [--corp <corpId>]
|
||||
seal-use rules create --description <text> --scope <scope> [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--description-file <path>] [--dry-run] [--corp <corpId>]
|
||||
seal-use rules update <code> [--description <text>|--description-file <path>] [--scope <scope>] [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--dry-run] [--corp <corpId>]
|
||||
seal-use rules delete <code> [--dry-run] --yes [--corp <corpId>]
|
||||
seal-use rules publish <versionName> [--dry-run] [--corp <corpId>]
|
||||
seal-use rules versions [--corp <corpId>]
|
||||
seal-use rules version <versionNumber|latest> [--corp <corpId>]
|
||||
seal-use rules diff <fromVersion> <toVersion> [--code <code>] [--include-unchanged] [--full] [--corp <corpId>]
|
||||
@@ -80,25 +80,25 @@ seal-use rules recode [--dry-run] --corp <corpId>
|
||||
seal-use rules map [--version <number|latest>] [--code <code>] [--corp <corpId>]
|
||||
seal-use webhook ready [<材料包.zip>] [--webhook <idOrName>] [--corp <corpId>]
|
||||
seal-use webhook status [<材料包.zip>] [--corp <corpId>]
|
||||
seal-use webhook list [--query <text>] [--show-secret] [--corp <corpId>]
|
||||
seal-use webhook get|find <idOrName> [--show-secret] [--corp <corpId>]
|
||||
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>]
|
||||
seal-use webhook list [--query <text>] [--reveal] [--corp <corpId>]
|
||||
seal-use webhook get|find <idOrName> [--reveal] [--corp <corpId>]
|
||||
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>]
|
||||
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>]
|
||||
seal-use webhook delete <idOrName> [--yes|--dry-run] [--corp <corpId>]
|
||||
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>]
|
||||
seal-use webhook resource-pack preview <资源包.zip|信息表.xlsx> [--min-file-size <bytes>] [--max-file-size <bytes>] [--allowed-extensions <.pdf,.xlsx,...>] [--corp <corpId>]
|
||||
seal-use webhook resource-pack push <资源包.zip|信息表.xlsx> [--webhook <idOrName>] [--corp <corpId>]
|
||||
seal-use webhook replay <recordId> [--webhook <idOrName>] [--sn-suffix <str>] [--dry-run] [--yes|--confirm] [--corp <corpId>]
|
||||
seal-use webhook replay --sn <documentSN> [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--yes|--confirm]
|
||||
seal-use webhook replay --limit <n> [--status <status>] [--source-corp <corpId>] [--target-corp <corpId>] [--yes|--confirm]
|
||||
seal-use approval-runs summary [--date YYYY-MM-DD] [--timezone Asia/Shanghai] [--corp <corpId>]
|
||||
seal-use approval-runs summary [--date <YYYY-MM-DD>] [--timezone Asia/Shanghai] [--corp <corpId>]
|
||||
seal-use approval-runs stats [--since 3months] [--dedupe-by sourceDocumentSN|sourceDocumentId|id] [--corp <corpId>]
|
||||
seal-use approval-runs count [--status APPROVED] [--start <YYYY-MM-DD|ms>] [--end <YYYY-MM-DD|ms>] [--corp <corpId>]
|
||||
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>]
|
||||
seal-use approval-runs count [--status APPROVED] [--start-date <YYYY-MM-DD|ms>] [--end-date <YYYY-MM-DD|ms>] [--corp <corpId>]
|
||||
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>]
|
||||
seal-use approval-runs hose-flow <recordId|SN> [--corp <corpId>]
|
||||
seal-use approval-runs list|search [--query text] [--humanResult 驳回] [--manualApprovalStatus TERMINATED] [--startDate ms] [--endDate ms] [--has-extra-risk] [--limit 20] [--includeBridge true] [--corp <corpId>]
|
||||
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>]
|
||||
seal-use approval-runs pick --sn <documentSN> [--batch <batchId>] [--latest] [--fields recordId,status,aiDecision] [--corp <corpId>]
|
||||
seal-use approval-runs get <recordId> [--summary] [--fields metadata|document.fields,result.summary] [--raw-json] [--full] [--output-file file.json] [--corp <corpId>]
|
||||
seal-use approval-runs cited-rules <recordId> [--corp <corpId>]
|
||||
@@ -111,7 +111,7 @@ 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>]
|
||||
seal-use approval-runs bridge [--sourceDocumentSN B26001887] [--corp <corpId>]
|
||||
seal-use approval-runs bridge [--source-document-sn B26001887] [--corp <corpId>]
|
||||
seal-use approval-runs replay <recordId> [--webhook <idOrName>] [--sn-suffix <str>] [--dry-run] [--yes|--confirm] [--corp <corpId>]
|
||||
seal-use approval-runs replay --sn <documentSN> [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--yes|--confirm]
|
||||
seal-use approval-runs replay --sn <documentSN> --channel hose-outbound [--sign-key <key>] [--target-corp <corpId>] [--dry-run] [--yes|--confirm]
|
||||
@@ -134,7 +134,7 @@ seal-use simulation create --mode material_pack --package-ids <materialPackageId
|
||||
seal-use simulation create --source-system weaver --request-ids "req-01,req-02" [--corp <corpId>]
|
||||
seal-use simulation status <batchId> [--corp <corpId>]
|
||||
seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s] [--corp <corpId>]
|
||||
seal-use simulation clean <batchId> --yes [--corp <corpId>]
|
||||
seal-use simulation delete <batchId> [--dry-run] --yes [--corp <corpId>]
|
||||
seal-use simulation specifications [--integration <sign-key>] [--corp <corpId>]
|
||||
seal-use simulation approval-definitions [--corp <corpId>]
|
||||
seal-use simulation list [--limit 50] [--all] [--query <text>] [--since <time>] [--until <time>] [--max-scan <n>] [--corp <corpId>]
|
||||
@@ -160,7 +160,7 @@ seal-use preference decision update --json '{"explicitApprove":"..."}' [--dry-ru
|
||||
seal-use preference thinking-depth set --default <medium|high> [--dry-run] [--corp <corpId>]
|
||||
seal-use preference thinking-depth policies list [--corp <corpId>]
|
||||
seal-use preference thinking-depth policies upsert --json '{...}' [--dry-run] [--corp <corpId>]
|
||||
seal-use preference thinking-depth policies remove <policyId> [--dry-run] [--corp <corpId>]
|
||||
seal-use preference thinking-depth policies delete <policyId> [--dry-run] [--corp <corpId>]
|
||||
seal-use config paths
|
||||
seal-use config get
|
||||
seal-use config mode <stateful|stateless> [--corp <corpId>]
|
||||
@@ -170,17 +170,17 @@ seal-use auth check [--corp <corpId>]
|
||||
seal-use auth link [--note <note>] [--expire <duration>] [--corp <corpId>]
|
||||
seal-use auth link --from-link <url> [--note <note>] [--expire <duration>]
|
||||
seal-use auth link list [--corp <corpId>]
|
||||
seal-use auth link revoke <tokenId> [--corp <corpId>]
|
||||
seal-use auth link revoke <tokenId> [--dry-run] [--corp <corpId>]
|
||||
seal-use auth hose-link [--corp <corpId>] [--expire <duration>] [--force]
|
||||
seal-use auth hose-openapi-token [--corp <corpId>] [--force]
|
||||
seal-use auth hose-extract-keys <url> [--reveal] [--save] [--app-key <key>] [--key-id <id>] [--name <customName>] [--overwrite]
|
||||
seal-use auth hose-keys [--corp <corpId>] [--reveal]
|
||||
seal-use users create --name <name> --phone <phone> [--dept <deptId>] [--corp <corpId>]
|
||||
seal-use users create --name <name> --phone <phone> [--dept <deptId>] [--dry-run] [--corp <corpId>]
|
||||
seal-use users search <keyword> [--corp <corpId>]
|
||||
seal-use users delegation <userIdOrPhone|name> [--note <note>] [--expire <duration>] [--corp <corpId>]
|
||||
seal-use users reset-password <userId> --yes [--corp <corpId>]
|
||||
seal-use users delegation <userIdOrPhone|name> [--note <note>] [--expire <duration>] [--dry-run] [--corp <corpId>]
|
||||
seal-use users reset-password <userId> [--dry-run] --yes [--corp <corpId>]
|
||||
seal-use users get <userId> [--corp <corpId>]
|
||||
seal-use users delete <userId> --yes [--corp <corpId>]
|
||||
seal-use users delete <userId> [--dry-run] --yes [--corp <corpId>]
|
||||
seal-use contacts departments [<departmentId>] [--corp <corpId>]
|
||||
seal-use contacts children <departmentId> [--corp <corpId>]
|
||||
seal-use contacts users <departmentId> [--corp <corpId>]
|
||||
@@ -201,13 +201,13 @@ seal-use billing features [--corp <corpId>]
|
||||
seal-use analytics insight [--start-date <ISO>] [--end-date <ISO>] [--limit <n>] [--corp <corpId>]
|
||||
seal-use analytics risks <tagId> [--start-date <ISO>] [--end-date <ISO>] [--corp <corpId>]
|
||||
seal-use analytics performance [--start-date <ISO|ms>] [--end-date <ISO|ms>] [--corp <corpId>]
|
||||
seal-use analytics analyze <recordId> [--corp <corpId>]
|
||||
seal-use analytics analyze <recordId> [--dry-run] [--corp <corpId>]
|
||||
seal-use analytics export [--downloads] [--out <file>] [--start-date <ISO>] [--end-date <ISO>] [--force] [--limit <n>] [--corp <corpId>]
|
||||
seal-use context [--ruleVersion <versionId|versionNumber|latest>] [--documentLimit 50] [--corp <corpId>]
|
||||
seal-use context [--rule-version <versionId|versionNumber|latest>] [--document-limit 50] [--corp <corpId>]
|
||||
seal-use source config [--corp <corpId>]
|
||||
seal-use documents list [--summary] [--fields <id,title,purpose,updatedAt>] [--scenarios <audit,fill>] [--limit 50] [--offset 0] [--corp <corpId>]
|
||||
seal-use documents get <documentId> [--out <path>] [--content-format raw] [--overwrite] [--corp <corpId>]
|
||||
seal-use documents search <keyword> [--maxResults 20] [--corp <corpId>]
|
||||
seal-use documents search <keyword> [--max-results 20] [--corp <corpId>]
|
||||
seal-use documents create --title <title> --purpose <purpose> [--content <text>|--content-file <path>] [--content-format raw] [--allow-empty] [--type <policy|document|video|pdf|feishu_doc>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--dry-run|--yes|--confirm] [--corp <corpId>]
|
||||
seal-use documents update <documentId> [--title <title>] [--purpose <purpose>] [--content <text>|--content-file <path>] [--content-format raw] [--allow-empty] [--type <policy|document|video|pdf|feishu_doc>] [--enabled <true|false>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--dry-run|--yes|--confirm] [--corp <corpId>]
|
||||
seal-use documents delete <documentId> [--dry-run|--yes|--confirm] [--corp <corpId>]
|
||||
@@ -310,7 +310,7 @@ Read-only discovery:
|
||||
- `seal-use analytics performance --corp <corpId> [--start-date <ISO|ms>] [--end-date <ISO|ms>]` queries approval performance metrics and Sankey decision flow.
|
||||
- `seal-use analytics analyze <recordId> --corp <corpId>` triggers on-demand smart insight risk analysis for an approval record.
|
||||
- `seal-use analytics export --corp <corpId> [--downloads] [--out <file>] [--start-date <ISO>] [--end-date <ISO>]` exports a comprehensive multi-sheet Excel report covering performance KPIs, decision flow, top risk tags, and detailed risk citations.
|
||||
- `seal-use context --corp <corpId> [--ruleVersion <versionId|versionNumber|latest>] [--documentLimit 50]` aggregates rules, knowledge documents, and style preferences.
|
||||
- `seal-use context --corp <corpId> [--rule-version <versionId|versionNumber|latest>] [--document-limit 50]` aggregates rules, knowledge documents, and style preferences.
|
||||
- `seal-use source config --corp <corpId>` resolves the live source-system configuration without changing it.
|
||||
|
||||
Test Enterprise Binding, Staging Synchronization & Automated Regression Testing:
|
||||
@@ -346,7 +346,7 @@ Approval rule maintenance:
|
||||
- `seal-use rules count [--version <number|latest>] [--corp <corpId>]`
|
||||
- `seal-use rules list [--version <number|latest>] [--summary] [--limit 20] [--offset 0] [--output-file <path>] [--corp <corpId>]`
|
||||
- `seal-use rules get <code> [--version <number|latest>] [--record-id <recordId>] [--corp <corpId>]`
|
||||
- `seal-use rules search <keyword> [--version <number|latest>] [--maxResults 20] [--corp <corpId>]`
|
||||
- `seal-use rules search <keyword> [--version <number|latest>] [--max-results 20] [--corp <corpId>]`
|
||||
- `seal-use rules create --description <text> --scope <scope> [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--description-file <path>] [--corp <corpId>]`
|
||||
- `seal-use rules update <code> [--description <text>|--description-file <path>] [--scope <scope>] [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--corp <corpId>]`
|
||||
- `seal-use rules delete <code> --yes [--corp <corpId>]`
|
||||
@@ -386,7 +386,7 @@ Approval knowledge documents:
|
||||
|
||||
- `seal-use documents list [--scenarios <audit,fill>] [--limit 50] [--offset 0] [--corp <corpId>]`
|
||||
- `seal-use documents get <documentId> [--corp <corpId>]`
|
||||
- `seal-use documents search <keyword> [--maxResults 20] [--corp <corpId>]`
|
||||
- `seal-use documents search <keyword> [--max-results 20] [--corp <corpId>]`
|
||||
- `seal-use documents create --title <title> --purpose <purpose> [--content <text>|--content-file <path>] [--type <policy|document|video|pdf|feishu_doc>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--corp <corpId>]`
|
||||
- `seal-use documents update <documentId> [--title <title>] [--purpose <purpose>] [--content <text>|--content-file <path>] [--type <policy|document|video|pdf|feishu_doc>] [--enabled <true|false>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--corp <corpId>]`
|
||||
- `seal-use documents delete <documentId> --yes [--corp <corpId>]` (删除前必须重新读取并确认;若只是暂时撤下内容,优先使用 `documents update <documentId> --enabled false`)
|
||||
@@ -396,12 +396,12 @@ Approval knowledge documents:
|
||||
Webhook integrations:
|
||||
|
||||
- `seal-use webhook ready [<资源包.zip|信息表.xlsx>] [--webhook <idOrName>] [--corp <corpId>]`
|
||||
- `seal-use webhook list [--query <text>] [--show-secret] [--corp <corpId>]`
|
||||
- `seal-use webhook get|find <idOrName> [--show-secret] [--corp <corpId>]`
|
||||
- `seal-use webhook add --name <name> --result-url <url> [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret <secret>] [--min-file-size <bytes>] [--max-file-size <bytes>] [--allowed-extensions <.pdf,.xlsx,...>] [--dry-run] [--corp <corpId>]`
|
||||
- `seal-use webhook list [--query <text>] [--reveal] [--corp <corpId>]`
|
||||
- `seal-use webhook get|find <idOrName> [--reveal] [--corp <corpId>]`
|
||||
- `seal-use webhook create --name <name> --result-url <url> [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret <secret>] [--min-file-size <bytes>] [--max-file-size <bytes>] [--allowed-extensions <.pdf,.xlsx,...>] [--dry-run] [--corp <corpId>]`
|
||||
- `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>]`
|
||||
- `seal-use webhook delete <idOrName> [--yes|--dry-run] [--corp <corpId>]`
|
||||
- `seal-use webhook resource-pack export [--limit <n>] [--status <status>] [--output <file.zip>] [--to-downloads] --corp <corpId>` (将线上审核记录打包导出为标准 Webhook 资源包,支持按条数、状态或指定单据 ID 筛选)
|
||||
- `seal-use webhook resource-pack export [--limit <n>] [--status <status>] [--out <file.zip>] [--downloads] --corp <corpId>` (将线上审核记录打包导出为标准 Webhook 资源包,支持按条数、状态或指定单据 ID 筛选)
|
||||
- `seal-use webhook resource-pack preview <资源包.zip|信息表.xlsx> [--min-file-size <bytes>] [--max-file-size <bytes>] [--allowed-extensions <.pdf,.xlsx,...>] --corp <corpId>`
|
||||
- `seal-use webhook resource-pack push <资源包.zip|信息表.xlsx> [--webhook <idOrName>] --corp <corpId>` (别名 `pack`,旧名 `material-pack` 兼容支持)
|
||||
- `seal-use webhook replay [<recordId>] [--sn <documentSN>] [--limit <n>] [--status <status>] [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--sn-suffix <str>] [--dry-run] [--yes|--confirm] [--force] [--corp <corpId>]` (通用单据重放:从历史审批单据汲取结构化表单与明细,清洗规范化字段类型,支持单条或批量重放到目标企业的 Webhook 触发审批。实际重放要求 `--yes` 或 `--confirm`;默认阻止向未授权生产环境重放以防污染数据,提供 `--force` 显式覆盖支持)
|
||||
@@ -421,7 +421,7 @@ Approval runs, simulations, and Langfuse bridge:
|
||||
- `seal-use simulation status <batchId> --corp <corpId>` performs one non-blocking status check and returns `QUEUED`/`RUNNING`/`COMPLETED`/`FAILED`-style state plus counters.
|
||||
- `seal-use simulation approval-definitions --corp <corpId>` lists available Feishu approval definitions so an `approvalCode` can be selected before creating a batch.
|
||||
- `seal-use simulation wait <batchId> --corp <corpId>`
|
||||
- `seal-use simulation clean <batchId> --yes --corp <corpId>`
|
||||
- `seal-use simulation delete <batchId> --yes --corp <corpId>`
|
||||
- `seal-use simulation list [--query <text>] [--since <time>] [--until <time>] [--all] --corp <corpId>` (过滤在本地完成,见下方“本地聚合”说明)
|
||||
- `seal-use simulation search "<关键词>" [--since 7d] [--all] --corp <corpId>` (**本地聚合检索,非云端原生**;先按 limit/offset 拉取批次再过滤,响应 `retrieval.serverSideSearch: false`)
|
||||
- `seal-use simulation get <batchId> --corp <corpId>`
|
||||
@@ -465,14 +465,14 @@ The diagnostic stages are `hose.openapi`, `hose.provisional`, `seal.sso`, and `s
|
||||
Search approval rules or knowledge documents:
|
||||
|
||||
```bash
|
||||
seal-use rules search <keyword> --maxResults 20 --corp <corpId>
|
||||
seal-use documents search <keyword> --maxResults 20 --corp <corpId>
|
||||
seal-use rules search <keyword> --max-results 20 --corp <corpId>
|
||||
seal-use documents search <keyword> --max-results 20 --corp <corpId>
|
||||
```
|
||||
|
||||
Get aggregated approval context:
|
||||
|
||||
```bash
|
||||
seal-use context --documentLimit 20 --corp <corpId>
|
||||
seal-use context --document-limit 20 --corp <corpId>
|
||||
```
|
||||
|
||||
Create, update, and publish approval rules:
|
||||
@@ -499,7 +499,7 @@ seal-use approval-runs summary --corp <corpId> --date 2026-06-09 --timezone Asia
|
||||
Find a run and include Langfuse bridge rows:
|
||||
|
||||
```bash
|
||||
seal-use approval-runs search --corp <corpId> --query <sourceDocumentSN> --limit 20 --includeBridge true
|
||||
seal-use approval-runs search --corp <corpId> --query <sourceDocumentSN> --limit 20 --include-bridge
|
||||
```
|
||||
|
||||
Resolve Langfuse trace/session hints:
|
||||
|
||||
@@ -64,11 +64,11 @@ Returns `id`, `code`, `ruleCode`, `runtimeRuleId`, `description`, `scope`, `stri
|
||||
|
||||
```bash
|
||||
# Search current draft rules (default)
|
||||
seal-use rules search <keyword> --maxResults 20 --corp <corpId>
|
||||
seal-use rules search <keyword> --max-results 20 --corp <corpId>
|
||||
|
||||
# Search latest published version or a specific historical version
|
||||
seal-use rules search <keyword> --version latest --maxResults 20 --corp <corpId>
|
||||
seal-use rules search <keyword> --version 16 --maxResults 20 --corp <corpId>
|
||||
seal-use rules search <keyword> --version latest --max-results 20 --corp <corpId>
|
||||
seal-use rules search <keyword> --version 16 --max-results 20 --corp <corpId>
|
||||
```
|
||||
|
||||
## Clear Draft Rules Before Import
|
||||
|
||||
@@ -60,7 +60,7 @@ All validation errors are collected and reported together in a single `MaterialP
|
||||
# Export online approval records to a local Webhook resource pack ZIP
|
||||
seal-use webhook resource-pack export --limit 10 --corp <sourceCorpId>
|
||||
# Export specific records and save to Downloads
|
||||
seal-use webhook resource-pack export <recordId> --to-downloads --corp <sourceCorpId>
|
||||
seal-use webhook resource-pack export <recordId> --downloads --corp <sourceCorpId>
|
||||
|
||||
# Check environment readiness and optionally pre-validate the resource pack
|
||||
seal-use webhook ready [--file <pack.zip>] [--corp <corpId>]
|
||||
@@ -97,7 +97,7 @@ Default configuration:
|
||||
|
||||
```bash
|
||||
# New Webhook: use the default 500-byte minimum and default extension whitelist
|
||||
seal-use webhook add --name "材料包入站" --result-url "https://your-domain.com/callback" --corp <corpId>
|
||||
seal-use webhook create --name "材料包入站" --result-url "https://your-domain.com/callback" --corp <corpId>
|
||||
|
||||
# Configure an existing Webhook; sizes are bytes and extensions are comma-separated
|
||||
seal-use webhook update <webhookIdOrName> \
|
||||
|
||||
+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]");
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { exportInsightReportToExcel } from "../../domains/seal/insight/export.js";
|
||||
import { runCapability } from "../helpers.js";
|
||||
import { booleanOption, numberOption, stringOption } from "../parser.js";
|
||||
import { booleanOption, dryRunOption, numberOption, stringOption } from "../parser.js";
|
||||
import { outputOptions, printJson } from "../printer.js";
|
||||
import type { ParsedArgs } from "../types.js";
|
||||
|
||||
@@ -72,7 +72,8 @@ export async function handleAnalyticsCommand(
|
||||
client,
|
||||
corp,
|
||||
{
|
||||
recordId
|
||||
recordId,
|
||||
dryRun: dryRunOption(args)
|
||||
},
|
||||
outputOptions(args.options)
|
||||
);
|
||||
|
||||
@@ -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,6 +15,7 @@ import { createDelegation, getMe } from "../../domains/seal/api.js";
|
||||
import { resolveHoseLinkIdentity, resolveSealLinkIdentity, summarizeSealLinkIdentity } from "../../domains/seal/enterprise/assist-identity.js";
|
||||
import {
|
||||
booleanOption,
|
||||
dryRunOption,
|
||||
parseDelegationExpireHours,
|
||||
parseHoseExpireSeconds,
|
||||
stringOption
|
||||
@@ -99,8 +100,14 @@ export async function handleAuthCommand(action: string | undefined, corp: CorpCo
|
||||
|
||||
if (subAction === "revoke") {
|
||||
const tokenId = args.command[3] ?? stringOption(args.options.tokenId) ?? stringOption(args.options.id);
|
||||
if (!tokenId) throw usageError("Usage: seal-use auth link revoke <tokenId>");
|
||||
await runCapability("sealDelegationRevoke", client, corp, { tokenId }, outputOptions(args.options));
|
||||
if (!tokenId) throw usageError("Usage: seal-use auth link revoke <tokenId> [--dry-run]");
|
||||
await runCapability(
|
||||
"sealDelegationRevoke",
|
||||
client,
|
||||
corp,
|
||||
{ tokenId, dryRun: dryRunOption(args) },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
import type { CorpEnvironment } from "../../../core/config/types.js";
|
||||
import { selectCorp } from "../../helpers.js";
|
||||
import { confirmationRequired, usageError } from "../../../core/errors.js";
|
||||
import { booleanOption, numberOption, stringOption } from "../../parser.js";
|
||||
import { booleanOption, dryRunOption, numberOption, stringOption } from "../../parser.js";
|
||||
import { printJson } from "../../printer.js";
|
||||
import type { ParsedArgs } from "../../types.js";
|
||||
import { formatSafeSourceDetail, resolveCorpSealUrl } from "./shared.js";
|
||||
@@ -167,6 +167,20 @@ export async function handleCorpOverview(
|
||||
throw usageError("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");
|
||||
}
|
||||
|
||||
const dryRun = dryRunOption(args);
|
||||
if (dryRun) {
|
||||
printJson({
|
||||
preview: true,
|
||||
dryRun: true,
|
||||
mutation: "corps mark",
|
||||
corpId: corp.id,
|
||||
corpName: corp.name,
|
||||
changesDiff: { before: corp.environment ?? undefined, after: targetEnv },
|
||||
note: "环境标签影响同步与重放安全守卫;去掉 --dry-run 并加 --confirm 才会实际写入。"
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
const confirmed = booleanOption(args.options.confirm) === true || booleanOption(args.options.yes) === true;
|
||||
if (!confirmed) {
|
||||
throw confirmationRequired(
|
||||
|
||||
@@ -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"]),
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
import { afterEach, describe, expect, test } from "bun:test";
|
||||
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { runCli } from "../runner.js";
|
||||
|
||||
/**
|
||||
* Mutation-preview (`--dry-run`) gates for commands that previously mutated
|
||||
* without a preview path (AGENTS.md "Safety Guardrail & Mutation Preview").
|
||||
* Every dry-run must return structured JSON with `preview: true` on stdout and
|
||||
* never issue a mutating HTTP request — reads (GET) are allowed for building
|
||||
* the before/after diff.
|
||||
*/
|
||||
|
||||
const ORIGINAL_ENV = {
|
||||
enterprises: process.env.SEAL_USE_ENTERPRISES_DIR,
|
||||
config: process.env.SEAL_USE_CONFIG_FILE,
|
||||
tokenStore: process.env.SEAL_USE_TOKEN_STORE,
|
||||
usageFile: process.env.SEAL_USE_USAGE_FILE
|
||||
};
|
||||
const ORIGINAL_FETCH = globalThis.fetch;
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
afterEach(() => {
|
||||
restoreEnv("SEAL_USE_ENTERPRISES_DIR", ORIGINAL_ENV.enterprises);
|
||||
restoreEnv("SEAL_USE_CONFIG_FILE", ORIGINAL_ENV.config);
|
||||
restoreEnv("SEAL_USE_TOKEN_STORE", ORIGINAL_ENV.tokenStore);
|
||||
restoreEnv("SEAL_USE_USAGE_FILE", ORIGINAL_ENV.usageFile);
|
||||
globalThis.fetch = ORIGINAL_FETCH;
|
||||
|
||||
for (const dir of tempDirs.splice(0)) {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
function restoreEnv(name: string, value: string | undefined) {
|
||||
if (value === undefined) delete process.env[name];
|
||||
else process.env[name] = value;
|
||||
}
|
||||
|
||||
function setupMockEnv() {
|
||||
const root = mkdtempSync(join(tmpdir(), "seal-use-dry-run-"));
|
||||
const enterprises = join(root, "enterprises");
|
||||
tempDirs.push(root);
|
||||
process.env.SEAL_USE_ENTERPRISES_DIR = enterprises;
|
||||
process.env.SEAL_USE_CONFIG_FILE = join(root, "config.json");
|
||||
process.env.SEAL_USE_TOKEN_STORE = join(root, "tokens.json");
|
||||
process.env.SEAL_USE_USAGE_FILE = join(root, "usage.json");
|
||||
mkdirSync(enterprises, { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(enterprises, "dry-run-corp.json"),
|
||||
JSON.stringify(
|
||||
{
|
||||
id: "dry-run-corp",
|
||||
name: "Dry Run Corp",
|
||||
environment: "test",
|
||||
seal: {
|
||||
url: "https://dry-run-corp.sealai.cc",
|
||||
endpoints: { approvalStylePreferences: "api/v1/agent/ai-approval/config" }
|
||||
},
|
||||
source: { type: "seal", token: "mock-token", sealUrl: "https://dry-run-corp.sealai.cc" }
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(root, "config.json"),
|
||||
JSON.stringify({ defaultCorpId: "dry-run-corp", stateful: true }, null, 2)
|
||||
);
|
||||
return { root, enterprises };
|
||||
}
|
||||
|
||||
/** Records `METHOD url` per request and answers every call with a generic 200. */
|
||||
function trackRequests() {
|
||||
const requests: string[] = [];
|
||||
globalThis.fetch = (async (input: RequestInfo | URL) => {
|
||||
const url = typeof input === "string"
|
||||
? input
|
||||
: input instanceof URL
|
||||
? input.toString()
|
||||
: input.url;
|
||||
const method = typeof input === "object" && "method" in input ? input.method : "GET";
|
||||
requests.push(`${method} ${url}`);
|
||||
return new Response(JSON.stringify({ data: {} }), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" }
|
||||
});
|
||||
}) as typeof fetch;
|
||||
return requests;
|
||||
}
|
||||
|
||||
describe("mutation preview (--dry-run) gates", () => {
|
||||
test("users create --dry-run previews without any network call", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["users", "create", "--name", "张三", "--phone", "13300001111", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"dryRun": true');
|
||||
expect(requests).toEqual([]);
|
||||
});
|
||||
|
||||
test("users delete --dry-run bypasses --yes and issues no mutating request", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["users", "delete", "user-123", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(requests.every((entry) => entry.startsWith("GET "))).toBe(true);
|
||||
});
|
||||
|
||||
test("rules create --dry-run previews the rule payload without any network call", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli([
|
||||
"rules", "create", "--description", "测试规则", "--scope", "general", "--dry-run"
|
||||
]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"mutation": "sealApprovalRuleCreate"');
|
||||
expect(requests).toEqual([]);
|
||||
});
|
||||
|
||||
test("rules delete --dry-run bypasses --yes and issues no mutating request", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["rules", "delete", "0025", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"deleted": 0');
|
||||
expect(requests.every((entry) => entry.startsWith("GET "))).toBe(true);
|
||||
});
|
||||
|
||||
test("rules publish --dry-run previews draft scale without publishing", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["rules", "publish", "v-test", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"published": false');
|
||||
expect(requests.every((entry) => entry.startsWith("GET "))).toBe(true);
|
||||
});
|
||||
|
||||
test("simulation delete --dry-run bypasses --yes and issues no mutating request", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["simulation", "delete", "batch-42", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"cleaned": 0');
|
||||
expect(requests.every((entry) => entry.startsWith("GET "))).toBe(true);
|
||||
});
|
||||
|
||||
test("analytics analyze --dry-run previews without triggering server-side analysis", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["analytics", "analyze", "record-77", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"triggered": false');
|
||||
expect(requests).toEqual([]);
|
||||
});
|
||||
|
||||
test("auth link revoke --dry-run previews without revoking", async () => {
|
||||
setupMockEnv();
|
||||
const requests = trackRequests();
|
||||
|
||||
const result = await runCli(["auth", "link", "revoke", "token-1", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(requests.every((entry) => entry.startsWith("GET "))).toBe(true);
|
||||
});
|
||||
|
||||
test("corps mark --dry-run previews the tag change without writing config", async () => {
|
||||
const { enterprises } = setupMockEnv();
|
||||
trackRequests();
|
||||
|
||||
const result = await runCli(["corps", "mark", "dry-run-corp", "--env", "production", "--dry-run"]);
|
||||
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain('"preview": true');
|
||||
expect(result.stdout).toContain('"after": "production"');
|
||||
|
||||
const config = JSON.parse(readFileSync(join(enterprises, "dry-run-corp.json"), "utf8"));
|
||||
expect(config.environment).toBe("test");
|
||||
});
|
||||
});
|
||||
+12
-10
@@ -12,6 +12,7 @@ import { runCapability, runCapabilityResult } from "../helpers.js";
|
||||
import { confirmationRequired, validationError, usageError } from "../../core/errors.js";
|
||||
import {
|
||||
booleanOption,
|
||||
dryRunOption,
|
||||
jsonObject,
|
||||
numberOption,
|
||||
parseRuleVersionSelector,
|
||||
@@ -220,7 +221,7 @@ export async function handleRulesCommand(
|
||||
"sealApprovalRuleCreate",
|
||||
client!,
|
||||
corp,
|
||||
{ description, scope, strictness },
|
||||
{ description, scope, strictness, dryRun: dryRunOption(args) },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
@@ -246,7 +247,7 @@ export async function handleRulesCommand(
|
||||
"sealApprovalRuleUpdate",
|
||||
client!,
|
||||
corp,
|
||||
{ ruleId, description, scope, strictness },
|
||||
{ ruleId, description, scope, strictness, dryRun: dryRunOption(args) },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
@@ -259,10 +260,11 @@ export async function handleRulesCommand(
|
||||
stringOption(args.options["rule-id"]) ??
|
||||
stringOption(args.options.code);
|
||||
if (!ruleId) {
|
||||
throw usageError("Usage: seal-use rules delete <code> --yes [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use rules delete <code> [--dry-run] --yes [--corp <corpId>]");
|
||||
}
|
||||
const confirmed = booleanOption(args.options.yes) === true || booleanOption(args.options.confirm) === true;
|
||||
if (!confirmed) {
|
||||
const dryRun = dryRunOption(args);
|
||||
if (!confirmed && !dryRun) {
|
||||
throw confirmationRequired(
|
||||
`Refusing to delete rule '${ruleId}' without --yes.`,
|
||||
`seal-use rules delete ${ruleId} --corp ${corp.id} --yes`
|
||||
@@ -272,7 +274,7 @@ export async function handleRulesCommand(
|
||||
"sealApprovalRuleDelete",
|
||||
client!,
|
||||
corp,
|
||||
{ ruleId },
|
||||
{ ruleId, dryRun },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
@@ -287,13 +289,13 @@ export async function handleRulesCommand(
|
||||
stringOption(args.options.name) ??
|
||||
(typeof payload.versionName === "string" ? payload.versionName : undefined);
|
||||
if (!versionName) {
|
||||
throw usageError("Usage: seal-use rules publish <versionName> [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use rules publish <versionName> [--dry-run] [--corp <corpId>]");
|
||||
}
|
||||
await runCapability(
|
||||
"sealApprovalRuleVersionPublish",
|
||||
client!,
|
||||
corp,
|
||||
{ versionName },
|
||||
{ versionName, dryRun: dryRunOption(args) },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
@@ -301,7 +303,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 +311,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([]);
|
||||
});
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { confirmationRequired, usageError, validationError } from "../../core/er
|
||||
import { runCapability, runCapabilityResult } from "../helpers.js";
|
||||
import {
|
||||
booleanOption,
|
||||
dryRunOption,
|
||||
jsonObject,
|
||||
numberOption,
|
||||
splitOption,
|
||||
@@ -172,15 +173,22 @@ export async function handleSimulationCommand(
|
||||
|
||||
if (action === "clean" || action === "delete") {
|
||||
const batchId = maybeName ?? stringOption(args.options.batchId) ?? stringOption(args.options["batch-id"]);
|
||||
if (!batchId) throw usageError("Usage: seal-use simulation clean <batchId> --yes");
|
||||
if (!batchId) throw usageError("Usage: seal-use simulation delete <batchId> [--dry-run] --yes");
|
||||
const confirmed = booleanOption(args.options.yes) === true || booleanOption(args.options.confirm) === true;
|
||||
if (!confirmed) {
|
||||
const dryRun = dryRunOption(args);
|
||||
if (!confirmed && !dryRun) {
|
||||
throw confirmationRequired(
|
||||
`Refusing to delete simulation batch '${batchId}' without --yes.`,
|
||||
`seal-use simulation clean ${batchId} --corp ${corp.id} --yes`
|
||||
`seal-use simulation delete ${batchId} --corp ${corp.id} --yes`
|
||||
);
|
||||
}
|
||||
await runCapability("sealSimulationBatchClean", client, corp, { batchId }, outputOptions(args.options));
|
||||
await runCapability(
|
||||
"sealSimulationBatchClean",
|
||||
client,
|
||||
corp,
|
||||
{ batchId, dryRun },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+18
-10
@@ -2,7 +2,7 @@ import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { confirmationRequired, usageError } from "../../core/errors.js";
|
||||
import { runCapability } from "../helpers.js";
|
||||
import { booleanOption, parseDelegationExpireHours, stringOption } from "../parser.js";
|
||||
import { booleanOption, dryRunOption, parseDelegationExpireHours, stringOption } from "../parser.js";
|
||||
import { outputOptions } from "../printer.js";
|
||||
import type { ParsedArgs } from "../types.js";
|
||||
|
||||
@@ -16,24 +16,31 @@ export async function handleUsersCommand(
|
||||
if (action === "create") {
|
||||
const name = stringOption(args.options.name) ?? maybeName;
|
||||
const phone = stringOption(args.options.phone);
|
||||
if (!name || !phone) throw usageError("Usage: seal-use users create --name <name> --phone <phone> [--dept <deptId>]");
|
||||
if (!name || !phone) throw usageError("Usage: seal-use users create --name <name> --phone <phone> [--dept <deptId>] [--dry-run]");
|
||||
const deptId = stringOption(args.options.dept) ?? stringOption(args.options.departmentId);
|
||||
const departmentIds = deptId ? [deptId] : undefined;
|
||||
await runCapability("sealUserCreate", client, corp, { name, phone, departmentIds }, outputOptions(args.options));
|
||||
await runCapability(
|
||||
"sealUserCreate",
|
||||
client,
|
||||
corp,
|
||||
{ name, phone, departmentIds, dryRun: dryRunOption(args) },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === "reset-password") {
|
||||
const userId = maybeName ?? stringOption(args.options.userId);
|
||||
if (!userId) throw usageError("Usage: seal-use users reset-password <userId> --yes");
|
||||
if (!userId) throw usageError("Usage: seal-use users reset-password <userId> [--dry-run] --yes");
|
||||
const confirmed = booleanOption(args.options.yes) === true || booleanOption(args.options.confirm) === true;
|
||||
if (!confirmed) {
|
||||
const dryRun = dryRunOption(args);
|
||||
if (!confirmed && !dryRun) {
|
||||
throw confirmationRequired(
|
||||
`Refusing to reset password of user '${userId}' without --yes.`,
|
||||
`seal-use users reset-password ${userId} --corp ${corp.id} --yes`
|
||||
);
|
||||
}
|
||||
await runCapability("sealUserResetPassword", client, corp, { userId }, outputOptions(args.options));
|
||||
await runCapability("sealUserResetPassword", client, corp, { userId, dryRun }, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,15 +59,16 @@ export async function handleUsersCommand(
|
||||
|
||||
if (action === "delete") {
|
||||
const userId = maybeName ?? stringOption(args.options.userId);
|
||||
if (!userId) throw usageError("Usage: seal-use users delete <userId> --yes");
|
||||
if (!userId) throw usageError("Usage: seal-use users delete <userId> [--dry-run] --yes");
|
||||
const confirmed = booleanOption(args.options.yes) === true || booleanOption(args.options.confirm) === true;
|
||||
if (!confirmed) {
|
||||
const dryRun = dryRunOption(args);
|
||||
if (!confirmed && !dryRun) {
|
||||
throw confirmationRequired(
|
||||
`Refusing to delete user '${userId}' without --yes.`,
|
||||
`seal-use users delete ${userId} --corp ${corp.id} --yes`
|
||||
);
|
||||
}
|
||||
await runCapability("sealUserDelete", client, corp, { userId }, outputOptions(args.options));
|
||||
await runCapability("sealUserDelete", client, corp, { userId, dryRun }, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,7 +89,7 @@ export async function handleUsersCommand(
|
||||
"sealUserDelegationCreate",
|
||||
client,
|
||||
corp,
|
||||
{ userIdOrPhone, note, expiresInHours },
|
||||
{ userIdOrPhone, note, expiresInHours, dryRun: dryRunOption(args) },
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
+42
-37
@@ -80,9 +80,10 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
name: "mark",
|
||||
group: "企业配置",
|
||||
summary: "Mark enterprise environment as production or test",
|
||||
usage: ["seal-use corps mark <corpId> --env <production|test> [--confirm]"],
|
||||
usage: ["seal-use corps mark <corpId> --env <production|test> [--dry-run] [--confirm]"],
|
||||
options: [
|
||||
{ flag: "--env <production|test>", description: "Target environment: 'production' or 'test' (required)" },
|
||||
{ flag: "--dry-run", description: "Preview the environment tag change without writing local config" },
|
||||
{ flag: "--confirm", description: "Confirm the environment update (required)" }
|
||||
],
|
||||
description: "Explicitly updates an enterprise's environment tag. Requires --confirm to prevent accidental changes."
|
||||
@@ -284,27 +285,27 @@ 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",
|
||||
summary: "Create a new draft approval rule",
|
||||
usage: ["seal-use rules create --description <text> --scope <scope> [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--description-file <path>] [--corp <corpId>]"]
|
||||
usage: ["seal-use rules create --description <text> --scope <scope> [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--description-file <path>] [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "update",
|
||||
summary: "Update a draft approval rule by code",
|
||||
usage: ["seal-use rules update <code> [--description <text>|--description-file <path>] [--scope <scope>] [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--corp <corpId>]"]
|
||||
usage: ["seal-use rules update <code> [--description <text>|--description-file <path>] [--scope <scope>] [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "delete",
|
||||
summary: "Delete a draft approval rule by code",
|
||||
usage: ["seal-use rules delete <code> --yes [--corp <corpId>]"]
|
||||
usage: ["seal-use rules delete <code> [--dry-run] --yes [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "publish",
|
||||
summary: "Publish current draft rules as a new formal version",
|
||||
usage: ["seal-use rules publish <versionName> [--corp <corpId>]"]
|
||||
usage: ["seal-use rules publish <versionName> [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "versions",
|
||||
@@ -386,18 +387,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 +415,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 +429,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 +477,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 +487,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 +517,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 +599,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 +801,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> [--dry-run] --yes [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "specifications",
|
||||
@@ -987,9 +990,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>]"]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1061,7 +1065,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "link revoke",
|
||||
summary: "【Seal 审核后台】撤销指定的 Seal 委托授权令牌",
|
||||
usage: ["seal-use auth link revoke <tokenId> [--corp <corpId>]"]
|
||||
usage: ["seal-use auth link revoke <tokenId> [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "hose-link",
|
||||
@@ -1120,7 +1124,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "create",
|
||||
summary: "Create a new tenant user",
|
||||
usage: ["seal-use users create --name <name> --phone <phone> [--dept <deptId>] [--corp <corpId>]"]
|
||||
usage: ["seal-use users create --name <name> --phone <phone> [--dept <deptId>] [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "search",
|
||||
@@ -1130,16 +1134,17 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "delegation",
|
||||
summary: "Create delegation token for a specific user",
|
||||
usage: ["seal-use users delegation <userIdOrPhone|name> [--note <note>] [--expire <duration>] [--corp <corpId>]"],
|
||||
usage: ["seal-use users delegation <userIdOrPhone|name> [--note <note>] [--expire <duration>] [--dry-run] [--corp <corpId>]"],
|
||||
options: [
|
||||
{ flag: "--note <note>", description: "委托授权备注说明" },
|
||||
{ flag: "--expire, --expires-in <duration>", description: "委托授权有效期,推荐 '7d' 或 '24h'(最大 7 天,兼容秒数并自动向下取整)" }
|
||||
{ flag: "--expire, --expires-in <duration>", description: "委托授权有效期,推荐 '7d' 或 '24h'(最大 7 天,兼容秒数并自动向下取整)" },
|
||||
{ flag: "--dry-run", description: "Preview the delegation parameters without minting a token" }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "reset-password",
|
||||
summary: "Reset user password",
|
||||
usage: ["seal-use users reset-password <userId> --yes [--corp <corpId>]"]
|
||||
usage: ["seal-use users reset-password <userId> [--dry-run] --yes [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "get",
|
||||
@@ -1149,7 +1154,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{
|
||||
name: "delete",
|
||||
summary: "Delete user",
|
||||
usage: ["seal-use users delete <userId> --yes [--corp <corpId>]"]
|
||||
usage: ["seal-use users delete <userId> [--dry-run] --yes [--corp <corpId>]"]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1316,7 +1321,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
name: "analyze",
|
||||
aliases: ["reanalyze"],
|
||||
summary: "Trigger on-demand smart insight risk analysis for an approval record",
|
||||
usage: ["seal-use analytics analyze <recordId> [--corp <corpId>]"]
|
||||
usage: ["seal-use analytics analyze <recordId> [--dry-run] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "export",
|
||||
@@ -1342,7 +1347,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 +1381,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);
|
||||
});
|
||||
});
|
||||
+19
-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,17 @@ 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"])
|
||||
);
|
||||
}
|
||||
|
||||
/** Shared `--dry-run` read for mutation-preview gates (charter: one canonical spelling). */
|
||||
export function dryRunOption(args: ParsedArgs): boolean | undefined {
|
||||
return booleanOption(args.options["dry-run"]) ?? booleanOption(args.options.dryRun);
|
||||
}
|
||||
|
||||
export function materialPackFilePolicyOptions(
|
||||
|
||||
@@ -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 (费控集成)",
|
||||
|
||||
@@ -43,7 +43,8 @@ describe("sealCapabilities", () => {
|
||||
expect(Object.keys(schema.properties ?? {})).toEqual([
|
||||
"description",
|
||||
"scope",
|
||||
"strictness"
|
||||
"strictness",
|
||||
"dryRun"
|
||||
]);
|
||||
expect(schema.required).toEqual(["description", "scope", "strictness"]);
|
||||
});
|
||||
|
||||
@@ -47,10 +47,28 @@ export const identityCapabilities = [
|
||||
name: "sealDelegationRevoke",
|
||||
description: "撤销/废除指定的 Seal 授权链接 (Delegation)",
|
||||
parameters: z.object({
|
||||
tokenId: z.string().describe("授权链接 ID (delegation record ID)")
|
||||
tokenId: z.string().describe("授权链接 ID (delegation record ID)"),
|
||||
dryRun: z.boolean().optional().describe("仅预览将被撤销的授权链接,不执行撤销")
|
||||
}),
|
||||
handler: async (client: KyInstance, params: { tokenId: string }) =>
|
||||
api.revokeDelegation(client, params.tokenId)
|
||||
handler: async (
|
||||
client: KyInstance,
|
||||
params: { tokenId: string; dryRun?: boolean }
|
||||
) => {
|
||||
if (params.dryRun) {
|
||||
const target = await api
|
||||
.listDelegations(client)
|
||||
.then((items) => items.find((item) => item.id === params.tokenId))
|
||||
.catch(() => undefined);
|
||||
return {
|
||||
preview: true,
|
||||
dryRun: true,
|
||||
mutation: "sealDelegationRevoke",
|
||||
revoked: 0,
|
||||
target: target ?? { id: params.tokenId }
|
||||
};
|
||||
}
|
||||
return api.revokeDelegation(client, params.tokenId);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "sealUserCreate",
|
||||
@@ -59,21 +77,42 @@ export const identityCapabilities = [
|
||||
name: z.string().describe("用户姓名"),
|
||||
phone: z.string().describe("手机号码 (例如 13300001111 或 +8613300001111)"),
|
||||
permissions: z.array(z.string()).optional().describe("权限列表,默认为 []"),
|
||||
departmentIds: z.array(z.string()).optional().describe("关联部门 ID 数组")
|
||||
departmentIds: z.array(z.string()).optional().describe("关联部门 ID 数组"),
|
||||
dryRun: z.boolean().optional().describe("仅预览将要创建的用户,不执行")
|
||||
}),
|
||||
handler: async (
|
||||
client: KyInstance,
|
||||
params: { name: string; phone: string; permissions?: string[]; departmentIds?: string[] }
|
||||
) => api.createLocalUser(client, params)
|
||||
params: { name: string; phone: string; permissions?: string[]; departmentIds?: string[]; dryRun?: boolean }
|
||||
) => {
|
||||
if (params.dryRun) {
|
||||
const { dryRun: _dryRun, ...payload } = params;
|
||||
return { preview: true, dryRun: true, mutation: "sealUserCreate", created: payload };
|
||||
}
|
||||
const { dryRun: _dryRun, ...payload } = params;
|
||||
return api.createLocalUser(client, payload);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "sealUserResetPassword",
|
||||
description: "重置指定 Seal 用户的默认/随机密码,并返回生成的新密码",
|
||||
parameters: z.object({
|
||||
userId: z.string().describe("用户 ID (_id)")
|
||||
userId: z.string().describe("用户 ID (_id)"),
|
||||
dryRun: z.boolean().optional().describe("仅预览将被重置密码的用户,不执行")
|
||||
}),
|
||||
handler: async (client: KyInstance, params: { userId: string }) =>
|
||||
api.resetUserPassword(client, params.userId)
|
||||
handler: async (client: KyInstance, params: { userId: string; dryRun?: boolean }) => {
|
||||
if (params.dryRun) {
|
||||
const before = await api.getUserDetail(client, params.userId).catch(() => undefined);
|
||||
return {
|
||||
preview: true,
|
||||
dryRun: true,
|
||||
mutation: "sealUserResetPassword",
|
||||
reset: 0,
|
||||
before,
|
||||
wouldDo: "重置该用户密码并返回新的初始随机密码"
|
||||
};
|
||||
}
|
||||
return api.resetUserPassword(client, params.userId);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "sealUserGet",
|
||||
@@ -97,19 +136,43 @@ export const identityCapabilities = [
|
||||
name: "sealUserDelete",
|
||||
description: "删除指定 Seal 本地用户",
|
||||
parameters: z.object({
|
||||
userId: z.string().describe("用户 ID (_id)")
|
||||
userId: z.string().describe("用户 ID (_id)"),
|
||||
dryRun: z.boolean().optional().describe("仅预览将被删除的用户,不执行删除")
|
||||
}),
|
||||
handler: async (client: KyInstance, params: { userId: string }) =>
|
||||
api.deleteLocalUser(client, params.userId)
|
||||
handler: async (client: KyInstance, params: { userId: string; dryRun?: boolean }) => {
|
||||
if (params.dryRun) {
|
||||
const before = await api.getUserDetail(client, params.userId).catch(() => undefined);
|
||||
return {
|
||||
preview: true,
|
||||
dryRun: true,
|
||||
mutation: "sealUserDelete",
|
||||
deleted: 0,
|
||||
before
|
||||
};
|
||||
}
|
||||
return api.deleteLocalUser(client, params.userId);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "sealUserActivate",
|
||||
description: "启用/激活已离职的 Seal 用户账号",
|
||||
parameters: z.object({
|
||||
userId: z.string().describe("用户 ID (_id)")
|
||||
userId: z.string().describe("用户 ID (_id)"),
|
||||
dryRun: z.boolean().optional().describe("仅预览将被激活的用户,不执行")
|
||||
}),
|
||||
handler: async (client: KyInstance, params: { userId: string }) =>
|
||||
api.activateLocalUser(client, params.userId)
|
||||
handler: async (client: KyInstance, params: { userId: string; dryRun?: boolean }) => {
|
||||
if (params.dryRun) {
|
||||
const before = await api.getUserDetail(client, params.userId).catch(() => undefined);
|
||||
return {
|
||||
preview: true,
|
||||
dryRun: true,
|
||||
mutation: "sealUserActivate",
|
||||
activated: 0,
|
||||
before
|
||||
};
|
||||
}
|
||||
return api.activateLocalUser(client, params.userId);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "sealUserDelegationCreate",
|
||||
@@ -123,18 +186,31 @@ export const identityCapabilities = [
|
||||
.min(1)
|
||||
.max(168)
|
||||
.optional()
|
||||
.describe("授权链接有效期小时数(1~168 小时,即最大 7 天,默认 24 小时)")
|
||||
.describe("授权链接有效期小时数(1~168 小时,即最大 7 天,默认 24 小时)"),
|
||||
dryRun: z.boolean().optional().describe("仅预览将要签发的授权链接参数,不执行")
|
||||
}),
|
||||
handler: async (
|
||||
client: KyInstance,
|
||||
params: { userIdOrPhone: string; note?: string; expiresInHours?: number },
|
||||
params: { userIdOrPhone: string; note?: string; expiresInHours?: number; dryRun?: boolean },
|
||||
context: CapabilityContext
|
||||
) =>
|
||||
api.createDelegationForUser(
|
||||
) => {
|
||||
if (params.dryRun) {
|
||||
const { dryRun: _dryRun, ...payload } = params;
|
||||
return {
|
||||
preview: true,
|
||||
dryRun: true,
|
||||
mutation: "sealUserDelegationCreate",
|
||||
issued: false,
|
||||
forUser: payload
|
||||
};
|
||||
}
|
||||
const { dryRun: _dryRun, ...payload } = params;
|
||||
return api.createDelegationForUser(
|
||||
client,
|
||||
params,
|
||||
payload,
|
||||
(token) => createSealClientForToken(context.corp, token),
|
||||
context.corp
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
];
|
||||
@@ -53,12 +53,25 @@ export const insightCapabilities = [
|
||||
name: "sealInsightRecordAnalyze",
|
||||
description: "对指定的审批单运行记录按需触发智能洞察风险分析",
|
||||
parameters: z.object({
|
||||
recordId: z.string().describe("审批单运行记录 ID (recordId)")
|
||||
recordId: z.string().describe("审批单运行记录 ID (recordId)"),
|
||||
dryRun: z.boolean().optional().describe("仅预览将要触发的分析,不实际触发服务端分析")
|
||||
}),
|
||||
handler: async (
|
||||
client: KyInstance,
|
||||
params: { recordId: string }
|
||||
) => api.analyzeInsightRecord(client, params.recordId)
|
||||
params: { recordId: string; dryRun?: boolean }
|
||||
) => {
|
||||
if (params.dryRun) {
|
||||
return {
|
||||
preview: true,
|
||||
dryRun: true,
|
||||
mutation: "sealInsightRecordAnalyze",
|
||||
recordId: params.recordId,
|
||||
triggered: false,
|
||||
wouldDo: "对该审批运行记录触发一次服务端智能洞察风险分析"
|
||||
};
|
||||
}
|
||||
return api.analyzeInsightRecord(client, params.recordId);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "sealInsightExport",
|
||||
|
||||
@@ -192,13 +192,25 @@ export const rulesCapabilities = [
|
||||
parameters: z.object({
|
||||
description: z.string().describe("规则描述"),
|
||||
scope: z.string().describe("适用场景"),
|
||||
strictness: z.enum(["MUST_FOLLOW", "SHOULD_FOLLOW", "SUGGESTION"]).describe("严格程度")
|
||||
strictness: z.enum(["MUST_FOLLOW", "SHOULD_FOLLOW", "SUGGESTION"]).describe("严格程度"),
|
||||
dryRun: z.boolean().optional().describe("仅预览将要创建的规则,不执行")
|
||||
}),
|
||||
handler: async (
|
||||
client: KyInstance,
|
||||
params: { description: string; scope: string; strictness: string }
|
||||
params: { description: string; scope: string; strictness: string; dryRun?: boolean },
|
||||
context: CapabilityContext
|
||||
) => {
|
||||
const created = await api.createApprovalRule(client, params);
|
||||
if (params.dryRun) {
|
||||
const { dryRun: _dryRun, ...payload } = params;
|
||||
return {
|
||||
...mutationPreview(context, "api/v1/rules", null, payload, 1),
|
||||
dryRun: true,
|
||||
mutation: "sealApprovalRuleCreate",
|
||||
created: 0
|
||||
};
|
||||
}
|
||||
const { dryRun: _dryRun, ...payload } = params;
|
||||
const created = await api.createApprovalRule(client, payload);
|
||||
const codeNum = parseRuleCodeNumber(created?.code);
|
||||
return codeNum !== undefined ? { ...created, code: formatRuleCode(codeNum) } : created;
|
||||
}
|
||||
@@ -211,7 +223,8 @@ export const rulesCapabilities = [
|
||||
description: z.string().optional(),
|
||||
scope: z.string().optional(),
|
||||
strictness: z.enum(["MUST_FOLLOW", "SHOULD_FOLLOW", "SUGGESTION"]).optional(),
|
||||
ifUnchanged: z.union([z.string(), z.number()]).optional().describe("乐观并发预检基准:当前草稿的 updatedAt(rules get 输出的北京时间字符串或毫秒时间戳);服务端草稿在该基准后被修改则拒绝更新")
|
||||
ifUnchanged: z.union([z.string(), z.number()]).optional().describe("乐观并发预检基准:当前草稿的 updatedAt(rules get 输出的北京时间字符串或毫秒时间戳);服务端草稿在该基准后被修改则拒绝更新"),
|
||||
dryRun: z.boolean().optional().describe("仅预览将要更新的字段与变更 Diff,不执行写入")
|
||||
}),
|
||||
handler: async (
|
||||
client: KyInstance,
|
||||
@@ -221,9 +234,31 @@ export const rulesCapabilities = [
|
||||
scope?: string;
|
||||
strictness?: string;
|
||||
ifUnchanged?: string | number;
|
||||
dryRun?: boolean;
|
||||
},
|
||||
context: CapabilityContext
|
||||
) => {
|
||||
if (params.dryRun) {
|
||||
const draftData = await api.listApprovalRules(client).catch(() => undefined);
|
||||
const targetCodeNum = parseRuleCodeNumber(params.ruleId.trim());
|
||||
const matched = draftData?.rules?.find(
|
||||
(r) => r.id === params.ruleId.trim() || (targetCodeNum !== undefined && parseRuleCodeNumber(r.code) === targetCodeNum)
|
||||
);
|
||||
const { dryRun: _dryRun, ifUnchanged: _ifUnchanged, ruleId: _ruleId, ...changes } = params;
|
||||
return {
|
||||
...mutationPreview(
|
||||
context,
|
||||
"api/v1/rules",
|
||||
matched ?? undefined,
|
||||
matched ? { ...matched, ...changes } : changes,
|
||||
1
|
||||
),
|
||||
dryRun: true,
|
||||
mutation: "sealApprovalRuleUpdate",
|
||||
ruleId: params.ruleId,
|
||||
updated: 0
|
||||
};
|
||||
}
|
||||
let resolvedRuleId = params.ruleId.trim();
|
||||
const targetCodeNum = parseRuleCodeNumber(resolvedRuleId);
|
||||
let draftRule: ApprovalRule | undefined;
|
||||
@@ -292,11 +327,17 @@ export const rulesCapabilities = [
|
||||
name: "sealApprovalRuleDelete",
|
||||
description: "删除 Seal 草稿审批规则",
|
||||
parameters: z.object({
|
||||
ruleId: z.string().describe("规则 ID 或规则编号 code")
|
||||
ruleId: z.string().describe("规则 ID 或规则编号 code"),
|
||||
dryRun: z.boolean().optional().describe("仅预览将被删除的规则,不执行删除")
|
||||
}),
|
||||
handler: async (client: KyInstance, params: { ruleId: string }) => {
|
||||
handler: async (
|
||||
client: KyInstance,
|
||||
params: { ruleId: string; dryRun?: boolean },
|
||||
context: CapabilityContext
|
||||
) => {
|
||||
let resolvedRuleId = params.ruleId.trim();
|
||||
const targetCodeNum = parseRuleCodeNumber(resolvedRuleId);
|
||||
let matchedRule: ApprovalRule | undefined;
|
||||
if (targetCodeNum !== undefined) {
|
||||
const draftData = await api.listApprovalRules(client).catch(() => undefined);
|
||||
if (draftData?.rules) {
|
||||
@@ -307,8 +348,18 @@ export const rulesCapabilities = [
|
||||
throw new Error(`未在当前草稿中找到编号为 ${params.ruleId} 的规则`);
|
||||
}
|
||||
resolvedRuleId = matched.id;
|
||||
matchedRule = matched;
|
||||
}
|
||||
}
|
||||
if (params.dryRun) {
|
||||
return {
|
||||
...mutationPreview(context, "api/v1/rules", matchedRule ?? { id: resolvedRuleId }, null, 1),
|
||||
dryRun: true,
|
||||
mutation: "sealApprovalRuleDelete",
|
||||
ruleId: resolvedRuleId,
|
||||
deleted: 0
|
||||
};
|
||||
}
|
||||
await api.deleteApprovalRule(client, resolvedRuleId);
|
||||
return { success: true, ruleId: resolvedRuleId };
|
||||
}
|
||||
@@ -406,10 +457,25 @@ export const rulesCapabilities = [
|
||||
name: "sealApprovalRuleVersionPublish",
|
||||
description: "发布 Seal 草稿审批规则为新版本",
|
||||
parameters: z.object({
|
||||
versionName: z.string().describe("版本名称")
|
||||
versionName: z.string().describe("版本名称"),
|
||||
dryRun: z.boolean().optional().describe("仅预览将要发布的草稿规模,不执行发布")
|
||||
}),
|
||||
handler: async (client: KyInstance, params: { versionName: string }, context: CapabilityContext) => {
|
||||
handler: async (
|
||||
client: KyInstance,
|
||||
params: { versionName: string; dryRun?: boolean },
|
||||
context: CapabilityContext
|
||||
) => {
|
||||
const draft = await api.listApprovalRules(client).catch(() => undefined);
|
||||
if (params.dryRun) {
|
||||
return {
|
||||
...mutationPreview(context, "api/v1/rules/versions", draft?.rules ?? [], { versionName: params.versionName }, draft?.rules?.length ?? 0),
|
||||
dryRun: true,
|
||||
mutation: "sealApprovalRuleVersionPublish",
|
||||
versionName: params.versionName,
|
||||
draftCount: draft?.rules?.length ?? 0,
|
||||
published: false
|
||||
};
|
||||
}
|
||||
const published = await api.publishApprovalRuleVersion(client, params.versionName);
|
||||
if (draft) {
|
||||
try { savePublishedRuleVersionSnapshot(context.corp.id, published.version, draft.rules); } catch {}
|
||||
|
||||
@@ -472,9 +472,21 @@ export const simulationCapabilities = [
|
||||
name: "sealSimulationBatchClean",
|
||||
description: "删除模拟测试批次产生的测试数据",
|
||||
parameters: z.object({
|
||||
batchId: z.string().describe("模拟批次 ID")
|
||||
batchId: z.string().describe("模拟批次 ID"),
|
||||
dryRun: z.boolean().optional().describe("仅预览批次当前状态与将被清理的数据,不执行删除")
|
||||
}),
|
||||
handler: async (client: KyInstance, params: { batchId: string }) => {
|
||||
handler: async (client: KyInstance, params: { batchId: string; dryRun?: boolean }) => {
|
||||
if (params.dryRun) {
|
||||
const before = await api.getSimulationBatch(client, params.batchId).catch(() => undefined);
|
||||
return {
|
||||
preview: true,
|
||||
dryRun: true,
|
||||
mutation: "sealSimulationBatchClean",
|
||||
batchId: params.batchId,
|
||||
cleaned: 0,
|
||||
before
|
||||
};
|
||||
}
|
||||
const result = await api.cleanSimulationBatch(client, params.batchId);
|
||||
return {
|
||||
batchId: params.batchId,
|
||||
|
||||
@@ -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