@wirecat/cli-base 0.80.8 → 0.80.9

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,25 @@ 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.80.9 — 07.11.2026
12
+
13
+ ### Fixed
14
+
15
+ - **The `wcat` launcher no longer fails with `exec: …/wcat-max: not found` when its tool is gone.** A tool
16
+ repaired the launcher only when it ran, never when `wcat` itself was the entry point, so a launcher left pointing at
17
+ an uninstalled tool stayed broken, and a pnpm bin folder earlier on PATH hid a working `wcat` further down. The
18
+ launcher script now checks its target. If it is missing it starts another `wcat-*` program of its own folder, then the
19
+ next `wcat` on PATH, and only then prints which file is missing and that the launcher is safe to delete. `SHIM_FORMAT`
20
+ is 2, so every tool rewrites an older launcher on its next start. `ensureLauncher` returns `failed` and writes nothing
21
+ when the folder holds no `wcat-<tool>` program. Shortcuts are unchanged except for the format number in their mark.
22
+ - **`cli-dev audit` accepts memo's `doctor --deep` in every parity group that covers `doctor`.** cli-memo 0.131.47
23
+ gave its own doctor a `--deep` switch that no other CLI has, so every other CLI's audit failed on
24
+ `same-path-contract … doctor --deep` and bitrix24-cli and beeline-cli kept a local `--differences` file that pinned
25
+ the CLI list of that day. A parity difference may now carry `only: "<cli>"`: the one CLI that has the path or flag
26
+ by design, every other CLI compared must lack it, and the CLI list is whoever was compared, so a CLI joining or
27
+ leaving does not stale it. It is stale when that CLI is compared and no longer differs. `only` takes no `expected`
28
+ and cannot be combined with `absent`. A CLI that kept a local difference for `doctor --deep` can delete it.
29
+
11
30
  ## 0.80.8 — 07.11.2026
12
31
 
13
32
  ### Changed — may break callers
package/dist/dev/audit.js CHANGED
@@ -254,18 +254,27 @@ export const auditClis = (inputs, options, rules = AUDIT_RULES) => {
254
254
  options.capabilities &&
255
255
  capabilityDifference(finding.target, finding.clis, inputs.map((input) => input.document), options.capabilities))
256
256
  .map((finding) => `${finding.rule} ${finding.target}`));
257
- // An `absent` difference names no CLI list: it stands for every finding where only that CLI lacks the flag.
257
+ // An `absent` or `only` difference names no CLI list: it stands for every finding where only that CLI lacks the
258
+ // flag, or only that CLI has it.
258
259
  const differences = options.groups.flatMap((group) => group.differences.flatMap((entry) => {
259
- if (!entry.absent)
260
+ const cli = entry.absent ?? entry.only;
261
+ if (!cli)
260
262
  return [{ group: group.name, ...entry }];
261
263
  const matching = findings.filter((finding) => {
262
264
  if (finding.rule !== entry.rule || finding.target !== `${named(finding.clis)} ${entry.target}`)
263
265
  return false;
264
- const others = Object.entries(finding.values ?? {}).filter(([cli]) => cli !== entry.absent);
265
- return (finding.values?.[entry.absent] === "absent" && new Set(others.map(([, value]) => value)).size === 1);
266
+ const mine = finding.values?.[cli];
267
+ const others = Object.entries(finding.values ?? {})
268
+ .filter(([name]) => name !== cli)
269
+ .map(([, value]) => value);
270
+ if (mine === undefined || others.length === 0)
271
+ return false;
272
+ return entry.absent
273
+ ? mine === "absent" && new Set(others).size === 1
274
+ : mine !== "absent" && others.every((value) => value === "absent");
266
275
  });
267
- if (matching.length === 0 && clis.includes(entry.absent))
268
- problems.push(`stale difference in ${group.name}, no such divergence — remove it: ${entry.rule} ${entry.target} (absent in ${entry.absent})`);
276
+ if (matching.length === 0 && clis.includes(cli))
277
+ problems.push(`stale difference in ${group.name}, no such divergence — remove it: ${entry.rule} ${entry.target} (${entry.absent ? "absent" : "only"} in ${cli})`);
269
278
  return matching.map((finding) => ({
270
279
  ...entry,
271
280
  group: group.name,
package/dist/dev/main.js CHANGED
@@ -604,6 +604,7 @@ const auditRun = (args, io) => {
604
604
  target: v.string(),
605
605
  expected: v.optional(v.string()),
606
606
  absent: v.optional(v.string()),
607
+ only: v.optional(v.string()),
607
608
  reason: v.string(),
608
609
  }));
609
610
  const parsed = v.safeParse(schema, readJson(at(values.differences)));
@@ -22,11 +22,13 @@ declare const parityGroupSchema: v.StrictObjectSchema<{
22
22
  /** Permanent differences, each with its reason; they count against the override budget of the group. */
23
23
  readonly differences: v.ArraySchema<v.StrictObjectSchema<{
24
24
  readonly rule: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a lower-case word, words joined by -">]>;
25
- /** `<clis> <path> <flag>`; with `absent`, only `<path> <flag>`: the CLI list is whoever else has it. */
25
+ /** `<clis> <path> <flag>`; with `absent` or `only`, only `<path> <flag>`: the CLI list is whoever else was compared. */
26
26
  readonly target: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
27
27
  readonly expected: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, undefined>;
28
28
  /** The CLI that lacks the path or flag by design; the rest must agree, so other CLIs joining do not stale it. */
29
29
  readonly absent: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a lower-case word, words joined by -">]>, undefined>;
30
+ /** The one CLI that has the path or flag by design; every other CLI compared must lack it. */
31
+ readonly only: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a lower-case word, words joined by -">]>, undefined>;
30
32
  readonly reason: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, v.MinLengthAction<string, 10, "say why, in a sentence">]>;
31
33
  }, undefined>, undefined>;
32
34
  }, undefined>;
@@ -51,11 +51,13 @@ const parityGroupSchema = v.strictObject({
51
51
  /** Permanent differences, each with its reason; they count against the override budget of the group. */
52
52
  differences: v.array(v.strictObject({
53
53
  rule: word,
54
- /** `<clis> <path> <flag>`; with `absent`, only `<path> <flag>`: the CLI list is whoever else has it. */
54
+ /** `<clis> <path> <flag>`; with `absent` or `only`, only `<path> <flag>`: the CLI list is whoever else was compared. */
55
55
  target: text,
56
56
  expected: v.optional(text),
57
57
  /** The CLI that lacks the path or flag by design; the rest must agree, so other CLIs joining do not stale it. */
58
58
  absent: v.optional(word),
59
+ /** The one CLI that has the path or flag by design; every other CLI compared must lack it. */
60
+ only: v.optional(word),
59
61
  reason: v.pipe(text, v.minLength(10, "say why, in a sentence")),
60
62
  })),
61
63
  });
@@ -64,8 +66,11 @@ export const defineParityGroups = (input) => parseRegistry("parity groups", v.ar
64
66
  ...groups.flatMap((group) => [
65
67
  ...duplicates(group.differences.map((entry) => `${entry.rule} ${entry.target}`)).map((both) => `${group.name}: "${both}" is listed twice`),
66
68
  ...group.differences
67
- .filter((entry) => entry.absent && entry.expected)
68
- .map((entry) => `${group.name}: "${entry.target}" has \`absent\`, which measures the values itself; drop \`expected\``),
69
+ .filter((entry) => (entry.absent || entry.only) && entry.expected)
70
+ .map((entry) => `${group.name}: "${entry.target}" has \`${entry.absent ? "absent" : "only"}\`, which measures the values itself; drop \`expected\``),
71
+ ...group.differences
72
+ .filter((entry) => entry.absent && entry.only)
73
+ .map((entry) => `${group.name}: "${entry.target}" has both \`absent\` and \`only\`; keep one`),
69
74
  ]),
70
75
  ]);
71
76
  const MEMO_HAS_NO_PROFILES = [
@@ -81,13 +86,20 @@ const MEMO_HAS_NO_PROFILES = [
81
86
  reason: "memo has no profiles: it reads other CLIs' stores and selects their accounts with --source and --account " +
82
87
  "(https://github.com/WireCatLabs/cli-base/issues/390)",
83
88
  }));
89
+ const MEMO_DOCTOR_DEEP = {
90
+ rule: "same-path-contract",
91
+ target: "doctor --deep",
92
+ only: "memo",
93
+ reason: "memo's doctor --deep also checks its own store (cli-memo #672); cli-core's shared doctor leaves --deep to " +
94
+ "each CLI, and no other CLI has one",
95
+ };
84
96
  export const PARITY_GROUPS = defineParityGroups([
85
97
  { name: "messengers", members: ["tg", "max"], covers: "tree", differences: [] },
86
98
  {
87
99
  name: "all",
88
100
  members: ["tg", "max", "memo", "drive", "zm", "wa"],
89
101
  covers: ["commands", "doctor", "skill", "mcp", "upgrade", "search", "notes", "meetings"],
90
- differences: MEMO_HAS_NO_PROFILES,
102
+ differences: [...MEMO_HAS_NO_PROFILES, MEMO_DOCTOR_DEEP],
91
103
  },
92
104
  // mail's `search messages` is cli-core's mail search, not the messengers' command: --complete took their 20-odd
93
105
  // differences as inherited (https://github.com/WireCatLabs/cli-base/issues/390). mail is compared everywhere else
@@ -96,7 +108,7 @@ export const PARITY_GROUPS = defineParityGroups([
96
108
  name: "mail-shared",
97
109
  members: ["tg", "max", "memo", "drive", "zm", "wa", "mail"],
98
110
  covers: ["commands", "doctor", "skill", "mcp", "upgrade", "notes", "meetings"],
99
- differences: MEMO_HAS_NO_PROFILES,
111
+ differences: [...MEMO_HAS_NO_PROFILES, MEMO_DOCTOR_DEEP],
100
112
  },
101
113
  // gcal is compared on what it already shares with every CLI; doctor, mcp, search and skill wait until the published
102
114
  // CLIs agree there (https://github.com/WireCatLabs/cli-base/issues/390), then gcal moves back into "all".
@@ -112,7 +124,7 @@ export const PARITY_GROUPS = defineParityGroups([
112
124
  name: "shared-roots",
113
125
  members: ["tg", "max", "memo", "drive", "zm", "wa", "b24", "beeline"],
114
126
  covers: ["commands", "doctor", "skill", "mcp", "upgrade"],
115
- differences: MEMO_HAS_NO_PROFILES,
127
+ differences: [...MEMO_HAS_NO_PROFILES, MEMO_DOCTOR_DEEP],
116
128
  },
117
129
  ]);
118
130
  const requiredRootSchema = v.strictObject({ path: v.pipe(v.array(segment), v.minLength(1)), meaning: text });
@@ -28,7 +28,8 @@ export declare const installed: (dir: string, program: string) => boolean;
28
28
  * - `written`: it was missing, broken or in an older format, and now starts the running tool.
29
29
  * - `foreign`: a `wcat` that cli-base did not write is there, and stays untouched.
30
30
  * - `newer`: a newer cli-base wrote it; this one leaves it alone.
31
- * - `failed`: it could not be written, such as a bin folder only an administrator may change.
31
+ * - `failed`: it could not be written, such as a bin folder only an administrator may change, or the folder holds
32
+ * no installed `wcat-<tool>` to start.
32
33
  */
33
34
  export type LauncherState = "kept" | "written" | "foreign" | "newer" | "failed";
34
35
  /**
@@ -81,6 +81,8 @@ const NAME = "wcat";
81
81
  */
82
82
  export const ensureLauncher = ({ dir, program, platform, }) => {
83
83
  try {
84
+ if (!exists(join(dir, program)))
85
+ return "failed";
84
86
  const mine = shimFiles("launcher", { dir, name: NAME, target: program, platform });
85
87
  const states = mine.map((file) => fileState(file.path));
86
88
  if (states.some((one) => one.state === "foreign"))
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Every file carries a mark line, so cli-base can tell its own files from anyone else's and never touches the rest.
7
7
  */
8
- export declare const SHIM_FORMAT = 1;
8
+ export declare const SHIM_FORMAT = 2;
9
9
  export type ShimKind = "launcher" | "shortcut";
10
10
  export interface ShimMark {
11
11
  format: number;
package/dist/wcat/shim.js CHANGED
@@ -8,13 +8,40 @@ import { DISPATCH_FLAG } from "./names.js";
8
8
  *
9
9
  * Every file carries a mark line, so cli-base can tell its own files from anyone else's and never touches the rest.
10
10
  */
11
- export const SHIM_FORMAT = 1;
11
+ export const SHIM_FORMAT = 2;
12
12
  const MARK = /^(?:#|REM) wirecat-shim (\d+) (launcher|shortcut) (\S+)\r?$/m;
13
13
  const NOTE = {
14
14
  launcher: "Written by @wirecat/cli-base. Any WireCat tool rewrites it when it breaks; it is safe to delete.",
15
15
  shortcut: "Made by `wcat shortcuts add`; `wcat shortcuts remove` takes it out.",
16
16
  };
17
17
  const shellQuote = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
18
+ /**
19
+ * The launcher is the entry point when the owner types `wcat`, so no tool has run to repair it: it looks for a
20
+ * working program itself. Order: its target, another `wcat-*` of the same folder, the next `wcat` on PATH. The
21
+ * variable stops two launchers from handing the start to each other.
22
+ */
23
+ const launcherBody = (dir, target, name) => [
24
+ 'ok() { [ -f "$1" ] && [ -x "$1" ]; }',
25
+ `dir=${shellQuote(dir)}`,
26
+ `target=${shellQuote(join(dir, target))}`,
27
+ 'if ! ok "$target"; then',
28
+ ' for t in "$dir"/wcat-*; do',
29
+ ' if ok "$t"; then target=$t; break; fi',
30
+ " done",
31
+ "fi",
32
+ `if ok "$target"; then exec "$target" ${DISPATCH_FLAG} "$@"; fi`,
33
+ 'if [ -z "$WIRECAT_LAUNCHER_SKIP" ]; then',
34
+ " WIRECAT_LAUNCHER_SKIP=1; export WIRECAT_LAUNCHER_SKIP",
35
+ " set -f; oldifs=$IFS; IFS=:",
36
+ " for d in $PATH; do",
37
+ ` if [ -n "$d" ] && [ "$d" != "$dir" ] && ok "$d/${name}"; then IFS=$oldifs; exec "$d/${name}" "$@"; fi`,
38
+ " done",
39
+ " IFS=$oldifs; set +f",
40
+ "fi",
41
+ `printf '%s\\n' "${name}: $target is missing and no other ${name}-* program was found in $dir or on PATH." \\`,
42
+ ` "This launcher is safe to delete: $dir/${name}" >&2`,
43
+ "exit 127",
44
+ ];
18
45
  /**
19
46
  * The files of one shim: `<name>` on Linux and macOS; `<name>.cmd` and `<name>.ps1` on Windows, the pair npm writes
20
47
  * for its own commands. The POSIX file names the folder in full, so a link to it from elsewhere still works; the
@@ -27,7 +54,13 @@ export const shimFiles = (kind, { dir, name, target, platform }) => {
27
54
  return [
28
55
  {
29
56
  path: join(dir, name),
30
- text: `#!/bin/sh\n# ${mark}\n# ${NOTE[kind]}\nexec ${shellQuote(join(dir, target))}${extra} "$@"\n`,
57
+ text: [
58
+ "#!/bin/sh",
59
+ `# ${mark}`,
60
+ `# ${NOTE[kind]}`,
61
+ ...(kind === "launcher" ? launcherBody(dir, target, name) : [`exec ${shellQuote(join(dir, target))} "$@"`]),
62
+ "",
63
+ ].join("\n"),
31
64
  },
32
65
  ];
33
66
  return [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-base",
3
- "version": "0.80.8",
3
+ "version": "0.80.9",
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",