@wirecat/cli-base 0.80.7 → 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 +41 -0
- package/dist/dev/audit.js +15 -6
- package/dist/dev/conformance.d.ts +12 -3
- package/dist/dev/conformance.js +111 -36
- package/dist/dev/main.js +1 -0
- package/dist/standards/audit.d.ts +3 -1
- package/dist/standards/audit.js +18 -6
- package/dist/wcat/launcher.d.ts +2 -1
- package/dist/wcat/launcher.js +2 -0
- package/dist/wcat/shim.d.ts +1 -1
- package/dist/wcat/shim.js +35 -2
- package/docs/standards/new-cli.md +12 -5
- package/docs/standards/releases.md +9 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,47 @@ 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
|
+
|
|
30
|
+
## 0.80.8 — 07.11.2026
|
|
31
|
+
|
|
32
|
+
### Changed — may break callers
|
|
33
|
+
|
|
34
|
+
- **`cli-dev repo-check` reads which checks main's ruleset requires.** It fails unless they include cli-template's
|
|
35
|
+
set: `standards`, `changelog / guard`, `validation / ci / check`, `validation / ci / bun`,
|
|
36
|
+
`validation / ci / secrets`, `validation / prose`, `validation / version`, `validation / node-22`,
|
|
37
|
+
`validation / repo-setup`, and `conformance` where `.github/workflows/release-pr.yml` exists. Before, a ruleset
|
|
38
|
+
that left out `conformance` passed, so a release pull request without its `## Conformance` section could be merged.
|
|
39
|
+
- **`cli-dev repo-check` checks the GitHub `npm` environment.** It fails unless only the `main` branch can deploy to
|
|
40
|
+
it: npm trusts `release.yml` by its name, and a dispatch runs that file from the branch it was started on. A
|
|
41
|
+
repository with no `npm` environment, or a private one on GitHub's free plan, is skipped with a warning.
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
|
|
45
|
+
- **`cli-dev live record` hashes the checked files, and `live check` compares that hash.** A record line is now
|
|
46
|
+
`<version> <commit> <date> <script> <tree>`, where `<tree>` is a SHA-256 of `git ls-tree HEAD -- src package.json
|
|
47
|
+
pnpm-lock.yaml`. A squash merge drops the release branch's commit from `main`, so a fresh clone could not release:
|
|
48
|
+
`live check` asked for a commit it did not have. It now needs no commit object; the commit stays as information.
|
|
49
|
+
A line recorded before this version has no `<tree>` and is still compared with its commit, so record the live check
|
|
50
|
+
again before the next release to drop the need for the branch commit.
|
|
51
|
+
|
|
11
52
|
## 0.80.7 — 07.11.2026
|
|
12
53
|
|
|
13
54
|
### Added
|
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
|
|
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
|
-
|
|
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
|
|
265
|
-
|
|
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(
|
|
268
|
-
problems.push(`stale difference in ${group.name}, no such divergence — remove it: ${entry.rule} ${entry.target} (absent in ${
|
|
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,
|
|
@@ -17,11 +17,20 @@ export interface LiveRecord {
|
|
|
17
17
|
commit: string;
|
|
18
18
|
date: string;
|
|
19
19
|
script: string;
|
|
20
|
+
tree: string;
|
|
20
21
|
}
|
|
22
|
+
/** A squash merge drops the checked commit from main, so a record names the checked files, not only the commit. */
|
|
23
|
+
export declare const liveTree: (shell: Shell) => string | undefined;
|
|
21
24
|
export declare const parseLiveRecords: (text: string) => LiveRecord[];
|
|
22
25
|
export declare const liveCheckProblems: (shell: Shell, records: readonly LiveRecord[], version: string) => string[];
|
|
23
|
-
/**
|
|
24
|
-
export declare const
|
|
26
|
+
/** The checks cli-template's workflows report on a pull request; `conformance` comes from its release-pr.yml. */
|
|
27
|
+
export declare const REQUIRED_CHECKS: string[];
|
|
28
|
+
export declare const rulesetProblems: (shell: Shell, slug: string, checks?: readonly string[]) => {
|
|
29
|
+
problems: string[];
|
|
30
|
+
skipped?: string;
|
|
31
|
+
};
|
|
32
|
+
/** npm trusts release.yml by name, so only `main` may run the job that holds the npm environment's token. */
|
|
33
|
+
export declare const environmentProblems: (shell: Shell, slug: string) => {
|
|
25
34
|
problems: string[];
|
|
26
35
|
skipped?: string;
|
|
27
36
|
};
|
|
@@ -29,6 +38,6 @@ export declare const rulesetProblems: (shell: Shell, slug: string) => {
|
|
|
29
38
|
export declare const takenMinutes: (ciPage: string) => Map<string, string>;
|
|
30
39
|
export declare const cronProblems: (workflow: string | undefined, repo: string, taken: Map<string, string>) => string[];
|
|
31
40
|
export declare const parityProblems: (cli: string, ownGroups: unknown) => string[];
|
|
32
|
-
export declare const CONFORMANCE_USAGE = " release-pr --base <commit> --body <file>\n a pull request that changes package.json's version since --base\n needs a non-empty \"## Conformance\" section in its description\n live record --script <path> [--file <path>]\n appends \"<version> <commit> <date> <script>\" to docs/dev/live-checks.txt\n after a live check passed; src
|
|
41
|
+
export declare const CONFORMANCE_USAGE = " release-pr --base <commit> --body <file>\n a pull request that changes package.json's version since --base\n needs a non-empty \"## Conformance\" section in its description\n live record --script <path> [--file <path>]\n appends \"<version> <commit> <date> <script> <tree>\" to docs/dev/live-checks.txt\n after a live check passed; <tree> hashes the committed src/,\n package.json and lockfile, which must be committed\n live check [--version <x.y.z>] [--file <path>]\n fails unless that version has a record and src/, package.json\n and the lockfile are the ones it hashed; needs no commit object,\n so a squash-merged release branch passes\n repo-check --cli <name> [--groups <file>]\n main's ruleset and its required checks, the npm environment\n limited to main (through gh; skipped without a login or network),\n monthly.yml's cron minute against WC-CI-9's list, and the CLI in\n a parity group (cli-base's, or --groups', config/parity-groups.json)";
|
|
33
42
|
export declare const conformanceCommand: (command: string, args: string[], io: DevIo, shell?: Shell) => number | undefined;
|
|
34
43
|
export {};
|
package/dist/dev/conformance.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { appendFileSync, existsSync, readFileSync } from "node:fs";
|
|
2
3
|
import { dirname, join, resolve } from "node:path";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -30,13 +31,18 @@ export const releasePrProblems = (body, baseVersion, version) => {
|
|
|
30
31
|
return [`the "## Conformance" section of this ${version} release pull request is empty`];
|
|
31
32
|
return [];
|
|
32
33
|
};
|
|
34
|
+
/** A squash merge drops the checked commit from main, so a record names the checked files, not only the commit. */
|
|
35
|
+
export const liveTree = (shell) => {
|
|
36
|
+
const listing = shell.run("git", ["ls-tree", "HEAD", "--", ...LIVE_PATHS]);
|
|
37
|
+
return listing.ok ? createHash("sha256").update(listing.out).digest("hex") : undefined;
|
|
38
|
+
};
|
|
33
39
|
export const parseLiveRecords = (text) => text
|
|
34
40
|
.split("\n")
|
|
35
41
|
.map((line) => line.trim())
|
|
36
42
|
.filter((line) => line && !line.startsWith("#"))
|
|
37
43
|
.map((line) => {
|
|
38
|
-
const [version = "", commit = "", date = "", script = ""] = line.split(/\s+/);
|
|
39
|
-
return { version, commit, date, script };
|
|
44
|
+
const [version = "", commit = "", date = "", script = "", tree = ""] = line.split(/\s+/);
|
|
45
|
+
return { version, commit, date, script, tree };
|
|
40
46
|
});
|
|
41
47
|
export const liveCheckProblems = (shell, records, version) => {
|
|
42
48
|
const record = records.findLast((entry) => entry.version === version);
|
|
@@ -45,6 +51,13 @@ export const liveCheckProblems = (shell, records, version) => {
|
|
|
45
51
|
`no live check recorded for ${version} in ${LIVE_FILE}: run the live check, then ` +
|
|
46
52
|
"`cli-dev live record --script <its script>` and commit the line in the release pull request",
|
|
47
53
|
];
|
|
54
|
+
if (record.tree)
|
|
55
|
+
return liveTree(shell) === record.tree
|
|
56
|
+
? []
|
|
57
|
+
: [
|
|
58
|
+
`${LIVE_PATHS.join(", ")} changed since ${version}'s live check at ${record.commit.slice(0, 12)}: ` +
|
|
59
|
+
"check the code that is released, and record it again",
|
|
60
|
+
];
|
|
48
61
|
if (!shell.run("git", ["cat-file", "-e", `${record.commit}^{commit}`]).ok)
|
|
49
62
|
return [`${version}'s live check names commit ${record.commit}, which this clone does not have; fetch it`];
|
|
50
63
|
if (!shell.run("git", ["diff", "--quiet", record.commit, "HEAD", "--", ...LIVE_PATHS]).ok)
|
|
@@ -85,13 +98,18 @@ const live = (args, io, shell) => {
|
|
|
85
98
|
}
|
|
86
99
|
const dirty = shell.run("git", ["status", "--porcelain", "--", ...LIVE_PATHS]);
|
|
87
100
|
if (!dirty.ok || dirty.out) {
|
|
88
|
-
io.err(`commit ${LIVE_PATHS.join(", ")} first: a record names the
|
|
101
|
+
io.err(`commit ${LIVE_PATHS.join(", ")} first: a record names the code that was checked`);
|
|
89
102
|
return 1;
|
|
90
103
|
}
|
|
91
104
|
const commit = shell.run("git", ["rev-parse", "HEAD"]).out;
|
|
105
|
+
const tree = liveTree(shell);
|
|
106
|
+
if (!tree) {
|
|
107
|
+
io.err(`git could not list ${LIVE_PATHS.join(", ")} at HEAD`);
|
|
108
|
+
return 1;
|
|
109
|
+
}
|
|
92
110
|
const date = (io.now?.() ?? new Date()).toISOString().slice(0, 10);
|
|
93
|
-
const line = `${version} ${commit} ${date} ${values.script}`;
|
|
94
|
-
appendFileSync(file, `${existsSync(file) ? "" : "# version commit date script — one line per passed live check\n"}${line}\n`);
|
|
111
|
+
const line = `${version} ${commit} ${date} ${values.script} ${tree}`;
|
|
112
|
+
appendFileSync(file, `${existsSync(file) ? "" : "# version commit date script tree — one line per passed live check\n"}${line}\n`);
|
|
95
113
|
io.out(line);
|
|
96
114
|
return 0;
|
|
97
115
|
};
|
|
@@ -115,36 +133,86 @@ const releasePr = (args, io, shell) => {
|
|
|
115
133
|
return problems.length > 0 ? 1 : 0;
|
|
116
134
|
};
|
|
117
135
|
const REQUIRED_RULES = ["deletion", "non_fast_forward", "pull_request", "required_status_checks"];
|
|
136
|
+
/** The checks cli-template's workflows report on a pull request; `conformance` comes from its release-pr.yml. */
|
|
137
|
+
export const REQUIRED_CHECKS = [
|
|
138
|
+
"standards",
|
|
139
|
+
"changelog / guard",
|
|
140
|
+
"validation / ci / check",
|
|
141
|
+
"validation / ci / bun",
|
|
142
|
+
"validation / ci / secrets",
|
|
143
|
+
"validation / prose",
|
|
144
|
+
"validation / version",
|
|
145
|
+
"validation / node-22",
|
|
146
|
+
"validation / repo-setup",
|
|
147
|
+
];
|
|
148
|
+
const FREE_PLAN = "Upgrade to GitHub Pro or make this repository public";
|
|
118
149
|
/** `skipped` when GitHub could not be asked (no gh, no login, no network): the caller says so and goes on. */
|
|
119
|
-
|
|
120
|
-
const answer = shell.run("gh", ["api",
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return { problems: [], skipped:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
150
|
+
const ghRead = (shell, path, what) => {
|
|
151
|
+
const answer = shell.run("gh", ["api", path]);
|
|
152
|
+
if (answer.ok) {
|
|
153
|
+
try {
|
|
154
|
+
return { ok: true, json: JSON.parse(answer.out) };
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return { ok: false, problems: [], skipped: "gh did not answer JSON" };
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const status = answer.out.match(/HTTP (\d{3})/)?.[1];
|
|
161
|
+
if (status === "401" || (!status && /gh auth login|GH_TOKEN/.test(answer.out)))
|
|
162
|
+
return { ok: false, problems: [], skipped: "gh is not signed in (set GH_TOKEN in CI)" };
|
|
163
|
+
if (!status)
|
|
164
|
+
return { ok: false, problems: [], skipped: `GitHub could not be reached: ${answer.out.split("\n")[0] ?? ""}` };
|
|
165
|
+
// A private repository on the free plan has no rulesets or environments (NEED-2331).
|
|
166
|
+
if (status === "403" && answer.out.includes(FREE_PLAN))
|
|
167
|
+
return { ok: false, status, problems: [], skipped: "a private repository on GitHub's free plan has none" };
|
|
168
|
+
return {
|
|
169
|
+
ok: false,
|
|
170
|
+
status,
|
|
171
|
+
problems: [
|
|
172
|
+
`GitHub answered ${status} for ${what}: ` +
|
|
173
|
+
(answer.out.match(/gh: ([^\n]*?) \(HTTP/)?.[1] ?? "the repository is missing or this token cannot read it"),
|
|
174
|
+
],
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
export const rulesetProblems = (shell, slug, checks = REQUIRED_CHECKS) => {
|
|
178
|
+
const read = ghRead(shell, `repos/${slug}/rules/branches/main`, `${slug}'s rules on main`);
|
|
179
|
+
if (!read.ok)
|
|
180
|
+
return read;
|
|
181
|
+
const rules = Array.isArray(read.json) ? read.json : [];
|
|
182
|
+
const types = rules.map((rule) => String(rule.type));
|
|
183
|
+
const missing = REQUIRED_RULES.filter((rule) => !types.includes(rule));
|
|
184
|
+
if (missing.length > 0)
|
|
185
|
+
return { problems: [`main's ruleset lacks ${missing.join(", ")} (cli-base docs/standards/new-cli.md, step 1)`] };
|
|
186
|
+
const required = new Set(rules.flatMap((rule) => rule.parameters?.required_status_checks?.map((check) => check.context) ?? []));
|
|
187
|
+
const absent = checks.filter((check) => !required.has(check));
|
|
188
|
+
return absent.length === 0
|
|
189
|
+
? { problems: [] }
|
|
190
|
+
: {
|
|
131
191
|
problems: [
|
|
132
|
-
`
|
|
133
|
-
(
|
|
192
|
+
`main's ruleset does not require ${absent.join(", ")}: add them to its required status checks ` +
|
|
193
|
+
"(cli-base docs/standards/new-cli.md, step 1)",
|
|
134
194
|
],
|
|
135
195
|
};
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
196
|
+
};
|
|
197
|
+
/** npm trusts release.yml by name, so only `main` may run the job that holds the npm environment's token. */
|
|
198
|
+
export const environmentProblems = (shell, slug) => {
|
|
199
|
+
const environment = ghRead(shell, `repos/${slug}/environments/npm`, `${slug}'s npm environment`);
|
|
200
|
+
if (!environment.ok)
|
|
201
|
+
return environment.status === "404"
|
|
202
|
+
? { problems: [], skipped: "the repository has no npm environment, so it does not publish yet" }
|
|
203
|
+
: environment;
|
|
204
|
+
const policy = environment.json
|
|
205
|
+
.deployment_branch_policy;
|
|
206
|
+
const limit = `limit the npm environment's deployment branches to main (cli-base docs/standards/new-cli.md, step 2)`;
|
|
207
|
+
if (policy?.custom_branch_policies !== true || policy.protected_branches !== false)
|
|
208
|
+
return { problems: [`any branch can deploy to npm: ${limit}`] };
|
|
209
|
+
const branches = ghRead(shell, `repos/${slug}/environments/npm/deployment-branch-policies`, `${slug}'s npm deployment branches`);
|
|
210
|
+
if (!branches.ok)
|
|
211
|
+
return branches;
|
|
212
|
+
const names = (branches.json.branch_policies ?? []).map((entry) => `${entry.type ?? "branch"}:${entry.name}`);
|
|
213
|
+
return names.length === 1 && names[0] === "branch:main"
|
|
146
214
|
? { problems: [] }
|
|
147
|
-
: { problems: [`
|
|
215
|
+
: { problems: [`the npm environment deploys from ${names.join(", ") || "no branch"}, not only main: ${limit}`] };
|
|
148
216
|
};
|
|
149
217
|
/** The WC-CI-9 table of taken monthly minutes, as `HH:MM → repository`. */
|
|
150
218
|
export const takenMinutes = (ciPage) => new Map([...ciPage.matchAll(/^\s*\|\s*(\d\d:\d\d)\s*\|\s*([\w.-]+)\s*\|\s*$/gm)].map(([, time, repo]) => [
|
|
@@ -191,11 +259,16 @@ const repoCheck = (args, io, shell) => {
|
|
|
191
259
|
}
|
|
192
260
|
const read = (path) => (existsSync(join(io.cwd, path)) ? readFileSync(join(io.cwd, path), "utf8") : undefined);
|
|
193
261
|
const groups = read(values.groups);
|
|
194
|
-
const
|
|
262
|
+
const checks = read(".github/workflows/release-pr.yml") === undefined ? REQUIRED_CHECKS : [...REQUIRED_CHECKS, "conformance"];
|
|
263
|
+
const ruleset = rulesetProblems(shell, slug, checks);
|
|
195
264
|
if (ruleset.skipped)
|
|
196
265
|
io.err(`repo-check: ruleset not checked — ${ruleset.skipped}`);
|
|
266
|
+
const environment = environmentProblems(shell, slug);
|
|
267
|
+
if (environment.skipped)
|
|
268
|
+
io.err(`repo-check: npm environment not checked — ${environment.skipped}`);
|
|
197
269
|
const problems = [
|
|
198
270
|
...ruleset.problems,
|
|
271
|
+
...environment.problems,
|
|
199
272
|
...cronProblems(read(".github/workflows/monthly.yml"), slug.split("/")[1] ?? "", takenMinutes(readFileSync(ciPagePath(), "utf8"))),
|
|
200
273
|
...parityProblems(values.cli, groups === undefined ? undefined : JSON.parse(groups)),
|
|
201
274
|
];
|
|
@@ -209,14 +282,16 @@ export const CONFORMANCE_USAGE = ` release-pr --base <commit> --body <file>
|
|
|
209
282
|
a pull request that changes package.json's version since --base
|
|
210
283
|
needs a non-empty "## Conformance" section in its description
|
|
211
284
|
live record --script <path> [--file <path>]
|
|
212
|
-
appends "<version> <commit> <date> <script>" to ${LIVE_FILE}
|
|
213
|
-
after a live check passed;
|
|
214
|
-
must be committed
|
|
285
|
+
appends "<version> <commit> <date> <script> <tree>" to ${LIVE_FILE}
|
|
286
|
+
after a live check passed; <tree> hashes the committed src/,
|
|
287
|
+
package.json and lockfile, which must be committed
|
|
215
288
|
live check [--version <x.y.z>] [--file <path>]
|
|
216
289
|
fails unless that version has a record and src/, package.json
|
|
217
|
-
and the lockfile are
|
|
290
|
+
and the lockfile are the ones it hashed; needs no commit object,
|
|
291
|
+
so a squash-merged release branch passes
|
|
218
292
|
repo-check --cli <name> [--groups <file>]
|
|
219
|
-
main's ruleset
|
|
293
|
+
main's ruleset and its required checks, the npm environment
|
|
294
|
+
limited to main (through gh; skipped without a login or network),
|
|
220
295
|
monthly.yml's cron minute against WC-CI-9's list, and the CLI in
|
|
221
296
|
a parity group (cli-base's, or --groups', config/parity-groups.json)`;
|
|
222
297
|
export const conformanceCommand = (command, args, io, shell = processShell(io.cwd)) => {
|
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
|
|
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>;
|
package/dist/standards/audit.js
CHANGED
|
@@ -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
|
|
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
|
|
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 });
|
package/dist/wcat/launcher.d.ts
CHANGED
|
@@ -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
|
/**
|
package/dist/wcat/launcher.js
CHANGED
|
@@ -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"))
|
package/dist/wcat/shim.d.ts
CHANGED
|
@@ -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 =
|
|
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 =
|
|
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:
|
|
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 [
|
|
@@ -103,10 +103,15 @@ installing that command; nothing else is registered anywhere.
|
|
|
103
103
|
1. **Create the repository** under the owner, with a ruleset on the default branch: no deletion, no force push,
|
|
104
104
|
changes only through a pull request, required status checks, and no bypass. Add the ruleset after the first
|
|
105
105
|
commit is on `main`, since a pull request rule leaves an empty repository no way to get one, and the required
|
|
106
|
-
check names exist only once CI has run.
|
|
106
|
+
check names exist only once CI has run. The required checks are `standards`, `changelog / guard`,
|
|
107
|
+
`validation / ci / check`, `validation / ci / bun`, `validation / ci / secrets`, `validation / prose`,
|
|
108
|
+
`validation / version`, `validation / node-22`, `validation / repo-setup` and `conformance`. See
|
|
109
|
+
[Releases](releases.md).
|
|
107
110
|
2. **Set npm trusted publishing** for the new package, naming `release.yml`, and add any secrets the CI needs. npm
|
|
108
111
|
offers this only once the package exists, so the owner publishes the first version with `bin/release --local`
|
|
109
|
-
and sets it right after.
|
|
112
|
+
and sets it right after. Limit the GitHub `npm` environment's deployment branches to `main` (Settings →
|
|
113
|
+
Environments → npm → Deployment branches → Selected branches): npm trusts `release.yml` by its name, and a
|
|
114
|
+
dispatch runs that file from the branch it was started on. See
|
|
110
115
|
[WC-REL-11](releases.md#wc-rel-11--publish-from-github-actions-with-npm-trusted-publishing).
|
|
111
116
|
3. **Pick a monthly cron minute** between 02:17 and 03:20 UTC that is not in the list of taken minutes under
|
|
112
117
|
[WC-CI-9](ci.md#wc-ci-9--run-full-validation-and-release-security-on-the-first-day-of-each-month-without-publishing).
|
|
@@ -118,9 +123,11 @@ installing that command; nothing else is registered anywhere.
|
|
|
118
123
|
in its own repository and runs `cli-dev audit --groups <file>`. See [Testing](testing.md).
|
|
119
124
|
|
|
120
125
|
`cli-dev repo-check --cli <name>` checks steps 1, 3 and 4 on every pull request of a CLI made from cli-template
|
|
121
|
-
(`ci.yml:repo-setup`): the ruleset's four rules on `main
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
(`ci.yml:repo-setup`): the ruleset's four rules on `main` and the required checks of step 1 (`conformance` only where
|
|
127
|
+
`release-pr.yml` exists), step 2's `npm` environment limited to `main`, a monthly minute no other repository holds,
|
|
128
|
+
and the CLI in a parity group. It reads GitHub with `gh` and the job's `GITHUB_TOKEN`; without a login or a network,
|
|
129
|
+
for a repository with no `npm` environment yet, or for a private repository on GitHub's free plan, which has no
|
|
130
|
+
rulesets or environments, it says so and skips that part, and fails on the rest.
|
|
124
131
|
|
|
125
132
|
The listings beyond npm (ClawHub, the MCP Registry, the Claude plugin, the docs site, Glama) are a checklist in
|
|
126
133
|
[Publishing](../PUBLISHING.md#a-new-cli).
|
|
@@ -215,20 +215,22 @@ A pull request that changes `package.json`'s version has a `## Conformance` sect
|
|
|
215
215
|
reviews ([New CLI](new-cli.md#done-when)). `cli-dev release-pr --base <commit> --body <file>` fails without one.
|
|
216
216
|
After the live check of the real service passes
|
|
217
217
|
([WC-TEST-18](testing.md#wc-test-18--check-the-real-service-by-hand-never-in-the-test-suite)),
|
|
218
|
-
`cli-dev live record --script <its script>` appends `<version> <commit> <date> <script>` to
|
|
219
|
-
`docs/dev/live-checks.txt`, committed in the release pull request
|
|
220
|
-
|
|
218
|
+
`cli-dev live record --script <its script>` appends `<version> <commit> <date> <script> <tree>` to
|
|
219
|
+
`docs/dev/live-checks.txt`, committed in the release pull request; `<tree>` is a SHA-256 of `git ls-tree HEAD -- src
|
|
220
|
+
package.json pnpm-lock.yaml`. `bin/release` runs `cli-dev live check` first: it refuses a version with no line, and
|
|
221
|
+
one whose `src/`, `package.json` or lockfile differ from the files the record hashed. The commit is information only;
|
|
222
|
+
a line from before cli-base 0.80.8 has no `<tree>` and is still compared with its commit.
|
|
221
223
|
|
|
222
224
|
- **Why:** every automated check passed on bitrix24-cli while it ignored `deny` on reads; a release that says what
|
|
223
225
|
was checked, and a live check bound to the code released, are what a reviewer reads instead of the whole diff.
|
|
224
|
-
The record is keyed by version, and compares
|
|
225
|
-
commit the live check never saw.
|
|
226
|
+
The record is keyed by version, and compares files rather than commits, because a squash merge gives `main` a
|
|
227
|
+
commit the live check never saw, and a fresh clone of `main` does not have the branch commit at all.
|
|
226
228
|
- **Enforced by:** `<app>: bin/release` · `<app>: release-pr.yml` · `src/dev/conformance.ts`.
|
|
227
|
-
- **Example:** `0.4.0 3f2a2e3… 2026-11-07 bin/b24-live
|
|
229
|
+
- **Example:** `0.4.0 3f2a2e3… 2026-11-07 bin/b24-live 9c41d0…` in `docs/dev/live-checks.txt`. A pull request
|
|
228
230
|
`chore(release): 0.4.0` without `## Conformance` fails `release-pr.yml`. `bin/release` writes the section into
|
|
229
231
|
the pull request it opens to raise a taken number, since only the number changes.
|
|
230
232
|
- **Exceptions:** cli-template's own release has no service to check; its `bin/release` skips the live check where
|
|
231
|
-
`
|
|
233
|
+
`kit/` exists, a folder `new` never copies.
|
|
232
234
|
- **Applies to:** every CLI made from cli-template 0.17.0 or later. **Since:** cli-base 0.80.3. **Rulings:** none.
|
|
233
235
|
|
|
234
236
|
## Sources
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-base",
|
|
3
|
-
"version": "0.80.
|
|
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",
|