From 245ec33d1acc65e43603a26514f64a6bf6aab507 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Sat, 24 Oct 2026 21:56:59 +0800 Subject: [PATCH 1/2] Enforce cross-domain naming charter with silent legacy aliases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unify the visible command surface on one canonical spelling per semantic concept while keeping every legacy spelling working as a silent parser/dispatcher alias (per .agents/rules/cli-protocol.md §6): - Fix silent-ignore accept-set gaps: webhook resource-pack export now reads --out/--output-file and --downloads/--download; approval-runs and webhook read canonical --start-date/--end-date; webhook secret reveal accepts --reveal/-r alongside legacy --show-secret. - Add kebab-case parser registrations for camel-only flags (human-result, manual-approval-status, include-bridge, rule-version, document-limit, context-lines, source-document-sn/-id, simulation-batch-id) and read them in rules/documents search, context, approval-runs list/summary/ bridge/export. - Retire verbs on the visible surface only: webhook create (add), simulation delete (clean), preference thinking-depth policies delete (remove); dispatch keeps both. Runtime nextAction suggestions and doctor knowledge switch to canonical spellings. - Add src/cli/naming-charter.test.ts: help surface must be lowercase kebab-case and free of retired tokens; canonical/legacy spellings must both parse; P0 accept-sets pinned. - Document the charter in .agents/rules/cli-protocol.md §7; sync AGENTS.md, README, and skills/references docs; regenerate cli.md and embedded skill artifacts. --- .agents/rules/cli-protocol.md | 38 +++++- AGENTS.md | 2 +- README.md | 2 +- skills/seal-use/references/cli.md | 54 ++++---- .../seal-use/references/rule-lightweight.md | 6 +- .../references/webhook-resource-pack.md | 4 +- src/cli.test.ts | 2 +- src/cli/commands/approval-runs.ts | 51 +++++--- src/cli/commands/context.ts | 4 +- src/cli/commands/documents.ts | 6 +- src/cli/commands/rules.ts | 6 +- src/cli/commands/simulation.test.ts | 4 +- src/cli/commands/simulation.ts | 4 +- src/cli/commands/webhook.ts | 13 +- src/cli/help.test.ts | 6 +- src/cli/help.ts | 53 ++++---- src/cli/naming-charter.test.ts | 122 ++++++++++++++++++ src/cli/parser.ts | 23 ++-- src/core/doctor/knowledge.ts | 4 +- .../seal/material-pack/material-pack.test.ts | 2 +- src/domains/seal/material-pack/ready.ts | 2 +- 21 files changed, 298 insertions(+), 110 deletions(-) create mode 100644 src/cli/naming-charter.test.ts diff --git a/.agents/rules/cli-protocol.md b/.agents/rules/cli-protocol.md index 010f4fb..b295c04 100644 --- a/.agents/rules/cli-protocol.md +++ b/.agents/rules/cli-protocol.md @@ -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`, `rules clear`, `corps sync-test`, `preference update`, `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,不做硬切断。 diff --git a/AGENTS.md b/AGENTS.md index 67b681e..5727d68 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,7 +35,7 @@ Prefer small domain functions over broad utility modules. - **Documented exception — document-output commands**: `seal-use --help` / `seal-use help ` (`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 `). - **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). diff --git a/README.md b/README.md index ecbb4f7..7d0fa98 100644 --- a/README.md +++ b/README.md @@ -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 ...` 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 diff --git a/skills/seal-use/references/cli.md b/skills/seal-use/references/cli.md index 10d656c..288ee1d 100644 --- a/skills/seal-use/references/cli.md +++ b/skills/seal-use/references/cli.md @@ -62,7 +62,7 @@ seal-use corps hose-keys [ | ] [--reveal] [--save] [--app-key seal-use rules count [--version ] [--corp ] seal-use rules list [--version ] [--summary] [--limit 20] [--offset 0] [--output-file ] [--corp ] seal-use rules get [--version ] [--record-id ] [--corp ] -seal-use rules search [--version ] [--maxResults 20] [--corp ] +seal-use rules search [--version ] [--max-results 20] [--corp ] seal-use rules create --description --scope [--strictness ] [--description-file ] [--corp ] seal-use rules update [--description |--description-file ] [--scope ] [--strictness ] [--corp ] seal-use rules delete --yes [--corp ] @@ -80,25 +80,25 @@ seal-use rules recode [--dry-run] --corp seal-use rules map [--version ] [--code ] [--corp ] seal-use webhook ready [<材料包.zip>] [--webhook ] [--corp ] seal-use webhook status [<材料包.zip>] [--corp ] -seal-use webhook list [--query ] [--show-secret] [--corp ] -seal-use webhook get|find [--show-secret] [--corp ] -seal-use webhook add --name --result-url [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret ] [--min-file-size 500] [--max-file-size ] [--allowed-extensions <.pdf,.xlsx,...>] [--dry-run] [--corp ] +seal-use webhook list [--query ] [--reveal] [--corp ] +seal-use webhook get|find [--reveal] [--corp ] +seal-use webhook create --name --result-url [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret ] [--min-file-size 500] [--max-file-size ] [--allowed-extensions <.pdf,.xlsx,...>] [--dry-run] [--corp ] seal-use webhook update [--name ] [--result-url ] [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret |--rotate-secret] [--min-file-size ] [--max-file-size ] [--allowed-extensions <.pdf,.xlsx,...>] [--clear-max-file-size] [--dry-run] [--corp ] seal-use webhook delete [--yes|--dry-run] [--corp ] -seal-use webhook resource-pack export [--limit ] [--status ] [--output ] [--to-downloads] [--corp ] -seal-use webhook resource-pack export [--output ] [--corp ] +seal-use webhook resource-pack export [--limit ] [--status ] [--out ] [--downloads] [--corp ] +seal-use webhook resource-pack export [--out ] [--corp ] seal-use webhook resource-pack export --record-ids [--corp ] seal-use webhook resource-pack preview <资源包.zip|信息表.xlsx> [--min-file-size ] [--max-file-size ] [--allowed-extensions <.pdf,.xlsx,...>] [--corp ] seal-use webhook resource-pack push <资源包.zip|信息表.xlsx> [--webhook ] [--corp ] seal-use webhook replay [--webhook ] [--sn-suffix ] [--dry-run] [--yes|--confirm] [--corp ] seal-use webhook replay --sn [--webhook ] [--source-corp ] [--target-corp ] [--yes|--confirm] seal-use webhook replay --limit [--status ] [--source-corp ] [--target-corp ] [--yes|--confirm] -seal-use approval-runs summary [--date YYYY-MM-DD] [--timezone Asia/Shanghai] [--corp ] +seal-use approval-runs summary [--date ] [--timezone Asia/Shanghai] [--corp ] seal-use approval-runs stats [--since 3months] [--dedupe-by sourceDocumentSN|sourceDocumentId|id] [--corp ] -seal-use approval-runs count [--status APPROVED] [--start ] [--end ] [--corp ] -seal-use approval-runs export [--sn ] [--start ] [--end ] [--force] [--status ] [--manual-status ] [--completed-only] [--limit ] [--downloads|--to-downloads] [--with-flow] [--out ] [--corp ] +seal-use approval-runs count [--status APPROVED] [--start-date ] [--end-date ] [--corp ] +seal-use approval-runs export [--sn ] [--start-date ] [--end-date ] [--force] [--status ] [--manual-status ] [--completed-only] [--limit ] [--downloads] [--with-flow] [--out ] [--corp ] seal-use approval-runs hose-flow [--corp ] -seal-use approval-runs list|search [--query text] [--humanResult 驳回] [--manualApprovalStatus TERMINATED] [--startDate ms] [--endDate ms] [--has-extra-risk] [--limit 20] [--includeBridge true] [--corp ] +seal-use approval-runs list|search [--query text] [--human-result 驳回] [--manual-approval-status TERMINATED] [--start-date ] [--end-date ] [--has-extra-risk] [--limit 20] [--include-bridge] [--corp ] seal-use approval-runs pick --sn [--batch ] [--latest] [--fields recordId,status,aiDecision] [--corp ] seal-use approval-runs get [--summary] [--fields metadata|document.fields,result.summary] [--raw-json] [--full] [--output-file file.json] [--corp ] seal-use approval-runs cited-rules [--corp ] @@ -111,7 +111,7 @@ seal-use approval-runs link [--corp ] seal-use approval-runs link --auto-login [--expire 7200] [--corp ] seal-use approval-runs link --type hose-document [--corp ] seal-use approval-runs link --sn [--auto-login] [--corp ] -seal-use approval-runs bridge [--sourceDocumentSN B26001887] [--corp ] +seal-use approval-runs bridge [--source-document-sn B26001887] [--corp ] seal-use approval-runs replay [--webhook ] [--sn-suffix ] [--dry-run] [--yes|--confirm] [--corp ] seal-use approval-runs replay --sn [--webhook ] [--source-corp ] [--target-corp ] [--yes|--confirm] seal-use approval-runs replay --sn --channel hose-outbound [--sign-key ] [--target-corp ] [--dry-run] [--yes|--confirm] @@ -134,7 +134,7 @@ seal-use simulation create --mode material_pack --package-ids ] seal-use simulation status [--corp ] seal-use simulation wait [--timeout 10m] [--poll-interval 2s] [--corp ] -seal-use simulation clean --yes [--corp ] +seal-use simulation delete --yes [--corp ] seal-use simulation specifications [--integration ] [--corp ] seal-use simulation approval-definitions [--corp ] seal-use simulation list [--limit 50] [--all] [--query ] [--since