@wirecat/cli-base 0.96.0 → 0.98.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 +81 -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 +2 -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 +8 -0
- package/dist/dev/lint.js +34 -7
- package/dist/dev/main.js +173 -23
- package/dist/dev/network.js +10 -2
- package/dist/dev/result-shape.d.ts +19 -0
- package/dist/dev/result-shape.js +263 -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 +2 -0
- package/dist/standards/audit.js +2 -0
- package/dist/standards/flags-account.d.ts +3 -0
- package/dist/standards/flags-account.js +36 -0
- package/dist/standards/index.d.ts +1 -1
- package/dist/standards/lint.d.ts +18 -2
- package/dist/standards/lint.js +29 -6
- package/dist/standards/output.d.ts +12 -0
- package/dist/standards/tables.d.ts +1 -1
- package/dist/standards/tables.js +1 -1
- package/dist/standards/vocabulary.js +3 -0
- package/docs/standards/README.md +1 -1
- package/docs/standards/accounts.md +3 -3
- package/docs/standards/layout.md +1 -1
- package/docs/standards/lifecycle.md +4 -6
- package/docs/standards/output.md +42 -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,87 @@ 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.98.0 — 12.11.2026
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **`cli-dev audit --family`: one command instead of each CLI's `scripts/audit.sh`.** Given the CLI's own built bin
|
|
16
|
+
(`--cli dist/bin/b24.js`), it installs the latest published CLIs of every parity group (mail and gcal included,
|
|
17
|
+
which the six copies left out), runs each in an empty home with the keyring out of reach, and reads every CLI's
|
|
18
|
+
`commands info --json`, so `same-error-reason` and `same-entity-schema` are measured at last. It defaults `--for`,
|
|
19
|
+
`--lint` and `--groups` as the script did. The two newly measured rules print their findings as warnings for now:
|
|
20
|
+
they are strict, so no baseline can hold them, and the script never measured them. See
|
|
21
|
+
[TOOLING.md](docs/TOOLING.md).
|
|
22
|
+
- **`cli-dev changelog fragments` and `cli-dev changelog level`.** The `changes/<branch>.md` fragment check and
|
|
23
|
+
collection, and the version-level check (`Added` needs a minor, a break a major), which b24 and cli-core each kept
|
|
24
|
+
as a script of their own, are now shared; `--next <x.y.z>` prints the version a release needs. Also exported from
|
|
25
|
+
`@wirecat/cli-base/release` (`readFragments`, `fragmentProblems`, `collectFragments`, `levelledVersion`,
|
|
26
|
+
`versionLevelProblem`, `CHANGELOG_HEADINGS`).
|
|
27
|
+
- **`cli-dev adopt <x.y.z>`: a shared-package bump done the same way in every CLI.** It pins the version
|
|
28
|
+
(`--package`, cli-core by default), runs `pnpm install`, then `generate` and `ci:quick` when the CLI has them, and
|
|
29
|
+
stops at the first failure. It opens no pull request yet.
|
|
30
|
+
- **Commands cli-core mounts can say so: `origin: "cli-core"`.** The commands document accepts the new value, and lint
|
|
31
|
+
treats such a command like a handwritten one. Once cli-core marks its commands, `cli-dev lint` fails a word rule's
|
|
32
|
+
baseline entry on the CLI's own command (it belongs in the overrides) and an override on cli-core's (it belongs in
|
|
33
|
+
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)
|
|
34
|
+
says; `--allow-stale` only warns, as for a stale entry. Nothing changes until then. To watch for: a reader of
|
|
35
|
+
`commands --json` on an older cli-base refuses a document with the new value, so cli-core marks its commands only
|
|
36
|
+
once the CLIs and tools that parse it are on this release.
|
|
37
|
+
- **A parity group's difference can expire.** A `differences` entry takes `review_after`, with the lint overrides'
|
|
38
|
+
rule: a warning from 14 days before, a failure 14 days after. An audit without `--for` also warns when the
|
|
39
|
+
baseline holds rows no CLI has any more.
|
|
40
|
+
- **`retrying()` in `@wirecat/cli-base/http`: one retry loop for provider CLIs.** It wraps a `FetchLike` (usually
|
|
41
|
+
`hostFetch`'s) and sends a read again after 408, 429, 5xx or a retryable error, a write only after a 429, waiting
|
|
42
|
+
the provider's `Retry-After` or a jittered backoff, within `budget`, and through a shared `pacer` when given.
|
|
43
|
+
b24, zoom, max, mail and beeline each wrote their own loop with different limits; see
|
|
44
|
+
[REFERENCE.md](docs/REFERENCE.md).
|
|
45
|
+
- **Vocabulary roles for the words cli-core's shared commands use.** `account remove --keep-data` and `--delete-data`,
|
|
46
|
+
`session start --answer-stdin`, `--client-id` and `--client-file`, `--hide-phone`, and the verb `call` (`api call`)
|
|
47
|
+
now have a meaning in the vocabulary. Eight CLIs carried about 35 baseline and override lines for them. To watch for:
|
|
48
|
+
`cli-dev lint` reports each of those lines as stale; remove them in the change that takes this release.
|
|
49
|
+
- **Lint gives an override's `review_after` two weeks either side.** An override warns from 14 days before its date
|
|
50
|
+
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
|
|
51
|
+
the date, and a date shared by several CLIs (`stats tasks show --chat`, 2026-12-01 in tg, max and wa) broke all of
|
|
52
|
+
them at once.
|
|
53
|
+
- **A `low` lint rule is advice and fails nothing.** `command-help-too-long` and `command-example-count` (now `low`)
|
|
54
|
+
print their new violations and stale baseline entries as warnings. Help-text polish no longer holds a merge.
|
|
55
|
+
- **A live check records only the files that ship.** `cli-dev live record` writes `v2:` and a hash that leaves out
|
|
56
|
+
`*.test.*`, `src/testing/`, `__snapshots__/` and `__fixtures__/`, so a merge that changes only tests needs no new
|
|
57
|
+
live check against the owner's account. b24's 0.15.0 took five pull requests, three of them new live records after
|
|
58
|
+
test-only merges. A record without `v2:` is still compared with every file, so existing lines keep passing.
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- **The command lint's empty home keeps the keyring out of reach.** The run-log probe and the WCAT describe check
|
|
63
|
+
ran the built CLI with an empty `HOME`, which does not hide the keyring: it is reached over D-Bus. They now set
|
|
64
|
+
`DBUS_SESSION_BUS_ADDRESS=disabled:` as well.
|
|
65
|
+
- **The audit baseline no longer lists `mcp --allow-send` and `--allow-dangerous`.** No published CLI has them on its
|
|
66
|
+
`mcp` commands any more (checked against tg 0.123.0, max 0.111.0, memo 0.131.87 and drive 0.65.0).
|
|
67
|
+
- **Stale standards text.** WC-ACCT-12's known gaps (zm has `session end`; gcal and mail have all four; memo has no
|
|
68
|
+
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
|
|
69
|
+
longer imports mail), WC-LAY-1 (memo has `contracts/`) and WC-TEST-14 (wa has an upgrade contract) now say what the CLIs
|
|
70
|
+
do. WC-OUT-11 and WC-OUT-15 name the audit that measures them.
|
|
71
|
+
- **`raw-network` no longer skips a file that hands the global `fetch` on through an object key or an argument.** A
|
|
72
|
+
file with `{ fetch: deps.fetch ?? fetch }` or `makeClient(fetch)` counted as one that binds its own `fetch`, so its
|
|
73
|
+
global `fetch` went unreported (mail-cli and cli-memo had such files). Only a declaration binds it now: a typed or
|
|
74
|
+
defaulted parameter, a destructuring pattern, an arrow's own parameter. To watch for: such files are now reported;
|
|
75
|
+
route them through `hostFetch`, or say why in `lint/overrides.json`.
|
|
76
|
+
|
|
77
|
+
## 0.97.0 — 11.11.2026
|
|
78
|
+
|
|
79
|
+
### Added
|
|
80
|
+
|
|
81
|
+
- **One shape for a list or a search in a TypeScript API, and a lint rule for it.** The handbook's new
|
|
82
|
+
[WC-OUT-25](docs/standards/output.md#wc-out-25--return-a-list-or-a-search-from-a-typescript-api-as-a-listresult)
|
|
83
|
+
says a list or search returns `{ items, hasMore, nextOffset?, nextCursor?, total? }`, the new `ListResult<T>` type
|
|
84
|
+
in `@wirecat/cli-base/standards`; `--json` keeps the envelope of WC-OUT-4. Until now cli-core's services answered
|
|
85
|
+
`{items, hasMore}`, `{items, has_more}`, `{hits, has_more}` or a bare array. `cli-dev lint` gets the rule
|
|
86
|
+
`result-shape`: it reads the `.d.ts` files that `package.json` publishes and names each page that keeps `hits`,
|
|
87
|
+
`has_more`, `limit_reached`, `next_offset` or `nextPage`, and each paged list or search that returns an array or
|
|
88
|
+
takes a page number. To watch for: the rule checks only built types, so run it after `tsc`; with none built, or
|
|
89
|
+
none published, it is skipped with a note. Today's violations go in `lint/baseline/result-shape.json` with
|
|
90
|
+
`--write-baseline`.
|
|
91
|
+
|
|
11
92
|
## 0.96.0 — 11.11.2026
|
|
12
93
|
|
|
13
94
|
### Changed — may break callers
|
|
@@ -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
|
@@ -27,7 +27,7 @@ export const snakeKeys = (value) => {
|
|
|
27
27
|
export const clisOf = (target) => (target.split(" ")[0] ?? "").replace(/:$/, "").split("+");
|
|
28
28
|
const named = (clis) => [...clis].sort(byText).join("+");
|
|
29
29
|
const handwritten = (document) => new Map(walk(document.commands)
|
|
30
|
-
.filter((command) => command.origin
|
|
30
|
+
.filter((command) => command.origin !== "generated")
|
|
31
31
|
.map((command) => [command.path.join(" "), command]));
|
|
32
32
|
const requiredRoots = (inputs, roots) => inputs.flatMap(({ document }) => {
|
|
33
33
|
const paths = new Set(walk(document.commands).map((command) => command.path.join(" ")));
|
|
@@ -105,7 +105,7 @@ const sameFlagMeaning = (inputs, vocabulary) => {
|
|
|
105
105
|
const options = [
|
|
106
106
|
...document.global_options,
|
|
107
107
|
...walk(document.commands)
|
|
108
|
-
.filter((command) => command.origin
|
|
108
|
+
.filter((command) => command.origin !== "generated")
|
|
109
109
|
.flatMap((command) => command.options),
|
|
110
110
|
];
|
|
111
111
|
for (const option of options) {
|
|
@@ -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
|
@@ -4,6 +4,7 @@ import { summaryOf } from "../commands/registry.js";
|
|
|
4
4
|
import { type LintRule, type Override } from "../standards/lint.js";
|
|
5
5
|
import type { Vocabulary } from "../standards/vocabulary.js";
|
|
6
6
|
import { type NetworkContext } from "./network.js";
|
|
7
|
+
import { type Declarations } from "./result-shape.js";
|
|
7
8
|
export interface Violation {
|
|
8
9
|
rule: string;
|
|
9
10
|
/** What the baseline and overrides name: `chats list`, `chats show <chat>`, `chats list --limit`, `--until`. */
|
|
@@ -29,6 +30,8 @@ export interface LintContext {
|
|
|
29
30
|
runLog?: RunLogProbe;
|
|
30
31
|
/** The CLI's own source and declared hosts, for `raw-network` and `undeclared-host`; absent, both find nothing. */
|
|
31
32
|
network?: NetworkContext;
|
|
33
|
+
/** The package's published `.d.ts` files, for `result-shape`; absent, it finds nothing. */
|
|
34
|
+
declarations?: Declarations;
|
|
32
35
|
}
|
|
33
36
|
export interface RunLogProbe {
|
|
34
37
|
kept: boolean;
|
|
@@ -63,3 +66,8 @@ export interface Judgement {
|
|
|
63
66
|
export declare const judge: (violations: readonly Violation[], baseline: Readonly<Record<string, readonly string[]>>, overrides: readonly Override[], budget: number, rules?: readonly LintRule[]) => Judgement;
|
|
64
67
|
/** What `--write-baseline` writes: per rule, the targets no override covers. A rule with none gets no file. */
|
|
65
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
|
@@ -10,6 +10,7 @@ import { isContentKey, logAttributesJsonSchema, logRecordSchema } from "../stand
|
|
|
10
10
|
import { itemEnvelopeSchema, jsonlEndSchema, jsonlItemSchema, listEnvelopeSchema } from "../standards/output.js";
|
|
11
11
|
import { jsonSchemaOf, SNAKE_CASE } from "../standards/registry.js";
|
|
12
12
|
import { rawNetwork, undeclaredHosts } from "./network.js";
|
|
13
|
+
import { resultShape } from "./result-shape.js";
|
|
13
14
|
const SUMMARY_LIMIT = 80;
|
|
14
15
|
const EXAMPLES_MIN = 1;
|
|
15
16
|
const EXAMPLES_MAX = 3;
|
|
@@ -87,7 +88,7 @@ const documentKeys = (value, path) => {
|
|
|
87
88
|
return [[key, at], ...(DATA_KEYS.has(key) ? [] : documentKeys(item, key === "commands" ? "commands" : at))];
|
|
88
89
|
});
|
|
89
90
|
};
|
|
90
|
-
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");
|
|
91
92
|
/** Splits an example the way a shell would for the quoting examples use: '…', "…" and a backslash. */
|
|
92
93
|
export const exampleWords = (line) => [...line.matchAll(/(?:'[^']*'|"(?:\\.|[^"\\])*"|\\.|[^\s'"\\])+/g)].map(([word]) => word.replace(/'([^']*)'|"((?:\\.|[^"\\])*)"|\\(.)/g, (_, single, double, escaped) => single ?? escaped ?? double.replace(/\\(.)/g, "$1")));
|
|
93
94
|
const BUILT_IN = ["-h", "--help"];
|
|
@@ -201,7 +202,7 @@ const declaredWrite = ({ effects }) => effects?.remote === "write" || effects?.l
|
|
|
201
202
|
const optionsOf = (document) => [
|
|
202
203
|
...document.global_options.map((option) => ({ option, target: longName(option.flags) })),
|
|
203
204
|
...walk(document.commands)
|
|
204
|
-
.filter((command) => command.origin
|
|
205
|
+
.filter((command) => command.origin !== "generated")
|
|
205
206
|
.flatMap((command) => command.options.map((option) => ({ option, target: `${label(command)} ${longName(option.flags)}` }))),
|
|
206
207
|
];
|
|
207
208
|
const CHECKS = {
|
|
@@ -226,7 +227,7 @@ const CHECKS = {
|
|
|
226
227
|
const roots = new Set(vocabulary.roots.map((entry) => entry.word));
|
|
227
228
|
const verbs = new Set(vocabulary.verbs.map((entry) => entry.word));
|
|
228
229
|
return walk(document.commands)
|
|
229
|
-
.filter((command) => command.commands.length > 0 && command.origin
|
|
230
|
+
.filter((command) => command.commands.length > 0 && command.origin !== "generated")
|
|
230
231
|
.filter((command) => !nouns.has(command.name) && !roots.has(command.name))
|
|
231
232
|
.map((command) => ({
|
|
232
233
|
target: label(command),
|
|
@@ -247,7 +248,7 @@ const CHECKS = {
|
|
|
247
248
|
for (const option of document.global_options)
|
|
248
249
|
note(option, "every command");
|
|
249
250
|
for (const command of walk(document.commands))
|
|
250
|
-
if (command.origin
|
|
251
|
+
if (command.origin !== "generated")
|
|
251
252
|
for (const option of command.options)
|
|
252
253
|
note(option, label(command));
|
|
253
254
|
const found = [];
|
|
@@ -275,7 +276,7 @@ const CHECKS = {
|
|
|
275
276
|
.filter((command) => (command.commands.length === 0 || command.runnable) && command.effects === undefined)
|
|
276
277
|
.map((command) => ({ target: label(command), message: "no effects; without them it counts as a write" })),
|
|
277
278
|
"command-help-too-long": (document) => walk(document.commands)
|
|
278
|
-
.filter((command) => command.origin
|
|
279
|
+
.filter((command) => command.origin !== "generated" && summaryOf(command).length > SUMMARY_LIMIT)
|
|
279
280
|
.map((command) => ({
|
|
280
281
|
target: label(command),
|
|
281
282
|
message: `summary is ${summaryOf(command).length} characters; at most ${SUMMARY_LIMIT}`,
|
|
@@ -290,7 +291,7 @@ const CHECKS = {
|
|
|
290
291
|
message: `${command.examples?.length ?? 0} examples; give ${EXAMPLES_MIN} to ${EXAMPLES_MAX}`,
|
|
291
292
|
})),
|
|
292
293
|
"faulty-help-example-parameters": (document) => withAncestors(document.commands)
|
|
293
|
-
.filter(([command]) => command.commands.length === 0 && command.origin
|
|
294
|
+
.filter(([command]) => command.commands.length === 0 && command.origin !== "generated")
|
|
294
295
|
.flatMap(([command, ancestors]) => (command.examples ?? []).flatMap((example) => {
|
|
295
296
|
const fault = faultOf(example, command, ancestors, document);
|
|
296
297
|
return fault === undefined ? [] : [{ target: `${label(command)}: ${example}`, message: fault }];
|
|
@@ -311,7 +312,7 @@ const CHECKS = {
|
|
|
311
312
|
"filter-flag": (document, vocabulary, context) => {
|
|
312
313
|
const roles = new Map(vocabulary.flags.map((flag) => [flag.name, flag.role]));
|
|
313
314
|
return walk(document.commands)
|
|
314
|
-
.filter((command) => command.origin
|
|
315
|
+
.filter((command) => command.origin !== "generated" &&
|
|
315
316
|
!declaredWrite(command) &&
|
|
316
317
|
(command.query || (["list", "events", "runs"].includes(command.name) && command.output)))
|
|
317
318
|
.flatMap((command) => {
|
|
@@ -430,6 +431,7 @@ const CHECKS = {
|
|
|
430
431
|
},
|
|
431
432
|
"raw-network": (_document, _vocabulary, context) => (context.network ? rawNetwork(context.network) : []),
|
|
432
433
|
"undeclared-host": (_document, _vocabulary, context) => (context.network ? undeclaredHosts(context.network) : []),
|
|
434
|
+
"result-shape": (_document, _vocabulary, context) => (context.declarations ? resultShape(context.declarations) : []),
|
|
433
435
|
};
|
|
434
436
|
export const lintRuleIds = () => Object.keys(CHECKS);
|
|
435
437
|
/** Every violation, one per rule and target, sorted. Generated commands keep the names of the API they mirror. */
|
|
@@ -482,3 +484,28 @@ export const baselineOf = (violations, overrides, rules = LINT_RULES) => {
|
|
|
482
484
|
.sort(),
|
|
483
485
|
]));
|
|
484
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
|
+
};
|