@wirecat/cli-base 0.97.0 → 0.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/commands/document.js +1 -1
  3. package/dist/commands/registry.d.ts +2 -1
  4. package/dist/dev/adopt.d.ts +6 -0
  5. package/dist/dev/adopt.js +43 -0
  6. package/dist/dev/audit.js +2 -2
  7. package/dist/dev/conformance.d.ts +5 -0
  8. package/dist/dev/conformance.js +24 -4
  9. package/dist/dev/family.d.ts +10 -0
  10. package/dist/dev/family.js +41 -0
  11. package/dist/dev/lint.d.ts +5 -0
  12. package/dist/dev/lint.js +32 -7
  13. package/dist/dev/main.js +166 -23
  14. package/dist/dev/network.js +10 -2
  15. package/dist/http/index.d.ts +23 -2
  16. package/dist/http/index.js +61 -0
  17. package/dist/release/fragments.d.ts +17 -0
  18. package/dist/release/fragments.js +108 -0
  19. package/dist/release/index.d.ts +2 -0
  20. package/dist/release/index.js +2 -0
  21. package/dist/release/level.d.ts +2 -0
  22. package/dist/release/level.js +52 -0
  23. package/dist/standards/audit.d.ts +2 -0
  24. package/dist/standards/audit.js +2 -0
  25. package/dist/standards/flags-account.d.ts +3 -0
  26. package/dist/standards/flags-account.js +36 -0
  27. package/dist/standards/lint.d.ts +17 -1
  28. package/dist/standards/lint.js +22 -5
  29. package/dist/standards/tables.d.ts +1 -1
  30. package/dist/standards/tables.js +1 -1
  31. package/dist/standards/vocabulary.js +3 -0
  32. package/docs/standards/accounts.md +3 -3
  33. package/docs/standards/layout.md +1 -1
  34. package/docs/standards/lifecycle.md +4 -6
  35. package/docs/standards/output.md +2 -2
  36. package/docs/standards/releases.md +6 -4
  37. package/docs/standards/testing.md +1 -1
  38. package/docs/standards/toolchain.md +7 -3
  39. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,72 @@ Versions before 0.8.0 are in the [git tags](https://github.com/WireCatLabs/cli-b
8
8
  Every entry says what changed as a caller sees it, why, and what to watch for — the rules are
9
9
  [`docs/dev/CONVENTIONS.md`](docs/dev/CONVENTIONS.md#the-changelog).
10
10
 
11
+ ## 0.98.0 — 12.11.2026
12
+
13
+ ### Added
14
+
15
+ - **`cli-dev audit --family`: one command instead of each CLI's `scripts/audit.sh`.** Given the CLI's own built bin
16
+ (`--cli dist/bin/b24.js`), it installs the latest published CLIs of every parity group (mail and gcal included,
17
+ which the six copies left out), runs each in an empty home with the keyring out of reach, and reads every CLI's
18
+ `commands info --json`, so `same-error-reason` and `same-entity-schema` are measured at last. It defaults `--for`,
19
+ `--lint` and `--groups` as the script did. The two newly measured rules print their findings as warnings for now:
20
+ they are strict, so no baseline can hold them, and the script never measured them. See
21
+ [TOOLING.md](docs/TOOLING.md).
22
+ - **`cli-dev changelog fragments` and `cli-dev changelog level`.** The `changes/<branch>.md` fragment check and
23
+ collection, and the version-level check (`Added` needs a minor, a break a major), which b24 and cli-core each kept
24
+ as a script of their own, are now shared; `--next <x.y.z>` prints the version a release needs. Also exported from
25
+ `@wirecat/cli-base/release` (`readFragments`, `fragmentProblems`, `collectFragments`, `levelledVersion`,
26
+ `versionLevelProblem`, `CHANGELOG_HEADINGS`).
27
+ - **`cli-dev adopt <x.y.z>`: a shared-package bump done the same way in every CLI.** It pins the version
28
+ (`--package`, cli-core by default), runs `pnpm install`, then `generate` and `ci:quick` when the CLI has them, and
29
+ stops at the first failure. It opens no pull request yet.
30
+ - **Commands cli-core mounts can say so: `origin: "cli-core"`.** The commands document accepts the new value, and lint
31
+ treats such a command like a handwritten one. Once cli-core marks its commands, `cli-dev lint` fails a word rule's
32
+ baseline entry on the CLI's own command (it belongs in the overrides) and an override on cli-core's (it belongs in
33
+ the baseline), as [WC-TOOL-16](docs/standards/toolchain.md#wc-tool-16--run-the-command-lint-on-the-built-cli-and-let-its-baseline-only-shrink)
34
+ says; `--allow-stale` only warns, as for a stale entry. Nothing changes until then. To watch for: a reader of
35
+ `commands --json` on an older cli-base refuses a document with the new value, so cli-core marks its commands only
36
+ once the CLIs and tools that parse it are on this release.
37
+ - **A parity group's difference can expire.** A `differences` entry takes `review_after`, with the lint overrides'
38
+ rule: a warning from 14 days before, a failure 14 days after. An audit without `--for` also warns when the
39
+ baseline holds rows no CLI has any more.
40
+ - **`retrying()` in `@wirecat/cli-base/http`: one retry loop for provider CLIs.** It wraps a `FetchLike` (usually
41
+ `hostFetch`'s) and sends a read again after 408, 429, 5xx or a retryable error, a write only after a 429, waiting
42
+ the provider's `Retry-After` or a jittered backoff, within `budget`, and through a shared `pacer` when given.
43
+ b24, zoom, max, mail and beeline each wrote their own loop with different limits; see
44
+ [REFERENCE.md](docs/REFERENCE.md).
45
+ - **Vocabulary roles for the words cli-core's shared commands use.** `account remove --keep-data` and `--delete-data`,
46
+ `session start --answer-stdin`, `--client-id` and `--client-file`, `--hide-phone`, and the verb `call` (`api call`)
47
+ now have a meaning in the vocabulary. Eight CLIs carried about 35 baseline and override lines for them. To watch for:
48
+ `cli-dev lint` reports each of those lines as stale; remove them in the change that takes this release.
49
+ - **Lint gives an override's `review_after` two weeks either side.** An override warns from 14 days before its date
50
+ and fails only once it is more than 14 days past it. Until now every CI run of a CLI went red on the morning after
51
+ the date, and a date shared by several CLIs (`stats tasks show --chat`, 2026-12-01 in tg, max and wa) broke all of
52
+ them at once.
53
+ - **A `low` lint rule is advice and fails nothing.** `command-help-too-long` and `command-example-count` (now `low`)
54
+ print their new violations and stale baseline entries as warnings. Help-text polish no longer holds a merge.
55
+ - **A live check records only the files that ship.** `cli-dev live record` writes `v2:` and a hash that leaves out
56
+ `*.test.*`, `src/testing/`, `__snapshots__/` and `__fixtures__/`, so a merge that changes only tests needs no new
57
+ live check against the owner's account. b24's 0.15.0 took five pull requests, three of them new live records after
58
+ test-only merges. A record without `v2:` is still compared with every file, so existing lines keep passing.
59
+
60
+ ### Fixed
61
+
62
+ - **The command lint's empty home keeps the keyring out of reach.** The run-log probe and the WCAT describe check
63
+ ran the built CLI with an empty `HOME`, which does not hide the keyring: it is reached over D-Bus. They now set
64
+ `DBUS_SESSION_BUS_ADDRESS=disabled:` as well.
65
+ - **The audit baseline no longer lists `mcp --allow-send` and `--allow-dangerous`.** No published CLI has them on its
66
+ `mcp` commands any more (checked against tg 0.123.0, max 0.111.0, memo 0.131.87 and drive 0.65.0).
67
+ - **Stale standards text.** WC-ACCT-12's known gaps (zm has `session end`; gcal and mail have all four; memo has no
68
+ sign-in of its own), WC-LIFE-15's list (drive, memo, zm and mail keep runs), WC-LIFE-13 and WC-LIFE-16 (memo no
69
+ longer imports mail), WC-LAY-1 (memo has `contracts/`) and WC-TEST-14 (wa has an upgrade contract) now say what the CLIs
70
+ do. WC-OUT-11 and WC-OUT-15 name the audit that measures them.
71
+ - **`raw-network` no longer skips a file that hands the global `fetch` on through an object key or an argument.** A
72
+ file with `{ fetch: deps.fetch ?? fetch }` or `makeClient(fetch)` counted as one that binds its own `fetch`, so its
73
+ global `fetch` went unreported (mail-cli and cli-memo had such files). Only a declaration binds it now: a typed or
74
+ defaulted parameter, a destructuring pattern, an arrow's own parameter. To watch for: such files are now reported;
75
+ route them through `hostFetch`, or say why in `lint/overrides.json`.
76
+
11
77
  ## 0.97.0 — 11.11.2026
12
78
 
13
79
  ### Added
@@ -41,7 +41,7 @@ const commandInfoSchema = v.object({
41
41
  summary: v.optional(v.string()),
42
42
  description: v.string(),
43
43
  usage: v.string(),
44
- origin: v.picklist(["handwritten", "generated"]),
44
+ origin: v.picklist(["handwritten", "generated", "cli-core"]),
45
45
  api_operation: v.optional(v.string()),
46
46
  effects: v.optional(effectsSchema),
47
47
  state: v.optional(v.picklist(["beta", "deprecated"])),
@@ -3,7 +3,8 @@ import type { QueryRegistry } from "../query/fields.js";
3
3
  import { type QueryInfo } from "../query/registry.js";
4
4
  import type { Effects } from "../standards/effects.js";
5
5
  import type { StepTarget } from "../standards/steps.js";
6
- export type Origin = "handwritten" | "generated";
6
+ /** `cli-core`: a command cli-core mounts, which the CLI does not own and cannot rename. */
7
+ export type Origin = "handwritten" | "generated" | "cli-core";
7
8
  export type CommandState = "beta" | "deprecated";
8
9
  /**
9
10
  * How long a command runs: `persistent` until it is stopped (a server, a watch), `interactive` until a person answers
@@ -0,0 +1,6 @@
1
+ export type Run = (command: string, args: readonly string[]) => number;
2
+ /**
3
+ * Moves the CLI onto `version` of a shared package the same way every time: the pin in package.json, the lockfile,
4
+ * the generated files and the quick checks. What the checks then report (pins, baselines) is the adoption's work.
5
+ */
6
+ export declare const adopt: (cwd: string, name: string, version: string, run: Run, log: (line: string) => void) => number;
@@ -0,0 +1,43 @@
1
+ import { readFileSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ const SECTIONS = ["dependencies", "devDependencies", "optionalDependencies"];
4
+ /**
5
+ * Moves the CLI onto `version` of a shared package the same way every time: the pin in package.json, the lockfile,
6
+ * the generated files and the quick checks. What the checks then report (pins, baselines) is the adoption's work.
7
+ */
8
+ export const adopt = (cwd, name, version, run, log) => {
9
+ if (!/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/.test(version)) {
10
+ log(`adopt takes a version such as 0.98.0, not "${version}"`);
11
+ return 2;
12
+ }
13
+ const path = join(cwd, "package.json");
14
+ const pkg = JSON.parse(readFileSync(path, "utf8"));
15
+ const found = SECTIONS.filter((section) => pkg[section]?.[name] !== undefined);
16
+ if (found.length === 0) {
17
+ log(`package.json does not depend on ${name}`);
18
+ return 2;
19
+ }
20
+ for (const section of found) {
21
+ const deps = pkg[section];
22
+ const range = deps[name].match(/^[\^~]/)?.[0] ?? "";
23
+ deps[name] = `${range}${version}`;
24
+ }
25
+ writeFileSync(path, `${JSON.stringify(pkg, null, 2)}\n`);
26
+ log(`${name} ${version} in package.json`);
27
+ const steps = [
28
+ ["pnpm", ["install"]],
29
+ ...["generate", "ci:quick"]
30
+ .filter((script) => pkg.scripts?.[script] !== undefined)
31
+ .map((script) => ["pnpm", ["run", script]]),
32
+ ];
33
+ for (const [command, args] of steps) {
34
+ log(`== ${command} ${args.join(" ")}`);
35
+ const code = run(command, args);
36
+ if (code !== 0) {
37
+ log(`${command} ${args.join(" ")} failed (${code}): fix it on this branch, then commit`);
38
+ return 1;
39
+ }
40
+ }
41
+ log(`adopted ${name} ${version}: review the diff, commit and open one pull request`);
42
+ return 0;
43
+ };
package/dist/dev/audit.js CHANGED
@@ -27,7 +27,7 @@ export const snakeKeys = (value) => {
27
27
  export const clisOf = (target) => (target.split(" ")[0] ?? "").replace(/:$/, "").split("+");
28
28
  const named = (clis) => [...clis].sort(byText).join("+");
29
29
  const handwritten = (document) => new Map(walk(document.commands)
30
- .filter((command) => command.origin === "handwritten")
30
+ .filter((command) => command.origin !== "generated")
31
31
  .map((command) => [command.path.join(" "), command]));
32
32
  const requiredRoots = (inputs, roots) => inputs.flatMap(({ document }) => {
33
33
  const paths = new Set(walk(document.commands).map((command) => command.path.join(" ")));
@@ -105,7 +105,7 @@ const sameFlagMeaning = (inputs, vocabulary) => {
105
105
  const options = [
106
106
  ...document.global_options,
107
107
  ...walk(document.commands)
108
- .filter((command) => command.origin === "handwritten")
108
+ .filter((command) => command.origin !== "generated")
109
109
  .flatMap((command) => command.options),
110
110
  ];
111
111
  for (const option of options) {
@@ -24,6 +24,11 @@ export interface LiveRecord {
24
24
  script: string;
25
25
  tree: string;
26
26
  }
27
+ /**
28
+ * Files under `LIVE_PATHS` that never reach the package: a test, a fixture, the test sandbox. A change to one alone
29
+ * changes nothing a user runs, so it does not ask for another live check against the owner's account.
30
+ */
31
+ export declare const LIVE_SKIPPED: RegExp;
27
32
  /** A squash merge drops the checked commit from main, so a record names the checked files, not only the commit. */
28
33
  export declare const liveTree: (shell: Shell) => string | undefined;
29
34
  export declare const parseLiveRecords: (text: string) => LiveRecord[];
@@ -40,11 +40,31 @@ export const firstReleaseProblems = (baseVersion, pkg) => baseVersion === "0.0.0
40
40
  '"bin", beside the short name if it keeps one, and call wcatStart first in the bin (WC-CMD-29)',
41
41
  ]
42
42
  : [];
43
- /** A squash merge drops the checked commit from main, so a record names the checked files, not only the commit. */
44
- export const liveTree = (shell) => {
43
+ /**
44
+ * Files under `LIVE_PATHS` that never reach the package: a test, a fixture, the test sandbox. A change to one alone
45
+ * changes nothing a user runs, so it does not ask for another live check against the owner's account.
46
+ */
47
+ export const LIVE_SKIPPED = /(?:^|\/)[^/]+\.test\.[cm]?[jt]sx?$|^src\/testing\/|(?:^|\/)__(?:snapshots|fixtures)__\//;
48
+ /** The hash version `liveTree` writes: `v2:` hashes only shipped files; a bare hash is the first form, every file. */
49
+ const LIVE_TREE_VERSION = "v2";
50
+ const everyFileTree = (shell) => {
45
51
  const listing = shell.run("git", ["ls-tree", "HEAD", "--", ...LIVE_PATHS]);
46
52
  return listing.ok ? createHash("sha256").update(listing.out).digest("hex") : undefined;
47
53
  };
54
+ /** A squash merge drops the checked commit from main, so a record names the checked files, not only the commit. */
55
+ export const liveTree = (shell) => {
56
+ const listing = shell.run("git", ["ls-tree", "-r", "HEAD", "--", ...LIVE_PATHS]);
57
+ if (!listing.ok)
58
+ return undefined;
59
+ const shipped = listing.out
60
+ .split("\n")
61
+ .filter((line) => line && !LIVE_SKIPPED.test(line.split("\t")[1] ?? ""))
62
+ .join("\n");
63
+ return `${LIVE_TREE_VERSION}:${createHash("sha256").update(shipped).digest("hex")}`;
64
+ };
65
+ /** A record's tree in the form it was written: a record from before `v2:` hashed every file. */
66
+ const treeLike = (shell, recorded) => (recorded.includes(":") ? liveTree(shell) : everyFileTree(shell));
67
+ const SHIPPED = `${LIVE_PATHS.join(", ")} (tests left out)`;
48
68
  export const parseLiveRecords = (text) => text
49
69
  .split("\n")
50
70
  .map((line) => line.trim())
@@ -61,10 +81,10 @@ export const liveCheckProblems = (shell, records, version) => {
61
81
  "`cli-dev live record --script <its script>` and commit the line in the release pull request",
62
82
  ];
63
83
  if (record.tree)
64
- return liveTree(shell) === record.tree
84
+ return treeLike(shell, record.tree) === record.tree
65
85
  ? []
66
86
  : [
67
- `${LIVE_PATHS.join(", ")} changed since ${version}'s live check at ${record.commit.slice(0, 12)}: ` +
87
+ `${SHIPPED} changed since ${version}'s live check at ${record.commit.slice(0, 12)}: ` +
68
88
  "check the code that is released, and record it again",
69
89
  ];
70
90
  if (!shell.run("git", ["cat-file", "-e", `${record.commit}^{commit}`]).ok)
@@ -0,0 +1,10 @@
1
+ import type { ParityGroup } from "../standards/audit.js";
2
+ /** Every other CLI of the parity groups that npm has, by name. */
3
+ export declare const familyPackages: (groups: readonly ParityGroup[], own: string) => Map<string, string>;
4
+ export interface Family {
5
+ /** Each installed CLI's bin, by name. */
6
+ bins: Map<string, string>;
7
+ close: () => void;
8
+ }
9
+ /** Installs the latest published `packages` into a folder of their own, without their install scripts. */
10
+ export declare const installFamily: (packages: ReadonlyMap<string, string>) => Family;
@@ -0,0 +1,41 @@
1
+ import { mkdtempSync, rmSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import spawn from "cross-spawn";
5
+ import { FIRST_PARTY_TOOLS } from "../wcat/names.js";
6
+ /** The published CLIs `audit --family` installs; beeline is not on npm yet. */
7
+ const PACKAGES = new Map([
8
+ ...FIRST_PARTY_TOOLS.flatMap((tool) => (tool.package ? [[tool.name, tool.package]] : [])),
9
+ ["gcal", "@wirecat/gcal-cli"],
10
+ ["b24", "@wirecat/bitrix24-cli"],
11
+ ]);
12
+ /** Every other CLI of the parity groups that npm has, by name. */
13
+ export const familyPackages = (groups, own) => new Map([...new Set(groups.flatMap((group) => group.members))]
14
+ .filter((name) => name !== own && PACKAGES.has(name))
15
+ .sort()
16
+ .map((name) => [name, PACKAGES.get(name)]));
17
+ /** Installs the latest published `packages` into a folder of their own, without their install scripts. */
18
+ export const installFamily = (packages) => {
19
+ const prefix = mkdtempSync(join(tmpdir(), "cli-dev-family-"));
20
+ const close = () => rmSync(prefix, { recursive: true, force: true });
21
+ const run = spawn.sync("npm", [
22
+ "install",
23
+ "--global",
24
+ "--prefix",
25
+ prefix,
26
+ "--ignore-scripts",
27
+ "--no-audit",
28
+ "--no-fund",
29
+ "--loglevel",
30
+ "error",
31
+ "--fetch-retries",
32
+ "6",
33
+ ...packages.values(),
34
+ ], { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 });
35
+ if (run.error || run.status !== 0) {
36
+ close();
37
+ throw new Error(`npm install of the family failed: ${run.error?.message ?? String(run.stderr).trim()}`);
38
+ }
39
+ const bin = process.platform === "win32" ? prefix : join(prefix, "bin");
40
+ return { bins: new Map([...packages.keys()].map((name) => [name, join(bin, name)])), close };
41
+ };
@@ -66,3 +66,8 @@ export interface Judgement {
66
66
  export declare const judge: (violations: readonly Violation[], baseline: Readonly<Record<string, readonly string[]>>, overrides: readonly Override[], budget: number, rules?: readonly LintRule[]) => Judgement;
67
67
  /** What `--write-baseline` writes: per rule, the targets no override covers. A rule with none gets no file. */
68
68
  export declare const baselineOf: (violations: readonly Violation[], overrides: readonly Override[], rules?: readonly LintRule[]) => Record<string, string[]>;
69
+ /**
70
+ * A word the CLI owns belongs in its overrides, where the count and the date keep it few; a word of a command cli-core
71
+ * mounts belongs in the baseline until cli-core or the vocabulary catches up. Silent until cli-core marks its commands.
72
+ */
73
+ export declare const misfiled: (document: CommandsDocument, baseline: Readonly<Record<string, readonly string[]>>, overrides: readonly Override[]) => string[];
package/dist/dev/lint.js CHANGED
@@ -88,7 +88,7 @@ const documentKeys = (value, path) => {
88
88
  return [[key, at], ...(DATA_KEYS.has(key) ? [] : documentKeys(item, key === "commands" ? "commands" : at))];
89
89
  });
90
90
  };
91
- const handwrittenLeaves = (document) => walk(document.commands).filter((command) => command.commands.length === 0 && command.origin === "handwritten");
91
+ const handwrittenLeaves = (document) => walk(document.commands).filter((command) => command.commands.length === 0 && command.origin !== "generated");
92
92
  /** Splits an example the way a shell would for the quoting examples use: '…', "…" and a backslash. */
93
93
  export const exampleWords = (line) => [...line.matchAll(/(?:'[^']*'|"(?:\\.|[^"\\])*"|\\.|[^\s'"\\])+/g)].map(([word]) => word.replace(/'([^']*)'|"((?:\\.|[^"\\])*)"|\\(.)/g, (_, single, double, escaped) => single ?? escaped ?? double.replace(/\\(.)/g, "$1")));
94
94
  const BUILT_IN = ["-h", "--help"];
@@ -202,7 +202,7 @@ const declaredWrite = ({ effects }) => effects?.remote === "write" || effects?.l
202
202
  const optionsOf = (document) => [
203
203
  ...document.global_options.map((option) => ({ option, target: longName(option.flags) })),
204
204
  ...walk(document.commands)
205
- .filter((command) => command.origin === "handwritten")
205
+ .filter((command) => command.origin !== "generated")
206
206
  .flatMap((command) => command.options.map((option) => ({ option, target: `${label(command)} ${longName(option.flags)}` }))),
207
207
  ];
208
208
  const CHECKS = {
@@ -227,7 +227,7 @@ const CHECKS = {
227
227
  const roots = new Set(vocabulary.roots.map((entry) => entry.word));
228
228
  const verbs = new Set(vocabulary.verbs.map((entry) => entry.word));
229
229
  return walk(document.commands)
230
- .filter((command) => command.commands.length > 0 && command.origin === "handwritten")
230
+ .filter((command) => command.commands.length > 0 && command.origin !== "generated")
231
231
  .filter((command) => !nouns.has(command.name) && !roots.has(command.name))
232
232
  .map((command) => ({
233
233
  target: label(command),
@@ -248,7 +248,7 @@ const CHECKS = {
248
248
  for (const option of document.global_options)
249
249
  note(option, "every command");
250
250
  for (const command of walk(document.commands))
251
- if (command.origin === "handwritten")
251
+ if (command.origin !== "generated")
252
252
  for (const option of command.options)
253
253
  note(option, label(command));
254
254
  const found = [];
@@ -276,7 +276,7 @@ const CHECKS = {
276
276
  .filter((command) => (command.commands.length === 0 || command.runnable) && command.effects === undefined)
277
277
  .map((command) => ({ target: label(command), message: "no effects; without them it counts as a write" })),
278
278
  "command-help-too-long": (document) => walk(document.commands)
279
- .filter((command) => command.origin === "handwritten" && summaryOf(command).length > SUMMARY_LIMIT)
279
+ .filter((command) => command.origin !== "generated" && summaryOf(command).length > SUMMARY_LIMIT)
280
280
  .map((command) => ({
281
281
  target: label(command),
282
282
  message: `summary is ${summaryOf(command).length} characters; at most ${SUMMARY_LIMIT}`,
@@ -291,7 +291,7 @@ const CHECKS = {
291
291
  message: `${command.examples?.length ?? 0} examples; give ${EXAMPLES_MIN} to ${EXAMPLES_MAX}`,
292
292
  })),
293
293
  "faulty-help-example-parameters": (document) => withAncestors(document.commands)
294
- .filter(([command]) => command.commands.length === 0 && command.origin === "handwritten")
294
+ .filter(([command]) => command.commands.length === 0 && command.origin !== "generated")
295
295
  .flatMap(([command, ancestors]) => (command.examples ?? []).flatMap((example) => {
296
296
  const fault = faultOf(example, command, ancestors, document);
297
297
  return fault === undefined ? [] : [{ target: `${label(command)}: ${example}`, message: fault }];
@@ -312,7 +312,7 @@ const CHECKS = {
312
312
  "filter-flag": (document, vocabulary, context) => {
313
313
  const roles = new Map(vocabulary.flags.map((flag) => [flag.name, flag.role]));
314
314
  return walk(document.commands)
315
- .filter((command) => command.origin === "handwritten" &&
315
+ .filter((command) => command.origin !== "generated" &&
316
316
  !declaredWrite(command) &&
317
317
  (command.query || (["list", "events", "runs"].includes(command.name) && command.output)))
318
318
  .flatMap((command) => {
@@ -484,3 +484,28 @@ export const baselineOf = (violations, overrides, rules = LINT_RULES) => {
484
484
  .sort(),
485
485
  ]));
486
486
  };
487
+ /** The rules about words: which list an exception goes in depends on who owns the word (WC-TOOL-16). */
488
+ const WORD_RULES = new Set(["unknown-verb", "unknown-resource", "option-role", "flag-synonym", "flag-two-meanings"]);
489
+ /**
490
+ * A word the CLI owns belongs in its overrides, where the count and the date keep it few; a word of a command cli-core
491
+ * mounts belongs in the baseline until cli-core or the vocabulary catches up. Silent until cli-core marks its commands.
492
+ */
493
+ export const misfiled = (document, baseline, overrides) => {
494
+ const commands = walk(document.commands).sort((a, b) => b.path.length - a.path.length);
495
+ if (!commands.some((command) => command.origin === "cli-core"))
496
+ return [];
497
+ const ownerOf = (target) => commands.find((command) => {
498
+ const path = label(command);
499
+ return target === path || target.startsWith(`${path} `) || target.startsWith(`${path}:`);
500
+ })?.origin;
501
+ return [
502
+ ...Object.entries(baseline)
503
+ .filter(([rule]) => WORD_RULES.has(rule))
504
+ .flatMap(([rule, targets]) => targets
505
+ .filter((target) => ownerOf(target) !== undefined && ownerOf(target) !== "cli-core")
506
+ .map((target) => `the CLI's own word in the baseline — move it to the overrides: ${rule} "${target}"`)),
507
+ ...overrides
508
+ .filter((entry) => WORD_RULES.has(entry.rule) && ownerOf(entry.target) === "cli-core")
509
+ .map((entry) => `cli-core's word in an override — move it to the baseline: ${entry.rule} "${entry.target}"`),
510
+ ];
511
+ };