@wirecat/cli-base 0.132.0 → 1.0.0-rc.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +7 -1
  3. package/dist/batch.d.ts +1 -0
  4. package/dist/batch.js +1 -0
  5. package/dist/codegen/graphql-fake.d.ts +1 -1
  6. package/dist/codegen/graphql-fake.js +1 -1
  7. package/dist/codegen/graphql.d.ts +1 -12
  8. package/dist/codegen/graphql.js +0 -44
  9. package/dist/codegen/index.d.ts +4 -3
  10. package/dist/codegen/index.js +2 -1
  11. package/dist/codegen/model.d.ts +4 -1
  12. package/dist/codegen/pipeline.d.ts +5 -5
  13. package/dist/codegen/runtime.d.ts +9 -2
  14. package/dist/codegen/runtime.js +7 -1
  15. package/dist/codegen/selection.d.ts +13 -0
  16. package/dist/codegen/selection.js +44 -0
  17. package/dist/codegen/wp-json.d.ts +2 -2
  18. package/dist/commands/document.d.ts +3 -0
  19. package/dist/commands/document.js +3 -0
  20. package/dist/commands/page.d.ts +14 -2
  21. package/dist/commands/page.js +3 -0
  22. package/dist/completion/index.d.ts +5 -1
  23. package/dist/completion/index.js +5 -1
  24. package/dist/credentials.d.ts +2 -0
  25. package/dist/credentials.js +2 -0
  26. package/dist/dev/api-report.d.ts +24 -0
  27. package/dist/dev/api-report.js +345 -0
  28. package/dist/dev/main.js +9 -19
  29. package/dist/dev/next-version.d.ts +5 -1
  30. package/dist/dev/next-version.js +30 -2
  31. package/dist/dev/result-shape.d.ts +4 -0
  32. package/dist/dev/result-shape.js +4 -4
  33. package/dist/dev/wcat-lint.d.ts +4 -1
  34. package/dist/dev/wcat-lint.js +9 -2
  35. package/dist/executable.d.ts +2 -0
  36. package/dist/executable.js +2 -0
  37. package/dist/http/fetch.d.ts +1 -0
  38. package/dist/http/fetch.js +1 -0
  39. package/dist/http/hosts.d.ts +11 -2
  40. package/dist/http/hosts.js +11 -2
  41. package/dist/http/index.d.ts +10 -2
  42. package/dist/http/index.js +10 -2
  43. package/dist/index.d.ts +2 -2
  44. package/dist/index.js +2 -2
  45. package/dist/logging.d.ts +3 -0
  46. package/dist/logging.js +3 -0
  47. package/dist/mcp/index.d.ts +17 -3
  48. package/dist/mcp/index.js +12 -2
  49. package/dist/output-buffer.d.ts +3 -0
  50. package/dist/output-buffer.js +1 -0
  51. package/dist/query/dates.d.ts +6 -1
  52. package/dist/query/dates.js +6 -1
  53. package/dist/query/help.d.ts +1 -0
  54. package/dist/query/help.js +1 -0
  55. package/dist/query/registry.d.ts +6 -1
  56. package/dist/query/registry.js +6 -1
  57. package/dist/query/types.d.ts +1 -0
  58. package/dist/query/types.js +1 -0
  59. package/dist/release/fold.d.ts +5 -0
  60. package/dist/release/fold.js +10 -1
  61. package/dist/release/fragments.d.ts +5 -2
  62. package/dist/release/fragments.js +18 -15
  63. package/dist/release/level.js +17 -11
  64. package/dist/skill/index.d.ts +34 -5
  65. package/dist/skill/index.js +21 -3
  66. package/dist/standards/audit.d.ts +15 -1
  67. package/dist/standards/audit.js +12 -1
  68. package/dist/standards/effects.d.ts +2 -0
  69. package/dist/standards/effects.js +1 -0
  70. package/dist/standards/errors.d.ts +2 -0
  71. package/dist/standards/errors.js +2 -0
  72. package/dist/standards/fields.d.ts +3 -0
  73. package/dist/standards/fields.js +2 -0
  74. package/dist/standards/identifiers.d.ts +7 -1
  75. package/dist/standards/identifiers.js +6 -1
  76. package/dist/standards/lint.d.ts +48 -8
  77. package/dist/standards/lint.js +45 -8
  78. package/dist/standards/log.d.ts +15 -3
  79. package/dist/standards/log.js +15 -3
  80. package/dist/standards/monthly.d.ts +2 -0
  81. package/dist/standards/monthly.js +2 -0
  82. package/dist/standards/output.d.ts +8 -1
  83. package/dist/standards/output.js +7 -1
  84. package/dist/standards/registry.d.ts +6 -1
  85. package/dist/standards/registry.js +6 -1
  86. package/dist/standards/steps.d.ts +5 -1
  87. package/dist/standards/steps.js +5 -1
  88. package/dist/standards/vocabulary.d.ts +5 -1
  89. package/dist/standards/vocabulary.js +5 -1
  90. package/dist/testing/index.d.ts +1 -2
  91. package/dist/testing/index.js +1 -2
  92. package/dist/update/index.d.ts +25 -4
  93. package/dist/update/index.js +24 -4
  94. package/dist/wcat/manifest.d.ts +11 -1
  95. package/dist/wcat/manifest.js +10 -1
  96. package/docs/standards/commands.md +5 -4
  97. package/docs/standards/docs.md +5 -2
  98. package/docs/standards/releases.md +37 -9
  99. package/docs/standards/toolchain.md +1 -1
  100. package/package.json +23 -5
package/CHANGELOG.md CHANGED
@@ -8,6 +8,84 @@ 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
+ ## 1.0.0-rc.0 — 23.11.2026
12
+
13
+ ### Added
14
+
15
+ - **Two changelog headings for libraries on their way to 1.0: "Changed — experimental" and "Deprecated".** Both need
16
+ a minor release. "Changed — may break callers" and "Removed" stay for the stable API and, from 1.0.0 on, need a
17
+ major. See [WC-REL-7](docs/standards/releases.md).
18
+ - **`bin/release --major`.** A version that raises the major over npm's latest now stops unless this flag is given.
19
+ - **`wirecat.stable` in `package.json` lists the stable entry points.** Semver covers them from 1.0.0 on. An entry
20
+ point not in the list is experimental as a whole, and so is a name tagged `@experimental` inside a stable one. The
21
+ list: `.`, `/http`, `/commands`, `/completion`, `/update`, `/codegen/runtime`, `/skill`, `/mcp`, `/query`,
22
+ `/standards`, `/standards/tables` (only the vocabulary), `/wcat/start` and `/wcat/manifest`. The
23
+ [README](README.md#install) says what that means for a caller. Inside them, 105 names are tagged `@experimental`:
24
+ names cli-core does not use and at most one other package imports, and the generated docs text (`commandsPage`,
25
+ `withVersion`, `skillFiles`). Among them: the lint and audit tables, the update check's internals (`mayNotify`,
26
+ `readUpdateState`), the Hermes skill helpers, `parseRetryAfter` and `createOutputBuffer`. An editor shows the tag on
27
+ hover.
28
+ - **`/codegen/runtime` also exports what a CLI reads the generated manifest with**: the types `ManifestOperation`,
29
+ `SchemaNode`, `ApiServer`, `SecurityScheme`, `SecurityRequirement`, `OAuthFlow`, `Pagination`, `PageParameter`,
30
+ `GraphqlBinding`, `OperationPermission`, `Effect`, `Selection` and `SignInPlace`, and `identifier`,
31
+ `graphqlDocument`, `parseSelection`, `signInPlace` and `signInRequirements`. They are stable there;
32
+ `/codegen`, which still exports them too, is experimental. Watch for: import them from `/codegen/runtime` in code
33
+ that runs, so a change to the generator cannot reach it.
34
+ - **`@wirecat/cli-base/package.json` can be imported or resolved.** `exports` blocked it, and some tools read it.
35
+ - **`cli-dev api-report`: the stable API as a committed text file.** A package lists its stable entry points in
36
+ `package.json` (`"wirecat": { "stable": [".", "./http"] }`), and the command writes `api/<entry>.api.txt` from the
37
+ built `.d.ts`, one line per declaration line, without the names whose TSDoc says `@experimental`. `--check` fails
38
+ when the committed report differs from the build. The shared `node-ci.yml` runs the check for every package that
39
+ lists `wirecat.stable` and skips the others. See [WC-REL-7](docs/standards/releases.md).
40
+ - **The changelog guard reads the API report.** A pull request that removes or changes a stable line needs an entry
41
+ under "Changed — may break callers" or "Removed", and one that only adds lines needs "Added". From 1.0.0 on, an
42
+ entry under either break heading also needs the `major` label. Watch for: a caller's own `changelog-guard.yml`
43
+ needs `labeled` and `unlabeled` in its `pull_request` types for a new label to re-run the guard.
44
+ - **`release-start.yml` collects the `changes/` fragments and takes the level they need**, as `bin/release` does, and
45
+ stops a version that raises the major unless the release starts with the new `major: true` input.
46
+
47
+ ### Changed — may break callers
48
+
49
+ - **`cli-dev lint` no longer warns about a short `"bin"` name beside a `wcat-<name>` that runs the same file**, the
50
+ pair the template writes (`ydisk` and `wcat-ydisk`). A short name alone, or one that runs another file, still warns.
51
+ Watch for: an override in `lint/overrides.json` for such a pair is now stale, and `cli-dev lint` fails until it is
52
+ removed. asterisk-cli (`pbx`), beeline-cli and gcal-cli carry one; delete that entry when bumping cli-base. See
53
+ [WC-CMD-29](docs/standards/commands.md).
54
+ - **The version-level check reads 1.0.0 rules.** From 1.0.0 on, a stable break needs a major, an experimental change
55
+ a minor. A release candidate (`1.0.0-rc.1`) counts as its plain version and is never read as the release below.
56
+ - **The optional peers `commander` and `vitest` are now `^15.0.0` and `^5.0.0`** instead of open ranges: `./commands`
57
+ and `./skill` use commander internals that a new major may change.
58
+ - **`engines.node` is `^22.16.0 || >=24`**, as in cli-core and every CLI, instead of `>=22`. Node 22.0 to 22.15 and
59
+ Node 23 were never tested. See [WC-TOOL-6](docs/standards/toolchain.md).
60
+
61
+ ### Changed — experimental
62
+
63
+ - **`/testing` no longer exports `brokenKeyring` and `captureStreams`.** Nothing imported them from there; import
64
+ them from the root, which keeps them stable. `memoryKeyring` stays in both.
65
+ - **Two `/codegen` names that clashed with names elsewhere are renamed.** `WriteOptions` (the options of
66
+ `writeArtifacts`) is `CodegenWriteOptions`, since the root's `WriteOptions` is the credential write. `Override`
67
+ is `ModelOverride`, since `/standards/tables` has a lint `Override`. An editor's auto-import picked the wrong one.
68
+
69
+ ### Deprecated
70
+
71
+ - **`Override` from `/codegen`**, now an alias of `ModelOverride`. cli-template's kit and the scripts of max-cli,
72
+ tg-cli and wordpress-cli use it. It goes in the next major.
73
+
74
+ ### Fixed
75
+
76
+ - **`next-version` keeps a taken major a major**: with 2.0.0 on npm, `2.0.0` gives `3.0.0`, not `2.1.0`.
77
+ - **A pre-release is published under npm's `next` tag**, from `bin/release` and from the release workflow. npm refuses
78
+ a pre-release without a tag, and `latest` must stay a release.
79
+ - **A release that collects `changes/` fragments or folds Unreleased no longer leaves a blank line between entries.**
80
+ A blank line inside a fragment, or a `###` heading that appears twice in the dated section, used to split the list
81
+ in two (ydisk 0.3.0's Fixed) or leave two blank lines in a row. Each heading now gets one list, with one blank line
82
+ around the heading. A blank line inside an entry, before its indented second paragraph, stays.
83
+
84
+ ### Removed
85
+
86
+ - **`abortError` and `retryOf` from the root export.** No package imports them; `realSleep` and the error record
87
+ still use them inside.
88
+
11
89
  ## 0.132.0 — 23.11.2026
12
90
 
13
91
  ### Added
package/README.md CHANGED
@@ -35,9 +35,15 @@ it alone.
35
35
  npm install @wirecat/cli-base
36
36
  ```
37
37
 
38
- It is ESM only, for Node 22 and later, and runs on Bun. `import` it (`require()` works from Node 22.12). Add
38
+ It is ESM only, for Node 22.16 and later (not 23), and runs on Bun. `import` it (`require()` works). Add
39
39
  `commander` if you use `/skill`, and `vitest` if you use `/testing/setup`.
40
40
 
41
+ **What semver covers.** The entry points listed under `wirecat.stable` in `package.json` are the stable API: from
42
+ 1.0.0 on, a break there waits for a major and is deprecated first. A name inside one of them that carries the TSDoc
43
+ tag `@experimental` is not covered, and neither is any entry point missing from the list (`/codegen`, `/release`,
44
+ `/testing`, `/testing/setup`, `/wcat`, the config files) or the `cli-dev` commands. Those may change in a minor,
45
+ under the changelog heading "Changed — experimental" ([WC-REL-7](docs/standards/releases.md)).
46
+
41
47
  [API reference](docs/REFERENCE.md) · [Architecture](docs/dev/ARCHITECTURE.md) · [Shared tooling](docs/TOOLING.md) ·
42
48
  [Standards handbook](docs/standards/README.md) · [Changelog](CHANGELOG.md) · [wirecat.dev](https://wirecat.dev)
43
49
 
package/dist/batch.d.ts CHANGED
@@ -56,4 +56,5 @@ export declare const runBatch: (requests: readonly PreparedBatchRequest[], optio
56
56
  failureContext?: FailureContext;
57
57
  fields?: readonly string[];
58
58
  }) => Promise<BatchReport>;
59
+ /** @experimental */
59
60
  export declare const projectBatchAnswers: (report: BatchReport, fields: readonly string[]) => BatchReport;
package/dist/batch.js CHANGED
@@ -164,6 +164,7 @@ export const runBatch = async (requests, options = {}) => {
164
164
  output_limited: outputLimited,
165
165
  };
166
166
  };
167
+ /** @experimental */
167
168
  export const projectBatchAnswers = (report, fields) => ({
168
169
  ...report,
169
170
  items: report.items.map((result) => result.status === "ok" ? { ...result, answer: projectFields(result.answer, fields) } : result),
@@ -4,9 +4,9 @@
4
4
  * field the type lacks, variables that break their schema and a missing sign-in, and answers `data.<field>` within
5
5
  * the selection. A test writes only its scenarios; one that answers outside the schema or the selection throws.
6
6
  */
7
- import { type Selection } from "./graphql.js";
8
7
  import type { ManifestOperation } from "./manifest.js";
9
8
  import type { SchemaNode } from "./model.js";
9
+ import { type Selection } from "./selection.js";
10
10
  type Definitions = Readonly<Record<string, SchemaNode>>;
11
11
  export interface GraphqlFakeCall {
12
12
  /** The matched operation's id; absent when the request matched none. */
@@ -5,8 +5,8 @@
5
5
  * the selection. A test writes only its scenarios; one that answers outside the schema or the selection throws.
6
6
  */
7
7
  import { sampleOf, schemaProblems } from "./fake.js";
8
- import { graphqlDocument, parseSelection } from "./graphql.js";
9
8
  import { identifier } from "./names.js";
9
+ import { graphqlDocument, parseSelection } from "./selection.js";
10
10
  const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
11
11
  /** What a selection walks into, through references, lists and a nullable wrapper: an object, a union or a leaf. */
12
12
  const shapeOf = (node, definitions, depth = 0) => {
@@ -1,4 +1,4 @@
1
- import type { ApiModel, GraphqlBinding, SchemaNode } from "./model.js";
1
+ import type { ApiModel, SchemaNode } from "./model.js";
2
2
  export interface GraphqlOptions {
3
3
  /** The endpoint every operation is sent to: `https://api.linear.app/graphql`. */
4
4
  url: string;
@@ -16,17 +16,6 @@ export interface GraphqlOptions {
16
16
  sourceRevision?: string;
17
17
  }
18
18
  export declare const GRAPHQL_DELETE_REASON = "a mutation whose name ends in Delete or Archive deletes";
19
- /** Builds the one document an operation sends: every variable declared and passed, the selection inside. */
20
- export declare const graphqlDocument: (binding: GraphqlBinding, selection?: string) => string;
21
- /** A selection as a tree: a field's name → its own selection, or `true` for a leaf. */
22
- export interface Selection {
23
- readonly [field: string]: Selection | true;
24
- }
25
- /**
26
- * `id title state { id type }` → its tree. Only names and braces: an argument, an alias, a fragment or a directive
27
- * throws, since nothing here can check one.
28
- */
29
- export declare const parseSelection: (text: string) => Selection;
30
19
  export declare const adaptGraphql: (introspection: unknown, options: GraphqlOptions) => ApiModel;
31
20
  /** The standard introspection query, deep enough for `[[Type!]!]!`. */
32
21
  export declare const INTROSPECTION_QUERY = "query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n types {\n kind name description\n fields(includeDeprecated: true) { name description isDeprecated args { ...InputValue } type { ...TypeRef } }\n inputFields { ...InputValue }\n enumValues(includeDeprecated: true) { name }\n possibleTypes { name }\n }\n }\n}\nfragment InputValue on __InputValue { name description defaultValue type { ...TypeRef } }\nfragment TypeRef on __Type {\n kind name\n ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } }\n}";
@@ -30,50 +30,6 @@ const typeText = (ref) => ref.kind === "NON_NULL" && ref.ofType
30
30
  ? `[${typeText(ref.ofType)}]`
31
31
  : String(ref.name);
32
32
  const named = (ref) => (ref.ofType ? named(ref.ofType) : String(ref.name));
33
- /** Builds the one document an operation sends: every variable declared and passed, the selection inside. */
34
- export const graphqlDocument = (binding, selection = binding.selection) => {
35
- const variables = Object.entries(binding.variables);
36
- const declared = variables.length ? `(${variables.map(([name, type]) => `$${name}: ${type}`).join(", ")})` : "";
37
- const passed = variables.length ? `(${variables.map(([name]) => `${name}: $${name}`).join(", ")})` : "";
38
- const inner = selection.trim() ? ` { ${selection.trim()} }` : "";
39
- return `${binding.operation} ${binding.field[0]?.toUpperCase()}${binding.field.slice(1)}${declared} { ${binding.field}${passed}${inner} }`;
40
- };
41
- /**
42
- * `id title state { id type }` → its tree. Only names and braces: an argument, an alias, a fragment or a directive
43
- * throws, since nothing here can check one.
44
- */
45
- export const parseSelection = (text) => {
46
- const tokens = text.match(/[_A-Za-z][_0-9A-Za-z]*|[{}]|\S/g) ?? [];
47
- let at = 0;
48
- const level = (nested) => {
49
- const fields = {};
50
- while (at < tokens.length) {
51
- const token = tokens[at];
52
- if (token === "}") {
53
- if (!nested)
54
- throw new Error(`selection "${text}": an unmatched }`);
55
- at += 1;
56
- return fields;
57
- }
58
- if (!/^[_A-Za-z]/.test(token))
59
- throw new Error(`selection "${text}": "${token}" — only field names and braces are supported`);
60
- at += 1;
61
- if (tokens[at] === "{") {
62
- at += 1;
63
- const inner = level(true);
64
- if (Object.keys(inner).length === 0)
65
- throw new Error(`selection "${text}": ${token} selects nothing`);
66
- fields[token] = inner;
67
- }
68
- else
69
- fields[token] = true;
70
- }
71
- if (nested)
72
- throw new Error(`selection "${text}": a { is not closed`);
73
- return fields;
74
- };
75
- return level(false);
76
- };
77
33
  const schemaOf = (raw) => {
78
34
  const root = object(raw) && object(raw.data) ? raw.data : raw;
79
35
  if (!object(root) || !object(root.__schema))
@@ -10,18 +10,19 @@
10
10
  */
11
11
  export { adaptDiscovery, type DiscoveryMetadata, type DiscoveryOptions, type DiscoveryProvenance, type DiscoveryResult, type DiscoveryService, readDiscovery, type SyncDiscoveryOptions, syncDiscovery, } from "./discovery.js";
12
12
  export { type FakeAnswer, type FakeApi, type FakeApiOptions, type FakeCall, fakeApi, sampleOf, schemaProblems, } from "./fake.js";
13
- export { adaptGraphql, GRAPHQL_DELETE_REASON, type GraphqlOptions, type GraphqlProvenance, graphqlDocument, INTROSPECTION_QUERY, parseSelection, readGraphql, type Selection, syncGraphql, } from "./graphql.js";
13
+ export { adaptGraphql, GRAPHQL_DELETE_REASON, type GraphqlOptions, type GraphqlProvenance, INTROSPECTION_QUERY, readGraphql, syncGraphql, } from "./graphql.js";
14
14
  export { type GraphqlFake, type GraphqlFakeAnswer, type GraphqlFakeCall, type GraphqlFakeOptions, graphqlFake, selectionProblems, } from "./graphql-fake.js";
15
15
  export { requestSchema } from "./json-schema.js";
16
16
  export { type CoverageOptions, coverageGenerator, definitionsGenerator, examplesGenerator, type ManifestOperation, manifestGenerator, } from "./manifest.js";
17
17
  export { type MergedSource, type MergeOptions, type MergeReport, mergeOpenApi, type SpecSource } from "./merge.js";
18
- export type { ApiBody, ApiModel, ApiOperation, ApiParameter, ApiSchema, ApiServer, Binding, CodeGenerator, Confidence, Discriminator, Effect, GeneratedArtifact, GraphqlBinding, HttpBinding, HttpMethod, OAuthFlow, OperationPermission, Override, PageParameter, Pagination, RpcBinding, SchemaNode, SecurityRequirement, SecurityScheme, SourceInfo, SourceReference, } from "./model.js";
18
+ export type { ApiBody, ApiModel, ApiOperation, ApiParameter, ApiSchema, ApiServer, Binding, CodeGenerator, Confidence, Discriminator, Effect, GeneratedArtifact, GraphqlBinding, HttpBinding, HttpMethod, ModelOverride, OAuthFlow, OperationPermission, Override, PageParameter, Pagination, RpcBinding, SchemaNode, SecurityRequirement, SecurityScheme, SourceInfo, SourceReference, } from "./model.js";
19
19
  export { apiCommandPath, bindingLabel, identifier, kebab } from "./names.js";
20
20
  export { adaptOpenApi, OpenApiError } from "./openapi.js";
21
21
  export { detectPagination } from "./pagination.js";
22
22
  export { type PatchedSpec, type PatchSpecOptions, patchSpec, type SpecPatch } from "./patch.js";
23
- 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";
23
+ export { type AuthOverride, applyNames, applyOverrides, applyPagination, applyPermissionRule, CodegenError, type CodegenWriteOptions, type CommandNames, type GenerateOptions, generate, type PermissionRule, READING_POST_REASON, validateModel, writeArtifacts, } from "./pipeline.js";
24
24
  export { type PostmanOptions, type PostmanResult, postmanToOpenApi } from "./postman.js";
25
+ export { graphqlDocument, parseSelection, type Selection } from "./selection.js";
25
26
  export { type SignInPlace, signInPlace, signInRequirements } from "./sign-in.js";
26
27
  export { API_SKILL_GROUPS, API_SKILL_INDEX, type ApiSkillOptions, apiSkillFiles } from "./skill.js";
27
28
  export { upgradeToOpenApi3 } from "./swagger.js";
@@ -10,7 +10,7 @@
10
10
  */
11
11
  export { adaptDiscovery, readDiscovery, syncDiscovery, } from "./discovery.js";
12
12
  export { fakeApi, sampleOf, schemaProblems, } from "./fake.js";
13
- export { adaptGraphql, GRAPHQL_DELETE_REASON, graphqlDocument, INTROSPECTION_QUERY, parseSelection, readGraphql, syncGraphql, } from "./graphql.js";
13
+ export { adaptGraphql, GRAPHQL_DELETE_REASON, INTROSPECTION_QUERY, readGraphql, syncGraphql, } from "./graphql.js";
14
14
  export { graphqlFake, selectionProblems, } from "./graphql-fake.js";
15
15
  export { requestSchema } from "./json-schema.js";
16
16
  export { coverageGenerator, definitionsGenerator, examplesGenerator, manifestGenerator, } from "./manifest.js";
@@ -21,6 +21,7 @@ export { detectPagination } from "./pagination.js";
21
21
  export { patchSpec } from "./patch.js";
22
22
  export { applyNames, applyOverrides, applyPagination, applyPermissionRule, CodegenError, generate, READING_POST_REASON, validateModel, writeArtifacts, } from "./pipeline.js";
23
23
  export { postmanToOpenApi } from "./postman.js";
24
+ export { graphqlDocument, parseSelection } from "./selection.js";
24
25
  export { signInPlace, signInRequirements } from "./sign-in.js";
25
26
  export { API_SKILL_GROUPS, API_SKILL_INDEX, apiSkillFiles } from "./skill.js";
26
27
  export { upgradeToOpenApi3 } from "./swagger.js";
@@ -263,13 +263,16 @@ export interface ApiModel {
263
263
  /** Set when `generate`'s `auth` replaced the source's sign-in: its reason, for the coverage page. */
264
264
  securityReason?: string;
265
265
  }
266
- export interface Override {
266
+ /** A correction to one operation of the model, keyed by its id in `generate`'s `overrides`. */
267
+ export interface ModelOverride {
267
268
  effect?: Effect;
268
269
  /** How the operation pages, where detection misses or misreads it; `null` says it does not page. */
269
270
  pagination?: Pagination | null;
270
271
  /** Required: an override nobody can explain is one nobody dares remove. */
271
272
  reason: string;
272
273
  }
274
+ /** @deprecated Use `ModelOverride`; the old name clashed with the lint `Override` of `/standards/tables`. */
275
+ export type Override = ModelOverride;
273
276
  export interface GeneratedArtifact {
274
277
  path: string;
275
278
  content: string;
@@ -1,4 +1,4 @@
1
- import type { ApiModel, ApiOperation, CodeGenerator, GeneratedArtifact, Override, Pagination, SecurityRequirement, SecurityScheme } from "./model.js";
1
+ import type { ApiModel, ApiOperation, CodeGenerator, GeneratedArtifact, ModelOverride, Pagination, SecurityRequirement, SecurityScheme } from "./model.js";
2
2
  export declare class CodegenError extends Error {
3
3
  readonly problems: readonly string[];
4
4
  constructor(problems: readonly string[]);
@@ -28,7 +28,7 @@ export declare const applyPagination: (model: ApiModel, overrides: Readonly<Reco
28
28
  pagination?: Pagination | null;
29
29
  reason: string;
30
30
  }>>, detect: boolean) => ApiModel;
31
- export declare const applyOverrides: (model: ApiModel, overrides: Readonly<Record<string, Override>>) => ApiModel;
31
+ export declare const applyOverrides: (model: ApiModel, overrides: Readonly<Record<string, ModelOverride>>) => ApiModel;
32
32
  /**
33
33
  * Which calls the CLI's own permission keys guard, so denying `files.delete` also holds over the raw `api` group:
34
34
  * `<group>.delete` for every destructive operation and for every flag in `deletingFlags` an operation takes (cli-core
@@ -80,7 +80,7 @@ export interface AuthOverride {
80
80
  /** Everything that would otherwise make an operation vanish or turn into a guess. */
81
81
  export declare const validateModel: (model: ApiModel) => void;
82
82
  export interface GenerateOptions {
83
- overrides?: Readonly<Record<string, Override>>;
83
+ overrides?: Readonly<Record<string, ModelOverride>>;
84
84
  /** Treat a POST to a `…/search` or `…/query` path as a read; an override still wins. */
85
85
  readingPosts?: boolean;
86
86
  /** Detect how each read pages; an override's `pagination` wins either way. */
@@ -92,7 +92,7 @@ export interface GenerateOptions {
92
92
  banner: readonly string[];
93
93
  }
94
94
  export declare const generate: (model: ApiModel, generators: readonly CodeGenerator[], options: GenerateOptions) => GeneratedArtifact[];
95
- export interface WriteOptions {
95
+ export interface CodegenWriteOptions {
96
96
  root: string;
97
97
  /** Compare only: report what is out of date and write nothing. */
98
98
  check?: boolean;
@@ -105,4 +105,4 @@ export interface WriteOptions {
105
105
  owns?: readonly string[];
106
106
  }
107
107
  /** Paths whose committed content differs from what was generated — written, or with `check`, only reported. */
108
- export declare const writeArtifacts: (artifacts: readonly GeneratedArtifact[], options: WriteOptions) => string[];
108
+ export declare const writeArtifacts: (artifacts: readonly GeneratedArtifact[], options: CodegenWriteOptions) => string[];
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * What generated Valibot schemas call at run time. Kept apart from the generator so a CLI loads
3
- * these few functions, not the code that writes code.
3
+ * these few functions, not the code that writes code. Also the stable part of the model a CLI reads the generated
4
+ * manifest with (the operation and schema types, `identifier`, the sign-in and GraphQL helpers):
5
+ * `/codegen` itself is experimental.
4
6
  *
5
7
  * Numbers arrive from a lossless JSON parser (`lossless-json` or anything shaped like its
6
8
  * `LosslessNumber`), because a 64-bit id read as a JS number is silently a different id.
@@ -10,6 +12,7 @@ interface LosslessLike {
10
12
  isLosslessNumber: true;
11
13
  value: string;
12
14
  }
15
+ /** @experimental */
13
16
  export declare const isLossless: (input: unknown) => input is LosslessLike;
14
17
  interface Range {
15
18
  minimum?: number;
@@ -21,4 +24,8 @@ export declare const int64: (range?: Range) => v.SchemaWithPipe<readonly [v.Cust
21
24
  export declare const integer: (range?: Range) => v.SchemaWithPipe<readonly [v.CustomSchema<number | bigint | LosslessLike, v.ErrorMessage<v.CustomIssue> | undefined>, v.TransformAction<number | bigint | LosslessLike, number>, v.CheckAction<number, "integer out of range">]>;
22
25
  export declare const number: (range?: Range) => v.SchemaWithPipe<readonly [v.CustomSchema<number | LosslessLike, v.ErrorMessage<v.CustomIssue> | undefined>, v.TransformAction<number | LosslessLike, number>, v.CheckAction<number, "number out of range">]>;
23
26
  export declare const unique: (items: readonly unknown[]) => boolean;
24
- export {};
27
+ export type { ManifestOperation } from "./manifest.js";
28
+ export type { ApiServer, Effect, GraphqlBinding, OAuthFlow, OperationPermission, PageParameter, Pagination, SchemaNode, SecurityRequirement, SecurityScheme, } from "./model.js";
29
+ export { identifier } from "./names.js";
30
+ export { graphqlDocument, parseSelection, type Selection } from "./selection.js";
31
+ export { type SignInPlace, signInPlace, signInRequirements } from "./sign-in.js";
@@ -1,11 +1,14 @@
1
1
  /**
2
2
  * What generated Valibot schemas call at run time. Kept apart from the generator so a CLI loads
3
- * these few functions, not the code that writes code.
3
+ * these few functions, not the code that writes code. Also the stable part of the model a CLI reads the generated
4
+ * manifest with (the operation and schema types, `identifier`, the sign-in and GraphQL helpers):
5
+ * `/codegen` itself is experimental.
4
6
  *
5
7
  * Numbers arrive from a lossless JSON parser (`lossless-json` or anything shaped like its
6
8
  * `LosslessNumber`), because a 64-bit id read as a JS number is silently a different id.
7
9
  */
8
10
  import * as v from "valibot";
11
+ /** @experimental */
9
12
  export const isLossless = (input) => typeof input === "object" &&
10
13
  input !== null &&
11
14
  input.isLosslessNumber === true &&
@@ -35,3 +38,6 @@ export const integer = (range = {}) => v.pipe(v.custom((input) => {
35
38
  }, "expected an integer within ±2^53"), v.transform((input) => Number(digitsOf(input))), v.check((value) => inRange(value, range), "integer out of range"));
36
39
  export const number = (range = {}) => v.pipe(v.custom((input) => (isLossless(input) ? Number.isFinite(Number(input.value)) : Number.isFinite(input)), "expected a number"), v.transform((input) => (isLossless(input) ? Number(input.value) : input)), v.check((value) => inRange(value, range), "number out of range"));
37
40
  export const unique = (items) => new Set(items.map((item) => JSON.stringify(item))).size === items.length;
41
+ export { identifier } from "./names.js";
42
+ export { graphqlDocument, parseSelection } from "./selection.js";
43
+ export { signInPlace, signInRequirements } from "./sign-in.js";
@@ -0,0 +1,13 @@
1
+ /** The two GraphQL helpers a CLI calls at run time, apart from the adapter so they load no codegen code. */
2
+ import type { GraphqlBinding } from "./model.js";
3
+ /** Builds the one document an operation sends: every variable declared and passed, the selection inside. */
4
+ export declare const graphqlDocument: (binding: GraphqlBinding, selection?: string) => string;
5
+ /** A selection as a tree: a field's name → its own selection, or `true` for a leaf. */
6
+ export interface Selection {
7
+ readonly [field: string]: Selection | true;
8
+ }
9
+ /**
10
+ * `id title state { id type }` → its tree. Only names and braces: an argument, an alias, a fragment or a directive
11
+ * throws, since nothing here can check one.
12
+ */
13
+ export declare const parseSelection: (text: string) => Selection;
@@ -0,0 +1,44 @@
1
+ /** Builds the one document an operation sends: every variable declared and passed, the selection inside. */
2
+ export const graphqlDocument = (binding, selection = binding.selection) => {
3
+ const variables = Object.entries(binding.variables);
4
+ const declared = variables.length ? `(${variables.map(([name, type]) => `$${name}: ${type}`).join(", ")})` : "";
5
+ const passed = variables.length ? `(${variables.map(([name]) => `${name}: $${name}`).join(", ")})` : "";
6
+ const inner = selection.trim() ? ` { ${selection.trim()} }` : "";
7
+ return `${binding.operation} ${binding.field[0]?.toUpperCase()}${binding.field.slice(1)}${declared} { ${binding.field}${passed}${inner} }`;
8
+ };
9
+ /**
10
+ * `id title state { id type }` → its tree. Only names and braces: an argument, an alias, a fragment or a directive
11
+ * throws, since nothing here can check one.
12
+ */
13
+ export const parseSelection = (text) => {
14
+ const tokens = text.match(/[_A-Za-z][_0-9A-Za-z]*|[{}]|\S/g) ?? [];
15
+ let at = 0;
16
+ const level = (nested) => {
17
+ const fields = {};
18
+ while (at < tokens.length) {
19
+ const token = tokens[at];
20
+ if (token === "}") {
21
+ if (!nested)
22
+ throw new Error(`selection "${text}": an unmatched }`);
23
+ at += 1;
24
+ return fields;
25
+ }
26
+ if (!/^[_A-Za-z]/.test(token))
27
+ throw new Error(`selection "${text}": "${token}" — only field names and braces are supported`);
28
+ at += 1;
29
+ if (tokens[at] === "{") {
30
+ at += 1;
31
+ const inner = level(true);
32
+ if (Object.keys(inner).length === 0)
33
+ throw new Error(`selection "${text}": ${token} selects nothing`);
34
+ fields[token] = inner;
35
+ }
36
+ else
37
+ fields[token] = true;
38
+ }
39
+ if (nested)
40
+ throw new Error(`selection "${text}": a { is not closed`);
41
+ return fields;
42
+ };
43
+ return level(false);
44
+ };
@@ -1,4 +1,4 @@
1
- import type { Override } from "./model.js";
1
+ import type { ModelOverride } from "./model.js";
2
2
  type Json = Record<string, unknown>;
3
3
  export interface WpJsonOptions {
4
4
  /** The namespaces the CLI offers, as `wp/v2`; every other route is left out and listed in `omissions`. */
@@ -17,7 +17,7 @@ export interface WpJsonResult {
17
17
  * For `generate`'s `overrides`: how each collection read pages. WordPress answers the list itself, counts pages from
18
18
  * 1 and gives their number in `X-WP-TotalPages`; a page past it is an error, not an empty list.
19
19
  */
20
- overrides: Record<string, Override>;
20
+ overrides: Record<string, ModelOverride>;
21
21
  /** What the document leaves out, one line each, for a reviewer. */
22
22
  omissions: string[];
23
23
  }
@@ -4,6 +4,8 @@ import { type CommandInfo, type OptionInfo } from "./registry.js";
4
4
  /**
5
5
  * What `<cli> commands --json` prints, in every CLI on cli-base. `scope` and `inherited_options` are
6
6
  * there only when one command path was asked for. Nothing else at the top: `cli-dev lint` refuses it.
7
+ *
8
+ * @experimental
7
9
  */
8
10
  export declare const commandsDocumentSchema: v.StrictObjectSchema<{
9
11
  readonly cli: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>;
@@ -56,6 +58,7 @@ export interface CommandsDocument {
56
58
  commands: CommandInfo[];
57
59
  exit_codes: Record<string, number>;
58
60
  }
61
+ /** @experimental */
59
62
  export declare const commandsDocumentJsonSchema: () => import("@valibot/to-json-schema").JsonSchema;
60
63
  export declare const parseCommandsDocument: (value: unknown) => {
61
64
  document: CommandsDocument;
@@ -67,6 +67,8 @@ const commandInfoSchema = v.object({
67
67
  /**
68
68
  * What `<cli> commands --json` prints, in every CLI on cli-base. `scope` and `inherited_options` are
69
69
  * there only when one command path was asked for. Nothing else at the top: `cli-dev lint` refuses it.
70
+ *
71
+ * @experimental
70
72
  */
71
73
  export const commandsDocumentSchema = v.strictObject({
72
74
  cli: v.pipe(v.string(), v.nonEmpty()),
@@ -80,6 +82,7 @@ export const commandsDocumentSchema = v.strictObject({
80
82
  commands: v.array(commandInfoSchema),
81
83
  exit_codes: v.record(v.string(), v.pipe(v.number(), v.integer())),
82
84
  });
85
+ /** @experimental */
83
86
  export const commandsDocumentJsonSchema = () => jsonSchemaOf(commandsDocumentSchema, { command: commandInfoSchema });
84
87
  export const parseCommandsDocument = (value) => {
85
88
  const parsed = v.safeParse(commandsDocumentSchema, value);
@@ -1,5 +1,9 @@
1
1
  import type { CommandInfo, OptionInfo } from "./registry.js";
2
- /** The labels of the tables; the same for every CLI writing in one language. */
2
+ /**
3
+ * The labels of the tables; the same for every CLI writing in one language.
4
+ *
5
+ * @experimental
6
+ */
3
7
  export type CommandsPageLabels = {
4
8
  option: string;
5
9
  does: string;
@@ -20,6 +24,7 @@ export type CommandsPageLabels = {
20
24
  /** Under a command that only reads from such a service. */
21
25
  readsOutside?: string;
22
26
  };
27
+ /** @experimental */
23
28
  export declare const COMMANDS_PAGE_LABELS: {
24
29
  readonly en: {
25
30
  readonly option: "Option";
@@ -54,7 +59,11 @@ export declare const COMMANDS_PAGE_LABELS: {
54
59
  readonly readsOutside: "**Читает из внешнего сервиса.**";
55
60
  };
56
61
  };
57
- /** The CLI's own words: everything on the page that is not read out of the program. */
62
+ /**
63
+ * The CLI's own words: everything on the page that is not read out of the program.
64
+ *
65
+ * @experimental
66
+ */
58
67
  export type CommandsPageText = {
59
68
  /** The first line, an HTML comment saying the page is generated and by what. */
60
69
  banner: string;
@@ -72,6 +81,7 @@ export type CommandsPageText = {
72
81
  /** Markdown after the exit codes; may be empty. */
73
82
  outro: string;
74
83
  };
84
+ /** @experimental */
75
85
  export type CommandsPage = {
76
86
  cli: string;
77
87
  commands: readonly CommandInfo[];
@@ -85,5 +95,7 @@ export type CommandsPage = {
85
95
  * The whole `docs/commands.md`: every command at any depth, every option and argument, the exit
86
96
  * codes. Descriptions are quoted as `--help` prints them, untranslated — a translation here would
87
97
  * give the sentence a second home, and the one on screen is the one that gets corrected.
98
+ *
99
+ * @experimental
88
100
  */
89
101
  export declare const commandsPage: ({ cli, commands, options, labels, text, details }: CommandsPage) => string;
@@ -1,4 +1,5 @@
1
1
  import { EXIT_CODES } from "../exit-codes.js";
2
+ /** @experimental */
2
3
  export const COMMANDS_PAGE_LABELS = {
3
4
  en: {
4
5
  option: "Option",
@@ -43,6 +44,8 @@ const sentence = (text) => {
43
44
  * The whole `docs/commands.md`: every command at any depth, every option and argument, the exit
44
45
  * codes. Descriptions are quoted as `--help` prints them, untranslated — a translation here would
45
46
  * give the sentence a second home, and the one on screen is the one that gets corrected.
47
+ *
48
+ * @experimental
46
49
  */
47
50
  export const commandsPage = ({ cli, commands, options, labels, text, details }) => {
48
51
  // What a value may be and what it is when left out: Commander keeps both out of the description.
@@ -29,7 +29,11 @@ export interface CompletionRequest {
29
29
  words: readonly string[];
30
30
  sources?: CompletionSources;
31
31
  }
32
- /** Tells the shell not to fall back to file names when nothing matched. */
32
+ /**
33
+ * Tells the shell not to fall back to file names when nothing matched.
34
+ *
35
+ * @experimental
36
+ */
33
37
  export declare const NO_FILE_COMPLETION = 4;
34
38
  export declare const suggest: ({ commands, globalOptions, words, sources }: CompletionRequest) => Suggestion[];
35
39
  /** The answer in the form the shell script reads. */
@@ -1,4 +1,8 @@
1
- /** Tells the shell not to fall back to file names when nothing matched. */
1
+ /**
2
+ * Tells the shell not to fall back to file names when nothing matched.
3
+ *
4
+ * @experimental
5
+ */
2
6
  export const NO_FILE_COMPLETION = 4;
3
7
  export const suggest = ({ commands, globalOptions = [], words, sources = {} }) => {
4
8
  const typed = words.at(-1) ?? "";
@@ -36,6 +36,8 @@ export declare const keyringService: (service: string, _configDir?: string, _iso
36
36
  /**
37
37
  * The temporary keyring service a moved run writes instead of the owner's entry: `<app>:<absolute config folder>`, the
38
38
  * shape `bin/keyring-dedupe` already finds and removes.
39
+ *
40
+ * @experimental
39
41
  */
40
42
  export declare const movedRunService: (service: string, configDir: string) => string;
41
43
  export interface WriteOptions {
@@ -13,6 +13,8 @@ export const keyringService = (service, _configDir, _isolated) => service;
13
13
  /**
14
14
  * The temporary keyring service a moved run writes instead of the owner's entry: `<app>:<absolute config folder>`, the
15
15
  * shape `bin/keyring-dedupe` already finds and removes.
16
+ *
17
+ * @experimental
16
18
  */
17
19
  export const movedRunService = (service, configDir) => `${service}:${resolve(configDir)}`;
18
20
  // One warning per run, not per instance: a run over several profiles builds one Credentials for each.
@@ -0,0 +1,24 @@
1
+ import type { DevIo } from "./main.js";
2
+ export declare const API_REPORT_USAGE = " api-report [--check] [--skip-build]\n builds the package, then writes api/<entry>.api.txt for each\n entry point package.json lists in \"wirecat.stable\", without\n the names whose TSDoc says @experimental; --check fails when a\n committed report differs. Does nothing without that list";
3
+ export declare const API_DIR = "api";
4
+ export declare const API_SUFFIX = ".api.txt";
5
+ interface Statement {
6
+ text: string;
7
+ doc: string;
8
+ }
9
+ /** Top-level statements with the `/** … *\/` comment right before each. */
10
+ export declare const statementsOf: (source: string) => Statement[];
11
+ export declare const reportFileOf: (entry: string) => string;
12
+ /** The stable entry points `package.json` lists, or undefined when it lists none (the package opted out). */
13
+ export declare const stableEntries: (pkg: Record<string, unknown>) => unknown;
14
+ /**
15
+ * One report per stable entry point, keyed by its path under `api/`: `<name> · <kind> · <line>` for each line of each
16
+ * stable declaration, sorted by name, so a pull request that removes or changes a stable name shows a removed line.
17
+ */
18
+ export declare const apiReports: (cwd: string) => {
19
+ files: Map<string, string>;
20
+ problems: string[];
21
+ };
22
+ /** The stable API report under api/: written, or with `--check` compared with the committed one. */
23
+ export declare const apiReportCommand: (args: string[], io: DevIo) => number;
24
+ export {};