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