@wirecat/cli-base 0.125.1 → 0.125.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 CHANGED
@@ -8,6 +8,40 @@ 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.125.3 — 21.11.2026
12
+
13
+ ### Fixed
14
+
15
+ - **`cli-dev audit --family` installs again when the registry drops the connection.** npm's `--fetch-retries` does
16
+ not cover a download cut off midway (`read ECONNRESET`), and about half the family installs failed that way. A
17
+ network error now tries the install up to three times; any other error, such as a package npm does not have,
18
+ fails at once as before.
19
+
20
+ ## 0.125.2 — 21.11.2026
21
+
22
+ ### Security
23
+
24
+ - **A generated `api` group never offers a call whose answer may hold a credential deep inside.** The manifest's
25
+ `response.sensitive` was set only when the answer itself was marked, so a credential one field deep (an object's
26
+ `password`) was printed. It now holds when any field of the answer, behind references too, is marked, and cli-core
27
+ leaves those calls out of `api` with "it returns a credential". `adaptOpenApi` marks a string with
28
+ `format: password`, OpenAPI's word for a value to hide, unless it is `writeOnly` and so never in an answer. Regenerate and review the coverage diff: a call whose answer
29
+ holds such a field leaves the `api` group.
30
+ - **The WordPress converter marks an application password secret.** WordPress answers a new application password in
31
+ clear and its index marks no field secret, so the `api` group of a WordPress CLI offered
32
+ `users-application-passwords-create`. `wpJsonToOpenApi` now gives every read-only `password`, `secret` or `token`
33
+ field `format: password`. The application password routes' create, list, get, update and introspect leave `api`,
34
+ as their answers share the schema; both deletes stay. A post's or a user's `password`, which the caller sets, is not
35
+ marked. A CLI that left the route out with `exclude` may drop that exclusion.
36
+
37
+ ### Fixed
38
+
39
+ - **Command names from paths no longer clash on WordPress's whole index.** A GET on a path that ends in a parameter,
40
+ with a GET one parameter deeper, is a list by that parameter: `block-types-list-namespace` beside
41
+ `block-types-get`. A DELETE on a collection beside a DELETE on its item is `…-delete-all`. Both pairs took one name
42
+ and stopped generation, so a CLI mapped one of them in `names.commands`. Mapped the list or the delete-all: nothing
43
+ changes. Mapped the item instead: the other one of the pair takes the new name, and its `api` key with it.
44
+
11
45
  ## 0.125.1 — 21.11.2026
12
46
 
13
47
  ### Fixed
@@ -28,7 +28,8 @@ const toManifest = (operation, tree) => withoutUndefined({
28
28
  ? withoutUndefined({
29
29
  confidence: operation.response.confidence,
30
30
  schema: tree.responseName(operation.id),
31
- sensitive: operation.response.schema?.sensitive,
31
+ // A credential one field deep is printed as surely as one at the top.
32
+ sensitive: holdsSecret(operation.response.schema, tree) || undefined,
32
33
  })
33
34
  : undefined,
34
35
  });
@@ -279,6 +279,10 @@ class Adapter {
279
279
  node.enum = values.map(String);
280
280
  if (source.format === "binary")
281
281
  node.format = "binary";
282
+ // OpenAPI's own word for a value to hide; an answer that holds one is never printed. A writeOnly one is never
283
+ // in an answer, as FastAPI's SecretStr input.
284
+ if (source.format === "password" && source.writeOnly !== true)
285
+ node.sensitive = true;
282
286
  if (typeof source.minLength === "number")
283
287
  node.minLength = source.minLength;
284
288
  if (typeof source.maxLength === "number")
@@ -43,17 +43,21 @@ const commandFromPath = (operation, all, names) => {
43
43
  const collection = all.some((other) => other.binding.kind === "http" &&
44
44
  ((other.binding.method === "GET" && other.binding.path === path) ||
45
45
  (other.binding.path.startsWith(`${path}/{`) && !other.binding.path.slice(path.length + 1).includes("/"))));
46
- // A PUT on the collection beside a PUT on its item is the "create or update by a unique value" (Attio's assert).
47
- const itemPut = all.some((other) => other.binding.kind === "http" &&
48
- other.binding.method === "PUT" &&
46
+ // The same method one parameter deeper: this path holds items, though it may end in a parameter itself.
47
+ const holdsItems = all.some((other) => other.binding.kind === "http" &&
48
+ other.binding.method === method &&
49
49
  other.binding.path.startsWith(`${path}/{`) &&
50
50
  !other.binding.path.slice(path.length + 1).includes("/"));
51
+ const last = parts.at(-1) ?? "";
51
52
  const verb = {
52
- GET: onItem || parts.at(-1) === "me" ? "get" : "list",
53
+ // WordPress's block-types/{namespace} beside block-types/{namespace}/{name}, and beside block-types' own list.
54
+ GET: onItem && holdsItems ? `list-${kebab(last.slice(1, -1))}` : onItem || last === "me" ? "get" : "list",
53
55
  HEAD: "head",
54
- DELETE: "delete",
56
+ // A DELETE on the collection beside one on its item deletes them all (WordPress's application passwords).
57
+ DELETE: !onItem && holdsItems ? "delete-all" : "delete",
55
58
  PATCH: "update",
56
- PUT: onItem ? "replace" : collection ? (itemPut ? "upsert" : "replace") : "",
59
+ // A PUT on the collection beside a PUT on its item is the "create or update by a unique value" (Attio's assert).
60
+ PUT: onItem ? "replace" : collection ? (holdsItems ? "upsert" : "replace") : "",
57
61
  POST: onItem ? "update" : collection ? "create" : "",
58
62
  }[method];
59
63
  return [...words, verb].filter(Boolean).join("-");
@@ -25,7 +25,8 @@ export interface WpJsonResult {
25
25
  * The OpenAPI document of the routes under `namespaces`. A route offers GET as a read, DELETE as a delete with its
26
26
  * arguments in the query (`force=true`), and one write: POST where the route takes it, as WordPress takes the same
27
27
  * call by POST, PUT and PATCH. A write's arguments are its JSON body. An array argument in the query travels as one
28
- * comma-separated value, which WordPress splits, as PHP keeps only the last of a repeated name.
28
+ * comma-separated value, which WordPress splits, as PHP keeps only the last of a repeated name. A read-only credential
29
+ * field becomes `format: password`, so no generated command prints an answer that may hold it.
29
30
  */
30
31
  export declare const wpJsonToOpenApi: (index: unknown, options: WpJsonOptions) => WpJsonResult;
31
32
  /** The snapshot's entry in `provenance.json`. */
@@ -18,6 +18,11 @@ const object = (value) => !!value && typeof value === "object" && !Array.isArray
18
18
  const DROPPED = new Set(["context", "readonly", "arg_options", "links", "$schema", "patternProperties", "required"]);
19
19
  /** WordPress names the boolean type `bool` in a few block attributes. */
20
20
  const typeName = (type) => type === "bool" ? "boolean" : Array.isArray(type) ? type.map(typeName) : type;
21
+ /**
22
+ * A secret WordPress makes and answers, as an application password's `password`: read-only, so no caller sets it. The
23
+ * index marks nothing secret, and a post's or a user's `password` is the caller's own input, never answered.
24
+ */
25
+ const credential = (name, field) => object(field) && field.readonly === true && /(^|_)(password|secret|token)$/i.test(name);
21
26
  /**
22
27
  * One JSON Schema draft 4 node, as WordPress writes it, → its OpenAPI 3.1 form: a field's `required: true` joins its
23
28
  * object's `required` list, a node with `properties` and no type is an object, and a draft 4 `exclusiveMinimum: true`
@@ -36,7 +41,10 @@ const schemaOf = (value, where) => {
36
41
  if (key === "type")
37
42
  out.type = typeName(field);
38
43
  else if (key === "properties" && object(field))
39
- out.properties = Object.fromEntries(Object.entries(field).map(([name, inner]) => [name, schemaOf(inner, `${where}/properties/${name}`)]));
44
+ out.properties = Object.fromEntries(Object.entries(field).map(([name, inner]) => [
45
+ name,
46
+ schemaOf(credential(name, inner) ? { ...inner, format: "password" } : inner, `${where}/properties/${name}`),
47
+ ]));
40
48
  else if (key === "items")
41
49
  out.items = schemaOf(field, `${where}/items`);
42
50
  else if ((key === "oneOf" || key === "anyOf") && Array.isArray(field))
@@ -133,7 +141,8 @@ const isList = (args) => "per_page" in args && "page" in args;
133
141
  * The OpenAPI document of the routes under `namespaces`. A route offers GET as a read, DELETE as a delete with its
134
142
  * arguments in the query (`force=true`), and one write: POST where the route takes it, as WordPress takes the same
135
143
  * call by POST, PUT and PATCH. A write's arguments are its JSON body. An array argument in the query travels as one
136
- * comma-separated value, which WordPress splits, as PHP keeps only the last of a repeated name.
144
+ * comma-separated value, which WordPress splits, as PHP keeps only the last of a repeated name. A read-only credential
145
+ * field becomes `format: password`, so no generated command prints an answer that may hold it.
137
146
  */
138
147
  export const wpJsonToOpenApi = (index, options) => {
139
148
  if (!object(index) || !object(index.routes))
@@ -1,3 +1,4 @@
1
+ import type { SpawnSyncReturns } from "node:child_process";
1
2
  import type { ParityGroup } from "../standards/audit.js";
2
3
  /** Every other CLI of the parity groups that npm has, by name. */
3
4
  export declare const familyPackages: (groups: readonly ParityGroup[], own: string) => Map<string, string>;
@@ -7,4 +8,4 @@ export interface Family {
7
8
  close: () => void;
8
9
  }
9
10
  /** 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;
11
+ export declare const installFamily: (packages: ReadonlyMap<string, string>, install?: (args: string[]) => SpawnSyncReturns<string>, wait?: number) => Family;
@@ -18,11 +18,15 @@ export const familyPackages = (groups, own) => new Map([...new Set(groups.flatMa
18
18
  .filter((name) => name !== own && PACKAGES.has(name))
19
19
  .sort()
20
20
  .map((name) => [name, PACKAGES.get(name)]));
21
+ // `--fetch-retries` covers a refused request, not a connection the registry drops mid-download: about half the
22
+ // installs of eight CLIs failed that way on 2026-11-19 and 2026-11-21 (`read ECONNRESET`).
23
+ const NETWORK = /^npm error network |\b(ECONNRESET|ETIMEDOUT|EAI_AGAIN|ECONNREFUSED|EPIPE|ENETUNREACH)\b/m;
24
+ const ATTEMPTS = 3;
21
25
  /** Installs the latest published `packages` into a folder of their own, without their install scripts. */
22
- export const installFamily = (packages) => {
26
+ export const installFamily = (packages, install = (args) => spawn.sync("npm", args, { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 }), wait = 3000) => {
23
27
  const prefix = mkdtempSync(join(tmpdir(), "cli-dev-family-"));
24
28
  const close = () => rmSync(prefix, { recursive: true, force: true });
25
- const run = spawn.sync("npm", [
29
+ const args = [
26
30
  "install",
27
31
  "--global",
28
32
  "--prefix",
@@ -35,7 +39,13 @@ export const installFamily = (packages) => {
35
39
  "--fetch-retries",
36
40
  "6",
37
41
  ...packages.values(),
38
- ], { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 });
42
+ ];
43
+ let run = install(args);
44
+ for (let attempt = 1; attempt < ATTEMPTS && run.status !== 0 && NETWORK.test(String(run.stderr)); attempt++) {
45
+ // A connection the registry dropped under load is often dropped again at once.
46
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, wait);
47
+ run = install(args);
48
+ }
39
49
  if (run.error || run.status !== 0) {
40
50
  close();
41
51
  throw new Error(`npm install of the family failed: ${run.error?.message ?? String(run.stderr).trim()}`);
@@ -52,6 +52,10 @@ what it cannot do yet.
52
52
  | WordPress's REST index | `adaptOpenApi(wpJsonToOpenApi(readWpJson(dir), { namespaces: ["wp/v2"] }).document)`, the index written by `syncWpJson` |
53
53
  | A Postman collection v2.0 or v2.1 (Braze) | `adaptOpenApi(postmanToOpenApi(collection, { variables }).document)`, the collection committed in `spec/<service>/` with its provenance; a POST that only reads gets an `effect` override |
54
54
 
55
+ A string with `format: password` (not `writeOnly`) is a credential: a call whose answer holds one anywhere gets
56
+ `response.sensitive` in the manifest, and cli-core offers no `api` command for it. `wpJsonToOpenApi` gives a read-only
57
+ `password`, `secret` or `token` field that format, as WordPress's index marks nothing secret.
58
+
55
59
  `upgradeToOpenApi3` converts with [swagger-converter](https://github.com/apigee-127/swagger-converter) (1.2 → 2.0) and
56
60
  [@scalar/openapi-upgrader](https://github.com/scalar/scalar/tree/main/packages/openapi-upgrader) (2.0 → 3.0). They are
57
61
  optional peer dependencies of cli-base: a CLI that converts adds them to its `devDependencies`. Commit the source as the
@@ -105,8 +109,11 @@ From the source the generator reads:
105
109
  runs any SQL). An override still wins.
106
110
  - **`names`**: `{ commands, fromPath, segments }`. `commands` maps an operation id to its command. With `fromPath`,
107
111
  the rest are named from the path and the method (`deals-list`, `deals-get`, `deals-create`, `deals-delete`,
108
- `deals-batch-archive`), leaving out path parameters and versions (`v3`, `2026-03`), which `segments` cannot rename. A name that comes out
109
- empty or not in kebab case stops generation; map that operation in `commands`. `segments` renames a path segment
112
+ `deals-batch-archive`), leaving out path parameters and versions (`v3`, `2026-03`), which `segments` cannot rename.
113
+ A path that ends in a parameter yet holds items one parameter deeper lists by that parameter
114
+ (`block-types-list-namespace` beside `block-types-get`); a DELETE on a collection beside one on its item is
115
+ `…-delete-all`; a PUT there is `…-upsert`. A name that comes out empty or not in kebab case stops generation; map
116
+ that operation in `commands`. `segments` renames a path segment
110
117
  or, with `""`, leaves it out: `{ "0-3": "deals", crm: "", objects: "" }`. Without `names` the command is the operation
111
118
  id in kebab case, as before.
112
119
  - **`permissions`**: `{ group, deletingFlags, forceFlags, shares, valueKeys }`. `group` is a name (`files`) or a function of the operation, for
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-base",
3
- "version": "0.125.1",
3
+ "version": "0.125.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",