@wirecat/cli-base 0.111.0 → 0.113.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 CHANGED
@@ -8,6 +8,63 @@ 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.113.0 — 17.11.2026
12
+
13
+ ### Added
14
+
15
+ - **A CLI's README has one first row of links: Docs, Install and Usage.**
16
+ [A new rule](docs/standards/docs.md#wc-doc-24--a-clis-readme-links-docs-install-and-usage-in-its-first-row) sets
17
+ the row under the hero line, with labels in the README's language and a community link only where the tool's
18
+ audience uses it. Today each CLI has its own row (Examples, Comparison, Discord or none), so a reader has to look
19
+ for the install page in a different place each time. It is checked in review, so no CLI fails a check. Each CLI
20
+ moves to the row at its next README change.
21
+ - **A parity difference can name the one CLI whose value differs.** Beside `absent` and `only`, an entry in a parity
22
+ group may say `differs: "<cli>"`: that CLI's summary or value name is its own by design, and every other CLI
23
+ compared must still agree. memo uses it for its `mcp` and `mcp serve` summaries, which name memo instead of a
24
+ profile (cli-memo 0.143.0). Before this, every CLI's `cli-dev audit` failed on those two summaries.
25
+
26
+ ## 0.112.0 — 17.11.2026
27
+
28
+ ### Added
29
+
30
+ - **`adaptOpenApi` reads an OpenAPI 3.1 field of several types.** `type: [string, number, "null"]`, as Resend's file
31
+ types its contact properties, becomes a union of one schema per type, nullable when the list holds `null`; each
32
+ member keeps the `enum` values and constraints that fit its type. Such a field stopped generation before. The types,
33
+ the Valibot schemas and `fakeApi` check it as any other union.
34
+ - **`adaptOpenApi` reads an upload sent as bytes.** A body with no JSON, multipart or form type whose schema is a binary
35
+ string (or none), as Petstore 3's `application/octet-stream` image upload, keeps its content type and no schema;
36
+ the manifest's `request.contentType` says how it travels. It stopped generation before. cli-core sends it from
37
+ `--body-file`.
38
+ - **`signInRequirements` and `signInPlace` say which sign-in a call needs and where the token goes.** The
39
+ requirements are the operation's own `security`, else the document's; a call whose requirements are absent or only
40
+ `{}` needs none. cli-core's `api` group signs by them and `fakeApi` checks by them, so a CLI's test and its real
41
+ calls follow one rule.
42
+ - **`fakeApi` checks the document's sign-in and each operation's own scheme.** `security` gives it the manifest's
43
+ default requirements, which an operation's own `security` (`[]` included) replaces; with `auth`, a call the
44
+ document leaves open no longer needs the header. `token` with `securitySchemes` checks each call by its own
45
+ schemes: `Bearer <token>`, an `api_key` header, or a key in the query, and none for an open call. A CLI's test
46
+ then drops the copy of the document's `security` onto each operation. An upload's bytes are taken as sent, under
47
+ the operation's content type.
48
+ - **`adaptOpenApi` reads three more shapes found in public specs.** An `allOf` member that holds only a description,
49
+ as Resend writes one beside a reference, now describes the field instead of stopping generation. A schema with only
50
+ `nullable: true`, as GitHub's file has, is a nullable "anything". An integer marked `unix-time` (Stripe) or
51
+ `unixtime` (OpenAI) is a plain integer; any other unknown integer format still stops generation. An `anyOf` or
52
+ `oneOf` whose members only add `required` fields to the object they sit on, as Resend's "give at least one of",
53
+ becomes a union of that whole object, once with each; before, each member was an empty object no body matched.
54
+ - **`adaptDiscovery` carries a Discovery document's OAuth.** A document with `auth.oauth2` gives the model an `oauth2`
55
+ scheme with its scopes, and each of its methods `security: [{ oauth2: <its scopes> }]`. Before, the manifest named
56
+ no sign-in, and cli-core sent the token only because a manifest without schemes got a bearer header.
57
+
58
+ ### Fixed
59
+
60
+ - **`fakeApi` answers a string schema with JSON text.** A sample answer of type string, as Petstore's `loginUser`, was
61
+ sent unquoted, as a file is, so the CLI could not read it. A string an answer in `answers` gives is still sent as it
62
+ is.
63
+ - **`sampleOf` gives a value the generated schemas accept for a simple `pattern` and a binary string.** A pattern of
64
+ literals, classes and counts, as Resend's `^#[0-9A-Fa-f]{6}$`, gets a matching string (`#000000`); a binary
65
+ string gets `attach://xxxxxx`, which the Valibot schema asks for. Before, a CLI's generated test sent a sample its
66
+ own check refused.
67
+
11
68
  ## 0.111.0 — 17.11.2026
12
69
 
13
70
  ### Added
@@ -66,6 +66,9 @@ export const adaptDiscovery = (documents, options = {}) => {
66
66
  const operations = [];
67
67
  const metadata = { scopes: {}, omissions: [] };
68
68
  const services = {};
69
+ // A document's `auth.oauth2` is Google's OAuth 2.0, the one sign-in its methods take.
70
+ const scopes = {};
71
+ let signsIn = false;
69
72
  const fail = (problem) => {
70
73
  throw new CodegenError([problem]);
71
74
  };
@@ -153,6 +156,11 @@ export const adaptDiscovery = (documents, options = {}) => {
153
156
  if (typeof document.rootUrl !== "string" || typeof document.servicePath !== "string")
154
157
  fail(`invalid Discovery document: ${service} has no rootUrl or servicePath`);
155
158
  services[service] = { rootUrl: String(document.rootUrl), servicePath: String(document.servicePath) };
159
+ const oauth2 = object(document.auth) && object(document.auth.oauth2) ? document.auth.oauth2 : undefined;
160
+ if (oauth2)
161
+ signsIn = true;
162
+ for (const [scope, value] of Object.entries(oauth2 && object(oauth2.scopes) ? oauth2.scopes : {}))
163
+ scopes[scope] = object(value) && typeof value.description === "string" ? value.description : "";
156
164
  for (const [id, value] of Object.entries(document.schemas))
157
165
  schemas.push({ id: `${service}_${id}`, schema: node(value, service, `/schemas/${id}`) });
158
166
  const walk = (resources, path) => {
@@ -198,6 +206,7 @@ export const adaptDiscovery = (documents, options = {}) => {
198
206
  };
199
207
  }),
200
208
  source: { location: `${service}${location}/methods/${name}` },
209
+ ...(oauth2 ? { security: [{ oauth2: metadata.scopes[raw.id] ?? [] }] } : {}),
201
210
  ...(raw.deprecated === true ? { deprecated: true } : {}),
202
211
  };
203
212
  if (object(raw.request))
@@ -234,6 +243,7 @@ export const adaptDiscovery = (documents, options = {}) => {
234
243
  },
235
244
  operations: operations.sort((a, b) => a.id.localeCompare(b.id)),
236
245
  schemas,
246
+ ...(signsIn ? { securitySchemes: { oauth2: { type: "oauth2", flows: { authorizationCode: { scopes } } } } } : {}),
237
247
  },
238
248
  metadata,
239
249
  services,
@@ -5,7 +5,7 @@
5
5
  * A name typed from memory then fails a test instead of reaching a real account.
6
6
  */
7
7
  import type { ManifestOperation } from "./manifest.js";
8
- import type { SchemaNode } from "./model.js";
8
+ import type { SchemaNode, SecurityRequirement, SecurityScheme } from "./model.js";
9
9
  export interface FakeCall {
10
10
  method: string;
11
11
  url: URL;
@@ -32,11 +32,24 @@ export interface FakeApiOptions {
32
32
  definitions: Readonly<Record<string, SchemaNode>>;
33
33
  /** The server the CLI calls: `https://cloud-api.yandex.net`. */
34
34
  baseUrl: string;
35
- /** The header and value every call to `baseUrl` must carry; omit for a service without sign-in. */
35
+ /**
36
+ * The header and value every call to `baseUrl` must carry, unless its `security` (its own, else the document's) is
37
+ * empty; omit for a service without sign-in. `token` instead checks each call by its schemes.
38
+ */
36
39
  auth?: {
37
40
  header: string;
38
41
  value: string;
39
42
  };
43
+ /**
44
+ * The token a call must carry where one of its security schemes puts it (`securitySchemes`): `Bearer <token>`, an
45
+ * `api_key` header, a key in the query. A call whose security, its own or else the document's, is absent or empty
46
+ * needs none, as cli-core's `api` group then sends none.
47
+ */
48
+ token?: string;
49
+ /** The document's default requirements, the manifest's `security`; an operation's own `security` replaces them. */
50
+ security?: readonly SecurityRequirement[];
51
+ /** The manifest's `securitySchemes`, which `token` is checked by. */
52
+ securitySchemes?: Readonly<Record<string, SecurityScheme>>;
40
53
  /** Answers by operation id. One without an answer gets a sample built from its response schema, with status 200. */
41
54
  answers?: Readonly<Record<string, Answering>>;
42
55
  /**
@@ -1,4 +1,5 @@
1
1
  import { identifier } from "./names.js";
2
+ import { signInPlace, signInRequirements } from "./sign-in.js";
2
3
  const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3
4
  const resolved = (node, definitions) => {
4
5
  let at = node;
@@ -129,6 +130,46 @@ export const schemaProblems = (value, node, definitions, where = "body", loose =
129
130
  }
130
131
  }
131
132
  };
133
+ /**
134
+ * A string a simple pattern accepts: anchors, literals, `[...]` classes, `\d`, `\w` and `{n}`, `{n,m}`, `+`, `*`, `?`.
135
+ * `undefined` for anything else, and for a sample the pattern still refuses.
136
+ */
137
+ const patternSample = (pattern) => {
138
+ const atoms = [];
139
+ let at = pattern.startsWith("^") ? 1 : 0;
140
+ const end = pattern.endsWith("$") && !pattern.endsWith("\\$") ? pattern.length - 1 : pattern.length;
141
+ while (at < end) {
142
+ const char = pattern[at];
143
+ let atom;
144
+ if (char === "[") {
145
+ const close = pattern.indexOf("]", at + 1);
146
+ if (close < 0 || pattern[at + 1] === "^")
147
+ return undefined;
148
+ atom = pattern[at + 1] === "\\" ? (pattern[at + 2] === "d" ? "0" : "x") : pattern[at + 1];
149
+ at = close + 1;
150
+ }
151
+ else if (char === "\\") {
152
+ const next = pattern[at + 1] ?? "";
153
+ atom = next === "d" ? "0" : next === "w" ? "x" : /[^a-zA-Z0-9]/.test(next) ? next : "";
154
+ if (!atom)
155
+ return undefined;
156
+ at += 2;
157
+ }
158
+ else if ("()|.".includes(char))
159
+ return undefined;
160
+ else {
161
+ atom = char;
162
+ at += 1;
163
+ }
164
+ const quantifier = /^(\{(\d+)(,\d*)?\}|\+|\*|\?)/.exec(pattern.slice(at, end));
165
+ const times = quantifier ? (quantifier[2] !== undefined ? Number(quantifier[2]) : quantifier[0] === "+" ? 1 : 0) : 1;
166
+ if (quantifier)
167
+ at += quantifier[0].length;
168
+ atoms.push(atom.repeat(times));
169
+ }
170
+ const sample = atoms.join("");
171
+ return regexOf(pattern)?.test(sample) ? sample : undefined;
172
+ };
132
173
  /** A value the schema accepts: the first enum value, the minimum, one array item, every object field. */
133
174
  export const sampleOf = (node, definitions, seen = new Set()) => {
134
175
  switch (node.type) {
@@ -143,8 +184,14 @@ export const sampleOf = (node, definitions, seen = new Set()) => {
143
184
  const parts = objectParts(node, definitions);
144
185
  return parts ? sampleOf({ type: "object", ...parts }, definitions, seen) : null;
145
186
  }
146
- case "string":
147
- return node.enum?.[0] ?? "x".repeat(Math.max(node.minLength ?? 6, 1)).slice(0, node.maxLength ?? 64);
187
+ case "string": {
188
+ if (node.enum?.[0] !== undefined)
189
+ return node.enum[0];
190
+ if (node.format === "binary")
191
+ return "attach://xxxxxx";
192
+ const plain = "x".repeat(Math.max(node.minLength ?? 6, 1)).slice(0, node.maxLength ?? 64);
193
+ return node.pattern === undefined ? plain : (patternSample(node.pattern) ?? plain);
194
+ }
148
195
  case "integer":
149
196
  case "number":
150
197
  return (node.type === "integer" ? node.enum?.[0] : undefined) ?? node.minimum ?? Math.min(1, node.maximum ?? 1);
@@ -199,6 +246,9 @@ const specificity = (template) => [
199
246
  -template.replace(/\{[^}]+\}/g, "").length,
200
247
  ];
201
248
  const JSON_BODY = /[/+]json\s*(;|$)/i;
249
+ const JSON_TYPE = { "content-type": "application/json" };
250
+ const FORM_BODY = /^(multipart\/form-data|application\/x-www-form-urlencoded)\s*(;|$)/i;
251
+ const mediaType = (type) => type?.split(";")[0]?.trim().toLowerCase();
202
252
  const hostAnswer = (hosts, host) => hosts?.[host] ??
203
253
  Object.entries(hosts ?? {}).find(([pattern]) => pattern.startsWith("*.") && host.endsWith(pattern.slice(1)) && host.length > pattern.length - 1)?.[1];
204
254
  const scalar = (raw, node) => {
@@ -221,6 +271,21 @@ export const fakeApi = (options) => {
221
271
  };
222
272
  const definitions = options.definitions;
223
273
  const problemsOf = (value, node, where) => schemaProblems(value, node, definitions, where, options.looseObjects);
274
+ const placesOf = (requirements) => {
275
+ const names = [...new Set(requirements.flatMap((one) => Object.keys(one)))];
276
+ const places = names.flatMap((name) => {
277
+ const scheme = options.securitySchemes?.[name];
278
+ const place = scheme && signInPlace(scheme);
279
+ return place ? [place] : [];
280
+ });
281
+ return { names, places };
282
+ };
283
+ const keyParameters = new Set(Object.values(options.securitySchemes ?? {}).flatMap((scheme) => {
284
+ const place = signInPlace(scheme);
285
+ return place?.in === "query" ? [place.name] : [];
286
+ }));
287
+ const carries = (request, url, place, token) => (place.in === "header" ? request.headers.get(place.name) : url.searchParams.get(place.name)) === place.value(token);
288
+ const leaks = (request, url, token) => [...request.headers.values()].some((value) => value.includes(token)) || url.search.includes(token);
224
289
  const fetch = async (input, init) => {
225
290
  const request = new Request(input, init);
226
291
  const url = new URL(request.url);
@@ -246,6 +311,8 @@ export const fakeApi = (options) => {
246
311
  return refuse(400, `${url.host} was called over ${url.protocol}`);
247
312
  if (options.auth && request.headers.has(options.auth.header))
248
313
  return refuse(400, `the ${options.auth.header} header was sent to ${url.host}, which is not the service`);
314
+ if (options.token !== undefined && leaks(request, url, options.token))
315
+ return refuse(400, `the token was sent to ${url.host}, which is not the service`);
249
316
  const { status = 200, body, headers } = await answer(call);
250
317
  return json(status, body, headers);
251
318
  }
@@ -264,13 +331,21 @@ export const fakeApi = (options) => {
264
331
  call.operation = operation.id;
265
332
  call.path = matchPath(operation.binding.path, path) ?? {};
266
333
  const where = `${operation.id}`;
267
- const open = operation.security?.length === 0;
334
+ const declaredSecurity = operation.security ?? options.security;
335
+ const open = declaredSecurity?.every((one) => Object.keys(one).length === 0) === true;
268
336
  if (options.auth && !open && request.headers.get(options.auth.header) !== options.auth.value)
269
337
  return refuse(401, `${where}: no ${options.auth.header} header with the expected sign-in`);
338
+ const requirements = signInRequirements(operation, options.security);
339
+ if (options.token !== undefined && requirements) {
340
+ const { names, places } = placesOf(requirements);
341
+ const token = options.token;
342
+ if (!places.some((place) => carries(request, url, place, token)))
343
+ return refuse(401, `${where}: no sign-in where its security names it (${names.join(" or ")})`);
344
+ }
270
345
  const problems = [];
271
346
  const declared = (location) => operation.parameters.filter((one) => one.in === location);
272
347
  for (const name of url.searchParams.keys())
273
- if (!declared("query").some((one) => one.name === name))
348
+ if (!declared("query").some((one) => one.name === name) && !keyParameters.has(name))
274
349
  problems.push(`${where}: no query parameter "${name}"`);
275
350
  for (const parameter of [...declared("query"), ...declared("path")]) {
276
351
  const values = parameter.in === "query" ? url.searchParams.getAll(parameter.name) : [call.path[parameter.name]];
@@ -292,6 +367,11 @@ export const fakeApi = (options) => {
292
367
  if (text !== "") {
293
368
  if (!operation.request)
294
369
  problems.push(`${where}: takes no body`);
370
+ else if (contentType && !JSON_BODY.test(contentType) && !FORM_BODY.test(contentType)) {
371
+ const sent = mediaType(request.headers.get("content-type"));
372
+ if (sent !== mediaType(contentType))
373
+ problems.push(`${where}: the body is sent as ${sent ?? "no content type"}, not ${contentType}`);
374
+ }
295
375
  else if (contentType && !JSON_BODY.test(contentType)) {
296
376
  try {
297
377
  const form = await new Response(bytes, { headers: request.headers }).formData();
@@ -326,8 +406,9 @@ export const fakeApi = (options) => {
326
406
  }
327
407
  const response = operation.response?.schema ? definitions[operation.response.schema] : undefined;
328
408
  const answering = options.answers?.[operation.id];
409
+ // A sample of a string answer is JSON text, never the bytes of a download.
329
410
  if (!answering)
330
- return json(200, response ? sampleOf(response, definitions) : undefined);
411
+ return json(200, response ? JSON.stringify(sampleOf(response, definitions)) : undefined, JSON_TYPE);
331
412
  const { status = 200, body, headers } = await answering(call);
332
413
  // A scenario that answers off the schema tests a service that does not exist.
333
414
  if (status >= 200 && status < 300 && response && body !== undefined) {
@@ -4,7 +4,8 @@
4
4
  * files with (`identifier`, `requestSchema`), and format-neutral: it parses no file format and
5
5
  * adds no runtime dependency. `adaptOpenApi` reads an OpenAPI document and `adaptDiscovery` Google Discovery
6
6
  * documents the consumer has parsed; `upgradeToOpenApi3` brings Swagger 1.2 and 2.0 to OpenAPI 3 through two optional
7
- * peer dependencies. `fakeApi` serves the generated manifest as a strict fake for a CLI's tests. An adapter from
7
+ * peer dependencies. `fakeApi` serves the generated manifest as a strict fake for a CLI's tests, and `signInRequirements` with
8
+ * `signInPlace` say which sign-in a call needs and where its token goes. An adapter from
8
9
  * Postman or anything else lives in the consumer.
9
10
  */
10
11
  export { adaptDiscovery, type DiscoveryMetadata, type DiscoveryOptions, type DiscoveryProvenance, type DiscoveryResult, type DiscoveryService, readDiscovery, type SyncDiscoveryOptions, syncDiscovery, } from "./discovery.js";
@@ -18,6 +19,7 @@ export { adaptOpenApi, OpenApiError } from "./openapi.js";
18
19
  export { detectPagination } from "./pagination.js";
19
20
  export { type PatchedSpec, type PatchSpecOptions, patchSpec, type SpecPatch } from "./patch.js";
20
21
  export { type AuthOverride, applyNames, applyOverrides, applyPagination, applyPermissionRule, CodegenError, type CommandNames, type GenerateOptions, generate, type PermissionRule, READING_POST_REASON, validateModel, type WriteOptions, writeArtifacts, } from "./pipeline.js";
22
+ export { type SignInPlace, signInPlace, signInRequirements } from "./sign-in.js";
21
23
  export { API_SKILL_GROUPS, API_SKILL_INDEX, type ApiSkillOptions, apiSkillFiles } from "./skill.js";
22
24
  export { upgradeToOpenApi3 } from "./swagger.js";
23
25
  export { typesGenerator } from "./typescript.js";
@@ -4,7 +4,8 @@
4
4
  * files with (`identifier`, `requestSchema`), and format-neutral: it parses no file format and
5
5
  * adds no runtime dependency. `adaptOpenApi` reads an OpenAPI document and `adaptDiscovery` Google Discovery
6
6
  * documents the consumer has parsed; `upgradeToOpenApi3` brings Swagger 1.2 and 2.0 to OpenAPI 3 through two optional
7
- * peer dependencies. `fakeApi` serves the generated manifest as a strict fake for a CLI's tests. An adapter from
7
+ * peer dependencies. `fakeApi` serves the generated manifest as a strict fake for a CLI's tests, and `signInRequirements` with
8
+ * `signInPlace` say which sign-in a call needs and where its token goes. An adapter from
8
9
  * Postman or anything else lives in the consumer.
9
10
  */
10
11
  export { adaptDiscovery, readDiscovery, syncDiscovery, } from "./discovery.js";
@@ -17,6 +18,7 @@ export { adaptOpenApi, OpenApiError } from "./openapi.js";
17
18
  export { detectPagination } from "./pagination.js";
18
19
  export { patchSpec } from "./patch.js";
19
20
  export { applyNames, applyOverrides, applyPagination, applyPermissionRule, CodegenError, generate, READING_POST_REASON, validateModel, writeArtifacts, } from "./pipeline.js";
21
+ export { signInPlace, signInRequirements } from "./sign-in.js";
20
22
  export { API_SKILL_GROUPS, API_SKILL_INDEX, apiSkillFiles } from "./skill.js";
21
23
  export { upgradeToOpenApi3 } from "./swagger.js";
22
24
  export { typesGenerator } from "./typescript.js";
@@ -32,6 +32,10 @@ const KNOWN = new Set([
32
32
  "$ref",
33
33
  "discriminator",
34
34
  ]);
35
+ /** Seconds since 1970 as Stripe (`unix-time`) and OpenAI (`unixtime`) mark them: a plain integer. */
36
+ const SECONDS = new Set(["unix-time", "unixtime"]);
37
+ /** What a type list's union keeps for itself instead of repeating it on each member. */
38
+ const TYPE_LIST_OWN = new Set(["description", "default", "deprecated", "nullable", "const", "enum", "title"]);
35
39
  const PRIMITIVE_CONSTRAINTS = ["pattern", "minLength", "maxLength", "minimum", "maximum", "enum"];
36
40
  /** What the HTTP client sets itself; as flags they would only invite a second, wrong value. */
37
41
  const TRANSPORT_HEADERS = new Set(["authorization", "user-agent", "content-type", "accept"]);
@@ -104,6 +108,13 @@ const strings = (source, keys) => Object.fromEntries(keys.flatMap((key) => (type
104
108
  const isNullOnly = (source) => isObject(source) &&
105
109
  (source.type === "null" ||
106
110
  (Array.isArray(source.type) && source.type.length > 0 && source.type.every((t) => t === "null")));
111
+ const fits = (value, type) => type === "integer"
112
+ ? Number.isInteger(value)
113
+ : type === "array"
114
+ ? Array.isArray(value)
115
+ : type === "object"
116
+ ? isObject(value)
117
+ : typeof value === type;
107
118
  const pick = (source, keys) => Object.fromEntries(keys.map((key) => [key, source[key]]));
108
119
  const typeOfConst = (value) => typeof value === "string"
109
120
  ? "string"
@@ -130,6 +141,13 @@ const typedFromExample = (schema) => {
130
141
  };
131
142
  return isObject(schema) && !marked(schema);
132
143
  };
144
+ const isRequiredOnly = (member) => isObject(member) && Array.isArray(member.required) && Object.keys(member).every((key) => key === "required");
145
+ const isNote = (member) => isObject(member) && Object.keys(member).every((keyword) => IGNORED.has(keyword) || keyword === "description");
146
+ /** A body schema that says "any bytes": none, `{}`, or a binary string, as 3.0 writes it or 3.1 does. */
147
+ const isBytes = (schema) => schema === undefined ||
148
+ (isObject(schema) &&
149
+ (Object.keys(schema).length === 0 ||
150
+ (schema.type === "string" && (schema.format === "binary" || schema.contentMediaType !== undefined))));
133
151
  class Adapter {
134
152
  problems = [];
135
153
  document;
@@ -173,15 +191,12 @@ class Adapter {
173
191
  return common;
174
192
  }
175
193
  /** OpenAPI 3.1 writes `nullable` as `type: [T, "null"]`. */
176
- #type(source, common, where) {
194
+ #type(source, common) {
177
195
  if (Array.isArray(source.type)) {
178
196
  const types = source.type.filter((type) => type !== "null");
179
197
  if (types.length !== source.type.length)
180
198
  common.nullable = true;
181
- if (types.length === 1)
182
- return types[0];
183
- this.problems.push(`${where}: a schema of several types ${JSON.stringify(source.type)}`);
184
- return null;
199
+ return types[0];
185
200
  }
186
201
  if (source.type !== undefined)
187
202
  return source.type;
@@ -225,9 +240,23 @@ class Adapter {
225
240
  if (keyword) {
226
241
  if (Array.isArray(source.type) && source.type.includes("null"))
227
242
  common.nullable = true;
228
- return this.#union(source[keyword], keyword, common, where);
243
+ const members = source[keyword];
244
+ // Resend's "give at least one of": members that only add required fields to the object they sit on.
245
+ if (isObject(source.properties) && members.every(isRequiredOnly)) {
246
+ const { [keyword]: _, ...object } = source;
247
+ const required = Array.isArray(source.required) ? source.required : [];
248
+ const whole = members.map((member) => ({
249
+ ...object,
250
+ required: [...required, ...member.required],
251
+ }));
252
+ return this.#union(whole, keyword, common, where);
253
+ }
254
+ return this.#union(members, keyword, common, where);
229
255
  }
230
- const type = this.#type(source, common, where);
256
+ const types = Array.isArray(source.type) ? source.type.filter((type) => type !== "null") : [];
257
+ if (types.length > 1)
258
+ return this.#typeList(source, types, common, where);
259
+ const type = this.#type(source, common);
231
260
  const values = source.const !== undefined ? [source.const] : Array.isArray(source.enum) ? source.enum : undefined;
232
261
  switch (type) {
233
262
  case "string": {
@@ -248,7 +277,7 @@ class Adapter {
248
277
  const node = { ...common, type: "integer" };
249
278
  if (source.format === "int32" || source.format === "int64")
250
279
  node.format = source.format;
251
- else if (source.format !== undefined)
280
+ else if (source.format !== undefined && !SECONDS.has(String(source.format)))
252
281
  this.problems.push(`${where}: unsupported integer format "${source.format}"`);
253
282
  if (typeof source.minimum === "number")
254
283
  node.minimum = source.minimum;
@@ -289,7 +318,7 @@ class Adapter {
289
318
  case null:
290
319
  return { type: "unknown" };
291
320
  case undefined:
292
- if (Object.keys(source).every((keyword) => IGNORED.has(keyword) || keyword === "description")) {
321
+ if (Object.keys(source).every((keyword) => IGNORED.has(keyword) || keyword === "description" || keyword === "nullable")) {
293
322
  return { ...common, type: "unknown" };
294
323
  }
295
324
  this.problems.push(`${where}: a schema with no type`);
@@ -299,6 +328,23 @@ class Adapter {
299
328
  return { type: "unknown" };
300
329
  }
301
330
  }
331
+ /**
332
+ * OpenAPI 3.1's `type: [string, number, "null"]`: a union of one schema per type, each keeping the constraints and
333
+ * enum values that fit it; a type no enum value fits is left out.
334
+ */
335
+ #typeList(source, types, common, where) {
336
+ if (source.type.includes("null"))
337
+ common.nullable = true;
338
+ const values = source.const !== undefined ? [source.const] : Array.isArray(source.enum) ? source.enum : undefined;
339
+ const rest = Object.fromEntries(Object.entries(source).filter(([key]) => !TYPE_LIST_OWN.has(key)));
340
+ const of = types.flatMap((type) => {
341
+ const fitting = values?.filter((value) => fits(value, type));
342
+ if (fitting?.length === 0)
343
+ return [];
344
+ return [this.schema({ ...rest, type, ...(fitting ? { enum: fitting } : {}) }, where)];
345
+ });
346
+ return { ...common, type: "union", of };
347
+ }
302
348
  #object(source, common, where) {
303
349
  const properties = {};
304
350
  for (const [name, property] of Object.entries(isObject(source.properties) ? source.properties : {})) {
@@ -380,6 +426,14 @@ class Adapter {
380
426
  }
381
427
  }
382
428
  #allOf(source, members, common, where) {
429
+ // A member with only a description, as Resend writes one beside a reference, describes the field and adds nothing.
430
+ const notes = members.filter(isNote);
431
+ if (notes.length > 0 && notes.length < members.length) {
432
+ const [note] = notes.flatMap((one) => typeof one.description === "string" && one.description.trim() ? [one] : []);
433
+ if (note && !common.description)
434
+ common.description = note.description;
435
+ return this.#allOf(source, members.filter((one) => !isNote(one)), common, where);
436
+ }
383
437
  const distributed = this.#distribute(members, common, where);
384
438
  if (distributed)
385
439
  return distributed;
@@ -448,7 +502,7 @@ class Adapter {
448
502
  }
449
503
  /**
450
504
  * JSON when offered, unless a multipart body carries a file, which JSON cannot; then multipart,
451
- * then a form. A content type outside these three refuses the operation.
505
+ * then a form, then bytes (a type whose schema is a binary string). Anything else refuses the operation.
452
506
  */
453
507
  #requestBody(source, where) {
454
508
  const content = isObject(source.content) ? source.content : {};
@@ -460,8 +514,12 @@ class Adapter {
460
514
  const body = { confidence: "contract", required: source.required === true };
461
515
  if (offered.length === 0)
462
516
  return body;
517
+ // An upload sent as the bytes themselves: `application/octet-stream`, an image type.
518
+ const raw = type ? undefined : offered.find((candidate) => isBytes(schemaOf(candidate)));
519
+ if (raw)
520
+ return { ...body, contentType: raw };
463
521
  if (!type) {
464
- this.problems.push(`${where}: a body must be JSON, multipart or a form, found ${offered.join(", ")}`);
522
+ this.problems.push(`${where}: a body must be JSON, multipart, a form or bytes, found ${offered.join(", ")}`);
465
523
  return body;
466
524
  }
467
525
  // Only a charset may be dropped: `application/merge-patch+json` must travel as itself.
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Which sign-in one call of a generated manifest needs and where its token goes. cli-core's `api` group signs requests
3
+ * by this and `fakeApi` checks them by it, so a CLI's test and its real calls cannot disagree.
4
+ */
5
+ import type { SecurityRequirement, SecurityScheme } from "./model.js";
6
+ /** Where one scheme carries a token, and what the header or query parameter then holds. */
7
+ export interface SignInPlace {
8
+ in: "header" | "query";
9
+ /** A header name in lower case, or a query parameter as the spec spells it. */
10
+ name: string;
11
+ value: (token: string) => string;
12
+ }
13
+ /** `undefined` for a scheme a token cannot be sent by: basic, digest, a key in a cookie, mutual TLS. */
14
+ export declare const signInPlace: (scheme: SecurityScheme) => SignInPlace | undefined;
15
+ /**
16
+ * The requirements one call signs in by: the operation's own `security`, else the document's. `undefined` when it needs
17
+ * no sign-in: neither says anything, as in a spec without security, or every requirement is `{}` (`security: []`
18
+ * included). An optional sign-in (`[{}, { oauth: [] }]`) still signs in.
19
+ */
20
+ export declare const signInRequirements: (operation: {
21
+ security?: readonly SecurityRequirement[];
22
+ }, document: readonly SecurityRequirement[] | undefined) => readonly SecurityRequirement[] | undefined;
@@ -0,0 +1,30 @@
1
+ const BEARER = { in: "header", name: "authorization", value: (token) => `Bearer ${token}` };
2
+ /** `undefined` for a scheme a token cannot be sent by: basic, digest, a key in a cookie, mutual TLS. */
3
+ export const signInPlace = (scheme) => {
4
+ if (scheme.type === "apiKey") {
5
+ if (!scheme.name || (scheme.in !== "header" && scheme.in !== "query"))
6
+ return undefined;
7
+ return {
8
+ in: scheme.in,
9
+ name: scheme.in === "header" ? scheme.name.toLowerCase() : scheme.name,
10
+ value: (token) => token,
11
+ };
12
+ }
13
+ if (scheme.type === "http") {
14
+ if (!scheme.scheme || /^bearer$/i.test(scheme.scheme))
15
+ return BEARER;
16
+ if (/^(basic|digest)$/i.test(scheme.scheme))
17
+ return undefined;
18
+ return { in: "header", name: "authorization", value: (token) => `${scheme.scheme} ${token}` };
19
+ }
20
+ return scheme.type === "oauth2" || scheme.type === "openIdConnect" ? BEARER : undefined;
21
+ };
22
+ /**
23
+ * The requirements one call signs in by: the operation's own `security`, else the document's. `undefined` when it needs
24
+ * no sign-in: neither says anything, as in a spec without security, or every requirement is `{}` (`security: []`
25
+ * included). An optional sign-in (`[{}, { oauth: [] }]`) still signs in.
26
+ */
27
+ export const signInRequirements = (operation, document) => {
28
+ const requirements = operation.security ?? document;
29
+ return requirements?.some((one) => Object.keys(one).length > 0) ? requirements : undefined;
30
+ };
package/dist/dev/audit.js CHANGED
@@ -285,7 +285,7 @@ export const auditClis = (inputs, options, rules = AUDIT_RULES) => {
285
285
  return findings
286
286
  .filter((finding) => finding.rule === entry.rule && finding.target.endsWith(` ${entry.target}`))
287
287
  .map((finding) => ({ ...entry, group: group.name, target: finding.target, expected: finding.message }));
288
- const cli = entry.absent ?? entry.only;
288
+ const cli = entry.absent ?? entry.only ?? entry.differs;
289
289
  if (!cli)
290
290
  return [{ group: group.name, ...entry }];
291
291
  const matching = findings.filter((finding) => {
@@ -297,12 +297,14 @@ export const auditClis = (inputs, options, rules = AUDIT_RULES) => {
297
297
  .map(([, value]) => value);
298
298
  if (mine === undefined || others.length === 0)
299
299
  return false;
300
- return entry.absent
301
- ? mine === "absent" && new Set(others).size === 1
302
- : mine !== "absent" && others.every((value) => value === "absent");
300
+ if (entry.absent)
301
+ return mine === "absent" && new Set(others).size === 1;
302
+ if (entry.only)
303
+ return mine !== "absent" && others.every((value) => value === "absent");
304
+ return mine !== "absent" && new Set(others).size === 1 && !others.includes(mine) && !others.includes("absent");
303
305
  });
304
306
  if (matching.length === 0 && clis.includes(cli))
305
- problems.push(`stale difference in ${group.name}, no such divergence — remove it: ${entry.rule} ${entry.target} (${entry.absent ? "absent" : "only"} in ${cli})`);
307
+ problems.push(`stale difference in ${group.name}, no such divergence — remove it: ${entry.rule} ${entry.target} (${entry.absent ? "absent" : entry.only ? "only" : "differs"} in ${cli})`);
306
308
  return matching.map((finding) => ({
307
309
  ...entry,
308
310
  group: group.name,
@@ -32,6 +32,8 @@ declare const parityGroupSchema: v.StrictObjectSchema<{
32
32
  readonly absent: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a lower-case word, words joined by -">]>, undefined>;
33
33
  /** The one CLI that has the path or flag by design; every other CLI compared must lack it. */
34
34
  readonly only: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a lower-case word, words joined by -">]>, undefined>;
35
+ /** The one CLI whose value (a summary, a value name) differs by design; every other CLI compared must agree. */
36
+ readonly differs: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a lower-case word, words joined by -">]>, undefined>;
35
37
  readonly reason: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, v.MinLengthAction<string, 10, "say why, in a sentence">]>;
36
38
  /** Warns from 14 days before and fails 14 days after, as a lint override does. */
37
39
  readonly review_after: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoDateAction<string, "a date, YYYY-MM-DD">]>, undefined>;
@@ -61,21 +61,27 @@ const parityGroupSchema = v.strictObject({
61
61
  absent: v.optional(word),
62
62
  /** The one CLI that has the path or flag by design; every other CLI compared must lack it. */
63
63
  only: v.optional(word),
64
+ /** The one CLI whose value (a summary, a value name) differs by design; every other CLI compared must agree. */
65
+ differs: v.optional(word),
64
66
  reason: v.pipe(text, v.minLength(10, "say why, in a sentence")),
65
67
  /** Warns from 14 days before and fails 14 days after, as a lint override does. */
66
68
  review_after: v.optional(v.pipe(v.string(), v.isoDate("a date, YYYY-MM-DD"))),
67
69
  })),
68
70
  });
71
+ /** Which of `absent`, `only` and `differs` a difference names: the CLI it measures by name. */
72
+ const kindOf = (entry) => ["absent", "only", "differs"].filter((one) => entry[one] !== undefined);
69
73
  export const defineParityGroups = (input) => parseRegistry("parity groups", v.array(parityGroupSchema), input, (groups) => [
70
74
  ...duplicates(groups.map((group) => group.name)).map((name) => `"${name}" is listed twice`),
71
75
  ...groups.flatMap((group) => [
72
76
  ...duplicates(group.differences.map((entry) => `${entry.rule} ${entry.target}`)).map((both) => `${group.name}: "${both}" is listed twice`),
73
77
  ...group.differences
74
- .filter((entry) => (entry.absent || entry.only) && entry.expected)
75
- .map((entry) => `${group.name}: "${entry.target}" has \`${entry.absent ? "absent" : "only"}\`, which measures the values itself; drop \`expected\``),
78
+ .filter((entry) => kindOf(entry).length === 1 && entry.expected)
79
+ .map((entry) => `${group.name}: "${entry.target}" has \`${kindOf(entry)[0]}\`, which measures the values itself; drop \`expected\``),
76
80
  ...group.differences
77
- .filter((entry) => entry.absent && entry.only)
78
- .map((entry) => `${group.name}: "${entry.target}" has both \`absent\` and \`only\`; keep one`),
81
+ .filter((entry) => kindOf(entry).length > 1)
82
+ .map((entry) => `${group.name}: "${entry.target}" has ${kindOf(entry)
83
+ .map((one) => `\`${one}\``)
84
+ .join(" and ")}; keep one`),
79
85
  ]),
80
86
  ]);
81
87
  const MEMO_HAS_NO_PROFILES = [
@@ -91,6 +97,13 @@ const MEMO_HAS_NO_PROFILES = [
91
97
  reason: "memo has no profiles: it reads other CLIs' stores and selects their accounts with --source and --account " +
92
98
  "(https://github.com/WireCatLabs/cli-base/issues/390)",
93
99
  }));
100
+ /** cli-core's shared `mcp` summaries name the profile; memo, which has none, names itself (cli-memo 0.143.0). */
101
+ const MEMO_MCP_SUMMARIES = ["mcp", "mcp serve"].map((path) => ({
102
+ rule: "same-path-contract",
103
+ target: `${path}: summary`,
104
+ differs: "memo",
105
+ reason: "memo has no profiles, so its mcp commands serve memo's commands rather than a profile's",
106
+ }));
94
107
  const MEMO_DOCTOR_DEEP = {
95
108
  rule: "same-path-contract",
96
109
  target: "doctor --deep",
@@ -124,7 +137,7 @@ export const PARITY_GROUPS = defineParityGroups([
124
137
  name: "all",
125
138
  members: ["tg", "max", "memo", "drive", "zm", "wa"],
126
139
  covers: ["commands", "doctor", "skill", "mcp", "upgrade", "search", "notes", "meetings"],
127
- differences: [...MEMO_HAS_NO_PROFILES, MEMO_DOCTOR_DEEP],
140
+ differences: [...MEMO_HAS_NO_PROFILES, ...MEMO_MCP_SUMMARIES, MEMO_DOCTOR_DEEP],
128
141
  },
129
142
  // mail's `search messages` is cli-core's mail search, not the messengers' command: --complete took their 20-odd
130
143
  // differences as inherited (https://github.com/WireCatLabs/cli-base/issues/390). mail is compared everywhere else
@@ -133,7 +146,7 @@ export const PARITY_GROUPS = defineParityGroups([
133
146
  name: "mail-shared",
134
147
  members: ["tg", "max", "memo", "drive", "zm", "wa", "mail"],
135
148
  covers: ["commands", "doctor", "skill", "mcp", "upgrade", "notes", "meetings"],
136
- differences: [...MEMO_HAS_NO_PROFILES, MEMO_DOCTOR_DEEP],
149
+ differences: [...MEMO_HAS_NO_PROFILES, ...MEMO_MCP_SUMMARIES, MEMO_DOCTOR_DEEP],
137
150
  },
138
151
  // gcal is compared on what it already shares with every CLI; doctor, mcp, search and skill wait until the published
139
152
  // CLIs agree there (https://github.com/WireCatLabs/cli-base/issues/390), then gcal moves back into "all".
@@ -151,7 +164,7 @@ export const PARITY_GROUPS = defineParityGroups([
151
164
  name: "shared-roots",
152
165
  members: ["tg", "max", "memo", "drive", "zm", "wa", "b24", "beeline", "pbx", "notion", "amo"],
153
166
  covers: ["commands", "doctor", "skill", "mcp", "upgrade"],
154
- differences: [...MEMO_HAS_NO_PROFILES, MEMO_DOCTOR_DEEP],
167
+ differences: [...MEMO_HAS_NO_PROFILES, ...MEMO_MCP_SUMMARIES, MEMO_DOCTOR_DEEP],
155
168
  },
156
169
  // The CRM CLIs on cli-core's shared CRM commands. amo-cli (amoCRM and Kommo) is not on npm yet, so `audit --family`
157
170
  // skips it, as beeline. Only b24 has `leads` (amoCRM has no lead apart from a deal), `products` (amo leaves them for
@@ -40,7 +40,7 @@ the four steps that need a person. A new CLI is ready for its first release when
40
40
  | [Data model](data-model.md) | `DATA` | 9 | Core entities, entities and source records, `external_id`, field names, links and duplicates, files, calendar entries |
41
41
  | [Testing](testing.md) | `TEST` | 19 | Sandbox, no network, no real waits, one test time limit, leak tests, coverage, contracts, test matrix, parity, fakes as strict as the service |
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
- | [Documents](docs.md) | `DOC` | 23 | User pages and developer pages, generated pages, current facts, changelog, repository page |
43
+ | [Documents](docs.md) | `DOC` | 24 | 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
45
  | [Releases](releases.md) | `REL` | 16 | `bin/release`, the release lock, versions, the owner's yes, trusted publishing |
46
46
  | [CI](ci.md) | `CI` | 13 | Hooks, the pull request budget, full validation, monthly runs, conflict markers |
@@ -1,6 +1,6 @@
1
1
  # Documents
2
2
 
3
- <!-- cspell:ignore whatsapp -->
3
+ <!-- cspell:ignore whatsapp ydisk -->
4
4
 
5
5
  ## Scope
6
6
 
@@ -75,10 +75,10 @@ Rule ids on this page are `WC-DOC-<n>`. How to read a rule, how ids work and whi
75
75
  - **Why:** most readers open only the README, and it must take them from "what is this" to a first result. A reader
76
76
  decides whether to install from what the tool does for them, so the gains and the "why" come before the steps.
77
77
  - **Enforced by:** review only.
78
- - **Example:** follow tg-cli's README order: the hero line with what the reader gets, three bold gains, what you get
79
- (with an invented conversation), why this tool and a one-line link to the comparison, quick start, use it with your
80
- agent, what it can do, how it works, settings and permissions, security, when something goes wrong,
81
- documentation, development. The install command stays within the first two screens.
78
+ - **Example:** follow tg-cli's README order: the hero line with what the reader gets, the links row (WC-DOC-24), three
79
+ bold gains, what you get (with an invented conversation), why this tool and a one-line link to the comparison, quick
80
+ start, use it with your agent, what it can do, how it works, settings and permissions, security, when something goes
81
+ wrong, documentation, development. The install command stays within the first two screens.
82
82
  - **Exceptions:** a library or a kit follows WC-DOC-23 instead.
83
83
  - **Applies to:** all CLIs. **Since:** cli-base 0.41.0. **Rulings:** NEED-500.
84
84
 
@@ -279,6 +279,36 @@ An agent that opens the skill carries SKILL.md in every later turn of its sessio
279
279
  - **Applies to:** cli-base, cli-core, cli-template and every other WireCat library or kit. **Since:** cli-base
280
280
  0.111.0. **Rulings:** none.
281
281
 
282
+ ### WC-DOC-24 · A CLI's README links Docs, Install and Usage in its first row
283
+
284
+ The first row of links sits right under the hero line. It has three links, in this order, with labels in the README's
285
+ own language:
286
+
287
+ - **Docs:** the tool's page on wirecat.dev once it exists, until then `docs/index.md`.
288
+ - **Install:** the site's install page for the tool once it exists, until then `docs/installation.md`.
289
+ - **Usage:** `docs/usage.md`.
290
+
291
+ A community link (Discord, Telegram or another) may follow as a fourth link, only where the tool's audience uses that
292
+ community. A link to examples or a comparison goes in the body, for example in "Why this tool".
293
+
294
+ - **Why:** a reader who arrives from npm, GitHub or a search looks for the same three things in every tool: what it
295
+ is, how to install it and how to use it. One row in one place lets them find each with one click. A community the
296
+ audience does not use is a dead end, so a tool for a mainly Russian-speaking audience has no Discord link.
297
+ - **Enforced by:** review only, check planned: a docs check that reads the first links row of the README.
298
+ - **Example:** ydisk-cli's README, below. The links are full GitHub addresses, since the npm package ships
299
+ `README.md` without `docs/` and a relative link breaks on npmjs.com. A README in Russian reads
300
+ "Документация · Установка · Использование".
301
+
302
+ ```html
303
+ <p align="center">
304
+ <a href="https://github.com/WireCatLabs/ydisk-cli/blob/main/docs/index.md">Docs</a> ·
305
+ <a href="https://github.com/WireCatLabs/ydisk-cli/blob/main/docs/installation.md">Install</a> ·
306
+ <a href="https://github.com/WireCatLabs/ydisk-cli/blob/main/docs/usage.md">Usage</a>
307
+ </p>
308
+ ```
309
+ - **Exceptions:** a library or a kit keeps its own links row under WC-DOC-23.
310
+ - **Applies to:** all CLIs. **Since:** cli-base 0.113.0. **Rulings:** none.
311
+
282
312
  ## Sources
283
313
 
284
314
  These documents explain the rules on this page in more detail. Where one of them disagrees with this page, this page
@@ -81,7 +81,7 @@ it changed, for the CLI's provenance.
81
81
 
82
82
  From the source the generator reads:
83
83
 
84
- - **Operations**: method and path, parameters, the request body (JSON, multipart or a form), and the first 2xx answer
84
+ - **Operations**: method and path, parameters, the request body (JSON, multipart, a form, or bytes for an upload), and the first 2xx answer
85
85
  with a JSON body (`200`, `201` as HubSpot creates, `202`, `207`, or `2XX`). `application/hal+json`,
86
86
  `application/json; charset=utf-8` and other JSON types count as JSON.
87
87
  - **Effect**: GET and HEAD read, POST, PUT and PATCH write, DELETE is destructive.
@@ -130,14 +130,17 @@ From the source the generator reads:
130
130
 
131
131
  ### A strict fake for tests
132
132
 
133
- `fakeApi({ operations, definitions, baseUrl, auth, answers, hosts })` serves the generated manifest and definitions as
134
- a `fetch` for a CLI's tests. It refuses, with a 4xx and a line in `refusals`, an unknown path or method, an unknown or
135
- mistyped query parameter (a repeated one is a list), a missing required one, a body field the schema lacks (JSON, a
136
- form or multipart), and a call without the `auth` header, unless the operation's `security` is `[]`. An operation
137
- answers a sample built from its response schema, or what `answers` gives for it, checked against that schema: an
138
- answer off the schema throws. A string, bytes or a stream is sent as it is, for a file. `hosts` answers the other
139
- hosts a link points at (`downloader.disk.yandex.ru`, `*.disk.yandex.net`), and refuses a call there over another
140
- scheme or with the `auth` header. A CLI writes only its scenarios. `looseObjects` lets unknown fields through, for a
133
+ `fakeApi({ operations, definitions, baseUrl, security, securitySchemes, token, answers, hosts })` serves the generated
134
+ manifest and definitions as a `fetch` for a CLI's tests. It refuses, with a 4xx and a line in `refusals`, an unknown
135
+ path or method, an unknown or mistyped query parameter (a repeated one is a list), a missing required one, a body field
136
+ the schema lacks (JSON, a form or multipart), an upload under another content type, and a call without its sign-in.
137
+ `token` is checked where the call's schemes put it (`Bearer <token>`, an `api_key` header, a key in the query), by
138
+ `signInRequirements`: the operation's own `security`, else the document's `security`, and none when neither names
139
+ one, as cli-core then sends none. The older `auth: { header, value }` is one header every call needs, unless its
140
+ `security` is empty. An operation answers a sample built from its response schema, as JSON, or what `answers` gives
141
+ for it, checked against that schema: an answer off the schema throws. A string, bytes or a stream an answer gives is
142
+ sent as it is, for a file. `hosts` answers the other hosts a link points at (`downloader.disk.yandex.ru`,
143
+ `*.disk.yandex.net`), and refuses a call there over another scheme or with the token. A CLI writes only its scenarios. `looseObjects` lets unknown fields through, for a
141
144
  source whose subtypes the definitions cannot tell apart.
142
145
 
143
146
  ### The API part of the agent skill
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-base",
3
- "version": "0.111.0",
3
+ "version": "0.113.0",
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",