@wirecat/cli-base 0.80.2 → 0.80.3
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 +17 -0
- package/config/lint/no-own-settings.grit +9 -0
- package/dist/dev/conformance.d.ts +34 -0
- package/dist/dev/conformance.js +227 -0
- package/dist/dev/main.js +8 -2
- package/docs/standards/README.md +1 -1
- package/docs/standards/ci.md +5 -5
- package/docs/standards/lifecycle.md +4 -3
- package/docs/standards/new-cli.md +7 -2
- package/docs/standards/permissions.md +13 -5
- package/docs/standards/releases.md +23 -0
- package/docs/standards/testing.md +5 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,23 @@ 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.3 — 07.11.2026
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **Checks a CLI made from cli-template runs so it cannot ship the mistakes bitrix24-cli shipped.**
|
|
16
|
+
`cli-dev release-pr --base <commit> --body <file>` fails a pull request that changes the version without a
|
|
17
|
+
`## Conformance` section. `cli-dev live record --script <path>` writes a passed live check to
|
|
18
|
+
`docs/dev/live-checks.txt` as `<version> <commit> <date> <script>`, and `cli-dev live check` fails a version with no
|
|
19
|
+
line, or whose `src/`, `package.json` or lockfile changed since that commit; `bin/release` runs it first
|
|
20
|
+
(WC-REL-17). `cli-dev repo-check --cli <name>` checks main's ruleset through `gh`, skipping that part with a line on
|
|
21
|
+
stderr when there is no login or network, the monthly cron minute against WC-CI-9's list, and that the CLI is in a
|
|
22
|
+
parity group.
|
|
23
|
+
- **`config/lint/no-own-settings.grit`**, a Biome plugin for a CLI on cli-core: a `resolveSettings` call outside
|
|
24
|
+
`baseContext(…)` is an error, since a context built that way skips the run, `--timeout` and the profile's
|
|
25
|
+
permissions (WC-LIFE-17, WC-PERM-23). Add it to the CLI's own `plugins` for `src/`; see
|
|
26
|
+
[Shared tooling](docs/TOOLING.md).
|
|
27
|
+
|
|
11
28
|
## 0.80.2 — 06.11.2026
|
|
12
29
|
|
|
13
30
|
### Added
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
language js
|
|
2
|
+
|
|
3
|
+
or {
|
|
4
|
+
`$_.resolveSettings($...)`,
|
|
5
|
+
`resolveSettings($...)`
|
|
6
|
+
} as $call where {
|
|
7
|
+
$call <: not within `baseContext($...)`,
|
|
8
|
+
register_diagnostic(span=$call, message="Take settings from cli-core's baseContext(command, configuration.resolveSettings), never by calling resolveSettings: a context built on its own skips --timeout, the run record, the MCP server's levels and the profile's permissions (WC-LIFE-17, WC-PERM-23).", severity="error")
|
|
9
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Shell } from "./land.js";
|
|
2
|
+
interface DevIo {
|
|
3
|
+
cwd: string;
|
|
4
|
+
now?: () => Date;
|
|
5
|
+
out: (text: string) => void;
|
|
6
|
+
err: (text: string) => void;
|
|
7
|
+
}
|
|
8
|
+
/** The paths whose change since a live check means the release was not the code that was checked. */
|
|
9
|
+
export declare const LIVE_PATHS: readonly ["src", "package.json", "pnpm-lock.yaml"];
|
|
10
|
+
export declare const LIVE_FILE = "docs/dev/live-checks.txt";
|
|
11
|
+
/** The text under a `Conformance` heading of any level, up to the next heading of that level or higher. */
|
|
12
|
+
export declare const conformanceSection: (body: string) => string | undefined;
|
|
13
|
+
/** A pull request that changes the version is a release pull request, and carries what was checked before it. */
|
|
14
|
+
export declare const releasePrProblems: (body: string, baseVersion: string, version: string) => string[];
|
|
15
|
+
export interface LiveRecord {
|
|
16
|
+
version: string;
|
|
17
|
+
commit: string;
|
|
18
|
+
date: string;
|
|
19
|
+
script: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const parseLiveRecords: (text: string) => LiveRecord[];
|
|
22
|
+
export declare const liveCheckProblems: (shell: Shell, records: readonly LiveRecord[], version: string) => string[];
|
|
23
|
+
/** `skipped` when GitHub could not be asked (no gh, no login, no network): the caller says so and goes on. */
|
|
24
|
+
export declare const rulesetProblems: (shell: Shell, slug: string) => {
|
|
25
|
+
problems: string[];
|
|
26
|
+
skipped?: string;
|
|
27
|
+
};
|
|
28
|
+
/** The WC-CI-9 table of taken monthly minutes, as `HH:MM → repository`. */
|
|
29
|
+
export declare const takenMinutes: (ciPage: string) => Map<string, string>;
|
|
30
|
+
export declare const cronProblems: (workflow: string | undefined, repo: string, taken: Map<string, string>) => string[];
|
|
31
|
+
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/, package.json and the lockfile\n 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 unchanged since its commit\n repo-check --cli <name> [--groups <file>]\n main's ruleset (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
|
+
export declare const conformanceCommand: (command: string, args: string[], io: DevIo, shell?: Shell) => number | undefined;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { appendFileSync, existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { parseArgs } from "node:util";
|
|
5
|
+
import { packageVersion } from "../release/index.js";
|
|
6
|
+
import { defineParityGroups, PARITY_GROUPS } from "../standards/audit.js";
|
|
7
|
+
import { processShell } from "./land.js";
|
|
8
|
+
/** The paths whose change since a live check means the release was not the code that was checked. */
|
|
9
|
+
export const LIVE_PATHS = ["src", "package.json", "pnpm-lock.yaml"];
|
|
10
|
+
export const LIVE_FILE = "docs/dev/live-checks.txt";
|
|
11
|
+
/** The text under a `Conformance` heading of any level, up to the next heading of that level or higher. */
|
|
12
|
+
export const conformanceSection = (body) => {
|
|
13
|
+
const lines = body.replaceAll("\r\n", "\n").split("\n");
|
|
14
|
+
const start = lines.findIndex((line) => /^#{1,6}\s+Conformance\s*$/i.test(line));
|
|
15
|
+
if (start < 0)
|
|
16
|
+
return undefined;
|
|
17
|
+
const level = (lines[start] ?? "").match(/^#+/)?.[0].length ?? 1;
|
|
18
|
+
const rest = lines.slice(start + 1);
|
|
19
|
+
const end = rest.findIndex((line) => (line.match(/^(#+)\s/)?.[1]?.length ?? 99) <= level);
|
|
20
|
+
return (end < 0 ? rest : rest.slice(0, end)).join("\n").trim();
|
|
21
|
+
};
|
|
22
|
+
/** A pull request that changes the version is a release pull request, and carries what was checked before it. */
|
|
23
|
+
export const releasePrProblems = (body, baseVersion, version) => {
|
|
24
|
+
if (baseVersion === version)
|
|
25
|
+
return [];
|
|
26
|
+
const section = conformanceSection(body);
|
|
27
|
+
if (section === undefined)
|
|
28
|
+
return [`this pull request raises the version ${baseVersion} → ${version} and has no "## Conformance" section`];
|
|
29
|
+
if (!section)
|
|
30
|
+
return [`the "## Conformance" section of this ${version} release pull request is empty`];
|
|
31
|
+
return [];
|
|
32
|
+
};
|
|
33
|
+
export const parseLiveRecords = (text) => text
|
|
34
|
+
.split("\n")
|
|
35
|
+
.map((line) => line.trim())
|
|
36
|
+
.filter((line) => line && !line.startsWith("#"))
|
|
37
|
+
.map((line) => {
|
|
38
|
+
const [version = "", commit = "", date = "", script = ""] = line.split(/\s+/);
|
|
39
|
+
return { version, commit, date, script };
|
|
40
|
+
});
|
|
41
|
+
export const liveCheckProblems = (shell, records, version) => {
|
|
42
|
+
const record = records.findLast((entry) => entry.version === version);
|
|
43
|
+
if (!record)
|
|
44
|
+
return [
|
|
45
|
+
`no live check recorded for ${version} in ${LIVE_FILE}: run the live check, then ` +
|
|
46
|
+
"`cli-dev live record --script <its script>` and commit the line in the release pull request",
|
|
47
|
+
];
|
|
48
|
+
if (!shell.run("git", ["cat-file", "-e", `${record.commit}^{commit}`]).ok)
|
|
49
|
+
return [`${version}'s live check names commit ${record.commit}, which this clone does not have; fetch it`];
|
|
50
|
+
if (!shell.run("git", ["diff", "--quiet", record.commit, "HEAD", "--", ...LIVE_PATHS]).ok)
|
|
51
|
+
return [
|
|
52
|
+
`${LIVE_PATHS.join(", ")} changed since ${version}'s live check at ${record.commit.slice(0, 12)}: ` +
|
|
53
|
+
"check the code that is released, and record it again",
|
|
54
|
+
];
|
|
55
|
+
return [];
|
|
56
|
+
};
|
|
57
|
+
const live = (args, io, shell) => {
|
|
58
|
+
const [action, ...rest] = args;
|
|
59
|
+
const { values } = parseArgs({
|
|
60
|
+
args: rest,
|
|
61
|
+
options: {
|
|
62
|
+
script: { type: "string" },
|
|
63
|
+
version: { type: "string" },
|
|
64
|
+
file: { type: "string", default: LIVE_FILE },
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const file = join(io.cwd, values.file);
|
|
68
|
+
const version = values.version ?? packageVersion(io.cwd);
|
|
69
|
+
if (action === "check") {
|
|
70
|
+
const records = existsSync(file) ? parseLiveRecords(readFileSync(file, "utf8")) : [];
|
|
71
|
+
const problems = liveCheckProblems(shell, records, version);
|
|
72
|
+
for (const problem of problems)
|
|
73
|
+
io.err(problem);
|
|
74
|
+
if (problems.length === 0)
|
|
75
|
+
io.out(`live check: ${version} passed on the code being released`);
|
|
76
|
+
return problems.length > 0 ? 1 : 0;
|
|
77
|
+
}
|
|
78
|
+
if (action !== "record") {
|
|
79
|
+
io.err(`cli-dev live: no action "${action ?? ""}" — the ones there are: record, check`);
|
|
80
|
+
return 2;
|
|
81
|
+
}
|
|
82
|
+
if (!values.script || /\s/.test(values.script)) {
|
|
83
|
+
io.err("live record needs --script <the live check that passed>, a path without spaces");
|
|
84
|
+
return 2;
|
|
85
|
+
}
|
|
86
|
+
const dirty = shell.run("git", ["status", "--porcelain", "--", ...LIVE_PATHS]);
|
|
87
|
+
if (!dirty.ok || dirty.out) {
|
|
88
|
+
io.err(`commit ${LIVE_PATHS.join(", ")} first: a record names the commit that was checked`);
|
|
89
|
+
return 1;
|
|
90
|
+
}
|
|
91
|
+
const commit = shell.run("git", ["rev-parse", "HEAD"]).out;
|
|
92
|
+
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`);
|
|
95
|
+
io.out(line);
|
|
96
|
+
return 0;
|
|
97
|
+
};
|
|
98
|
+
const releasePr = (args, io, shell) => {
|
|
99
|
+
const { values } = parseArgs({ args, options: { base: { type: "string" }, body: { type: "string" } } });
|
|
100
|
+
if (!values.base || !values.body) {
|
|
101
|
+
io.err("release-pr needs --base <commit> and --body <file with the pull request's description>");
|
|
102
|
+
return 2;
|
|
103
|
+
}
|
|
104
|
+
const base = shell.run("git", ["show", `${values.base}:package.json`]);
|
|
105
|
+
if (!base.ok) {
|
|
106
|
+
io.err(`cannot read package.json at ${values.base}: ${base.out.split("\n")[0]}`);
|
|
107
|
+
return 2;
|
|
108
|
+
}
|
|
109
|
+
const baseVersion = String(JSON.parse(base.out).version);
|
|
110
|
+
const problems = releasePrProblems(readFileSync(join(io.cwd, values.body), "utf8"), baseVersion, packageVersion(io.cwd));
|
|
111
|
+
for (const problem of problems)
|
|
112
|
+
io.err(problem);
|
|
113
|
+
if (problems.length === 0)
|
|
114
|
+
io.out("release pull request: ok");
|
|
115
|
+
return problems.length > 0 ? 1 : 0;
|
|
116
|
+
};
|
|
117
|
+
const REQUIRED_RULES = ["deletion", "non_fast_forward", "pull_request", "required_status_checks"];
|
|
118
|
+
/** `skipped` when GitHub could not be asked (no gh, no login, no network): the caller says so and goes on. */
|
|
119
|
+
export const rulesetProblems = (shell, slug) => {
|
|
120
|
+
const answer = shell.run("gh", ["api", `repos/${slug}/rules/branches/main`]);
|
|
121
|
+
if (!answer.ok) {
|
|
122
|
+
const status = answer.out.match(/HTTP (\d{3})/)?.[1];
|
|
123
|
+
if (status === "401" || (!status && /gh auth login|GH_TOKEN/.test(answer.out)))
|
|
124
|
+
return { problems: [], skipped: "gh is not signed in (set GH_TOKEN in CI)" };
|
|
125
|
+
if (!status)
|
|
126
|
+
return { problems: [], skipped: `GitHub could not be reached: ${answer.out.split("\n")[0] ?? ""}` };
|
|
127
|
+
return {
|
|
128
|
+
problems: [
|
|
129
|
+
`GitHub answered ${status} for ${slug}'s rules on main: ` +
|
|
130
|
+
(answer.out.match(/gh: ([^\n]*?) \(HTTP/)?.[1] ?? "the repository is missing or this token cannot read it"),
|
|
131
|
+
],
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
let types;
|
|
135
|
+
try {
|
|
136
|
+
types = JSON.parse(answer.out).map((rule) => String(rule.type));
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return { problems: [], skipped: "gh did not answer JSON" };
|
|
140
|
+
}
|
|
141
|
+
const missing = REQUIRED_RULES.filter((rule) => !types.includes(rule));
|
|
142
|
+
return missing.length === 0
|
|
143
|
+
? { problems: [] }
|
|
144
|
+
: { problems: [`main's ruleset lacks ${missing.join(", ")} (cli-base docs/standards/new-cli.md, step 1)`] };
|
|
145
|
+
};
|
|
146
|
+
/** The WC-CI-9 table of taken monthly minutes, as `HH:MM → repository`. */
|
|
147
|
+
export const takenMinutes = (ciPage) => new Map([...ciPage.matchAll(/^\s*\|\s*(\d\d:\d\d)\s*\|\s*([\w.-]+)\s*\|\s*$/gm)].map(([, time, repo]) => [
|
|
148
|
+
time,
|
|
149
|
+
repo,
|
|
150
|
+
]));
|
|
151
|
+
export const cronProblems = (workflow, repo, taken) => {
|
|
152
|
+
if (workflow === undefined)
|
|
153
|
+
return [".github/workflows/monthly.yml is missing (WC-CI-9)"];
|
|
154
|
+
const cron = workflow.match(/cron:\s*["']([^"']+)["']/)?.[1];
|
|
155
|
+
const [minute, hour, day] = cron?.split(/\s+/) ?? [];
|
|
156
|
+
if (!cron || !/^\d+$/.test(minute ?? "") || !/^\d+$/.test(hour ?? ""))
|
|
157
|
+
return ["monthly.yml has no fixed cron minute and hour (WC-CI-9)"];
|
|
158
|
+
if (day !== "1")
|
|
159
|
+
return [`monthly.yml runs on day ${day}, not the first of the month (WC-CI-9)`];
|
|
160
|
+
const time = `${hour?.padStart(2, "0")}:${minute?.padStart(2, "0")}`;
|
|
161
|
+
const owner = taken.get(time);
|
|
162
|
+
return owner && owner !== repo
|
|
163
|
+
? [`monthly.yml runs at ${time} UTC, ${owner}'s minute: pick a free one from WC-CI-9's list and add it there`]
|
|
164
|
+
: [];
|
|
165
|
+
};
|
|
166
|
+
export const parityProblems = (cli, ownGroups) => {
|
|
167
|
+
const groups = ownGroups === undefined ? PARITY_GROUPS : [...PARITY_GROUPS, ...defineParityGroups(ownGroups)];
|
|
168
|
+
return groups.some((group) => group.members.includes(cli))
|
|
169
|
+
? []
|
|
170
|
+
: [`${cli} is in no parity group: add it to cli-base's PARITY_GROUPS (new-cli.md, step 4)`];
|
|
171
|
+
};
|
|
172
|
+
const ciPagePath = () => join(dirname(fileURLToPath(import.meta.url)), "../../docs/standards/ci.md");
|
|
173
|
+
const repoCheck = (args, io, shell) => {
|
|
174
|
+
const { values } = parseArgs({
|
|
175
|
+
args,
|
|
176
|
+
options: { cli: { type: "string" }, groups: { type: "string", default: "config/parity-groups.json" } },
|
|
177
|
+
});
|
|
178
|
+
if (!values.cli) {
|
|
179
|
+
io.err("repo-check needs --cli <the command's name>");
|
|
180
|
+
return 2;
|
|
181
|
+
}
|
|
182
|
+
const manifest = JSON.parse(readFileSync(join(io.cwd, "package.json"), "utf8"));
|
|
183
|
+
const url = typeof manifest.repository === "string" ? manifest.repository : (manifest.repository?.url ?? "");
|
|
184
|
+
const slug = url.match(/github\.com[/:]([\w.-]+\/[\w.-]+?)(?:\.git)?$/)?.[1];
|
|
185
|
+
if (!slug) {
|
|
186
|
+
io.err("package.json names no GitHub repository");
|
|
187
|
+
return 2;
|
|
188
|
+
}
|
|
189
|
+
const read = (path) => (existsSync(join(io.cwd, path)) ? readFileSync(join(io.cwd, path), "utf8") : undefined);
|
|
190
|
+
const groups = read(values.groups);
|
|
191
|
+
const ruleset = rulesetProblems(shell, slug);
|
|
192
|
+
if (ruleset.skipped)
|
|
193
|
+
io.err(`repo-check: ruleset not checked — ${ruleset.skipped}`);
|
|
194
|
+
const problems = [
|
|
195
|
+
...ruleset.problems,
|
|
196
|
+
...cronProblems(read(".github/workflows/monthly.yml"), slug.split("/")[1] ?? "", takenMinutes(readFileSync(ciPagePath(), "utf8"))),
|
|
197
|
+
...parityProblems(values.cli, groups === undefined ? undefined : JSON.parse(groups)),
|
|
198
|
+
];
|
|
199
|
+
for (const problem of problems)
|
|
200
|
+
io.err(problem);
|
|
201
|
+
if (problems.length === 0)
|
|
202
|
+
io.out(`repo-check: ${slug} ok`);
|
|
203
|
+
return problems.length > 0 ? 1 : 0;
|
|
204
|
+
};
|
|
205
|
+
export const CONFORMANCE_USAGE = ` release-pr --base <commit> --body <file>
|
|
206
|
+
a pull request that changes package.json's version since --base
|
|
207
|
+
needs a non-empty "## Conformance" section in its description
|
|
208
|
+
live record --script <path> [--file <path>]
|
|
209
|
+
appends "<version> <commit> <date> <script>" to ${LIVE_FILE}
|
|
210
|
+
after a live check passed; src/, package.json and the lockfile
|
|
211
|
+
must be committed
|
|
212
|
+
live check [--version <x.y.z>] [--file <path>]
|
|
213
|
+
fails unless that version has a record and src/, package.json
|
|
214
|
+
and the lockfile are unchanged since its commit
|
|
215
|
+
repo-check --cli <name> [--groups <file>]
|
|
216
|
+
main's ruleset (through gh; skipped without a login or network),
|
|
217
|
+
monthly.yml's cron minute against WC-CI-9's list, and the CLI in
|
|
218
|
+
a parity group (cli-base's, or --groups', config/parity-groups.json)`;
|
|
219
|
+
export const conformanceCommand = (command, args, io, shell = processShell(io.cwd)) => {
|
|
220
|
+
if (command === "release-pr")
|
|
221
|
+
return releasePr(args, io, shell);
|
|
222
|
+
if (command === "live")
|
|
223
|
+
return live(args, io, shell);
|
|
224
|
+
if (command === "repo-check")
|
|
225
|
+
return repoCheck(args, io, shell);
|
|
226
|
+
return undefined;
|
|
227
|
+
};
|
package/dist/dev/main.js
CHANGED
|
@@ -20,6 +20,7 @@ import { issuesOf, RegistryError } from "../standards/registry.js";
|
|
|
20
20
|
import { VOCABULARY } from "../standards/vocabulary.js";
|
|
21
21
|
import { auditClis, scorecardTable, snakeKeys } from "./audit.js";
|
|
22
22
|
import { readCapabilities } from "./capabilities.js";
|
|
23
|
+
import { CONFORMANCE_USAGE, conformanceCommand } from "./conformance.js";
|
|
23
24
|
import { changelogChange, landChange, landFold, newestTag, processShell, restoreChange } from "./land.js";
|
|
24
25
|
import { baselineOf, judge, lintCommands, RUN_LOG_COMMANDS, walk } from "./lint.js";
|
|
25
26
|
import { nextVersion } from "./next-version.js";
|
|
@@ -75,7 +76,8 @@ const USAGE = `usage: cli-dev <command> [options]
|
|
|
75
76
|
whose modules keep their installed place, as cli-core's do;
|
|
76
77
|
--harmless names a third-party file whose import.meta or
|
|
77
78
|
__dirname was read and found harmless. Fails when a bundled
|
|
78
|
-
module would look for a file or package in the wrong place
|
|
79
|
+
module would look for a file or package in the wrong place
|
|
80
|
+
${CONFORMANCE_USAGE}`;
|
|
79
81
|
const load = async (cwd, path) => (await import(pathToFileURL(isAbsolute(path) ? path : join(cwd, path)).href));
|
|
80
82
|
const report = (io, problems, ok) => {
|
|
81
83
|
for (const problem of problems)
|
|
@@ -739,8 +741,12 @@ export const main = async (argv, io) => {
|
|
|
739
741
|
case "-h":
|
|
740
742
|
io.out(USAGE);
|
|
741
743
|
return 0;
|
|
742
|
-
default:
|
|
744
|
+
default: {
|
|
745
|
+
const handled = conformanceCommand(command ?? "", args, io);
|
|
746
|
+
if (handled !== undefined)
|
|
747
|
+
return handled;
|
|
743
748
|
io.err(command ? `cli-dev: no command "${command}"\n\n${USAGE}` : USAGE);
|
|
744
749
|
return 2;
|
|
750
|
+
}
|
|
745
751
|
}
|
|
746
752
|
};
|
package/docs/standards/README.md
CHANGED
|
@@ -42,7 +42,7 @@ the four steps that need a person. A new CLI is ready for its first release when
|
|
|
42
42
|
| [Security](security.md) | `SECR` | 24 | Secrets, logs, keyring, argv, error text, untrusted text, scanners, workflow hardening, reporting, OAuth sign-in and which app it uses, meeting secrets, keyring in moved-folder runs |
|
|
43
43
|
| [Documents](docs.md) | `DOC` | 21 | User pages and developer pages, generated pages, current facts, changelog, repository page |
|
|
44
44
|
| [Comparisons](comparisons.md) | `CMP` | 11 | Which tools a comparison page lists, rows as user tasks, agents and safety, where others are better, proof of marks |
|
|
45
|
-
| [Releases](releases.md) | `REL` |
|
|
45
|
+
| [Releases](releases.md) | `REL` | 16 | `bin/release`, the release lock, versions, the owner's yes, trusted publishing |
|
|
46
46
|
| [CI](ci.md) | `CI` | 12 | Hooks, the pull request budget, full validation, monthly runs |
|
|
47
47
|
| [Time](time.md) | `TIME` | 7 | UTC in the store and in answers, the zone at input and display edges, date-only filters, tests in another zone, the time in answers agents plan by |
|
|
48
48
|
| [Style](style.md) | `STYLE` | 10 | Comments, TypeScript habits, commit messages |
|
package/docs/standards/ci.md
CHANGED
|
@@ -158,12 +158,12 @@ its prompt in cli-template says so from cli-template 0.8.0. A CLI on an older te
|
|
|
158
158
|
### WC-CI-9 · Run full validation and release security on the first day of each month, without publishing
|
|
159
159
|
|
|
160
160
|
- **Why:** a repository with no merges for weeks still meets new advisories, new runner images and expired pins.
|
|
161
|
-
- **Enforced by:** `monthly.yml:validation` · `monthly.yml:security`.
|
|
161
|
+
- **Enforced by:** `monthly.yml:validation` · `monthly.yml:security` · `<app>: pnpm repo:check`.
|
|
162
162
|
- **Example:** `monthly.yml`, from the community template, calls the repository's `ci.yml` and the pinned cli-base
|
|
163
|
-
`release-checks.yml`. Each repository has its own minute, between 02:17 and 03:20 UTC, so runs do not overlap.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
`release-checks.yml`. Each repository has its own minute, between 02:17 and 03:20 UTC, so runs do not overlap. A CLI made from cli-template starts with
|
|
164
|
+
the template's own minute and changes it (see [New CLI](new-cli.md)). `cli-dev repo-check` refuses a minute held
|
|
165
|
+
by another repository in this list, and a day other than the first. Taken minutes, from each `monthly.yml` on the
|
|
166
|
+
default branch:
|
|
167
167
|
|
|
168
168
|
| UTC | Repository |
|
|
169
169
|
|---|---|
|
|
@@ -310,9 +310,10 @@ builds settings with `resolveSettings` and calls the provider outside the run lo
|
|
|
310
310
|
run's events, no `run_id` or `duration_ms` in `meta`, and none of an MCP server's stricter levels. bitrix24-cli's
|
|
311
311
|
own `contextOf` shipped that way, and `missing-run-log` passed, since cli-core keeps every failed command as a run
|
|
312
312
|
anyway.
|
|
313
|
-
- **Enforced by:**
|
|
314
|
-
|
|
315
|
-
|
|
313
|
+
- **Enforced by:** `config/lint/no-own-settings.grit`, for settings resolved on their own. That the request
|
|
314
|
+
happens inside the run: review only, check planned: a cli-core test kit contract that runs each remote command
|
|
315
|
+
against the CLI's fake with --record and expects a run named after the command, the request in its events, and a
|
|
316
|
+
timeout (exit 9) from a fake that never answers.
|
|
316
317
|
- **Example:** gcal's `api` command calls
|
|
317
318
|
`baseContext(command, configuration.resolveSettings).run((events) => use(googleApi({ ...options, events })))`.
|
|
318
319
|
`b24 work deals list --json` answers a `run_id` that names `deals-list`.
|
|
@@ -110,13 +110,18 @@ installing that command; nothing else is registered anywhere.
|
|
|
110
110
|
[WC-REL-11](releases.md#wc-rel-11--publish-from-github-actions-with-npm-trusted-publishing).
|
|
111
111
|
3. **Pick a monthly cron minute** between 02:17 and 03:20 UTC that is not in the list of taken minutes under
|
|
112
112
|
[WC-CI-9](ci.md#wc-ci-9--run-full-validation-and-release-security-on-the-first-day-of-each-month-without-publishing).
|
|
113
|
-
The copy of `.github/workflows/monthly.yml` keeps the template's own minute, 03:02, and
|
|
114
|
-
|
|
113
|
+
The copy of `.github/workflows/monthly.yml` keeps the template's own minute, 03:02; change it by hand, and add the
|
|
114
|
+
new minute to the list in the step 4 pull request.
|
|
115
115
|
4. **WireCat CLIs only: join the shared lists.** A pull request to cli-base's `PARITY_GROUPS` (at least the `all`
|
|
116
116
|
group, which compares the shared root commands), a line in cli-core's `WIRECAT_TOOLS` and a line in cli-docs'
|
|
117
117
|
`tools.json`. A messenger also joins cli-core's `parity.json`. A CLI outside WireCatLabs keeps its parity groups
|
|
118
118
|
in its own repository and runs `cli-dev audit --groups <file>`. See [Testing](testing.md).
|
|
119
119
|
|
|
120
|
+
`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`, a monthly minute no other repository holds, and the CLI in
|
|
122
|
+
a parity group. It reads the ruleset with `gh` and the job's `GITHUB_TOKEN`; without a login or a network it says so
|
|
123
|
+
and skips that part, and fails on the rest.
|
|
124
|
+
|
|
120
125
|
The listings beyond npm (ClawHub, the MCP Registry, the Claude plugin, the docs site, Glama) are a checklist in
|
|
121
126
|
[Publishing](../PUBLISHING.md#a-new-cli).
|
|
122
127
|
|
|
@@ -389,16 +389,24 @@ The program definition passes `configuration` as it is, not a struct of its part
|
|
|
389
389
|
`toolsFromCommands(commands, { permissions: configuration.permissions, … })` in a server of the CLI's own. Otherwise
|
|
390
390
|
each tool's `available` and `level` come from the messenger's keys, not the CLI's.
|
|
391
391
|
|
|
392
|
+
The contract plan's `deny` block (cli-testing 0.6.0) checks it. It runs the built CLI in an empty home with no
|
|
393
|
+
network. Each command that reaches the service and names a key in its `--dry-run` gets `deny` in the profile and must
|
|
394
|
+
exit 5 with `permission_error`, touching no network, keyring or child process. Then each is called over `mcp serve`
|
|
395
|
+
and must be refused with `permission_error`, not a `validation_error`. It fails when no read, or no write of a CLI
|
|
396
|
+
that has writes, names a key. The Biome plugin refuses a `resolveSettings` call outside `baseContext`, the way a CLI
|
|
397
|
+
builds a context of its own.
|
|
398
|
+
|
|
392
399
|
- **Why:** a `deny` that stops nothing is worse than no setting, since the owner believes it holds. bitrix24-cli
|
|
393
400
|
ignored every read `deny`, on the command line and over MCP, for three releases. The type accepts the partial
|
|
394
401
|
struct, so nothing warned.
|
|
395
|
-
- **Enforced by:**
|
|
396
|
-
|
|
402
|
+
- **Enforced by:** `cli-testing: cli-contract deny` · `<app>: pnpm contracts:check` ·
|
|
403
|
+
`config/lint/no-own-settings.grit`.
|
|
397
404
|
- **Example:** gcal's `src/program.ts` passes `configuration` to the definition and to
|
|
398
405
|
`appMcpCommand(IDENTITY, configuration, …)`. With `{ "deals": "deny" }` in the profile, `b24 work deals list`
|
|
399
|
-
exits 5 (`permission_error`) and sends nothing.
|
|
400
|
-
|
|
401
|
-
|
|
406
|
+
exits 5 (`permission_error`) and sends nothing. cli-template's `contracts/plan.json` has
|
|
407
|
+
`"deny": { "profile": "personal", "skip": {…} }`, so every CLI made from it runs the check on each pull request.
|
|
408
|
+
- **Exceptions:** known gaps, as of 2026-11-07: beeline's definition passes only `resolveSettings`, and the MCP
|
|
409
|
+
servers of b24 and beeline call `toolsFromCommands` without `permissions`.
|
|
402
410
|
- **Applies to:** every CLI on cli-core's `run()`. **Since:** cli-base 0.80.1. **Rulings:** none.
|
|
403
411
|
|
|
404
412
|
## Sources
|
|
@@ -208,6 +208,29 @@ fixtures, `scripts/`, `.github/`, `bin/release`, `config/`, `lint/`, `contracts/
|
|
|
208
208
|
as `release-check.ts --package-only`.
|
|
209
209
|
- **Applies to:** all CLIs. **Since:** cli-base 0.41.0. **Rulings:** none.
|
|
210
210
|
|
|
211
|
+
### WC-REL-17 · A release pull request says what was checked, and the release needs a recorded live check
|
|
212
|
+
|
|
213
|
+
A pull request that changes `package.json`'s version has a `## Conformance` section that is not empty: the
|
|
214
|
+
`release:check` result, the live check's record line, the fresh audit's report or a link to it, and the slice
|
|
215
|
+
reviews ([New CLI](new-cli.md#done-when)). `cli-dev release-pr --base <commit> --body <file>` fails without one.
|
|
216
|
+
After the live check of the real service passes
|
|
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. `bin/release` runs `cli-dev live check` first: it
|
|
220
|
+
refuses a version with no line, and one whose `src/`, `package.json` or lockfile changed since the recorded commit.
|
|
221
|
+
|
|
222
|
+
- **Why:** every automated check passed on bitrix24-cli while it ignored `deny` on reads; a release that says what
|
|
223
|
+
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 paths rather than commits, because a squash merge gives `main` a
|
|
225
|
+
commit the live check never saw.
|
|
226
|
+
- **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` in `docs/dev/live-checks.txt`. A pull request
|
|
228
|
+
`chore(release): 0.4.0` without `## Conformance` fails `release-pr.yml`. `bin/release` writes the section into
|
|
229
|
+
the pull request it opens to raise a taken number, since only the number changes.
|
|
230
|
+
- **Exceptions:** cli-template's own release has no service to check; its `bin/release` skips the live check where
|
|
231
|
+
`template.json` exists, a file `new` never copies.
|
|
232
|
+
- **Applies to:** every CLI made from cli-template 0.17.0 or later. **Since:** cli-base 0.80.3. **Rulings:** none.
|
|
233
|
+
|
|
211
234
|
## Sources
|
|
212
235
|
|
|
213
236
|
These documents explain the rules on this page in more detail. Where one of them disagrees with this page, this page
|
|
@@ -232,10 +232,13 @@ and which run after merge is in [CI](ci.md).
|
|
|
232
232
|
### WC-TEST-18 · Check the real service by hand, never in the test suite
|
|
233
233
|
|
|
234
234
|
- **Why:** a check against a real account needs a live login and can send messages to people.
|
|
235
|
-
- **Enforced by:**
|
|
235
|
+
- **Enforced by:** `<app>: bin/release` · `src/dev/conformance.ts`, for the record. Running the scenarios stays a
|
|
236
|
+
person's job.
|
|
236
237
|
- **Example:** live scenarios run by hand, by the owner or with the owner's yes, on test profiles and test chats
|
|
237
238
|
only. The cast lives in an ignored file, no profile is assumed, and the record keeps the shape of each answer,
|
|
238
|
-
never its content. When a scenario is run again, the sentence it supports is updated.
|
|
239
|
+
never its content. When a scenario is run again, the sentence it supports is updated. A passed run is recorded
|
|
240
|
+
with `cli-dev live record --script <its script>`, and `bin/release` refuses a version without one
|
|
241
|
+
([WC-REL-17](releases.md#wc-rel-17--a-release-pull-request-says-what-was-checked-and-the-release-needs-a-recorded-live-check)).
|
|
239
242
|
- **Exceptions:** a messenger with no test accounts, such as WhatsApp, where a second account or a second linked
|
|
240
243
|
device would change the owner's real one, runs live scenarios on the owner's profile and only in the owner's own
|
|
241
244
|
chat (the chat with themselves). It never writes to another person, and still runs only with the owner's yes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-base",
|
|
3
|
-
"version": "0.80.
|
|
3
|
+
"version": "0.80.3",
|
|
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",
|