@wirecat/cli-base 0.104.0 → 0.105.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.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,16 @@ 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.105.0 — 16.11.2026
12
+
13
+ ### Fixed
14
+
15
+ - **`same-path-contract` compares a path only among CLIs whose groups share a member.** It joined the members of every
16
+ group that covers the root, so the `crm` group (b24 and amo, covering `search`, `store` and `account`) compared amo
17
+ with tg, max and the "all" members, which share no group with it: amo's `audit:commands` failed on 20 new findings.
18
+ Groups that share a CLI (messengers, all, mail-shared and gcal-shared share tg and max) are still compared together,
19
+ so their findings do not change.
20
+
11
21
  ## 0.104.0 — 16.11.2026
12
22
 
13
23
  ### Added
package/dist/dev/audit.js CHANGED
@@ -62,43 +62,58 @@ const samePathContract = (inputs, groups) => {
62
62
  message: `only in ${having.join(", ")}`,
63
63
  });
64
64
  }
65
- const having = [...new Set(covering.flatMap((group) => group.members))]
66
- .filter((cli) => trees.get(cli)?.has(path))
67
- .sort(byText);
68
- if (having.length < 2)
69
- continue;
70
- const commands = new Map(having.map((cli) => [cli, trees.get(cli)?.get(path)]));
71
- const push = (what, values) => {
72
- if (new Set(values.values()).size > 1)
73
- found.push({
74
- rule: "same-path-contract",
75
- clis: having,
76
- target: `${named(having)} ${path}${what}`,
77
- message: describe(values),
78
- values: Object.fromEntries(values),
79
- });
80
- };
81
- const kinds = new Map([...commands].map(([cli, command]) => [
82
- cli,
83
- optionKinds([
84
- ...(inputs.find((input) => input.document.cli === cli)?.document.global_options ?? []),
85
- ...command.options,
86
- ]),
87
- ]));
88
- const flags = [
89
- ...new Set([...commands.values()].flatMap((command) => [...optionKinds(command.options).keys()])),
90
- ].sort(byText);
91
- for (const flag of flags)
92
- push(` ${flag}`, new Map([...kinds].map(([cli, one]) => [cli, shownKind(one.get(flag))])));
93
- push(": output", new Map([...commands].map(([cli, command]) => [
94
- cli,
95
- command.output ? [command.output.entity, command.output.view].filter(Boolean).join("/") : "none",
96
- ])));
97
- const own = (cli, text) => text.replace(new RegExp(`\\b${cli}\\b`, "g"), "<cli>");
98
- push(": summary", new Map([...commands].map(([cli, command]) => [cli, JSON.stringify(own(cli, summaryOf(command)))])));
65
+ for (const members of linkedMembers(covering)) {
66
+ const having = members.filter((cli) => trees.get(cli)?.has(path)).sort(byText);
67
+ if (having.length >= 2)
68
+ pathDifferences(found, inputs, trees, path, having);
69
+ }
99
70
  }
100
71
  return found;
101
72
  };
73
+ /** The members of groups that share one, joined: two groups with no CLI in common are never compared. */
74
+ const linkedMembers = (groups) => {
75
+ const joined = [];
76
+ for (const group of groups) {
77
+ const touching = joined.filter((members) => group.members.some((cli) => members.has(cli)));
78
+ const merged = new Set([...group.members, ...touching.flatMap((members) => [...members])]);
79
+ for (const one of touching)
80
+ joined.splice(joined.indexOf(one), 1);
81
+ joined.push(merged);
82
+ }
83
+ return joined.map((members) => [...members]);
84
+ };
85
+ /** Each way the CLIs `having` a shared path differ on it, added to `found`. */
86
+ const pathDifferences = (found, inputs, trees, path, having) => {
87
+ const commands = new Map(having.map((cli) => [cli, trees.get(cli)?.get(path)]));
88
+ const push = (what, values) => {
89
+ if (new Set(values.values()).size > 1)
90
+ found.push({
91
+ rule: "same-path-contract",
92
+ clis: having,
93
+ target: `${named(having)} ${path}${what}`,
94
+ message: describe(values),
95
+ values: Object.fromEntries(values),
96
+ });
97
+ };
98
+ const kinds = new Map([...commands].map(([cli, command]) => [
99
+ cli,
100
+ optionKinds([
101
+ ...(inputs.find((input) => input.document.cli === cli)?.document.global_options ?? []),
102
+ ...command.options,
103
+ ]),
104
+ ]));
105
+ const flags = [
106
+ ...new Set([...commands.values()].flatMap((command) => [...optionKinds(command.options).keys()])),
107
+ ].sort(byText);
108
+ for (const flag of flags)
109
+ push(` ${flag}`, new Map([...kinds].map(([cli, one]) => [cli, shownKind(one.get(flag))])));
110
+ push(": output", new Map([...commands].map(([cli, command]) => [
111
+ cli,
112
+ command.output ? [command.output.entity, command.output.view].filter(Boolean).join("/") : "none",
113
+ ])));
114
+ const own = (cli, text) => text.replace(new RegExp(`\\b${cli}\\b`, "g"), "<cli>");
115
+ push(": summary", new Map([...commands].map(([cli, command]) => [cli, JSON.stringify(own(cli, summaryOf(command)))])));
116
+ };
102
117
  const sameFlagMeaning = (inputs, vocabulary) => {
103
118
  const registered = registeredKinds(vocabulary);
104
119
  const uses = new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-base",
3
- "version": "0.104.0",
3
+ "version": "0.105.0",
4
4
  "description": "The parts every command line tool needs: output modes, terminal rendering, error model, exit codes, credentials, clocks",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Viacheslav Ptsarev",