diff --git a/.github/workflows/changelog-guard.yml b/.github/workflows/changelog-guard.yml index 0e90edea..fc55b048 100644 --- a/.github/workflows/changelog-guard.yml +++ b/.github/workflows/changelog-guard.yml @@ -1,4 +1,5 @@ -# Called from each repository's own workflow on pull_request (types: opened, edited, synchronize, reopened): +# Called from each repository's own workflow on pull_request (types: opened, edited, synchronize, reopened, labeled, +# unlabeled; the label ones re-run the `major` label rule): # # jobs: # changelog: @@ -10,7 +11,7 @@ name: Changelog guard on: workflow_call: pull_request: - types: [opened, edited, synchronize, reopened] + types: [opened, edited, synchronize, reopened, labeled, unlabeled] permissions: contents: read @@ -40,4 +41,5 @@ jobs: TITLE: ${{ github.event.pull_request.title }} BASE_SHA: ${{ github.event.pull_request.base.sha }} HEAD_SHA: ${{ github.event.pull_request.head.sha }} + LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }} run: node .changelog-guard/scripts/changelog-guard.ts "$TITLE" "$BASE_SHA" "$HEAD_SHA" diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index cb5c3c4a..1f8cf53c 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -144,6 +144,16 @@ jobs: cat "$RUNNER_TEMP/slow.txt" text=$(awk '{ gsub(/%/, "%25"); printf "%s%s", (NR > 1 ? "%0A" : ""), $0 }' "$RUNNER_TEMP/slow.txt") echo "::warning title=Tests over 3 s (WC-TEST-20)::$text" + # WC-REL-7: a package that lists its stable entry points in package.json ("wirecat": { "stable": [...] }) keeps + # their API report in api/ current; the changelog guard then asks for the heading a change to it needs. + - name: api report + run: | + stable=$(node -p 'Boolean(require("./package.json").wirecat?.stable)') + [ "$stable" = "true" ] || { echo "::notice::package.json lists no wirecat.stable, so no API report check"; exit 0; } + if [ -x node_modules/.bin/cli-dev ]; then dev=node_modules/.bin/cli-dev + elif [ -f dist/dev/bin.js ]; then dev="node dist/dev/bin.js" + else echo "::error::package.json lists wirecat.stable, but there is no cli-dev to check api/"; exit 1; fi + $dev api-report --check --skip-build # One step per script, after test:coverage: test:matrix:check reads that run's argv log, so with shards it runs # in `coverage` instead. - name: cli steps to skip diff --git a/.github/workflows/release-start.yml b/.github/workflows/release-start.yml index b16296dd..a8484c93 100644 --- a/.github/workflows/release-start.yml +++ b/.github/workflows/release-start.yml @@ -38,6 +38,10 @@ on: node-version: type: string default: "24" + major: + description: "Allow a version that raises the major over npm's latest; without it, such a release stops (WC-REL-7)" + type: boolean + default: false secrets: app-private-key: required: true @@ -98,6 +102,7 @@ jobs: UNRELEASED: ${{ inputs.unreleased }} AFTER_RAISE: ${{ inputs.after-raise }} CHECK: ${{ inputs.check }} + MAJOR: ${{ inputs.major }} run: | set -eu package=$(node -p 'require("./package.json").name') @@ -113,26 +118,47 @@ jobs: latest=$(npm view "$package" version --prefer-online 2>/dev/null || true) versions=$(npm view "$package" versions --json --prefer-online 2>/dev/null || true) + renumber() { + node -e 'const fs = require("fs"); const [o, n, taken, unreleased] = process.argv.slice(1) + const swap = (file, from, to, optional) => { + if (optional && !fs.existsSync(file)) return + const text = fs.readFileSync(file, "utf8") + if (!text.includes(from)) throw new Error(`${file} has no ${JSON.stringify(from.trim())} to raise ${o} to ${n}`) + fs.writeFileSync(file, text.replace(from, to)) + } + swap("package.json", `"version": "${o}"`, `"version": "${n}"`) + swap("src/version.ts", `VERSION = "${o}"`, `VERSION = "${n}"`, true) + const today = new Date().toLocaleDateString("en-GB").replaceAll("/", ".") + if (taken) swap("CHANGELOG.md", `\n## ${unreleased}\n`, `\n## ${n} — ${today}\n`) + else swap("CHANGELOG.md", `\n## ${o} — `, `\n## ${n} — `)' "$1" "$2" "$3" "$UNRELEASED" + if [ -n "$AFTER_RAISE" ]; then VERSION=$2 sh -c "$AFTER_RAISE"; fi + } + # The changes/ fragments go into the version's section, which may then need a higher level (an Added is a + # minor, a stable break a major from 1.0.0 on). + fragments() { + [ -n "$(find changes -maxdepth 1 -type f -name '*.md' ! -name README.md 2>/dev/null)" ] || return 0 + $CLI_DEV changelog fragments --collect "$version" + levelled=$($CLI_DEV changelog level --next "$version") + [ "$levelled" != "$version" ] || return 0 + levelled=$($CLI_DEV next-version "$levelled" "$latest" "$versions") + echo "the changelog needs $levelled — releasing it instead of $version" + renumber "$version" "$levelled" "" + why="${why:+$why; }the changelog needs $levelled" + version=$levelled + } next=$($CLI_DEV next-version "$version" "$latest" "$versions") why="" if [ "$next" != "$version" ]; then taken="" if published "$version"; then taken=1; why="$version is already on npm"; else why="$version is not above npm's latest $latest"; fi echo "$why — releasing $next instead" - node -e 'const fs = require("fs"); const [o, n, taken, unreleased] = process.argv.slice(1) - const swap = (file, from, to, optional) => { - if (optional && !fs.existsSync(file)) return - const text = fs.readFileSync(file, "utf8") - if (!text.includes(from)) throw new Error(`${file} has no ${JSON.stringify(from.trim())} to raise ${o} to ${n}`) - fs.writeFileSync(file, text.replace(from, to)) - } - swap("package.json", `"version": "${o}"`, `"version": "${n}"`) - swap("src/version.ts", `VERSION = "${o}"`, `VERSION = "${n}"`, true) - const today = new Date().toLocaleDateString("en-GB").replaceAll("/", ".") - if (taken) swap("CHANGELOG.md", `\n## ${unreleased}\n`, `\n## ${n} — ${today}\n`) - else swap("CHANGELOG.md", `\n## ${o} — `, `\n## ${n} — `)' "$version" "$next" "$taken" "$UNRELEASED" + renumber "$version" "$next" "$taken" version=$next - if [ -n "$AFTER_RAISE" ]; then VERSION=$version sh -c "$AFTER_RAISE"; fi + fi + fragments + if [ -n "$latest" ] && [ "${version%%.*}" != "${latest%%.*}" ] && [ "$MAJOR" != "true" ]; then + echo "::error::$version raises the major version over npm's $latest — start the release with major allowed if that is meant" + exit 1 fi top=$(sed -n '/^## /{p;q;}' CHANGELOG.md) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26181224..57b84502 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,33 @@ Every entry says what changed as a caller sees it, why, and what to watch for a minor release. "Changed — may break callers" and "Removed" stay for the stable API and, from 1.0.0 on, need a major. See [WC-REL-7](docs/standards/releases.md). - **`bin/release --major`.** A version that raises the major over npm's latest now stops unless this flag is given. +- **`wirecat.stable` in `package.json` lists the stable entry points.** Semver covers them from 1.0.0 on. An entry + point not in the list is experimental as a whole, and so is a name tagged `@experimental` inside a stable one. The + list: `.`, `/http`, `/commands`, `/completion`, `/update`, `/codegen/runtime`, `/skill`, `/mcp`, `/query`, + `/standards`, `/standards/tables` (only the vocabulary), `/wcat/start` and `/wcat/manifest`. The + [README](README.md#install) says what that means for a caller. Inside them, 105 names are tagged `@experimental`: + names cli-core does not use and at most one other package imports, and the generated docs text (`commandsPage`, + `withVersion`, `skillFiles`). Among them: the lint and audit tables, the update check's internals (`mayNotify`, + `readUpdateState`), the Hermes skill helpers, `parseRetryAfter` and `createOutputBuffer`. An editor shows the tag on + hover. +- **`/codegen/runtime` also exports what a CLI reads the generated manifest with**: the types `ManifestOperation`, + `SchemaNode`, `ApiServer`, `SecurityScheme`, `SecurityRequirement`, `OAuthFlow`, `Pagination`, `PageParameter`, + `GraphqlBinding`, `OperationPermission`, `Effect`, `Selection` and `SignInPlace`, and `identifier`, + `graphqlDocument`, `parseSelection`, `signInPlace` and `signInRequirements`. They are stable there; + `/codegen`, which still exports them too, is experimental. Watch for: import them from `/codegen/runtime` in code + that runs, so a change to the generator cannot reach it. +- **`@wirecat/cli-base/package.json` can be imported or resolved.** `exports` blocked it, and some tools read it. +- **`cli-dev api-report`: the stable API as a committed text file.** A package lists its stable entry points in + `package.json` (`"wirecat": { "stable": [".", "./http"] }`), and the command writes `api/.api.txt` from the + built `.d.ts`, one line per declaration line, without the names whose TSDoc says `@experimental`. `--check` fails + when the committed report differs from the build. The shared `node-ci.yml` runs the check for every package that + lists `wirecat.stable` and skips the others. See [WC-REL-7](docs/standards/releases.md). +- **The changelog guard reads the API report.** A pull request that removes or changes a stable line needs an entry + under "Changed — may break callers" or "Removed", and one that only adds lines needs "Added". From 1.0.0 on, an + entry under either break heading also needs the `major` label. Watch for: a caller's own `changelog-guard.yml` + needs `labeled` and `unlabeled` in its `pull_request` types for a new label to re-run the guard. +- **`release-start.yml` collects the `changes/` fragments and takes the level they need**, as `bin/release` does, and + stops a version that raises the major unless the release starts with the new `major: true` input. ### Changed — may break callers @@ -28,6 +55,21 @@ Every entry says what changed as a caller sees it, why, and what to watch for a minor. A release candidate (`1.0.0-rc.1`) counts as its plain version and is never read as the release below. - **The optional peers `commander` and `vitest` are now `^15.0.0` and `^5.0.0`** instead of open ranges: `./commands` and `./skill` use commander internals that a new major may change. +- **`engines.node` is `^22.16.0 || >=24`**, as in cli-core and every CLI, instead of `>=22`. Node 22.0 to 22.15 and + Node 23 were never tested. See [WC-TOOL-6](docs/standards/toolchain.md). + +### Changed — experimental + +- **`/testing` no longer exports `brokenKeyring` and `captureStreams`.** Nothing imported them from there; import + them from the root, which keeps them stable. `memoryKeyring` stays in both. +- **Two `/codegen` names that clashed with names elsewhere are renamed.** `WriteOptions` (the options of + `writeArtifacts`) is `CodegenWriteOptions`, since the root's `WriteOptions` is the credential write. `Override` + is `ModelOverride`, since `/standards/tables` has a lint `Override`. An editor's auto-import picked the wrong one. + +### Deprecated + +- **`Override` from `/codegen`**, now an alias of `ModelOverride`. cli-template's kit and the scripts of max-cli, + tg-cli and wordpress-cli use it. It goes in the next major. ### Fixed @@ -39,6 +81,11 @@ Every entry says what changed as a caller sees it, why, and what to watch for 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 around the heading. A blank line inside an entry, before its indented second paragraph, stays. +### Removed + +- **`abortError` and `retryOf` from the root export.** No package imports them; `realSleep` and the error record + still use them inside. + ## 0.132.0 — 23.11.2026 ### Added diff --git a/README.md b/README.md index c6a12990..ea04a9cf 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,15 @@ it alone. npm install @wirecat/cli-base ``` -It is ESM only, for Node 22 and later, and runs on Bun. `import` it (`require()` works from Node 22.12). Add +It is ESM only, for Node 22.16 and later (not 23), and runs on Bun. `import` it (`require()` works). Add `commander` if you use `/skill`, and `vitest` if you use `/testing/setup`. +**What semver covers.** The entry points listed under `wirecat.stable` in `package.json` are the stable API: from +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 +tag `@experimental` is not covered, and neither is any entry point missing from the list (`/codegen`, `/release`, +`/testing`, `/testing/setup`, `/wcat`, the config files) or the `cli-dev` commands. Those may change in a minor, +under the changelog heading "Changed — experimental" ([WC-REL-7](docs/standards/releases.md)). + [API reference](docs/REFERENCE.md) · [Architecture](docs/dev/ARCHITECTURE.md) · [Shared tooling](docs/TOOLING.md) · [Standards handbook](docs/standards/README.md) · [Changelog](CHANGELOG.md) · [wirecat.dev](https://wirecat.dev) diff --git a/api/codegen-runtime.api.txt b/api/codegen-runtime.api.txt new file mode 100644 index 00000000..f765e917 --- /dev/null +++ b/api/codegen-runtime.api.txt @@ -0,0 +1,202 @@ +# @wirecat/cli-base "./codegen/runtime": the stable API, written by cli-dev api-report. Do not edit. +ApiServer · interface · export interface ApiServer { +ApiServer · interface · url: string; +ApiServer · interface · description?: string; +ApiServer · interface · variables?: Readonly>; +ApiServer · interface · } +Effect · type · export type Effect = "read" | "write" | "destructive"; +GraphqlBinding · interface · export interface GraphqlBinding { +GraphqlBinding · interface · kind: "graphql"; +GraphqlBinding · interface · operation: "query" | "mutation"; +GraphqlBinding · interface · field: string; +GraphqlBinding · interface · variables: Readonly>; +GraphqlBinding · interface · selection: string; +GraphqlBinding · interface · } +ManifestOperation · interface · export interface ManifestOperation { +ManifestOperation · interface · id: string; +ManifestOperation · interface · command: string; +ManifestOperation · interface · group?: string; +ManifestOperation · interface · binding: Binding; +ManifestOperation · interface · effect: Effect; +ManifestOperation · interface · summary?: string; +ManifestOperation · interface · description?: string; +ManifestOperation · interface · tags: readonly string[]; +ManifestOperation · interface · deprecated?: boolean; +ManifestOperation · interface · parameters: readonly { +ManifestOperation · interface · name: string; +ManifestOperation · interface · in: "path" | "query" | "header" | "body"; +ManifestOperation · interface · sensitive?: boolean; +ManifestOperation · interface · required: boolean; +ManifestOperation · interface · description?: string; +ManifestOperation · interface · schema: SchemaNode; +ManifestOperation · interface · }[]; +ManifestOperation · interface · request?: { +ManifestOperation · interface · required: boolean; +ManifestOperation · interface · confidence: Confidence; +ManifestOperation · interface · schema?: string; +ManifestOperation · interface · contentType?: string; +ManifestOperation · interface · }; +ManifestOperation · interface · response?: { +ManifestOperation · interface · confidence: Confidence; +ManifestOperation · interface · schema?: string; +ManifestOperation · interface · sensitive?: boolean; +ManifestOperation · interface · }; +ManifestOperation · interface · security?: readonly SecurityRequirement[]; +ManifestOperation · interface · permissions?: readonly OperationPermission[]; +ManifestOperation · interface · pagination?: Pagination; +ManifestOperation · interface · } +OAuthFlow · interface · export interface OAuthFlow { +OAuthFlow · interface · authorizationUrl?: string; +OAuthFlow · interface · tokenUrl?: string; +OAuthFlow · interface · refreshUrl?: string; +OAuthFlow · interface · scopes: Readonly>; +OAuthFlow · interface · } +OperationPermission · interface · export interface OperationPermission { +OperationPermission · interface · key: string; +OperationPermission · interface · body?: readonly string[]; +OperationPermission · interface · query?: readonly string[]; +OperationPermission · interface · values?: Readonly>; +OperationPermission · interface · unless?: Readonly>; +OperationPermission · interface · } +PageParameter · interface · export interface PageParameter { +PageParameter · interface · in: "query" | "body"; +PageParameter · interface · name: string; +PageParameter · interface · } +Pagination · type · export type Pagination = { +Pagination · type · style: "cursor"; +Pagination · type · cursor: PageParameter; +Pagination · type · next: string; +Pagination · type · items?: string; +Pagination · type · hasMore?: string; +Pagination · type · limit?: PageParameter; +Pagination · type · } | { +Pagination · type · style: "offset"; +Pagination · type · offset: PageParameter; +Pagination · type · limit?: PageParameter; +Pagination · type · items: string; +Pagination · type · total?: string; +Pagination · type · } | { +Pagination · type · style: "page"; +Pagination · type · page: PageParameter; +Pagination · type · limit?: PageParameter; +Pagination · type · items: string; +Pagination · type · total?: string; +Pagination · type · start?: number; +Pagination · type · pagesHeader?: string; +Pagination · type · } +Pagination · type · | { +Pagination · type · style: "link"; +Pagination · type · next: string; +Pagination · type · items?: string; +Pagination · type · }; +SchemaNode · type · export type SchemaNode = SchemaCommon & ({ +SchemaNode · type · type: "ref"; +SchemaNode · type · ref: string; +SchemaNode · type · } | { +SchemaNode · type · type: "string"; +SchemaNode · type · format?: "binary" | "file-reference"; +SchemaNode · type · enum?: readonly string[]; +SchemaNode · type · minLength?: number; +SchemaNode · type · maxLength?: number; +SchemaNode · type · pattern?: string; +SchemaNode · type · } | { +SchemaNode · type · type: "integer"; +SchemaNode · type · format?: "int32" | "int64"; +SchemaNode · type · minimum?: number; +SchemaNode · type · maximum?: number; +SchemaNode · type · enum?: readonly number[]; +SchemaNode · type · } | { +SchemaNode · type · type: "number"; +SchemaNode · type · minimum?: number; +SchemaNode · type · maximum?: number; +SchemaNode · type · } | { +SchemaNode · type · type: "boolean"; +SchemaNode · type · enum?: readonly boolean[]; +SchemaNode · type · } | { +SchemaNode · type · type: "array"; +SchemaNode · type · items: SchemaNode; +SchemaNode · type · minItems?: number; +SchemaNode · type · maxItems?: number; +SchemaNode · type · uniqueItems?: boolean; +SchemaNode · type · } | { +SchemaNode · type · type: "object"; +SchemaNode · type · properties: Readonly>; +SchemaNode · type · required: readonly string[]; +SchemaNode · type · additionalProperties?: SchemaNode; +SchemaNode · type · } | { +SchemaNode · type · type: "union"; +SchemaNode · type · of: readonly SchemaNode[]; +SchemaNode · type · } +SchemaNode · type · | { +SchemaNode · type · type: "allOf"; +SchemaNode · type · of: readonly SchemaNode[]; +SchemaNode · type · } +SchemaNode · type · | { +SchemaNode · type · type: "unknown"; +SchemaNode · type · }); +SchemaNode · type · interface SchemaCommon { +SchemaNode · type · sensitive?: boolean; +SchemaNode · type · description?: string; +SchemaNode · type · nullable?: boolean; +SchemaNode · type · deprecated?: boolean; +SchemaNode · type · default?: unknown; +SchemaNode · type · } +SecurityRequirement · type · export type SecurityRequirement = Readonly>; +SecurityScheme · interface · export interface SecurityScheme { +SecurityScheme · interface · type: "apiKey" | "http" | "oauth2" | "openIdConnect" | "mutualTLS"; +SecurityScheme · interface · description?: string; +SecurityScheme · interface · name?: string; +SecurityScheme · interface · in?: "query" | "header" | "cookie"; +SecurityScheme · interface · scheme?: string; +SecurityScheme · interface · bearerFormat?: string; +SecurityScheme · interface · flows?: Readonly>>; +SecurityScheme · interface · openIdConnectUrl?: string; +SecurityScheme · interface · } +Selection · interface · export interface Selection { +Selection · interface · readonly [field: string]: Selection | true; +Selection · interface · } +SignInPlace · interface · export interface SignInPlace { +SignInPlace · interface · in: "header" | "query"; +SignInPlace · interface · name: string; +SignInPlace · interface · value: (token: string) => string; +SignInPlace · interface · basic?: true; +SignInPlace · interface · } +graphqlDocument · const · export declare const graphqlDocument: (binding: GraphqlBinding, selection?: string) => string; +identifier · const · export declare const identifier: (id: string) => string; +int64 · const · export declare const int64: (range?: Range) => v.SchemaWithPipe | undefined>, v.TransformAction, v.CheckAction]>; +int64 · const · interface Range { +int64 · const · minimum?: number; +int64 · const · maximum?: number; +int64 · const · } +int64 · const · interface LosslessLike { +int64 · const · isLosslessNumber: true; +int64 · const · value: string; +int64 · const · } +integer · const · export declare const integer: (range?: Range) => v.SchemaWithPipe | undefined>, v.TransformAction, v.CheckAction]>; +integer · const · interface Range { +integer · const · minimum?: number; +integer · const · maximum?: number; +integer · const · } +integer · const · interface LosslessLike { +integer · const · isLosslessNumber: true; +integer · const · value: string; +integer · const · } +number · const · export declare const number: (range?: Range) => v.SchemaWithPipe | undefined>, v.TransformAction, v.CheckAction]>; +number · const · interface Range { +number · const · minimum?: number; +number · const · maximum?: number; +number · const · } +number · const · interface LosslessLike { +number · const · isLosslessNumber: true; +number · const · value: string; +number · const · } +parseSelection · const · export declare const parseSelection: (text: string) => Selection; +signInPlace · const · export declare const signInPlace: (scheme: SecurityScheme) => SignInPlace | undefined; +signInRequirements · const · export declare const signInRequirements: (operation: { +signInRequirements · const · security?: readonly SecurityRequirement[]; +signInRequirements · const · }, document: readonly SecurityRequirement[] | undefined) => readonly SecurityRequirement[] | undefined; +unique · const · export declare const unique: (items: readonly unknown[]) => boolean; diff --git a/api/commands.api.txt b/api/commands.api.txt new file mode 100644 index 00000000..45f5ea56 --- /dev/null +++ b/api/commands.api.txt @@ -0,0 +1,121 @@ +# @wirecat/cli-base "./commands": the stable API, written by cli-dev api-report. Do not edit. +ArgumentInfo · interface · export interface ArgumentInfo { +ArgumentInfo · interface · name: string; +ArgumentInfo · interface · required: boolean; +ArgumentInfo · interface · variadic: boolean; +ArgumentInfo · interface · description: string; +ArgumentInfo · interface · choices?: readonly string[]; +ArgumentInfo · interface · default?: unknown; +ArgumentInfo · interface · } +CommandInfo · interface · export interface CommandInfo { +CommandInfo · interface · path: readonly string[]; +CommandInfo · interface · name: string; +CommandInfo · interface · summary?: string; +CommandInfo · interface · description: string; +CommandInfo · interface · usage: string; +CommandInfo · interface · origin: Origin; +CommandInfo · interface · api_operation?: string; +CommandInfo · interface · effects?: Effects; +CommandInfo · interface · state?: CommandState; +CommandInfo · interface · partial?: boolean; +CommandInfo · interface · lifetime?: CommandLifetime; +CommandInfo · interface · reaches?: CommandReach; +CommandInfo · interface · mcp?: false; +CommandInfo · interface · offline?: false; +CommandInfo · interface · cooperative?: boolean; +CommandInfo · interface · examples?: readonly string[]; +CommandInfo · interface · output?: CommandOutput; +CommandInfo · interface · query?: QueryInfo; +CommandInfo · interface · runnable?: true; +CommandInfo · interface · arguments: readonly ArgumentInfo[]; +CommandInfo · interface · options: readonly OptionInfo[]; +CommandInfo · interface · commands: readonly CommandInfo[]; +CommandInfo · interface · } +CommandLifetime · type · export type CommandLifetime = "persistent" | "interactive"; +CommandMeta · interface · export interface CommandMeta { +CommandMeta · interface · origin?: Origin; +CommandMeta · interface · api_operation?: string; +CommandMeta · interface · effects?: Effects; +CommandMeta · interface · state?: CommandState; +CommandMeta · interface · partial?: boolean; +CommandMeta · interface · lifetime?: CommandLifetime; +CommandMeta · interface · reaches?: CommandReach; +CommandMeta · interface · mcp?: boolean; +CommandMeta · interface · offline?: boolean; +CommandMeta · interface · cooperative?: boolean; +CommandMeta · interface · examples?: readonly string[]; +CommandMeta · interface · output?: CommandOutput; +CommandMeta · interface · query?: QueryRegistry; +CommandMeta · interface · } +CommandOutput · interface · export interface CommandOutput { +CommandOutput · interface · entity: string; +CommandOutput · interface · view?: string; +CommandOutput · interface · } +CommandReach · type · export type CommandReach = "other_service"; +CommandState · type · export type CommandState = "beta" | "deprecated"; +CommandsDocument · interface · export interface CommandsDocument { +CommandsDocument · interface · cli: string; +CommandsDocument · interface · version: string; +CommandsDocument · interface · contract: number; +CommandsDocument · interface · description: string; +CommandsDocument · interface · global_options: OptionInfo[]; +CommandsDocument · interface · scope?: string[]; +CommandsDocument · interface · inherited_options?: { +CommandsDocument · interface · path: string[]; +CommandsDocument · interface · options: OptionInfo[]; +CommandsDocument · interface · }[]; +CommandsDocument · interface · commands: CommandInfo[]; +CommandsDocument · interface · exit_codes: Record; +CommandsDocument · interface · } +CommandsDocumentAbout · interface · export interface CommandsDocumentAbout { +CommandsDocumentAbout · interface · cli: string; +CommandsDocumentAbout · interface · version: string; +CommandsDocumentAbout · interface · contract: number; +CommandsDocumentAbout · interface · } +OptionInfo · interface · export interface OptionInfo { +OptionInfo · interface · flags: string; +OptionInfo · interface · description: string; +OptionInfo · interface · takes_value: boolean; +OptionInfo · interface · mandatory: boolean; +OptionInfo · interface · choices?: readonly string[]; +OptionInfo · interface · default?: unknown; +OptionInfo · interface · env?: string; +OptionInfo · interface · conflicts?: readonly string[]; +OptionInfo · interface · implies?: Readonly>; +OptionInfo · interface · mcp?: false; +OptionInfo · interface · } +OptionMeta · interface · export interface OptionMeta { +OptionMeta · interface · mcp?: boolean; +OptionMeta · interface · } +Origin · type · export type Origin = "handwritten" | "generated" | "cli-core"; +SharedContractOverride · interface · export interface SharedContractOverride { +SharedContractOverride · interface · command: readonly string[]; +SharedContractOverride · interface · field: string; +SharedContractOverride · interface · before: unknown; +SharedContractOverride · interface · after: unknown; +SharedContractOverride · interface · reason: string; +SharedContractOverride · interface · } +annotate · const · export declare const annotate: (command: T, meta: CommandMeta) => T; +annotateOption · const · export declare const annotateOption: (option: T, meta: OptionMeta) => T; +assertSharedContracts · const · export declare const assertSharedContracts: (root: Command) => void; +commandsDocument · const · export declare const commandsDocument: (root: Command, about: CommandsDocumentAbout) => CommandsDocument; +customizeSharedCommand · const · export declare const customizeSharedCommand: (reference: Command, reason: string, build: () => Command, expectedOverrides: readonly SharedContractOverride[]) => Command; +describeOptions · const · export declare const describeOptions: (command: Command) => OptionInfo[]; +describeProgram · const · export declare const describeProgram: (root: Command) => CommandInfo[]; +flatten · const · export declare const flatten: (commands: readonly CommandInfo[]) => CommandInfo[]; +hasSharedContract · const · export declare const hasSharedContract: (command: Command) => boolean; +metaOf · const · export declare const metaOf: (command: Command) => CommandMeta; +optionMetaOf · const · export declare const optionMetaOf: (option: Option) => OptionMeta; +overrideSharedContract · const · export declare const overrideSharedContract: (command: T, reason: string, change: (command: T) => void) => T; +parseCommandsDocument · const · export declare const parseCommandsDocument: (value: unknown) => { +parseCommandsDocument · const · document: CommandsDocument; +parseCommandsDocument · const · problems?: undefined; +parseCommandsDocument · const · } | { +parseCommandsDocument · const · document?: undefined; +parseCommandsDocument · const · problems: string[]; +parseCommandsDocument · const · }; +refuseJoinedPath · const · export declare const refuseJoinedPath: (root: Command, args: readonly string[], prefix?: readonly string[]) => void; +sharedCommand · const · export declare const sharedCommand: (factory: (...args: Args) => Result) => (...args: Args) => Result; +sharedContractOverrides · const · export declare const sharedContractOverrides: (root: Command) => SharedContractOverride[]; +sharedContracts · const · export declare const sharedContracts: (root: Command) => Record; +stepTargets · const · export declare const stepTargets: (root: Command) => ((command: string) => StepTarget | undefined); diff --git a/api/completion.api.txt b/api/completion.api.txt new file mode 100644 index 00000000..27810b11 --- /dev/null +++ b/api/completion.api.txt @@ -0,0 +1,19 @@ +# @wirecat/cli-base "./completion": the stable API, written by cli-dev api-report. Do not edit. +CompletionRequest · interface · export interface CompletionRequest { +CompletionRequest · interface · commands: readonly CommandInfo[]; +CompletionRequest · interface · globalOptions?: readonly OptionInfo[]; +CompletionRequest · interface · words: readonly string[]; +CompletionRequest · interface · sources?: CompletionSources; +CompletionRequest · interface · } +CompletionSources · interface · export interface CompletionSources { +CompletionSources · interface · arguments?: Readonly>; +CompletionSources · interface · options?: Readonly>; +CompletionSources · interface · firstWord?: Values; +CompletionSources · interface · } +Suggestion · interface · export interface Suggestion { +Suggestion · interface · value: string; +Suggestion · interface · description: string; +Suggestion · interface · } +Values · type · export type Values = () => readonly (string | Suggestion)[]; +formatSuggestions · const · export declare const formatSuggestions: (suggestions: readonly Suggestion[]) => string; +suggest · const · export declare const suggest: ({ commands, globalOptions, words, sources }: CompletionRequest) => Suggestion[]; diff --git a/api/http.api.txt b/api/http.api.txt new file mode 100644 index 00000000..024472ae --- /dev/null +++ b/api/http.api.txt @@ -0,0 +1,32 @@ +# @wirecat/cli-base "./http": the stable API, written by cli-dev api-report. Do not edit. +FetchLike · type · export type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise; +HostFetchOptions · interface · export interface HostFetchOptions { +HostFetchOptions · interface · hosts: readonly string[]; +HostFetchOptions · interface · fetch?: FetchLike; +HostFetchOptions · interface · timeoutMs?: number; +HostFetchOptions · interface · redirects?: number; +HostFetchOptions · interface · credentialScope?: string; +HostFetchOptions · interface · } +JsonResponseOptions · interface · export interface JsonResponseOptions { +JsonResponseOptions · interface · maxBytes: number; +JsonResponseOptions · interface · signal?: AbortSignal; +JsonResponseOptions · interface · } +PacerLike · interface · export interface PacerLike { +PacerLike · interface · reserve(): Promise; +PacerLike · interface · holdFor(ms: number): Promise; +PacerLike · interface · } +RetryingOptions · interface · export interface RetryingOptions { +RetryingOptions · interface · retry?: RetryConfig; +RetryingOptions · interface · reads?: (method: string, url: URL) => boolean; +RetryingOptions · interface · pacer?: PacerLike; +RetryingOptions · interface · budget?: number; +RetryingOptions · interface · sleep?: SleepLike; +RetryingOptions · interface · now?: WallClock; +RetryingOptions · interface · random?: () => number; +RetryingOptions · interface · } +hostFetch · const · export declare const hostFetch: (options: HostFetchOptions) => FetchLike; +providerWaitMs · const · export declare const providerWaitMs: (headers: Headers, now: WallClock) => number | undefined; +readJsonResponse · const · export declare const readJsonResponse: (response: Response, options: JsonResponseOptions) => Promise; +retryableStatus · const · export declare const retryableStatus: (status: number) => boolean; +retrying · const · export declare const retrying: (send: FetchLike, options?: RetryingOptions) => FetchLike; +statusToCode · const · export declare const statusToCode: (status: number) => ErrorCode; diff --git a/api/index.api.txt b/api/index.api.txt new file mode 100644 index 00000000..1cde63dd --- /dev/null +++ b/api/index.api.txt @@ -0,0 +1,309 @@ +# @wirecat/cli-base ".": the stable API, written by cli-dev api-report. Do not edit. +BASE_CONSTANTS · const · export declare const BASE_CONSTANTS: import("url").URL; +BATCH_LIMITS · const · export declare const BATCH_LIMITS: Readonly<{ +BATCH_LIMITS · const · requests: 32; +BATCH_LIMITS · const · input_bytes: 262144; +BATCH_LIMITS · const · read_bytes: 67108864; +BATCH_LIMITS · const · output_bytes: 4194304; +BATCH_LIMITS · const · }>; +BatchContext · interface · export interface BatchContext { +BatchContext · interface · signal?: AbortSignal; +BatchContext · interface · reserveReadBytes: (bytes: number) => void; +BatchContext · interface · } +BatchHandler · interface · export interface BatchHandler { +BatchHandler · interface · command: readonly string[]; +BatchHandler · interface · prepare: (args: readonly string[]) => BatchOperation; +BatchHandler · interface · } +BatchOperation · interface · export interface BatchOperation { +BatchOperation · interface · run: (context: BatchContext) => Promise<{ +BatchOperation · interface · answer: unknown; +BatchOperation · interface · complete: boolean; +BatchOperation · interface · }>; +BatchOperation · interface · } +BatchReport · interface · export interface BatchReport { +BatchReport · interface · items: BatchResult[]; +BatchReport · interface · complete: boolean; +BatchReport · interface · read_bytes_reserved: number; +BatchReport · interface · read_bytes_limit: number; +BatchReport · interface · output_limited: boolean; +BatchReport · interface · } +BatchResult · type · export type BatchResult = { +BatchResult · type · id: string; +BatchResult · type · command: string[]; +BatchResult · type · } & ({ +BatchResult · type · status: "ok"; +BatchResult · type · answer: unknown; +BatchResult · type · complete: boolean; +BatchResult · type · } | { +BatchResult · type · status: "error" | "not_run"; +BatchResult · type · error: ReturnType["error"]; +BatchResult · type · complete: false; +BatchResult · type · }); +CREDENTIAL_STORAGE · const · export declare const CREDENTIAL_STORAGE: readonly ["auto", "keyring", "file"]; +CatchCrashesOptions · interface · export interface CatchCrashesOptions extends FailureContext { +CatchCrashesOptions · interface · cli: string; +CatchCrashesOptions · interface · interactive: boolean; +CatchCrashesOptions · interface · write?: (text: string) => void; +CatchCrashesOptions · interface · exit?: (code: number) => void; +CatchCrashesOptions · interface · target?: Pick; +CatchCrashesOptions · interface · } +CliError · class · export declare class CliError extends Error { +CliError · class · readonly code: ErrorCode; +CliError · class · readonly details: CliErrorDetails; +CliError · class · constructor(code: ErrorCode, message: string, details?: CliErrorDetails); +CliError · class · } +CliErrorDetails · interface · export interface CliErrorDetails { +CliErrorDetails · interface · readonly status?: number; +CliErrorDetails · interface · readonly retryable?: boolean; +CliErrorDetails · interface · readonly attempts?: number; +CliErrorDetails · interface · readonly request_id?: string; +CliErrorDetails · interface · readonly operation_id?: string; +CliErrorDetails · interface · readonly run_id?: string; +CliErrorDetails · interface · readonly retry_after_ms?: number; +CliErrorDetails · interface · readonly sent?: boolean; +CliErrorDetails · interface · readonly operation?: string; +CliErrorDetails · interface · readonly reason?: string; +CliErrorDetails · interface · readonly param?: string; +CliErrorDetails · interface · readonly [key: string]: unknown; +CliErrorDetails · interface · } +CredentialSource · type · export type CredentialSource = "environment" | "keyring" | "file"; +CredentialStorage · type · export type CredentialStorage = (typeof CREDENTIAL_STORAGE)[number]; +Credentials · class · export declare class Credentials { +Credentials · class · constructor(options: CredentialsOptions); +Credentials · class · read(account: string): StoredCredential | undefined; +Credentials · class · write(account: string, secret: string, options?: WriteOptions): CredentialSource; +Credentials · class · remove(account: string): CredentialSource[]; +Credentials · class · } +CredentialsOptions · interface · export interface CredentialsOptions { +CredentialsOptions · interface · configDir: string; +CredentialsOptions · interface · service: string; +CredentialsOptions · interface · isolated?: boolean; +CredentialsOptions · interface · envVar?: string; +CredentialsOptions · interface · storage?: CredentialStorage; +CredentialsOptions · interface · keyring?: KeyringStore; +CredentialsOptions · interface · env?: NodeJS.ProcessEnv; +CredentialsOptions · interface · fileName?: string; +CredentialsOptions · interface · warn?: (message: string) => void; +CredentialsOptions · interface · } +DEFAULT_RETRY · const · export declare const DEFAULT_RETRY: RetryConfig; +Deadline · interface · export interface Deadline { +Deadline · interface · readonly signal: AbortSignal; +Deadline · interface · race(body: (signal: AbortSignal) => Promise): Promise; +Deadline · interface · dispose(): void; +Deadline · interface · } +DeadlineOptions · interface · export interface DeadlineOptions { +DeadlineOptions · interface · timeoutMs?: number; +DeadlineOptions · interface · signal?: AbortSignal; +DeadlineOptions · interface · sleep?: SleepLike; +DeadlineOptions · interface · } +EXIT_CODES · const · export declare const EXIT_CODES: Record; +ErrorCode · type · export type ErrorCode = (typeof errorCodes)[number]; +ErrorRecord · type · export type ErrorRecord = Omit & { +ErrorRecord · type · run_id?: string; +ErrorRecord · type · }; +ErrorRecordOptions · interface · export interface ErrorRecordOptions { +ErrorRecordOptions · interface · command: string; +ErrorRecordOptions · interface · service: string; +ErrorRecordOptions · interface · version: string; +ErrorRecordOptions · interface · time?: Date; +ErrorRecordOptions · interface · } +FailureContext · interface · export interface FailureContext { +FailureContext · interface · reasons?: readonly ErrorReason[]; +FailureContext · interface · details?: readonly string[]; +FailureContext · interface · steps?: readonly StepDefinition[]; +FailureContext · interface · runId?: string; +FailureContext · interface · effects?: Effects; +FailureContext · interface · targets?: StepInput["targets"]; +FailureContext · interface · } +GENERIC_FAILURE · const · export declare const GENERIC_FAILURE = 1; +KeyringStore · interface · export interface KeyringStore { +KeyringStore · interface · get(service: string, account: string): string | null; +KeyringStore · interface · set(service: string, account: string, secret: string): void; +KeyringStore · interface · delete(service: string, account: string): boolean; +KeyringStore · interface · } +Logger · interface · export interface Logger { +Logger · interface · debug(event: object, message?: string): void; +Logger · interface · info(event: object, message?: string): void; +Logger · interface · warn(event: object, message?: string): void; +Logger · interface · error(event: object, message?: string): void; +Logger · interface · } +MonotonicClock · type · export type MonotonicClock = () => number; +Paths · interface · export interface Paths { +Paths · interface · config: string; +Paths · interface · state: string; +Paths · interface · cache: string; +Paths · interface · } +PathsOptions · interface · export interface PathsOptions { +PathsOptions · interface · appName: string; +PathsOptions · interface · prefix?: string; +PathsOptions · interface · env?: NodeJS.ProcessEnv; +PathsOptions · interface · platform?: NodeJS.Platform; +PathsOptions · interface · } +PreparedBatchRequest · interface · export interface PreparedBatchRequest { +PreparedBatchRequest · interface · id: string; +PreparedBatchRequest · interface · command: string[]; +PreparedBatchRequest · interface · operation: BatchOperation; +PreparedBatchRequest · interface · } +PrettyOptions · interface · export interface PrettyOptions { +PrettyOptions · interface · color: boolean; +PrettyOptions · interface · } +RENDER_FORMATS · const · export declare const RENDER_FORMATS: readonly ["pretty", "json", "jsonl"]; +RecordInput · interface · export interface RecordInput { +RecordInput · interface · severity: LogSeverity; +RecordInput · interface · event: object; +RecordInput · interface · time: string; +RecordInput · interface · runId: string; +RecordInput · interface · traceId?: string; +RecordInput · interface · command: string; +RecordInput · interface · resource: LogRecord["resource"]; +RecordInput · interface · allow?: readonly string[]; +RecordInput · interface · redact?: readonly string[]; +RecordInput · interface · } +RecordLogOptions · interface · export interface RecordLogOptions { +RecordLogOptions · interface · to?: string | ((line: string) => void); +RecordLogOptions · interface · runId: string; +RecordLogOptions · interface · command: string; +RecordLogOptions · interface · resource: LogRecord["resource"]; +RecordLogOptions · interface · traceId?: string; +RecordLogOptions · interface · redact?: string[]; +RecordLogOptions · interface · allow?: readonly string[]; +RecordLogOptions · interface · onError?: (error: Error) => void; +RecordLogOptions · interface · now?: () => Date; +RecordLogOptions · interface · } +RenderErrorOptions · interface · export interface RenderErrorOptions { +RenderErrorOptions · interface · cli: string; +RenderErrorOptions · interface · interactive: boolean; +RenderErrorOptions · interface · record?: ErrorRecord; +RenderErrorOptions · interface · } +RenderFormat · type · export type RenderFormat = (typeof RENDER_FORMATS)[number]; +Renderer · interface · export interface Renderer { +Renderer · interface · result(value: unknown): void; +Renderer · interface · stream(items: Iterable): void; +Renderer · interface · note(message: string): void; +Renderer · interface · success(message: string): void; +Renderer · interface · warn(message: string): void; +Renderer · interface · failure(message: string): void; +Renderer · interface · } +RendererOptions · interface · export interface RendererOptions { +RendererOptions · interface · format: RenderFormat; +RendererOptions · interface · color: boolean; +RendererOptions · interface · streams?: Streams; +RendererOptions · interface · quiet?: boolean; +RendererOptions · interface · } +RetryConfig · interface · export interface RetryConfig { +RetryConfig · interface · retries: number; +RetryConfig · interface · baseDelayMs: number; +RetryConfig · interface · maxDelayMs: number; +RetryConfig · interface · maxRetryAfterMs: number; +RetryConfig · interface · } +SleepLike · type · export type SleepLike = (ms: number, signal?: AbortSignal, reason?: SleepReason) => Promise; +SleepReason · type · export type SleepReason = "timeout" | "retry"; +StoredCredential · interface · export interface StoredCredential { +StoredCredential · interface · secret: string; +StoredCredential · interface · source: CredentialSource; +StoredCredential · interface · } +Streams · interface · export interface Streams { +Streams · interface · data: (text: string) => void; +Streams · interface · diagnostic: (text: string) => void; +Streams · interface · drain?: (signal?: AbortSignal) => Promise; +Streams · interface · progress?: (text: string) => void; +Streams · interface · } +WallClock · type · export type WallClock = () => Date; +WriteOptions · interface · export interface WriteOptions { +WriteOptions · interface · signIn?: boolean; +WriteOptions · interface · } +backoffMs · const · export declare const backoffMs: (attempt: number, config: RetryConfig, random: () => number) => number; +baseConstantsSchema · const · export declare const baseConstantsSchema: v.ObjectSchema<{}, undefined>; +brokenKeyring · const · export declare const brokenKeyring: (message?: string) => KeyringStore; +captureStreams · const · export declare const captureStreams: () => Streams & { +captureStreams · const · stdout: string[]; +captureStreams · const · stderr: string[]; +captureStreams · const · }; +catchCrashes · const · export declare const catchCrashes: (options: CatchCrashesOptions) => (() => void); +configFilePath · const · export declare const configFilePath: (configDir: string, fileName?: string) => string; +createDeadline · const · export declare const createDeadline: ({ timeoutMs, signal, sleep }?: DeadlineOptions) => Deadline; +createRecordLog · const · export declare const createRecordLog: ({ to, runId, command, resource, traceId, redact, allow, onError, now, }: RecordLogOptions) => Logger; +createRenderer · const · export declare const createRenderer: ({ format, color, streams, quiet, }: RendererOptions) => Renderer; +errorCodes · const · export declare const errorCodes: readonly ["validation_error", "configuration_error", "authentication_error", "permission_error", "not_found", "confirmation_required", "rate_limited", "timeout", "network_error", "provider_error", "provider_unavailable", "invalid_response", "outcome_unknown", "conflict", "cancelled"]; +errorObjectOf · const · export declare const errorObjectOf: (failure: unknown, context?: FailureContext) => ErrorObject; +errorRecordOf · const · export declare const errorRecordOf: (failure: unknown, object: ErrorObject, options: ErrorRecordOptions) => ErrorRecord; +exitCodeFor · const · export declare const exitCodeFor: (code: ErrorCode) => number; +exitCodeOfAnswer · const · export declare const exitCodeOfAnswer: (meta: Pick, partial?: boolean) => number; +exitCodeOfError · const · export declare const exitCodeOfError: ({ error }: ErrorObject) => number; +fieldsOf · const · export declare const fieldsOf: (value: string) => string[]; +indent · const · export declare const indent: (text: string, spaces: number) => string; +isCliError · const · export declare const isCliError: (value: unknown) => value is CliError; +isMovedRun · const · export declare const isMovedRun: (options: PathsOptions & { +isMovedRun · const · home?: string | undefined; +isMovedRun · const · }) => boolean; +keyringService · const · export declare const keyringService: (service: string, _configDir?: string, _isolated?: boolean) => string; +loadConfigFile · const · export declare const loadConfigFile: (path: string, schema: TSchema, fallback: () => v.InferOutput) => v.InferOutput; +loadConstants · const · export declare const loadConstants: (layers: readonly URL[], schema: TSchema) => v.InferOutput; +logRecordOf · const · export declare const logRecordOf: ({ severity, event, time, runId, traceId, command, resource, allow, redact, }: RecordInput) => LogRecord; +mcpErrorResult · const · export declare const mcpErrorResult: (object: ErrorObject) => { +mcpErrorResult · const · content: { +mcpErrorResult · const · type: "text"; +mcpErrorResult · const · text: string; +mcpErrorResult · const · }[]; +mcpErrorResult · const · structuredContent: { +mcpErrorResult · const · error: { +mcpErrorResult · const · code: "authentication_error" | "cancelled" | "configuration_error" | "confirmation_required" | "conflict" | "internal_error" | "invalid_response" | "network_error" | "not_found" | "outcome_unknown" | "permission_error" | "provider_error" | "provider_unavailable" | "rate_limited" | "timeout" | "validation_error"; +mcpErrorResult · const · reason: string; +mcpErrorResult · const · message: string; +mcpErrorResult · const · param?: string | undefined; +mcpErrorResult · const · details?: { +mcpErrorResult · const · [x: string]: unknown; +mcpErrorResult · const · } | undefined; +mcpErrorResult · const · next?: ({ +mcpErrorResult · const · kind: "command"; +mcpErrorResult · const · step: string; +mcpErrorResult · const · command: string; +mcpErrorResult · const · args: { +mcpErrorResult · const · [x: string]: unknown; +mcpErrorResult · const · }; +mcpErrorResult · const · line?: string | undefined; +mcpErrorResult · const · why: string; +mcpErrorResult · const · safe_to_auto_execute: boolean; +mcpErrorResult · const · } | { +mcpErrorResult · const · kind: "user_action"; +mcpErrorResult · const · step: string; +mcpErrorResult · const · why: string; +mcpErrorResult · const · safe_to_auto_execute: false; +mcpErrorResult · const · })[] | undefined; +mcpErrorResult · const · retry: { +mcpErrorResult · const · safe: boolean; +mcpErrorResult · const · after_ms?: number | undefined; +mcpErrorResult · const · }; +mcpErrorResult · const · run_id?: string | undefined; +mcpErrorResult · const · }; +mcpErrorResult · const · }; +mcpErrorResult · const · isError: true; +mcpErrorResult · const · }; +memoryKeyring · const · export declare const memoryKeyring: (initial?: Record) => KeyringStore & { +memoryKeyring · const · entries: Map; +memoryKeyring · const · }; +monotonic · const · export declare const monotonic: MonotonicClock; +pathsAreOverridden · const · export declare const pathsAreOverridden: ({ appName, prefix, env }: PathsOptions) => boolean; +prepareBatch · const · export declare const prepareBatch: (input: string, handlers: readonly BatchHandler[]) => PreparedBatchRequest[]; +processStreams · const · export declare const processStreams: Streams; +projectFields · const · export declare const projectFields: (value: unknown, fields: readonly string[]) => unknown; +readBatchInput · const · export declare const readBatchInput: (source: AsyncIterable, options?: { +readBatchInput · const · signal?: AbortSignal; +readBatchInput · const · }) => Promise; +realSleep · const · export declare const realSleep: SleepLike; +renderError · const · export declare const renderError: (object: ErrorObject, options: RenderErrorOptions) => string; +renderPretty · const · export declare const renderPretty: (value: unknown, options: PrettyOptions) => string; +resolvePaths · const · export declare const resolvePaths: (options: PathsOptions) => Paths; +runBatch · const · export declare const runBatch: (requests: readonly PreparedBatchRequest[], options?: { +runBatch · const · signal?: AbortSignal; +runBatch · const · maxReadBytes?: number; +runBatch · const · maxOutputBytes?: number; +runBatch · const · failureContext?: FailureContext; +runBatch · const · fields?: readonly string[]; +runBatch · const · }) => Promise; +saveConfigFile · const · export declare const saveConfigFile: (path: string, config: unknown) => void; +singleLine · const · export declare const singleLine: (text: string) => string; +systemKeyring · const · export declare const systemKeyring: KeyringStore; +visibleControls · const · export declare const visibleControls: (text: string) => string; +wallClock · const · export declare const wallClock: WallClock; +writeSecurely · const · export declare const writeSecurely: (path: string, contents: string | Uint8Array, mode: number) => void; diff --git a/api/mcp.api.txt b/api/mcp.api.txt new file mode 100644 index 00000000..88cd1c6e --- /dev/null +++ b/api/mcp.api.txt @@ -0,0 +1,30 @@ +# @wirecat/cli-base "./mcp": the stable API, written by cli-dev api-report. Do not edit. +CommandResult · interface · export interface CommandResult { +CommandResult · interface · status: number | null; +CommandResult · interface · error?: Error; +CommandResult · interface · stdout: string; +CommandResult · interface · stderr: string; +CommandResult · interface · } +McpClient · type · export type McpClient = "codex" | "claude-code"; +ProbeResult · interface · export interface ProbeResult { +ProbeResult · interface · tools: string[]; +ProbeResult · interface · potentialWrites: string[]; +ProbeResult · interface · } +RunCommand · type · export type RunCommand = (file: string, args: string[]) => CommandResult; +StdioEntry · interface · export interface StdioEntry { +StdioEntry · interface · type: "stdio"; +StdioEntry · interface · command: string; +StdioEntry · interface · args: string[]; +StdioEntry · interface · env?: Record; +StdioEntry · interface · } +installStdioEntry · const · export declare const installStdioEntry: (client: McpClient, name: string, entry: StdioEntry, { run }?: { +installStdioEntry · const · run?: RunCommand; +installStdioEntry · const · }) => { +installStdioEntry · const · client: McpClient; +installStdioEntry · const · name: string; +installStdioEntry · const · command: string[]; +installStdioEntry · const · }; +probeStdio · const · export declare const probeStdio: (entry: StdioEntry, { timeoutMs, start, }?: { +probeStdio · const · timeoutMs?: number; +probeStdio · const · start?: (file: string, args: string[], env: NodeJS.ProcessEnv) => ChildProcessWithoutNullStreams; +probeStdio · const · }) => Promise; diff --git a/api/query.api.txt b/api/query.api.txt new file mode 100644 index 00000000..cc23dcb8 --- /dev/null +++ b/api/query.api.txt @@ -0,0 +1,125 @@ +# @wirecat/cli-base "./query": the stable API, written by cli-dev api-report. Do not edit. +DateRange · interface · export interface DateRange { +DateRange · interface · lower?: number; +DateRange · interface · upper?: number; +DateRange · interface · lower_inclusive: boolean; +DateRange · interface · upper_inclusive: boolean; +DateRange · interface · } +EvaluateOptions · interface · export interface EvaluateOptions { +EvaluateOptions · interface · zone?: string; +EvaluateOptions · interface · now?: number; +EvaluateOptions · interface · relation?: (node: Predicate, item: Readonly>) => boolean; +EvaluateOptions · interface · } +FIELD_TYPES · const · export declare const FIELD_TYPES: readonly ["kw", "txt", "enum", "num", "time", "bool", "ref"]; +FieldAnnotations · interface · export interface FieldAnnotations { +FieldAnnotations · interface · exclude?: readonly string[]; +FieldAnnotations · interface · text?: readonly string[]; +FieldAnnotations · interface · relations?: Readonly & Partial>>>; +FieldAnnotations · interface · states?: Readonly>; +FieldAnnotations · interface · examples?: Readonly>; +FieldAnnotations · interface · native?: readonly string[]; +FieldAnnotations · interface · negatable?: readonly string[]; +FieldAnnotations · interface · validate?: Readonly void>>; +FieldAnnotations · interface · } +FieldInfo · type · export type FieldInfo = Omit; +FieldSpec · interface · export interface FieldSpec { +FieldSpec · interface · name: string; +FieldSpec · interface · type: FieldType; +FieldSpec · interface · operators: readonly Operator[]; +FieldSpec · interface · values?: readonly string[]; +FieldSpec · interface · example: string; +FieldSpec · interface · relation?: string; +FieldSpec · interface · native?: boolean; +FieldSpec · interface · placement?: "and"; +FieldSpec · interface · negatable?: boolean; +FieldSpec · interface · validate?: (node: Predicate) => void; +FieldSpec · interface · } +FieldType · type · export type FieldType = (typeof FIELD_TYPES)[number]; +OPERATORS_BY_TYPE · const · export declare const OPERATORS_BY_TYPE: Readonly>; +Occur · type · export type Occur = "must" | "should" | "must_not"; +Operator · type · export type Operator = "term" | "phrase" | "wildcard" | "regex" | "range"; +ParseOptions · interface · export interface ParseOptions extends QueryContext { +ParseOptions · interface · defaultField?: string; +ParseOptions · interface · proximity?: boolean; +ParseOptions · interface · } +Predicate · interface · export interface Predicate { +Predicate · interface · kind: "predicate"; +Predicate · interface · field: string; +Predicate · interface · operator: Operator; +Predicate · interface · value: string; +Predicate · interface · upper?: string; +Predicate · interface · lower_inclusive?: boolean; +Predicate · interface · upper_inclusive?: boolean; +Predicate · interface · span: Span; +Predicate · interface · implicit?: true; +Predicate · interface · slop?: number; +Predicate · interface · } +QUERY_BACKENDS · const · export declare const QUERY_BACKENDS: readonly ["sql", "native"]; +QUERY_LIMITS · const · export declare const QUERY_LIMITS: { +QUERY_LIMITS · const · readonly bytes: 8192; +QUERY_LIMITS · const · readonly depth: 32; +QUERY_LIMITS · const · readonly nodes: 256; +QUERY_LIMITS · const · }; +QUERY_REASONS · const · export declare const QUERY_REASONS: { +QUERY_REASONS · const · reason: string; +QUERY_REASONS · const · code: "authentication_error" | "cancelled" | "configuration_error" | "confirmation_required" | "conflict" | "internal_error" | "invalid_response" | "network_error" | "not_found" | "outcome_unknown" | "permission_error" | "provider_error" | "provider_unavailable" | "rate_limited" | "timeout" | "validation_error"; +QUERY_REASONS · const · message: string; +QUERY_REASONS · const · details: string[]; +QUERY_REASONS · const · step?: string | undefined; +QUERY_REASONS · const · }[]; +QueryAst · interface · export interface QueryAst { +QueryAst · interface · version: 1; +QueryAst · interface · language: "lucene-v1"; +QueryAst · interface · root: QueryNode; +QueryAst · interface · } +QueryBackend · type · export type QueryBackend = (typeof QUERY_BACKENDS)[number]; +QueryContext · interface · export interface QueryContext { +QueryContext · interface · command?: string; +QueryContext · interface · guide?: string; +QueryContext · interface · } +QueryInfo · interface · export interface QueryInfo extends Omit { +QueryInfo · interface · fields: FieldInfo[]; +QueryInfo · interface · } +QueryNode · type · export type QueryNode = Predicate | { +QueryNode · type · kind: "boolean"; +QueryNode · type · clauses: { +QueryNode · type · occur: Occur; +QueryNode · type · node: QueryNode; +QueryNode · type · }[]; +QueryNode · type · span: Span; +QueryNode · type · }; +QueryRegistry · interface · export interface QueryRegistry { +QueryRegistry · interface · entity: string; +QueryRegistry · interface · backend: QueryBackend; +QueryRegistry · interface · fields: readonly FieldSpec[]; +QueryRegistry · interface · defaults?: readonly string[]; +QueryRegistry · interface · } +Span · type · export type Span = { +Span · type · start: number; +Span · type · end: number; +Span · type · }; +ValidateOptions · interface · export interface ValidateOptions extends QueryContext { +ValidateOptions · interface · zone?: string; +ValidateOptions · interface · } +dateRange · const · export declare const dateRange: (lower: string, upper: string, lowerInclusive: boolean, upperInclusive: boolean, zone: string, span: Span, now?: number) => DateRange; +dayBoundary · const · export declare const dayBoundary: (value: string, zone: string, next: boolean, span: Span) => number; +defineQuery · const · export declare const defineQuery: (registry: QueryRegistry) => QueryRegistry; +evaluate · const · export declare const evaluate: (ast: QueryAst, fields: readonly FieldSpec[], item: Readonly>, options?: EvaluateOptions) => boolean; +fieldsHelp · const · export declare const fieldsHelp: (registry: Pick & Partial>, guide?: string) => string; +fieldsNamed · const · export declare const fieldsNamed: (ast: QueryAst) => Set; +implicitTextTerms · const · export declare const implicitTextTerms: (text: string) => Set; +parseLucene · const · export declare const parseLucene: (text: string, { defaultField, proximity, ...context }?: ParseOptions) => QueryAst; +queryAstSchema · const · export declare const queryAstSchema: v.ObjectSchema<{ +queryAstSchema · const · readonly version: v.LiteralSchema<1, undefined>; +queryAstSchema · const · readonly language: v.LiteralSchema<"lucene-v1", undefined>; +queryAstSchema · const · readonly root: v.GenericSchema; +queryAstSchema · const · }, undefined>; +queryDescription · const · export declare const queryDescription: (registry: Pick & Partial>) => string; +queryError · function · export declare function queryError(reason: string, span: Span, alternative?: string, context?: QueryContext, details?: Record): never; +queryFieldsOf · const · export declare const queryFieldsOf: (schema: v.GenericSchema, annotations?: FieldAnnotations) => FieldSpec[]; +timezoneOf · const · export declare const timezoneOf: (given?: string) => string; +validateQuery · const · export declare const validateQuery: (ast: QueryAst, registry: QueryRegistry, options?: ValidateOptions) => QueryAst; +walkQuery · const · export declare const walkQuery: (node: QueryNode) => Predicate[]; +zonedMoment · const · export declare const zonedMoment: (value: string, zone: string, span: Span, { end }?: { +zonedMoment · const · end?: boolean | undefined; +zonedMoment · const · }) => number; diff --git a/api/skill.api.txt b/api/skill.api.txt new file mode 100644 index 00000000..e1201514 --- /dev/null +++ b/api/skill.api.txt @@ -0,0 +1,60 @@ +# @wirecat/cli-base "./skill": the stable API, written by cli-dev api-report. Do not edit. +SKILL_TARGETS · const · export declare const SKILL_TARGETS: readonly ["claude", "agents"]; +SkillApp · interface · export interface SkillApp { +SkillApp · interface · command: string; +SkillApp · interface · appName: string; +SkillApp · interface · version: string; +SkillApp · interface · } +SkillEnvironment · type · export type SkillEnvironment = (command: Command) => { +SkillEnvironment · type · renderer: Renderer; +SkillEnvironment · type · streams: Streams; +SkillEnvironment · type · env?: Env; +SkillEnvironment · type · }; +SkillEnvironment · type · type Env = Readonly>; +SkillHintRequest · interface · export interface SkillHintRequest { +SkillHintRequest · interface · app: SkillApp; +SkillHintRequest · interface · argv: readonly string[]; +SkillHintRequest · interface · env: Env; +SkillHintRequest · interface · statePath: string; +SkillHintRequest · interface · enabled?: boolean; +SkillHintRequest · interface · now?: () => number; +SkillHintRequest · interface · } +SkillHintRequest · interface · type Env = Readonly>; +SkillResource · interface · export interface SkillResource { +SkillResource · interface · uri: string; +SkillResource · interface · name: string; +SkillResource · interface · title: string; +SkillResource · interface · description: string; +SkillResource · interface · mimeType: "text/markdown"; +SkillResource · interface · read: () => { +SkillResource · interface · contents: { +SkillResource · interface · uri: string; +SkillResource · interface · mimeType: "text/markdown"; +SkillResource · interface · text: string; +SkillResource · interface · }[]; +SkillResource · interface · }; +SkillResource · interface · instruction: string; +SkillResource · interface · } +SkillState · type · export type SkillState = "current" | "stale" | "missing" | "unversioned"; +SkillTarget · type · export type SkillTarget = (typeof SKILL_TARGETS)[number]; +SkillTargetStatus · interface · export interface SkillTargetStatus { +SkillTargetStatus · interface · target: SkillTarget; +SkillTargetStatus · interface · path: string; +SkillTargetStatus · interface · installed: string | null; +SkillTargetStatus · interface · state: SkillState; +SkillTargetStatus · interface · } +hermesCopyPath · const · export declare const hermesCopyPath: (appName: string, env: Env) => string; +hermesCopyPath · const · type Env = Readonly>; +installSkill · const · export declare const installSkill: (app: SkillApp, skill: URL, { targets, env }?: { +installSkill · const · targets?: readonly SkillTarget[]; +installSkill · const · env?: Env; +installSkill · const · }) => string[]; +installSkill · const · type Env = Readonly>; +skillCommand · const · export declare const skillCommand: (app: SkillApp, skill: URL, environment: SkillEnvironment, more?: Readonly>) => Command; +skillHint · const · export declare const skillHint: ({ app, argv, env, statePath, enabled, now }: SkillHintRequest) => string | undefined; +skillResource · const · export declare const skillResource: (app: SkillApp, skill: URL) => SkillResource; +skillResources · const · export declare const skillResources: (app: SkillApp, skill: URL) => SkillResource[]; +skillStatus · const · export declare const skillStatus: (app: SkillApp, env?: Env) => SkillTargetStatus[]; +skillStatus · const · type Env = Readonly>; +skillVersion · const · export declare const skillVersion: (content: string) => string | undefined; +writeSkillFolder · const · export declare const writeSkillFolder: (app: SkillApp, skill: URL, folder: string) => string; diff --git a/api/standards-tables.api.txt b/api/standards-tables.api.txt new file mode 100644 index 00000000..99885dc8 --- /dev/null +++ b/api/standards-tables.api.txt @@ -0,0 +1,52 @@ +# @wirecat/cli-base "./standards/tables": the stable API, written by cli-dev api-report. Do not edit. +FLAG_ROLES · const · export declare const FLAG_ROLES: { +FLAG_ROLES · const · readonly paging: "which part of a long answer: how many, which page, where to continue"; +FLAG_ROLES · const · readonly output: "how the answer is shaped or shown"; +FLAG_ROLES · const · readonly sort: "the order of the answer"; +FLAG_ROLES · const · readonly mode: "how the command runs, not what it reads"; +FLAG_ROLES · const · readonly action: "does something extra besides the answer"; +FLAG_ROLES · const · readonly budget: "how much time or work the command may spend"; +FLAG_ROLES · const · readonly scope: "which accounts, providers or sources are read; never picked for you, so a flag and not a query field"; +FLAG_ROLES · const · readonly target: "which thing or time window the command acts on, when that is not a list's filter"; +FLAG_ROLES · const · readonly value: "sets a field on a write"; +FLAG_ROLES · const · readonly query: "a query in the query language, beside a search's own words"; +FLAG_ROLES · const · }; +FLAG_TYPES · const · export declare const FLAG_TYPES: readonly ["switch", "count", "number", "string", "id", "time", "duration", "choice", "list", "path", "cursor"]; +FlagRole · type · export type FlagRole = keyof typeof FLAG_ROLES; +FlagType · type · export type FlagType = (typeof FLAG_TYPES)[number]; +VOCABULARY · const · export declare const VOCABULARY: Vocabulary; +Vocabulary · type · export type Vocabulary = v.InferOutput; +VocabularyFlag · type · export type VocabularyFlag = Vocabulary["flags"][number]; +VocabularyNoun · type · export type VocabularyNoun = Vocabulary["nouns"][number]; +VocabularyVerb · type · export type VocabularyVerb = Vocabulary["verbs"][number]; +vocabularySchema · const · export declare const vocabularySchema: v.StrictObjectSchema<{ +vocabularySchema · const · readonly verbs: v.ArraySchema, v.RegexAction]>; +vocabularySchema · const · readonly meaning: v.SchemaWithPipe, v.RegexAction]>; +vocabularySchema · const · readonly replaces: v.OptionalSchema, v.RegexAction]>, undefined>, undefined>; +vocabularySchema · const · }, undefined>, undefined>; +vocabularySchema · const · readonly nouns: v.ArraySchema, v.RegexAction]>; +vocabularySchema · const · readonly meaning: v.SchemaWithPipe, v.RegexAction]>; +vocabularySchema · const · readonly kind: v.PicklistSchema<["collection", "singular"], undefined>; +vocabularySchema · const · readonly replaces: v.OptionalSchema, v.RegexAction]>, undefined>, undefined>; +vocabularySchema · const · }, undefined>, undefined>; +vocabularySchema · const · readonly views: v.ArraySchema, v.RegexAction]>; +vocabularySchema · const · readonly meaning: v.SchemaWithPipe, v.RegexAction]>; +vocabularySchema · const · }, undefined>, undefined>; +vocabularySchema · const · readonly roots: v.ArraySchema, v.RegexAction]>; +vocabularySchema · const · readonly meaning: v.SchemaWithPipe, v.RegexAction]>; +vocabularySchema · const · }, undefined>, undefined>; +vocabularySchema · const · readonly flags: v.ArraySchema, v.RegexAction]>; +vocabularySchema · const · readonly value: v.OptionalSchema, v.RegexAction">]>, undefined>; +vocabularySchema · const · readonly type: v.PicklistSchema; +vocabularySchema · const · readonly role: v.PicklistSchema<["action" | "budget" | "mode" | "output" | "paging" | "query" | "scope" | "sort" | "target" | "value", ...("action" | "budget" | "mode" | "output" | "paging" | "query" | "scope" | "sort" | "target" | "value")[]], undefined>; +vocabularySchema · const · readonly meaning: v.SchemaWithPipe, v.RegexAction]>; +vocabularySchema · const · readonly otherValues: v.OptionalSchema, v.RegexAction]>, undefined>, undefined>; +vocabularySchema · const · readonly unit: v.OptionalSchema, v.RegexAction]>, undefined>; +vocabularySchema · const · readonly replaces: v.OptionalSchema, v.RegexAction]>, undefined>, undefined>; +vocabularySchema · const · }, undefined>, undefined>; +vocabularySchema · const · }, undefined>; diff --git a/api/standards.api.txt b/api/standards.api.txt new file mode 100644 index 00000000..5ab80f60 --- /dev/null +++ b/api/standards.api.txt @@ -0,0 +1,527 @@ +# @wirecat/cli-base "./standards": the stable API, written by cli-dev api-report. Do not edit. +BASE_REASONS · const · export declare const BASE_REASONS: ErrorReason[]; +COMPACT_FLAG · const · export declare const COMPACT_FLAG = "--compact"; +CRASH_CODE · const · export declare const CRASH_CODE = "internal_error"; +CRASH_REASON · const · export declare const CRASH_REASON = "command.crashed"; +Effects · type · export type Effects = v.InferOutput; +ErrorObject · type · export type ErrorObject = v.InferOutput; +ErrorReason · type · export type ErrorReason = v.InferOutput; +ErrorReason · type · declare const reasonSchema: v.StrictObjectSchema<{ +ErrorReason · type · readonly reason: v.SchemaWithPipe, v.RegexAction]>; +ErrorReason · type · readonly code: v.PicklistSchema<["validation_error", "configuration_error", "authentication_error", "permission_error", "not_found", "confirmation_required", "rate_limited", "timeout", "network_error", "provider_error", "provider_unavailable", "invalid_response", "outcome_unknown", "conflict", "cancelled", "internal_error"], undefined>; +ErrorReason · type · readonly message: v.SchemaWithPipe, v.RegexAction]>, v.MaxLengthAction]>; +ErrorReason · type · readonly details: v.ArraySchema, v.RegexAction]>, undefined>; +ErrorReason · type · readonly step: v.OptionalSchema, v.RegexAction]>, undefined>; +ErrorReason · type · }, undefined>; +Issue · type · export type Issue = v.InferOutput; +ItemEnvelope · interface · export interface ItemEnvelope { +ItemEnvelope · interface · item: T; +ItemEnvelope · interface · next?: NextStep[]; +ItemEnvelope · interface · missing?: Missing[]; +ItemEnvelope · interface · meta: Meta; +ItemEnvelope · interface · } +LOG_SEVERITIES · const · export declare const LOG_SEVERITIES: readonly ["trace", "debug", "info", "warn", "error", "fatal"]; +ListEnvelope · interface · export interface ListEnvelope { +ListEnvelope · interface · items: T[]; +ListEnvelope · interface · page: Page; +ListEnvelope · interface · next?: NextStep[]; +ListEnvelope · interface · missing?: Missing[]; +ListEnvelope · interface · meta: Meta; +ListEnvelope · interface · } +ListResult · interface · export interface ListResult { +ListResult · interface · items: T[]; +ListResult · interface · hasMore: boolean; +ListResult · interface · nextOffset?: number; +ListResult · interface · nextCursor?: string; +ListResult · interface · total?: Total; +ListResult · interface · } +LogEvent · type · export type LogEvent = v.InferOutput; +LogEvent · type · declare const logEventSchema: v.StrictObjectSchema<{ +LogEvent · type · readonly id: v.SchemaWithPipe, v.RegexAction]>; +LogEvent · type · readonly meaning: v.SchemaWithPipe, v.RegexAction]>; +LogEvent · type · readonly keys: v.ArraySchema, undefined>; +LogEvent · type · }, undefined>; +LogRecord · type · export type LogRecord = v.InferOutput; +LogSeverity · type · export type LogSeverity = (typeof LOG_SEVERITIES)[number]; +MAX_NEXT_STEPS · const · export declare const MAX_NEXT_STEPS = 2; +Meta · type · export type Meta = v.InferOutput; +Missing · type · export type Missing = v.InferOutput; +NextStep · type · export type NextStep = v.InferOutput; +Page · type · export type Page = v.InferOutput; +Query · type · export type Query = v.InferOutput; +Ranking · type · export type Ranking = v.InferOutput; +STEPS · const · export declare const STEPS: StepDefinition[]; +StepDefinition · type · export type StepDefinition = v.InferOutput; +StepDefinition · type · declare const stepSchema: v.UnionSchema<[v.StrictObjectSchema<{ +StepDefinition · type · readonly id: v.SchemaWithPipe, v.RegexAction]>; +StepDefinition · type · readonly kind: v.OptionalSchema, "command">; +StepDefinition · type · readonly command: v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.SchemaWithPipe, v.RegexAction]>], undefined>; +StepDefinition · type · readonly args: v.ArraySchema, v.RegexAction]>; +StepDefinition · type · readonly required: v.BooleanSchema; +StepDefinition · type · }, undefined>, undefined>; +StepDefinition · type · readonly why: v.SchemaWithPipe, v.RegexAction]>, v.MaxLengthAction]>; +StepDefinition · type · }, undefined>, v.StrictObjectSchema<{ +StepDefinition · type · readonly id: v.SchemaWithPipe, v.RegexAction]>; +StepDefinition · type · readonly kind: v.LiteralSchema<"user_action", undefined>; +StepDefinition · type · readonly why: v.SchemaWithPipe, v.RegexAction]>, v.MaxLengthAction]>; +StepDefinition · type · }, undefined>], undefined>; +StepInput · interface · export interface StepInput { +StepInput · interface · args?: Readonly>; +StepInput · interface · values?: Readonly>; +StepInput · interface · command?: string; +StepInput · interface · targets?: (command: string) => StepTarget | undefined; +StepInput · interface · } +StepTarget · interface · export interface StepTarget { +StepTarget · interface · effects?: Effects; +StepTarget · interface · names: readonly string[]; +StepTarget · interface · } +Total · type · export type Total = v.InferOutput; +clockMeta · const · export declare const clockMeta: (at: number, zone: string) => { +clockMeta · const · now: string; +clockMeta · const · now_local: string; +clockMeta · const · timezone: string; +clockMeta · const · }; +defineLogEvents · const · export declare const defineLogEvents: (input: unknown) => LogEvent[]; +defineReasons · const · export declare const defineReasons: (input: unknown) => ErrorReason[]; +defineSteps · const · export declare const defineSteps: (input: unknown) => StepDefinition[]; +effectsSchema · const · export declare const effectsSchema: v.StrictObjectSchema<{ +effectsSchema · const · readonly remote: v.PicklistSchema; +effectsSchema · const · readonly local: v.PicklistSchema; +effectsSchema · const · }, undefined>; +errorObjectSchema · const · export declare const errorObjectSchema: v.StrictObjectSchema<{ +errorObjectSchema · const · readonly error: v.StrictObjectSchema<{ +errorObjectSchema · const · readonly code: v.PicklistSchema<["validation_error", "configuration_error", "authentication_error", "permission_error", "not_found", "confirmation_required", "rate_limited", "timeout", "network_error", "provider_error", "provider_unavailable", "invalid_response", "outcome_unknown", "conflict", "cancelled", "internal_error"], undefined>; +errorObjectSchema · const · readonly reason: v.SchemaWithPipe, v.RegexAction]>; +errorObjectSchema · const · readonly message: v.SchemaWithPipe, v.RegexAction]>; +errorObjectSchema · const · readonly param: v.OptionalSchema, v.RegexAction]>, undefined>; +errorObjectSchema · const · readonly details: v.OptionalSchema, v.UnknownSchema, undefined>, undefined>; +errorObjectSchema · const · readonly next: v.OptionalSchema; +errorObjectSchema · const · readonly step: v.SchemaWithPipe, v.RegexAction]>; +errorObjectSchema · const · readonly command: v.SchemaWithPipe, v.RegexAction]>; +errorObjectSchema · const · readonly args: v.RecordSchema, v.UnknownSchema, undefined>; +errorObjectSchema · const · readonly line: v.OptionalSchema, v.RegexAction]>, undefined>; +errorObjectSchema · const · readonly why: v.SchemaWithPipe, v.RegexAction]>; +errorObjectSchema · const · readonly safe_to_auto_execute: v.BooleanSchema; +errorObjectSchema · const · }, undefined>, v.StrictObjectSchema<{ +errorObjectSchema · const · readonly kind: v.LiteralSchema<"user_action", undefined>; +errorObjectSchema · const · readonly step: v.SchemaWithPipe, v.RegexAction]>; +errorObjectSchema · const · readonly why: v.SchemaWithPipe, v.RegexAction]>; +errorObjectSchema · const · readonly safe_to_auto_execute: v.LiteralSchema; +errorObjectSchema · const · }, undefined>], undefined>, undefined>, v.MaxLengthAction<({ +errorObjectSchema · const · kind: "command"; +errorObjectSchema · const · step: string; +errorObjectSchema · const · command: string; +errorObjectSchema · const · args: { +errorObjectSchema · const · [x: string]: unknown; +errorObjectSchema · const · }; +errorObjectSchema · const · line?: string | undefined; +errorObjectSchema · const · why: string; +errorObjectSchema · const · safe_to_auto_execute: boolean; +errorObjectSchema · const · } | { +errorObjectSchema · const · kind: "user_action"; +errorObjectSchema · const · step: string; +errorObjectSchema · const · why: string; +errorObjectSchema · const · safe_to_auto_execute: false; +errorObjectSchema · const · })[], 2, undefined>]>, undefined>; +errorObjectSchema · const · readonly retry: v.StrictObjectSchema<{ +errorObjectSchema · const · readonly safe: v.BooleanSchema; +errorObjectSchema · const · readonly after_ms: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>, undefined>; +errorObjectSchema · const · }, undefined>; +errorObjectSchema · const · readonly run_id: v.OptionalSchema, v.RegexAction]>, undefined>; +errorObjectSchema · const · }, undefined>; +errorObjectSchema · const · }, undefined>; +isContentKey · const · export declare const isContentKey: (key: string) => boolean; +isoTime · const · export declare const isoTime: v.SchemaWithPipe, v.IsoTimestampAction, v.EndsWithAction]>; +issueSchema · const · export declare const issueSchema: v.StrictObjectSchema<{ +issueSchema · const · readonly code: v.PicklistSchema; +issueSchema · const · readonly reason: v.OptionalSchema, v.RegexAction]>, undefined>; +issueSchema · const · readonly source: v.SchemaWithPipe, v.RegexAction]>; +issueSchema · const · }, undefined>; +itemEnvelopeSchema · const · export declare const itemEnvelopeSchema: (item: T) => v.StrictObjectSchema<{ +itemEnvelopeSchema · const · readonly item: T; +itemEnvelopeSchema · const · readonly next: v.OptionalSchema; +itemEnvelopeSchema · const · readonly step: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · readonly command: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · readonly args: v.RecordSchema, v.UnknownSchema, undefined>; +itemEnvelopeSchema · const · readonly line: v.OptionalSchema, v.RegexAction]>, undefined>; +itemEnvelopeSchema · const · readonly why: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · readonly safe_to_auto_execute: v.BooleanSchema; +itemEnvelopeSchema · const · }, undefined>, v.StrictObjectSchema<{ +itemEnvelopeSchema · const · readonly kind: v.LiteralSchema<"user_action", undefined>; +itemEnvelopeSchema · const · readonly step: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · readonly why: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · readonly safe_to_auto_execute: v.LiteralSchema; +itemEnvelopeSchema · const · }, undefined>], undefined>, undefined>, v.MaxLengthAction<({ +itemEnvelopeSchema · const · kind: "command"; +itemEnvelopeSchema · const · step: string; +itemEnvelopeSchema · const · command: string; +itemEnvelopeSchema · const · args: { +itemEnvelopeSchema · const · [x: string]: unknown; +itemEnvelopeSchema · const · }; +itemEnvelopeSchema · const · line?: string | undefined; +itemEnvelopeSchema · const · why: string; +itemEnvelopeSchema · const · safe_to_auto_execute: boolean; +itemEnvelopeSchema · const · } | { +itemEnvelopeSchema · const · kind: "user_action"; +itemEnvelopeSchema · const · step: string; +itemEnvelopeSchema · const · why: string; +itemEnvelopeSchema · const · safe_to_auto_execute: false; +itemEnvelopeSchema · const · })[], 2, undefined>]>, undefined>; +itemEnvelopeSchema · const · readonly missing: v.OptionalSchema, v.RegexAction]>; +itemEnvelopeSchema · const · readonly why: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · readonly step: v.OptionalSchema, v.RegexAction]>, undefined>; +itemEnvelopeSchema · const · }, undefined>, undefined>, undefined>; +itemEnvelopeSchema · const · readonly meta: v.StrictObjectSchema<{ +itemEnvelopeSchema · const · readonly run_id: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · readonly duration_ms: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +itemEnvelopeSchema · const · readonly accounts: v.OptionalSchema, v.RegexAction]>, undefined>, undefined>; +itemEnvelopeSchema · const · readonly complete: v.BooleanSchema; +itemEnvelopeSchema · const · readonly issues: v.OptionalSchema; +itemEnvelopeSchema · const · readonly reason: v.OptionalSchema, v.RegexAction]>, undefined>; +itemEnvelopeSchema · const · readonly source: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · }, undefined>, undefined>, undefined>; +itemEnvelopeSchema · const · readonly truncated: v.OptionalSchema, undefined>; +itemEnvelopeSchema · const · readonly timezone: v.OptionalSchema, v.RegexAction]>, undefined>; +itemEnvelopeSchema · const · readonly now: v.OptionalSchema, v.IsoTimestampAction, v.EndsWithAction]>, undefined>; +itemEnvelopeSchema · const · readonly now_local: v.OptionalSchema, v.RegexAction]>, undefined>; +itemEnvelopeSchema · const · readonly window: v.OptionalSchema, v.IsoTimestampAction, v.EndsWithAction]>, undefined>; +itemEnvelopeSchema · const · readonly until: v.OptionalSchema, v.IsoTimestampAction, v.EndsWithAction]>, undefined>; +itemEnvelopeSchema · const · }, undefined>, undefined>; +itemEnvelopeSchema · const · readonly ranking: v.OptionalSchema; +itemEnvelopeSchema · const · readonly reason_id: v.OptionalSchema, v.RegexAction]>, undefined>; +itemEnvelopeSchema · const · readonly provider: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · readonly model: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · readonly endpoint: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · readonly sent: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +itemEnvelopeSchema · const · readonly cost_usd: v.NullableSchema, v.MinValueAction]>, undefined>; +itemEnvelopeSchema · const · readonly usage: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>; +itemEnvelopeSchema · const · readonly output: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +itemEnvelopeSchema · const · }, undefined>, undefined>; +itemEnvelopeSchema · const · readonly ms: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +itemEnvelopeSchema · const · }, undefined>, undefined>; +itemEnvelopeSchema · const · readonly model_run: v.OptionalSchema, v.RegexAction]>; +itemEnvelopeSchema · const · readonly model: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · readonly endpoint: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · readonly sent: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +itemEnvelopeSchema · const · readonly done: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +itemEnvelopeSchema · const · readonly left: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +itemEnvelopeSchema · const · readonly usage: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>; +itemEnvelopeSchema · const · readonly output: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +itemEnvelopeSchema · const · }, undefined>, undefined>; +itemEnvelopeSchema · const · readonly cost_usd: v.NullableSchema, v.MinValueAction]>, undefined>; +itemEnvelopeSchema · const · readonly ms: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +itemEnvelopeSchema · const · }, undefined>, undefined>; +itemEnvelopeSchema · const · readonly query: v.OptionalSchema, v.RegexAction]>; +itemEnvelopeSchema · const · readonly chat_id: v.SchemaWithPipe, v.RegexAction]>; +itemEnvelopeSchema · const · readonly title: v.NullableSchema, v.RegexAction]>, undefined>; +itemEnvelopeSchema · const · }, undefined>, undefined>; +itemEnvelopeSchema · const · readonly respelled: v.OptionalSchema, v.RegexAction]>; +itemEnvelopeSchema · const · readonly tried: v.SchemaWithPipe, v.RegexAction]>, undefined>, v.MinLengthAction]>; +itemEnvelopeSchema · const · }, undefined>, undefined>, undefined>; +itemEnvelopeSchema · const · }, undefined>, undefined>; +itemEnvelopeSchema · const · }, undefined>; +itemEnvelopeSchema · const · }, undefined>; +jsonSchemaOf · const · export declare const jsonSchemaOf: (schema: v.GenericSchema, definitions?: Record) => import("@valibot/to-json-schema").JsonSchema; +jsonlEndSchema · const · export declare const jsonlEndSchema: v.StrictObjectSchema<{ +jsonlEndSchema · const · readonly type: v.LiteralSchema<"end", undefined>; +jsonlEndSchema · const · readonly complete: v.BooleanSchema; +jsonlEndSchema · const · readonly issues: v.OptionalSchema; +jsonlEndSchema · const · readonly reason: v.OptionalSchema, v.RegexAction]>, undefined>; +jsonlEndSchema · const · readonly source: v.SchemaWithPipe, v.RegexAction]>; +jsonlEndSchema · const · }, undefined>, undefined>, undefined>; +jsonlEndSchema · const · readonly page: v.VariantSchema<"mode", [v.StrictObjectSchema<{ +jsonlEndSchema · const · readonly mode: v.LiteralSchema<"page", undefined>; +jsonlEndSchema · const · readonly limit: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +jsonlEndSchema · const · readonly has_more: v.BooleanSchema; +jsonlEndSchema · const · readonly next_page: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>, undefined>; +jsonlEndSchema · const · readonly total: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>; +jsonlEndSchema · const · readonly relation: v.PicklistSchema<["eq", "gte"], undefined>; +jsonlEndSchema · const · }, undefined>, undefined>; +jsonlEndSchema · const · }, undefined>, v.StrictObjectSchema<{ +jsonlEndSchema · const · readonly mode: v.LiteralSchema<"cursor", undefined>; +jsonlEndSchema · const · readonly limit: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +jsonlEndSchema · const · readonly has_more: v.BooleanSchema; +jsonlEndSchema · const · readonly next_cursor: v.OptionalSchema, v.RegexAction]>, undefined>; +jsonlEndSchema · const · readonly total: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>; +jsonlEndSchema · const · readonly relation: v.PicklistSchema<["eq", "gte"], undefined>; +jsonlEndSchema · const · }, undefined>, undefined>; +jsonlEndSchema · const · }, undefined>], undefined>; +jsonlEndSchema · const · }, undefined>; +jsonlItemSchema · const · export declare const jsonlItemSchema: (item: T) => v.StrictObjectSchema<{ +jsonlItemSchema · const · readonly type: v.LiteralSchema<"item", undefined>; +jsonlItemSchema · const · readonly data: T; +jsonlItemSchema · const · }, undefined>; +jsonlOf · const · export declare const jsonlOf: ({ items, page, meta }: ListEnvelope) => string; +listEnvelopeSchema · const · export declare const listEnvelopeSchema: (item: T) => v.StrictObjectSchema<{ +listEnvelopeSchema · const · readonly items: v.ArraySchema; +listEnvelopeSchema · const · readonly page: v.VariantSchema<"mode", [v.StrictObjectSchema<{ +listEnvelopeSchema · const · readonly mode: v.LiteralSchema<"page", undefined>; +listEnvelopeSchema · const · readonly limit: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · readonly has_more: v.BooleanSchema; +listEnvelopeSchema · const · readonly next_page: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>, undefined>; +listEnvelopeSchema · const · readonly total: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · readonly relation: v.PicklistSchema<["eq", "gte"], undefined>; +listEnvelopeSchema · const · }, undefined>, undefined>; +listEnvelopeSchema · const · }, undefined>, v.StrictObjectSchema<{ +listEnvelopeSchema · const · readonly mode: v.LiteralSchema<"cursor", undefined>; +listEnvelopeSchema · const · readonly limit: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · readonly has_more: v.BooleanSchema; +listEnvelopeSchema · const · readonly next_cursor: v.OptionalSchema, v.RegexAction]>, undefined>; +listEnvelopeSchema · const · readonly total: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · readonly relation: v.PicklistSchema<["eq", "gte"], undefined>; +listEnvelopeSchema · const · }, undefined>, undefined>; +listEnvelopeSchema · const · }, undefined>], undefined>; +listEnvelopeSchema · const · readonly next: v.OptionalSchema; +listEnvelopeSchema · const · readonly step: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · readonly command: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · readonly args: v.RecordSchema, v.UnknownSchema, undefined>; +listEnvelopeSchema · const · readonly line: v.OptionalSchema, v.RegexAction]>, undefined>; +listEnvelopeSchema · const · readonly why: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · readonly safe_to_auto_execute: v.BooleanSchema; +listEnvelopeSchema · const · }, undefined>, v.StrictObjectSchema<{ +listEnvelopeSchema · const · readonly kind: v.LiteralSchema<"user_action", undefined>; +listEnvelopeSchema · const · readonly step: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · readonly why: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · readonly safe_to_auto_execute: v.LiteralSchema; +listEnvelopeSchema · const · }, undefined>], undefined>, undefined>, v.MaxLengthAction<({ +listEnvelopeSchema · const · kind: "command"; +listEnvelopeSchema · const · step: string; +listEnvelopeSchema · const · command: string; +listEnvelopeSchema · const · args: { +listEnvelopeSchema · const · [x: string]: unknown; +listEnvelopeSchema · const · }; +listEnvelopeSchema · const · line?: string | undefined; +listEnvelopeSchema · const · why: string; +listEnvelopeSchema · const · safe_to_auto_execute: boolean; +listEnvelopeSchema · const · } | { +listEnvelopeSchema · const · kind: "user_action"; +listEnvelopeSchema · const · step: string; +listEnvelopeSchema · const · why: string; +listEnvelopeSchema · const · safe_to_auto_execute: false; +listEnvelopeSchema · const · })[], 2, undefined>]>, undefined>; +listEnvelopeSchema · const · readonly missing: v.OptionalSchema, v.RegexAction]>; +listEnvelopeSchema · const · readonly why: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · readonly step: v.OptionalSchema, v.RegexAction]>, undefined>; +listEnvelopeSchema · const · }, undefined>, undefined>, undefined>; +listEnvelopeSchema · const · readonly meta: v.StrictObjectSchema<{ +listEnvelopeSchema · const · readonly run_id: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · readonly duration_ms: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · readonly accounts: v.OptionalSchema, v.RegexAction]>, undefined>, undefined>; +listEnvelopeSchema · const · readonly complete: v.BooleanSchema; +listEnvelopeSchema · const · readonly issues: v.OptionalSchema; +listEnvelopeSchema · const · readonly reason: v.OptionalSchema, v.RegexAction]>, undefined>; +listEnvelopeSchema · const · readonly source: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · }, undefined>, undefined>, undefined>; +listEnvelopeSchema · const · readonly truncated: v.OptionalSchema, undefined>; +listEnvelopeSchema · const · readonly timezone: v.OptionalSchema, v.RegexAction]>, undefined>; +listEnvelopeSchema · const · readonly now: v.OptionalSchema, v.IsoTimestampAction, v.EndsWithAction]>, undefined>; +listEnvelopeSchema · const · readonly now_local: v.OptionalSchema, v.RegexAction]>, undefined>; +listEnvelopeSchema · const · readonly window: v.OptionalSchema, v.IsoTimestampAction, v.EndsWithAction]>, undefined>; +listEnvelopeSchema · const · readonly until: v.OptionalSchema, v.IsoTimestampAction, v.EndsWithAction]>, undefined>; +listEnvelopeSchema · const · }, undefined>, undefined>; +listEnvelopeSchema · const · readonly ranking: v.OptionalSchema; +listEnvelopeSchema · const · readonly reason_id: v.OptionalSchema, v.RegexAction]>, undefined>; +listEnvelopeSchema · const · readonly provider: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · readonly model: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · readonly endpoint: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · readonly sent: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · readonly cost_usd: v.NullableSchema, v.MinValueAction]>, undefined>; +listEnvelopeSchema · const · readonly usage: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · readonly output: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · }, undefined>, undefined>; +listEnvelopeSchema · const · readonly ms: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · }, undefined>, undefined>; +listEnvelopeSchema · const · readonly model_run: v.OptionalSchema, v.RegexAction]>; +listEnvelopeSchema · const · readonly model: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · readonly endpoint: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · readonly sent: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · readonly done: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · readonly left: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · readonly usage: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · readonly output: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · }, undefined>, undefined>; +listEnvelopeSchema · const · readonly cost_usd: v.NullableSchema, v.MinValueAction]>, undefined>; +listEnvelopeSchema · const · readonly ms: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +listEnvelopeSchema · const · }, undefined>, undefined>; +listEnvelopeSchema · const · readonly query: v.OptionalSchema, v.RegexAction]>; +listEnvelopeSchema · const · readonly chat_id: v.SchemaWithPipe, v.RegexAction]>; +listEnvelopeSchema · const · readonly title: v.NullableSchema, v.RegexAction]>, undefined>; +listEnvelopeSchema · const · }, undefined>, undefined>; +listEnvelopeSchema · const · readonly respelled: v.OptionalSchema, v.RegexAction]>; +listEnvelopeSchema · const · readonly tried: v.SchemaWithPipe, v.RegexAction]>, undefined>, v.MinLengthAction]>; +listEnvelopeSchema · const · }, undefined>, undefined>, undefined>; +listEnvelopeSchema · const · }, undefined>, undefined>; +listEnvelopeSchema · const · }, undefined>; +listEnvelopeSchema · const · }, undefined>; +logAttributesJsonSchema · const · export declare const logAttributesJsonSchema: (allow?: readonly string[]) => Record; +logRecordSchema · const · export declare const logRecordSchema: v.StrictObjectSchema<{ +logRecordSchema · const · readonly time: v.SchemaWithPipe, v.IsoTimestampAction, v.EndsWithAction]>; +logRecordSchema · const · readonly severity: v.PicklistSchema; +logRecordSchema · const · readonly body: v.StringSchema; +logRecordSchema · const · readonly run_id: v.SchemaWithPipe, v.RegexAction]>; +logRecordSchema · const · readonly trace_id: v.OptionalSchema, v.RegexAction]>, undefined>; +logRecordSchema · const · readonly command: v.StringSchema; +logRecordSchema · const · readonly attributes: v.RecordSchema, v.UnknownSchema, undefined>; +logRecordSchema · const · readonly resource: v.StrictObjectSchema<{ +logRecordSchema · const · readonly service: v.SchemaWithPipe, v.RegexAction]>; +logRecordSchema · const · readonly version: v.SchemaWithPipe, v.RegexAction]>; +logRecordSchema · const · }, undefined>; +logRecordSchema · const · }, undefined>; +metaSchema · const · export declare const metaSchema: v.StrictObjectSchema<{ +metaSchema · const · readonly run_id: v.SchemaWithPipe, v.RegexAction]>; +metaSchema · const · readonly duration_ms: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +metaSchema · const · readonly accounts: v.OptionalSchema, v.RegexAction]>, undefined>, undefined>; +metaSchema · const · readonly complete: v.BooleanSchema; +metaSchema · const · readonly issues: v.OptionalSchema; +metaSchema · const · readonly reason: v.OptionalSchema, v.RegexAction]>, undefined>; +metaSchema · const · readonly source: v.SchemaWithPipe, v.RegexAction]>; +metaSchema · const · }, undefined>, undefined>, undefined>; +metaSchema · const · readonly truncated: v.OptionalSchema, undefined>; +metaSchema · const · readonly timezone: v.OptionalSchema, v.RegexAction]>, undefined>; +metaSchema · const · readonly now: v.OptionalSchema, v.IsoTimestampAction, v.EndsWithAction]>, undefined>; +metaSchema · const · readonly now_local: v.OptionalSchema, v.RegexAction]>, undefined>; +metaSchema · const · readonly window: v.OptionalSchema, v.IsoTimestampAction, v.EndsWithAction]>, undefined>; +metaSchema · const · readonly until: v.OptionalSchema, v.IsoTimestampAction, v.EndsWithAction]>, undefined>; +metaSchema · const · }, undefined>, undefined>; +metaSchema · const · readonly ranking: v.OptionalSchema; +metaSchema · const · readonly reason_id: v.OptionalSchema, v.RegexAction]>, undefined>; +metaSchema · const · readonly provider: v.SchemaWithPipe, v.RegexAction]>; +metaSchema · const · readonly model: v.SchemaWithPipe, v.RegexAction]>; +metaSchema · const · readonly endpoint: v.SchemaWithPipe, v.RegexAction]>; +metaSchema · const · readonly sent: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +metaSchema · const · readonly cost_usd: v.NullableSchema, v.MinValueAction]>, undefined>; +metaSchema · const · readonly usage: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>; +metaSchema · const · readonly output: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +metaSchema · const · }, undefined>, undefined>; +metaSchema · const · readonly ms: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +metaSchema · const · }, undefined>, undefined>; +metaSchema · const · readonly model_run: v.OptionalSchema, v.RegexAction]>; +metaSchema · const · readonly model: v.SchemaWithPipe, v.RegexAction]>; +metaSchema · const · readonly endpoint: v.SchemaWithPipe, v.RegexAction]>; +metaSchema · const · readonly sent: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +metaSchema · const · readonly done: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +metaSchema · const · readonly left: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +metaSchema · const · readonly usage: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>; +metaSchema · const · readonly output: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +metaSchema · const · }, undefined>, undefined>; +metaSchema · const · readonly cost_usd: v.NullableSchema, v.MinValueAction]>, undefined>; +metaSchema · const · readonly ms: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +metaSchema · const · }, undefined>, undefined>; +metaSchema · const · readonly query: v.OptionalSchema, v.RegexAction]>; +metaSchema · const · readonly chat_id: v.SchemaWithPipe, v.RegexAction]>; +metaSchema · const · readonly title: v.NullableSchema, v.RegexAction]>, undefined>; +metaSchema · const · }, undefined>, undefined>; +metaSchema · const · readonly respelled: v.OptionalSchema, v.RegexAction]>; +metaSchema · const · readonly tried: v.SchemaWithPipe, v.RegexAction]>, undefined>, v.MinLengthAction]>; +metaSchema · const · }, undefined>, undefined>, undefined>; +metaSchema · const · }, undefined>, undefined>; +metaSchema · const · }, undefined>; +missingSchema · const · export declare const missingSchema: v.StrictObjectSchema<{ +missingSchema · const · readonly field: v.SchemaWithPipe, v.RegexAction]>; +missingSchema · const · readonly why: v.SchemaWithPipe, v.RegexAction]>; +missingSchema · const · readonly step: v.OptionalSchema, v.RegexAction]>, undefined>; +missingSchema · const · }, undefined>; +nextStepSchema · const · export declare const nextStepSchema: v.VariantSchema<"kind", [v.StrictObjectSchema<{ +nextStepSchema · const · readonly kind: v.LiteralSchema<"command", undefined>; +nextStepSchema · const · readonly step: v.SchemaWithPipe, v.RegexAction]>; +nextStepSchema · const · readonly command: v.SchemaWithPipe, v.RegexAction]>; +nextStepSchema · const · readonly args: v.RecordSchema, v.UnknownSchema, undefined>; +nextStepSchema · const · readonly line: v.OptionalSchema, v.RegexAction]>, undefined>; +nextStepSchema · const · readonly why: v.SchemaWithPipe, v.RegexAction]>; +nextStepSchema · const · readonly safe_to_auto_execute: v.BooleanSchema; +nextStepSchema · const · }, undefined>, v.StrictObjectSchema<{ +nextStepSchema · const · readonly kind: v.LiteralSchema<"user_action", undefined>; +nextStepSchema · const · readonly step: v.SchemaWithPipe, v.RegexAction]>; +nextStepSchema · const · readonly why: v.SchemaWithPipe, v.RegexAction]>; +nextStepSchema · const · readonly safe_to_auto_execute: v.LiteralSchema; +nextStepSchema · const · }, undefined>], undefined>; +pageSchema · const · export declare const pageSchema: v.VariantSchema<"mode", [v.StrictObjectSchema<{ +pageSchema · const · readonly mode: v.LiteralSchema<"page", undefined>; +pageSchema · const · readonly limit: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +pageSchema · const · readonly has_more: v.BooleanSchema; +pageSchema · const · readonly next_page: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>, undefined>; +pageSchema · const · readonly total: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>; +pageSchema · const · readonly relation: v.PicklistSchema<["eq", "gte"], undefined>; +pageSchema · const · }, undefined>, undefined>; +pageSchema · const · }, undefined>, v.StrictObjectSchema<{ +pageSchema · const · readonly mode: v.LiteralSchema<"cursor", undefined>; +pageSchema · const · readonly limit: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +pageSchema · const · readonly has_more: v.BooleanSchema; +pageSchema · const · readonly next_cursor: v.OptionalSchema, v.RegexAction]>, undefined>; +pageSchema · const · readonly total: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>; +pageSchema · const · readonly relation: v.PicklistSchema<["eq", "gte"], undefined>; +pageSchema · const · }, undefined>, undefined>; +pageSchema · const · }, undefined>], undefined>; +querySchema · const · export declare const querySchema: v.StrictObjectSchema<{ +querySchema · const · readonly chat: v.OptionalSchema, v.RegexAction]>; +querySchema · const · readonly chat_id: v.SchemaWithPipe, v.RegexAction]>; +querySchema · const · readonly title: v.NullableSchema, v.RegexAction]>, undefined>; +querySchema · const · }, undefined>, undefined>; +querySchema · const · readonly respelled: v.OptionalSchema, v.RegexAction]>; +querySchema · const · readonly tried: v.SchemaWithPipe, v.RegexAction]>, undefined>, v.MinLengthAction]>; +querySchema · const · }, undefined>, undefined>, undefined>; +querySchema · const · }, undefined>; +rankingSchema · const · export declare const rankingSchema: v.StrictObjectSchema<{ +rankingSchema · const · readonly applied: v.BooleanSchema; +rankingSchema · const · readonly reason_id: v.OptionalSchema, v.RegexAction]>, undefined>; +rankingSchema · const · readonly provider: v.SchemaWithPipe, v.RegexAction]>; +rankingSchema · const · readonly model: v.SchemaWithPipe, v.RegexAction]>; +rankingSchema · const · readonly endpoint: v.SchemaWithPipe, v.RegexAction]>; +rankingSchema · const · readonly sent: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +rankingSchema · const · readonly cost_usd: v.NullableSchema, v.MinValueAction]>, undefined>; +rankingSchema · const · readonly usage: v.OptionalSchema, v.IntegerAction, v.MinValueAction]>; +rankingSchema · const · readonly output: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +rankingSchema · const · }, undefined>, undefined>; +rankingSchema · const · readonly ms: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +rankingSchema · const · }, undefined>; +reference · const · export declare const reference: v.SchemaWithPipe, v.RegexAction]>; +stepOf · const · export declare const stepOf: (definition: StepDefinition, input?: StepInput) => NextStep; +totalSchema · const · export declare const totalSchema: v.StrictObjectSchema<{ +totalSchema · const · readonly value: v.SchemaWithPipe, v.IntegerAction, v.MinValueAction]>; +totalSchema · const · readonly relation: v.PicklistSchema<["eq", "gte"], undefined>; +totalSchema · const · }, undefined>; +traceIdOf · const · export declare const traceIdOf: (traceparent: unknown) => string | undefined; +writes · const · export declare const writes: (effects: Effects | undefined) => boolean; diff --git a/api/update.api.txt b/api/update.api.txt new file mode 100644 index 00000000..dbc54eff --- /dev/null +++ b/api/update.api.txt @@ -0,0 +1,29 @@ +# @wirecat/cli-base "./update": the stable API, written by cli-dev api-report. Do not edit. +Installer · type · export type Installer = "pnpm" | "npm" | "bun" | "npx" | "checkout" | "unknown"; +NoticeRequest · interface · export interface NoticeRequest extends NotifyContext { +NoticeRequest · interface · argv: readonly string[]; +NoticeRequest · interface · packageName: string; +NoticeRequest · interface · command: string; +NoticeRequest · interface · upgradeCommand?: string; +NoticeRequest · interface · version: string; +NoticeRequest · interface · statePath: string; +NoticeRequest · interface · fetch: FetchLike; +NoticeRequest · interface · now?: () => number; +NoticeRequest · interface · } +NotifyContext · interface · export interface NotifyContext { +NotifyContext · interface · format: string; +NotifyContext · interface · stderrIsTTY: boolean; +NotifyContext · interface · quiet: boolean; +NotifyContext · interface · enabled: boolean; +NotifyContext · interface · installer: Installer; +NotifyContext · interface · env: Readonly>; +NotifyContext · interface · offVariables?: readonly string[]; +NotifyContext · interface · } +installerOf · const · export declare const installerOf: (scriptPath: string) => Installer; +isNewer · const · export declare const isNewer: (candidate: string, current: string) => boolean; +latestVersion · const · export declare const latestVersion: (packageName: string, fetch: FetchLike, { timeoutMs }?: { +latestVersion · const · timeoutMs?: number; +latestVersion · const · }) => Promise; +runUpdate · const · export declare const runUpdate: (argv: readonly string[]) => number; +updateCommand · const · export declare const updateCommand: (installer: Installer, packageName: string) => string[] | undefined; +updateNotice · const · export declare const updateNotice: ({ argv, packageName, command, upgradeCommand, version, statePath, fetch, now, ...context }: NoticeRequest) => Promise; diff --git a/api/wcat-manifest.api.txt b/api/wcat-manifest.api.txt new file mode 100644 index 00000000..05ed1120 --- /dev/null +++ b/api/wcat-manifest.api.txt @@ -0,0 +1,156 @@ +# @wirecat/cli-base "./wcat/manifest": the stable API, written by cli-dev api-report. Do not edit. +MANIFEST_FILE · const · export declare const MANIFEST_FILE = "contracts/wirecat.json"; +Manifest · type · export type Manifest = v.InferOutput; +ManifestIdentity · interface · export interface ManifestIdentity extends WcatTool { +ManifestIdentity · interface · appName: string; +ManifestIdentity · interface · envPrefix: string; +ManifestIdentity · interface · tagline?: string; +ManifestIdentity · interface · signIn?: SignIn; +ManifestIdentity · interface · syncs?: string; +ManifestIdentity · interface · meetingsProvider?: string; +ManifestIdentity · interface · hosts?: readonly string[]; +ManifestIdentity · interface · userHosts?: string; +ManifestIdentity · interface · permissionOf?: (path: readonly string[]) => string | null; +ManifestIdentity · interface · } +ManifestInput · interface · export interface ManifestInput { +ManifestInput · interface · identity: ManifestIdentity; +ManifestInput · interface · commands: readonly CommandInfo[]; +ManifestInput · interface · pkg: ManifestPackage; +ManifestInput · interface · skills: boolean; +ManifestInput · interface · } +ManifestPackage · interface · export interface ManifestPackage { +ManifestPackage · interface · name?: unknown; +ManifestPackage · interface · bin?: unknown; +ManifestPackage · interface · } +SHARED_HOSTS · const · export declare const SHARED_HOSTS: readonly string[]; +SignIn · type · export type SignIn = v.InferOutput; +SignIn · type · declare const signInSchema: v.StrictObjectSchema<{ +SignIn · type · readonly gives: v.SchemaWithPipe, v.RegexAction, v.MaxLengthAction]>; +SignIn · type · readonly asks: v.SchemaWithPipe, v.RegexAction, v.MaxLengthAction]>; +SignIn · type · readonly methods: v.OptionalSchema, v.RegexAction]>; +SignIn · type · readonly label: v.SchemaWithPipe, v.RegexAction, v.MaxLengthAction]>; +SignIn · type · readonly words: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +SignIn · type · readonly stdin: v.OptionalSchema, undefined>; +SignIn · type · readonly site: v.OptionalSchema, undefined>; +SignIn · type · readonly login: v.OptionalSchema, undefined>; +SignIn · type · }, undefined>, undefined>, v.MinLengthAction<{ +SignIn · type · id: string; +SignIn · type · label: string; +SignIn · type · words: string[]; +SignIn · type · stdin?: boolean | undefined; +SignIn · type · site?: "--site" | undefined; +SignIn · type · login?: "--login" | undefined; +SignIn · type · }[], 1, undefined>]>, undefined>; +SignIn · type · }, undefined>; +buildManifest · const · export declare const buildManifest: ({ identity, commands, pkg, skills }: ManifestInput) => Manifest; +manifestSchema · const · export declare const manifestSchema: v.StrictObjectSchema<{ +manifestSchema · const · readonly wcat_manifest: v.LiteralSchema<2, undefined>; +manifestSchema · const · readonly name: v.SchemaWithPipe, v.RegexAction]>; +manifestSchema · const · readonly description: v.SchemaWithPipe, v.RegexAction, v.MaxLengthAction]>; +manifestSchema · const · readonly docs_url: v.OptionalSchema, v.UrlAction, v.StartsWithAction]>, undefined>; +manifestSchema · const · readonly package: v.SchemaWithPipe, v.RegexAction]>; +manifestSchema · const · readonly bin: v.SchemaWithPipe, v.RegexAction]>; +manifestSchema · const · readonly commands: v.ArraySchema, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly summary: v.OptionalSchema, v.RegexAction, v.MaxLengthAction]>, undefined>; +manifestSchema · const · readonly effects: v.StrictObjectSchema<{ +manifestSchema · const · readonly remote: v.PicklistSchema; +manifestSchema · const · readonly local: v.PicklistSchema; +manifestSchema · const · }, undefined>; +manifestSchema · const · readonly permission: v.OptionalSchema, v.NonEmptyAction]>, undefined>; +manifestSchema · const · readonly entity: v.OptionalSchema, v.RegexAction]>, undefined>; +manifestSchema · const · }, undefined>, undefined>; +manifestSchema · const · readonly entities: v.OptionalSchema, v.RegexAction]>, v.StrictObjectSchema<{ +manifestSchema · const · readonly fields: v.SchemaWithPipe, v.RegexAction]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · }, undefined>, undefined>, undefined>; +manifestSchema · const · readonly network: v.OptionalSchema, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>; +manifestSchema · const · readonly user_hosts: v.OptionalSchema, v.RegexAction, v.MaxLengthAction]>, undefined>; +manifestSchema · const · }, undefined>, undefined>; +manifestSchema · const · readonly desktop: v.StrictObjectSchema<{ +manifestSchema · const · readonly tagline: v.SchemaWithPipe, v.RegexAction, v.MaxLengthAction]>; +manifestSchema · const · readonly profiles: v.NullableSchema, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly shape: v.LiteralSchema<"items", undefined>; +manifestSchema · const · }, undefined>, undefined>; +manifestSchema · const · readonly doctor: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly runs: v.NullableSchema, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly show: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · }, undefined>, undefined>; +manifestSchema · const · readonly search: v.NullSchema; +manifestSchema · const · readonly setup: v.NullableSchema, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>, undefined>; +manifestSchema · const · readonly signIn: v.NullableSchema, v.RegexAction, v.MaxLengthAction]>; +manifestSchema · const · readonly asks: v.SchemaWithPipe, v.RegexAction, v.MaxLengthAction]>; +manifestSchema · const · readonly methods: v.OptionalSchema, v.RegexAction]>; +manifestSchema · const · readonly label: v.SchemaWithPipe, v.RegexAction, v.MaxLengthAction]>; +manifestSchema · const · readonly words: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly stdin: v.OptionalSchema, undefined>; +manifestSchema · const · readonly site: v.OptionalSchema, undefined>; +manifestSchema · const · readonly login: v.OptionalSchema, undefined>; +manifestSchema · const · }, undefined>, undefined>, v.MinLengthAction<{ +manifestSchema · const · id: string; +manifestSchema · const · label: string; +manifestSchema · const · words: string[]; +manifestSchema · const · stdin?: boolean | undefined; +manifestSchema · const · site?: "--site" | undefined; +manifestSchema · const · login?: "--login" | undefined; +manifestSchema · const · }[], 1, undefined>]>, undefined>; +manifestSchema · const · readonly setupFrom: v.OptionalSchema, undefined>; +manifestSchema · const · }, undefined>, undefined>; +manifestSchema · const · readonly skill: v.NullableSchema, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly install: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly show: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · }, undefined>, undefined>; +manifestSchema · const · readonly mcpServer: v.NullableSchema, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly stop: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly status: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly revoke: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly config: v.NullableSchema, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>, undefined>; +manifestSchema · const · }, undefined>, undefined>; +manifestSchema · const · readonly tasks: v.NullSchema; +manifestSchema · const · readonly sync: v.NullableSchema, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly last: v.NullableSchema, v.MaxLengthAction, v.RegexAction) => string>]>, v.SchemaWithPipe, v.RegexAction]>], undefined>, undefined>, v.MinLengthAction]>, undefined>; +manifestSchema · const · readonly lastShape: v.LiteralSchema<"runs", undefined>; +manifestSchema · const · readonly what: v.SchemaWithPipe, v.RegexAction, v.MaxLengthAction]>; +manifestSchema · const · readonly note: v.NullSchema; +manifestSchema · const · }, undefined>, undefined>; +manifestSchema · const · readonly storeInfo: v.NullSchema; +manifestSchema · const · readonly storeTables: v.NullSchema; +manifestSchema · const · readonly storeTableSizes: v.NullSchema; +manifestSchema · const · readonly storeCheck: v.NullSchema; +manifestSchema · const · readonly storeBackup: v.NullSchema; +manifestSchema · const · readonly storeBackupEncrypted: v.NullSchema; +manifestSchema · const · readonly storeResetPreview: v.NullSchema; +manifestSchema · const · readonly storeReset: v.NullSchema; +manifestSchema · const · readonly storage: v.StrictObjectSchema<{ +manifestSchema · const · readonly app: v.SchemaWithPipe, v.RegexAction]>; +manifestSchema · const · readonly env: v.SchemaWithPipe, v.RegexAction]>; +manifestSchema · const · }, undefined>; +manifestSchema · const · readonly settings: v.NullSchema; +manifestSchema · const · readonly accountRemove: v.OptionalSchema, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>, undefined>; +manifestSchema · const · readonly remove: v.NullableSchema; +manifestSchema · const · readonly keepData: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly deleteData: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly dryRun: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>; +manifestSchema · const · readonly confirm: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>; +manifestSchema · const · }, undefined>, undefined>; +manifestSchema · const · readonly removes: v.ArraySchema, undefined>; +manifestSchema · const · readonly keeps: v.ArraySchema, undefined>; +manifestSchema · const · }, undefined>, undefined>; +manifestSchema · const · readonly meetings: v.OptionalSchema, v.RegexAction]>; +manifestSchema · const · readonly show: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · readonly transcript: v.SchemaWithPipe, v.MaxLengthAction, v.RegexAction) => string>]>, undefined>, v.MinLengthAction]>; +manifestSchema · const · }, undefined>, undefined>; +manifestSchema · const · }, undefined>; +manifestSchema · const · }, undefined>; +manifestText · const · export declare const manifestText: (manifest: Manifest) => string; diff --git a/api/wcat-start.api.txt b/api/wcat-start.api.txt new file mode 100644 index 00000000..68c7b8cf --- /dev/null +++ b/api/wcat-start.api.txt @@ -0,0 +1,20 @@ +# @wirecat/cli-base "./wcat/start": the stable API, written by cli-dev api-report. Do not edit. +WcatStart · interface · export interface WcatStart { +WcatStart · interface · code?: number; +WcatStart · interface · launcher?: LauncherState; +WcatStart · interface · } +WcatStartIo · interface · export interface WcatStartIo { +WcatStartIo · interface · argv: readonly string[]; +WcatStartIo · interface · env: NodeJS.ProcessEnv; +WcatStartIo · interface · platform: NodeJS.Platform; +WcatStartIo · interface · stdout: { +WcatStartIo · interface · write: (text: string) => unknown; +WcatStartIo · interface · isTTY?: boolean; +WcatStartIo · interface · }; +WcatStartIo · interface · stderr: { +WcatStartIo · interface · write: (text: string) => unknown; +WcatStartIo · interface · isTTY?: boolean; +WcatStartIo · interface · }; +WcatStartIo · interface · script: string; +WcatStartIo · interface · } +wcatStart · const · export declare const wcatStart: (tool: WcatTool, io?: Partial) => Promise; diff --git a/cspell.json b/cspell.json index cdbe8153..65878d35 100644 --- a/cspell.json +++ b/cspell.json @@ -2,5 +2,5 @@ "version": "0.2", "files": ["README.md", "docs/standards/**/*.md"], "import": ["./config/wirecat/cspell.json"], - "words": ["bitrix", "gcal", "Glama", "hubspot", "RAML", "SECR", "upgrader", "wcat", "whatsapp", "ydisk"] + "words": ["attio", "bitrix", "gcal", "Glama", "hubspot", "RAML", "SECR", "upgrader", "wcat", "whatsapp", "ydisk"] } diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index a818a67f..3ce43643 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -23,7 +23,7 @@ and why it is built this way. | `credentials` | environment → keyring → file, warning once and falling through when the keyring refuses | | `logging` | `createRecordLog`: one `LogRecord` per JSON line (OpenTelemetry field names, flat), secrets and content-naming keys redacted at any depth, top-level keys off the allow-list (`LOG_ATTRIBUTE_KEYS` + `allow`) written without their value; `logRecordOf` builds the same record for a writer of its own; a file that cannot be written is reported to `onError`, never thrown | | `retry` | full-jitter backoff, and the distinction between "no answer came" and "safe to repeat" | -| `/testing` | `captureStreams`, `memoryKeyring`, `brokenKeyring`, `fakeClock` | +| `/testing` | `memoryKeyring`, `fakeClock`, `allowNetwork`, `expectRegisteredEvents`; `captureStreams` and `brokenKeyring` come from the root | | `/commands` | the command registry: `describeProgram`, `annotate`, `annotateOption`, `flatten`, `refuseJoinedPath`, and `commandsDocument` — the one `commands --json` shape, with its schema — see below | | `/completion` | shell completion over the registry: `suggest`, `formatSuggestions` — see below | | `/update` | keeping an install current: `installerOf`, `updateCommand`, `latestVersion`, `mayNotify`, `updateNotice`, `runUpdate` — see below | @@ -313,7 +313,11 @@ OpenAPI equivalent (digest, AWS) stop generation, unless `exclude` names the req The effect follows the method, so a POST that only reads, as Braze's exports, needs an `effect` override. The generated schemas import `@wirecat/cli-base/codegen/runtime` at run time — a few number -helpers, not the generator. Numbers are expected from a lossless JSON parser (`lossless-json`): a +helpers, not the generator. Code that reads the manifest at run time takes its types (`ManifestOperation`, +`SchemaNode`, …), `identifier`, `graphqlDocument`, `parseSelection`, `signInPlace` and `signInRequirements` from there +too: they are stable there, while `/codegen` is experimental. + +Numbers are expected from a lossless JSON parser (`lossless-json`): a 64-bit integer comes out as its exact decimal string, and any other integer that does not fit a JS number fails instead of rounding. Objects are loose, so a field the API added later passes through. Unions retain every alternative, including recursive references and Boolean literals. diff --git a/docs/dev/ARCHITECTURE.md b/docs/dev/ARCHITECTURE.md index d4368897..06607987 100644 --- a/docs/dev/ARCHITECTURE.md +++ b/docs/dev/ARCHITECTURE.md @@ -19,7 +19,7 @@ review guidelines for module size. The entry-point map below applies it to this | `/completion` | shell completion over that tree | `/commands` types | | `/update` | which installer put the CLI there, the daily notice, running the update | `config` (the state file), `/http`'s `FetchLike` | | `/codegen` | build time: an OpenAPI document → `ApiModel` → types, Valibot schemas, manifest, coverage page | nothing at run time | -| `/codegen/runtime` | the number helpers generated schemas import | `valibot` | +| `/codegen/runtime` | the number helpers generated schemas import, and the manifest types, `identifier` and the sign-in and GraphQL helpers code that runs reads the manifest with | `valibot`; type-only imports of the codegen model | | `/release` | release checks a CLI runs before it publishes: `releaseCheck` and the checks it runs (changelog shape, document links, versions in step, package contents) | Node built-ins only | | `/skill` | the CLI's SKILL.md for agents: the `skill` command, the daily hint, the MCP resource | Commander at runtime, `/update`'s state file, the root's `Renderer` and `Streams` types | | `/mcp` | local stdio MCP entry setup and a handshake probe | Node child processes; no messenger or MCP SDK dependency | @@ -27,7 +27,7 @@ review guidelines for module size. The entry-point map below applies it to this | `/wcat` | the `wcat` umbrella: dispatching to `wcat-` programs, `--wcat-describe`, the launcher and the shortcuts | Node built-ins, `cross-spawn`; the root's errors and failure rendering, loaded only when `wcat` itself runs | | `/wcat/start` | `wcatStart`, a CLI's first call: describe, dispatch mode, the launcher check | Node built-ins; the dispatcher only in dispatch mode | | `/wcat/manifest` | `contracts/wirecat.json` for WireCat Desktop: `buildManifest`, `manifestSchema`, the plain-word rule | `valibot`; `/commands` and `/standards` | -| `/testing` | `captureStreams`, `memoryKeyring`, `brokenKeyring`, `fakeClock`, `allowNetwork` | the root | +| `/testing` | `memoryKeyring`, `fakeClock`, `allowNetwork`, `expectRegisteredEvents` | the root | | `/testing/setup` | a vitest `setupFiles` entry: per-file sandbox, a keyring that throws, no network | `vitest` (optional peer) | Each is a separate `exports` entry in [`package.json`](../../package.json), built from diff --git a/docs/standards/releases.md b/docs/standards/releases.md index dcf1c839..87904437 100644 --- a/docs/standards/releases.md +++ b/docs/standards/releases.md @@ -90,7 +90,9 @@ on the [CI](ci.md) page. what the package promises to keep. A library promises only its stable API; what it marks experimental may change in a minor, so majors stay rare and work does not wait for them (NEED-2893). - **Enforced by:** `: bin/release`, which also stops a version that raises the major unless it runs with - --major. + --major; `release-start.yml:prepare`, which collects the changes/ fragments, takes the level they need and stops a + major unless the release starts with major allowed; `node-ci.yml:check`, which runs cli-dev api-report --check; + `changelog-guard.yml:guard`, which asks for the heading a change to the API report needs and for the major label. - **Example:** - A break of the stable API goes under "Changed — may break callers" or "Removed". Before 1.0.0 it raises the minor (`0.40.4` to `0.41.0`); from 1.0.0 on, the major (`1.4.0` to `2.0.0`). @@ -99,6 +101,21 @@ on the [CI](ci.md) page. - Raise the patch (`1.4.0` to `1.4.1`) only when every entry is a fix or a change to the documents. - A stable break waits for a major the owner chose. Until then it lands as an addition beside the old API, which is deprecated, never as a change in place. + - **How a library marks its stable API.** `package.json` lists the stable entry points, the `exports` keys: + `"wirecat": { "stable": [".", "./paths"] }`. An entry point not listed is experimental as a whole. Inside a stable + entry point, a declaration whose TSDoc says `@experimental` is experimental; `@deprecated` keeps its usual meaning. + A package with no `wirecat.stable` list has no API check. + - **The API report.** `cli-dev api-report` builds the package and writes `api/.api.txt` for each stable entry + point: one line per line of each stable declaration, as ` · · `, sorted by name and + without comments. Commit it with the change. In CI, `cli-dev api-report --check` fails when it differs from the + build. + - **The changelog guard reads the report's diff.** A pull request that removes or changes a line needs an entry under + "Changed — may break callers" or "Removed"; one that only adds lines needs one under "Added". From 1.0.0 on, a pull + request with an entry under either break heading also needs the `major` label, and waits for the next major. A + report the base did not have is a first one and needs nothing. + - **What the report does not see:** a change in behaviour, in JSON output or in a type the stable declarations import + from a file the entry point does not export; adding a required field to an options type shows as an addition. Pick + the heading for those by hand. - **Exceptions:** a pre-release version (`1.0.0-rc.1`) is chosen by hand and published under npm's `next` tag; the version check reads the last plain release as the one below it. - **Applies to:** all CLIs and shared libraries. **Since:** cli-base 0.41.0; the 1.0.0 rules since the next release. diff --git a/docs/standards/toolchain.md b/docs/standards/toolchain.md index 27ba228a..f8b5aba5 100644 --- a/docs/standards/toolchain.md +++ b/docs/standards/toolchain.md @@ -94,7 +94,7 @@ plus community itself. cli-template follows every rule here as a CLI does `node-22` job. - **Exceptions:** cli-docs and community publish no runtime package. tg needs `^22.19.0`. memo, drive, cli-base and the CLIs made from a template before 0.11.0 do not run Node 22 in any workflow yet. - cli-base's own `engines` is still `>=22`. The unit suite runs on Windows and macOS for tg, max and drive + The unit suite runs on Windows and macOS for tg, max and drive (`platforms: true`), and for gcal at release, monthly and on a manual run; zoom and memo still fail tests there, so theirs is off. - **Applies to:** the CLIs, cli-core and cli-base. **Since:** cli-base 0.41.0. **Rulings:** NEED-11. diff --git a/package.json b/package.json index 40c14eb4..861dd87f 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ }, "type": "module", "engines": { - "node": ">=22" + "node": "^22.16.0 || >=24" }, "packageManager": "pnpm@11.28.8", "files": [ @@ -108,7 +108,25 @@ "./tsconfig.test.json": "./config/tsconfig.test.json", "./tsconfig.scripts.json": "./config/tsconfig.scripts.json", "./lefthook.yml": "./config/lefthook.yml", - "./cspell": "./config/cspell.json" + "./cspell": "./config/cspell.json", + "./package.json": "./package.json" + }, + "wirecat": { + "stable": [ + ".", + "./http", + "./commands", + "./completion", + "./update", + "./codegen/runtime", + "./skill", + "./mcp", + "./query", + "./standards", + "./standards/tables", + "./wcat/start", + "./wcat/manifest" + ] }, "scripts": { "build": "tsc --build --force", diff --git a/scripts/changelog-guard.test.ts b/scripts/changelog-guard.test.ts index ddb26af2..9fad25d6 100644 --- a/scripts/changelog-guard.test.ts +++ b/scripts/changelog-guard.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest" -import { checkChangelog, FRAGMENTS } from "./changelog-guard.ts" +import { type ApiReport, checkChangelog, FRAGMENTS } from "./changelog-guard.ts" const entry = "- **Changed.** The thing, because of the reason." const base = (unreleasedHeading: string) => @@ -246,3 +246,47 @@ describe("restoring immutable release notes", () => { ).toBeUndefined() }) }) + +describe("the stable API report and the major label", () => { + const report = [ + '# @acme/lib "."', + "open · function · export declare function open(): void;", + "Options · interface · }", + ] + const api = (head: string[], before = report): ApiReport[] => [ + { path: "api/index.api.txt", base: before?.join("\n"), head: head.join("\n") }, + ] + const guard = (options: { + api?: ReturnType + fragments?: string[] + version?: string + labels?: string[] + }) => + checkChangelog({ title: "feat: thing", base: base("Unreleased"), head: base("Unreleased"), tags: [], ...options }) + + it("needs a break heading for a removed or changed stable line, and Added for a new one", () => { + const changed = api([report[0] as string, "open · function · export declare function open(path: string): void;"]) + expect(guard({ api: changed })).toMatch(/lost or changed "open · function · export declare function open\(\)/) + expect(guard({ api: changed, fragments: ["### Added\n\n- **Added.** It.\n"] })).toMatch(/lost or changed/) + expect(guard({ api: changed, fragments: [`### Removed\n\n${entry}\n`] })).toBeUndefined() + const grown = api([...report, "close · function · export declare function close(): void;"]) + expect(guard({ api: grown })).toMatch(/gained names; add an entry under "Added"/) + expect(guard({ api: grown, fragments: ["### Added\n\n- **Added.** close.\n"] })).toBeUndefined() + }) + + it("counts repeated lines, reads new Unreleased entries, and skips a first report", () => { + expect(guard({ api: api(report.slice(0, 2), [...report, "Options · interface · }"]) })).toMatch(/lost or changed/) + const head = base("Unreleased").replace("### Fixed", `### Changed — may break callers\n\n${entry}\n\n### Fixed`) + const changed = api([report[0] as string]) + expect(checkChangelog({ title: "feat: x", base: base("Unreleased"), head, tags: [], api: changed })).toBeUndefined() + expect(guard({ api: [{ path: "api/index.api.txt", head: report.join("\n") }] })).toBeUndefined() + }) + + it("needs the major label for a stable break from 1.0.0 on, and not before", () => { + const fragments = [`### Changed — may break callers\n\n${entry}\n`] + expect(guard({ fragments, version: "0.132.0" })).toBeUndefined() + expect(guard({ fragments, version: "1.2.0" })).toMatch(/needs a major: add the `major` label/) + expect(guard({ fragments, version: "1.2.0", labels: ["major"] })).toBeUndefined() + expect(guard({ fragments: ["### Added\n\n- **Added.** It.\n"], version: "1.2.0" })).toBeUndefined() + }) +}) diff --git a/scripts/changelog-guard.ts b/scripts/changelog-guard.ts index 704b0b2e..4544d138 100644 --- a/scripts/changelog-guard.ts +++ b/scripts/changelog-guard.ts @@ -12,6 +12,11 @@ // into the dated version only if it still publishes this commit. // 3. No `###` heading repeats inside a section the pull request leaves untagged: an entry belongs under the // section's existing heading. Only a repeat the base did not have fails, so an old one does not block others. +// 4. A change to a stable API report, `api/.api.txt` (`cli-dev api-report`), has its changelog heading among the +// entries the pull request adds: a removed or changed line needs "Changed — may break callers" or "Removed", an +// added one "Added". A report the base did not have is a first one and needs nothing. +// 5. From 1.0.0 on, a pull request that adds a stable break ("Changed — may break callers", "Removed") carries the +// `major` label: it waits for a major the owner chose (WC-REL-7). import { execFileSync } from "node:child_process" type Sections = Map @@ -21,6 +26,51 @@ const CHANGELOG_TITLE = /^\w+\((release|changelog)\)!?:/ const UNRELEASED = /^## (Unreleased|Не выпущено)\s*$/i const DATED = /^## v?(\d+\.\d+\.\d+\S*) [—–-] \S/ export const FRAGMENTS = /^changes\/(?!README\.md$)[^/]+\.md$/ +export const API_REPORTS = /^api\/[^/]+\.api\.txt$/ +const BREAKS = ["Changed — may break callers", "Removed"] + +export type ApiReport = { path: string; base?: string; head: string } + +/** The `###` headings with an entry the pull request adds, in a fragment or under the unreleased heading. */ +function addedHeadings(base: Sections, head: Sections, fragments: readonly string[]): Set { + const found = new Set() + const scan = (lines: readonly string[], fresh: (line: string) => boolean) => { + let heading: string | undefined + for (const line of lines) { + if (line.startsWith("### ")) heading = line.slice(4).trim() + else if (heading && line.trim() !== "" && !line.startsWith("#") && fresh(line)) found.add(heading) + } + } + for (const text of fragments) scan(text.split("\n"), () => true) + const unreleased = (all: Sections) => [...all].find(([heading]) => UNRELEASED.test(heading))?.[1] ?? [] + const old = new Set(unreleased(base)) + scan(unreleased(head), (line) => !old.has(line)) + return found +} + +/** Lines of `from` that `to` has fewer of; a report's lines repeat (`}`), so they are counted, not just looked up. */ +function missingLines(from: string, to: string): string[] { + const left = new Map() + for (const line of to.split("\n")) left.set(line, (left.get(line) ?? 0) + 1) + return from.split("\n").filter((line) => { + if (line.trim() === "" || line.startsWith("#")) return false + const count = left.get(line) ?? 0 + left.set(line, count - 1) + return count <= 0 + }) +} + +function apiProblem(reports: readonly ApiReport[], added: Set): string | undefined { + for (const { path, base, head } of reports) { + if (base === undefined) continue + const removed = missingLines(base, head) + if (removed.length > 0 && !BREAKS.some((heading) => added.has(heading))) + return `${path}: the stable API lost or changed "${removed[0]}"; add an entry under "Changed — may break callers" or "Removed" (WC-REL-7)` + if (removed.length === 0 && missingLines(head, base).length > 0 && !added.has("Added")) + return `${path}: the stable API gained names; add an entry under "Added" (WC-REL-7)` + } + return undefined +} function duplicateHeading(text: string): string | undefined { const seen = new Set() @@ -67,6 +117,11 @@ export function checkChangelog(input: { releasedText?: (version: string) => string | undefined /** The text of each `changes/*.md` fragment the pull request adds or edits. */ fragments?: string[] + /** Each `api/.api.txt` the pull request changes; `base` is absent for a new one. */ + api?: ApiReport[] + /** The head's package.json version and the pull request's labels, for the `major` label rule. */ + version?: string + labels?: string[] }): string | undefined { const repeated = duplicateHeading(input.head) if (repeated) return `CHANGELOG.md: duplicate heading for ${repeated}; keep one section per version` @@ -103,6 +158,13 @@ export function checkChangelog(input: { const repeat = [...repeatedSubheadings(head, tagged)].find((found) => !before.has(found)) if (repeat) return `CHANGELOG.md: ${repeat}; put the entry under the heading that is already there` + const added = addedHeadings(base, head, input.fragments ?? []) + const api = apiProblem(input.api ?? [], added) + if (api) return api + const major = Number((input.version ?? "0").split(".")[0]) + if (major >= 1 && BREAKS.some((heading) => added.has(heading)) && !input.labels?.includes("major")) + return `a stable break ("Changed — may break callers" or "Removed") needs a major: add the \`major\` label, and the pull request waits for the next major (WC-REL-7)` + if (!BREAKING_TITLE.test(input.title)) return undefined const entry = (line: string) => line.trim() !== "" && !line.startsWith("#") if (input.fragments?.some((text) => text.split("\n").some(entry))) return undefined @@ -124,30 +186,36 @@ function main() { process.exit(2) } const mergeBase = git("merge-base", baseSha, headSha).trim() - const show = (sha: string) => { + const shown = (sha: string, path: string) => { try { - return git("show", `${sha}:CHANGELOG.md`) + return git("show", `${sha}:${path}`) } catch { - return "" + return undefined } } + const show = (sha: string) => shown(sha, "CHANGELOG.md") ?? "" const fragments = git("diff", "--name-only", "--diff-filter=AM", mergeBase, headSha, "--", "changes") .split("\n") .filter((path) => FRAGMENTS.test(path)) .map((path) => git("show", `${headSha}:${path}`)) + const api = git("diff", "--name-only", mergeBase, headSha, "--", "api") + .split("\n") + .filter((path) => API_REPORTS.test(path)) + .map((path) => ({ path, base: shown(mergeBase, path), head: shown(headSha, path) ?? "" })) + let labels: string[] = [] + try { + labels = JSON.parse(process.env.LABELS || "[]") + } catch {} const message = checkChangelog({ title, fragments, + api, + labels, + version: JSON.parse(shown(headSha, "package.json") ?? "{}").version, base: show(mergeBase), head: show(headSha), tags: git("tag", "--list", "v*").split("\n").filter(Boolean), - releasedText: (version) => { - try { - return git("show", `v${version}:CHANGELOG.md`) - } catch { - return undefined - } - }, + releasedText: (version) => shown(`v${version}`, "CHANGELOG.md"), }) if (message) { console.error(message) diff --git a/src/batch.ts b/src/batch.ts index af2bcad8..c3f182a5 100644 --- a/src/batch.ts +++ b/src/batch.ts @@ -204,6 +204,7 @@ export const runBatch = async ( } } +/** @experimental */ export const projectBatchAnswers = (report: BatchReport, fields: readonly string[]): BatchReport => ({ ...report, items: report.items.map((result) => diff --git a/src/codegen/graphql-fake.ts b/src/codegen/graphql-fake.ts index 6205441e..0ba552d5 100644 --- a/src/codegen/graphql-fake.ts +++ b/src/codegen/graphql-fake.ts @@ -6,10 +6,10 @@ */ import { sampleOf, schemaProblems } from "./fake.js" -import { graphqlDocument, parseSelection, type Selection } from "./graphql.js" import type { ManifestOperation } from "./manifest.js" import type { GraphqlBinding, SchemaNode } from "./model.js" import { identifier } from "./names.js" +import { graphqlDocument, parseSelection, type Selection } from "./selection.js" type Definitions = Readonly> diff --git a/src/codegen/graphql.ts b/src/codegen/graphql.ts index 66df2123..84288678 100644 --- a/src/codegen/graphql.ts +++ b/src/codegen/graphql.ts @@ -88,52 +88,6 @@ const typeText = (ref: TypeRef): string => const named = (ref: TypeRef): string => (ref.ofType ? named(ref.ofType) : String(ref.name)) -/** Builds the one document an operation sends: every variable declared and passed, the selection inside. */ -export const graphqlDocument = (binding: GraphqlBinding, selection: string = binding.selection): string => { - const variables = Object.entries(binding.variables) - const declared = variables.length ? `(${variables.map(([name, type]) => `$${name}: ${type}`).join(", ")})` : "" - const passed = variables.length ? `(${variables.map(([name]) => `${name}: $${name}`).join(", ")})` : "" - const inner = selection.trim() ? ` { ${selection.trim()} }` : "" - return `${binding.operation} ${binding.field[0]?.toUpperCase()}${binding.field.slice(1)}${declared} { ${binding.field}${passed}${inner} }` -} - -/** A selection as a tree: a field's name → its own selection, or `true` for a leaf. */ -export interface Selection { - readonly [field: string]: Selection | true -} - -/** - * `id title state { id type }` → its tree. Only names and braces: an argument, an alias, a fragment or a directive - * throws, since nothing here can check one. - */ -export const parseSelection = (text: string): Selection => { - const tokens = text.match(/[_A-Za-z][_0-9A-Za-z]*|[{}]|\S/g) ?? [] - let at = 0 - const level = (nested: boolean): Selection => { - const fields: Record = {} - while (at < tokens.length) { - const token = tokens[at] as string - if (token === "}") { - if (!nested) throw new Error(`selection "${text}": an unmatched }`) - at += 1 - return fields - } - if (!/^[_A-Za-z]/.test(token)) - throw new Error(`selection "${text}": "${token}" — only field names and braces are supported`) - at += 1 - if (tokens[at] === "{") { - at += 1 - const inner = level(true) - if (Object.keys(inner).length === 0) throw new Error(`selection "${text}": ${token} selects nothing`) - fields[token] = inner - } else fields[token] = true - } - if (nested) throw new Error(`selection "${text}": a { is not closed`) - return fields - } - return level(false) -} - const schemaOf = (raw: unknown): Json => { const root = object(raw) && object(raw.data) ? raw.data : raw if (!object(root) || !object(root.__schema)) diff --git a/src/codegen/index.ts b/src/codegen/index.ts index e0102e47..b45b93ce 100644 --- a/src/codegen/index.ts +++ b/src/codegen/index.ts @@ -33,11 +33,8 @@ export { GRAPHQL_DELETE_REASON, type GraphqlOptions, type GraphqlProvenance, - graphqlDocument, INTROSPECTION_QUERY, - parseSelection, readGraphql, - type Selection, syncGraphql, } from "./graphql.js" export { @@ -74,6 +71,7 @@ export type { GraphqlBinding, HttpBinding, HttpMethod, + ModelOverride, OAuthFlow, OperationPermission, Override, @@ -97,16 +95,17 @@ export { applyPagination, applyPermissionRule, CodegenError, + type CodegenWriteOptions, type CommandNames, type GenerateOptions, generate, type PermissionRule, READING_POST_REASON, validateModel, - type WriteOptions, writeArtifacts, } from "./pipeline.js" export { type PostmanOptions, type PostmanResult, postmanToOpenApi } from "./postman.js" +export { graphqlDocument, parseSelection, type Selection } from "./selection.js" export { type SignInPlace, signInPlace, signInRequirements } from "./sign-in.js" export { API_SKILL_GROUPS, API_SKILL_INDEX, type ApiSkillOptions, apiSkillFiles } from "./skill.js" export { upgradeToOpenApi3 } from "./swagger.js" diff --git a/src/codegen/model.ts b/src/codegen/model.ts index 05342dd1..b620c761 100644 --- a/src/codegen/model.ts +++ b/src/codegen/model.ts @@ -257,7 +257,8 @@ export interface ApiModel { securityReason?: string } -export interface Override { +/** A correction to one operation of the model, keyed by its id in `generate`'s `overrides`. */ +export interface ModelOverride { effect?: Effect /** How the operation pages, where detection misses or misreads it; `null` says it does not page. */ pagination?: Pagination | null @@ -265,6 +266,9 @@ export interface Override { reason: string } +/** @deprecated Use `ModelOverride`; the old name clashed with the lint `Override` of `/standards/tables`. */ +export type Override = ModelOverride + export interface GeneratedArtifact { path: string content: string diff --git a/src/codegen/pipeline.ts b/src/codegen/pipeline.ts index 7c3e6c5f..b0ff0bfe 100644 --- a/src/codegen/pipeline.ts +++ b/src/codegen/pipeline.ts @@ -6,8 +6,8 @@ import type { ApiSchema, CodeGenerator, GeneratedArtifact, + ModelOverride, OperationPermission, - Override, PageParameter, Pagination, SchemaNode, @@ -229,7 +229,7 @@ export const applyPagination = ( return { ...model, operations } } -export const applyOverrides = (model: ApiModel, overrides: Readonly>): ApiModel => { +export const applyOverrides = (model: ApiModel, overrides: Readonly>): ApiModel => { const known = new Set(model.operations.map((operation) => operation.id)) const stale = Object.keys(overrides).filter((id) => !known.has(id)) if (stale.length > 0) { @@ -608,7 +608,7 @@ export const validateModel = (model: ApiModel): void => { } export interface GenerateOptions { - overrides?: Readonly> + overrides?: Readonly> /** Treat a POST to a `…/search` or `…/query` path as a read; an override still wins. */ readingPosts?: boolean /** Detect how each read pages; an override's `pagination` wins either way. */ @@ -644,7 +644,7 @@ export const generate = ( return artifacts.map((artifact) => ({ ...artifact, content: commentFor(artifact.path, banner) + artifact.content })) } -export interface WriteOptions { +export interface CodegenWriteOptions { root: string /** Compare only: report what is out of date and write nothing. */ check?: boolean @@ -658,7 +658,7 @@ export interface WriteOptions { } /** Paths whose committed content differs from what was generated — written, or with `check`, only reported. */ -export const writeArtifacts = (artifacts: readonly GeneratedArtifact[], options: WriteOptions): string[] => { +export const writeArtifacts = (artifacts: readonly GeneratedArtifact[], options: CodegenWriteOptions): string[] => { const stale: string[] = [] for (const artifact of artifacts) { const target = join(options.root, artifact.path) diff --git a/src/codegen/runtime.ts b/src/codegen/runtime.ts index 02816ae3..e74779e3 100644 --- a/src/codegen/runtime.ts +++ b/src/codegen/runtime.ts @@ -1,6 +1,8 @@ /** * What generated Valibot schemas call at run time. Kept apart from the generator so a CLI loads - * these few functions, not the code that writes code. + * these few functions, not the code that writes code. Also the stable part of the model a CLI reads the generated + * manifest with (the operation and schema types, `identifier`, the sign-in and GraphQL helpers): + * `/codegen` itself is experimental. * * Numbers arrive from a lossless JSON parser (`lossless-json` or anything shaped like its * `LosslessNumber`), because a 64-bit id read as a JS number is silently a different id. @@ -12,6 +14,7 @@ interface LosslessLike { value: string } +/** @experimental */ export const isLossless = (input: unknown): input is LosslessLike => typeof input === "object" && input !== null && @@ -71,3 +74,20 @@ export const number = (range: Range = {}) => export const unique = (items: readonly unknown[]): boolean => new Set(items.map((item) => JSON.stringify(item))).size === items.length + +export type { ManifestOperation } from "./manifest.js" +export type { + ApiServer, + Effect, + GraphqlBinding, + OAuthFlow, + OperationPermission, + PageParameter, + Pagination, + SchemaNode, + SecurityRequirement, + SecurityScheme, +} from "./model.js" +export { identifier } from "./names.js" +export { graphqlDocument, parseSelection, type Selection } from "./selection.js" +export { type SignInPlace, signInPlace, signInRequirements } from "./sign-in.js" diff --git a/src/codegen/selection.ts b/src/codegen/selection.ts new file mode 100644 index 00000000..8b52a6b5 --- /dev/null +++ b/src/codegen/selection.ts @@ -0,0 +1,48 @@ +/** The two GraphQL helpers a CLI calls at run time, apart from the adapter so they load no codegen code. */ +import type { GraphqlBinding } from "./model.js" + +/** Builds the one document an operation sends: every variable declared and passed, the selection inside. */ +export const graphqlDocument = (binding: GraphqlBinding, selection: string = binding.selection): string => { + const variables = Object.entries(binding.variables) + const declared = variables.length ? `(${variables.map(([name, type]) => `$${name}: ${type}`).join(", ")})` : "" + const passed = variables.length ? `(${variables.map(([name]) => `${name}: $${name}`).join(", ")})` : "" + const inner = selection.trim() ? ` { ${selection.trim()} }` : "" + return `${binding.operation} ${binding.field[0]?.toUpperCase()}${binding.field.slice(1)}${declared} { ${binding.field}${passed}${inner} }` +} + +/** A selection as a tree: a field's name → its own selection, or `true` for a leaf. */ +export interface Selection { + readonly [field: string]: Selection | true +} + +/** + * `id title state { id type }` → its tree. Only names and braces: an argument, an alias, a fragment or a directive + * throws, since nothing here can check one. + */ +export const parseSelection = (text: string): Selection => { + const tokens = text.match(/[_A-Za-z][_0-9A-Za-z]*|[{}]|\S/g) ?? [] + let at = 0 + const level = (nested: boolean): Selection => { + const fields: Record = {} + while (at < tokens.length) { + const token = tokens[at] as string + if (token === "}") { + if (!nested) throw new Error(`selection "${text}": an unmatched }`) + at += 1 + return fields + } + if (!/^[_A-Za-z]/.test(token)) + throw new Error(`selection "${text}": "${token}" — only field names and braces are supported`) + at += 1 + if (tokens[at] === "{") { + at += 1 + const inner = level(true) + if (Object.keys(inner).length === 0) throw new Error(`selection "${text}": ${token} selects nothing`) + fields[token] = inner + } else fields[token] = true + } + if (nested) throw new Error(`selection "${text}": a { is not closed`) + return fields + } + return level(false) +} diff --git a/src/codegen/wp-json.ts b/src/codegen/wp-json.ts index 4abe406c..8a74f6bc 100644 --- a/src/codegen/wp-json.ts +++ b/src/codegen/wp-json.ts @@ -10,7 +10,7 @@ */ import { mkdirSync, readFileSync, writeFileSync } from "node:fs" import { join } from "node:path" -import type { Override } from "./model.js" +import type { ModelOverride } from "./model.js" import { derivedId } from "./openapi.js" import { CodegenError } from "./pipeline.js" import { sha256, sortKeys } from "./snapshot.js" @@ -37,7 +37,7 @@ export interface WpJsonResult { * For `generate`'s `overrides`: how each collection read pages. WordPress answers the list itself, counts pages from * 1 and gives their number in `X-WP-TotalPages`; a page past it is an error, not an empty list. */ - overrides: Record + overrides: Record /** What the document leaves out, one line each, for a reviewer. */ omissions: string[] } @@ -184,7 +184,7 @@ export const wpJsonToOpenApi = (index: unknown, options: WpJsonOptions): WpJsonR const problems: string[] = [] const omissions: string[] = [] const paths: Record = {} - const overrides: Record = {} + const overrides: Record = {} const schemas: Record = {} const left = new Map() const schemaRef = (route: string, schema: unknown): Json => { diff --git a/src/commands/document.ts b/src/commands/document.ts index 664d3b16..d50a424d 100644 --- a/src/commands/document.ts +++ b/src/commands/document.ts @@ -75,6 +75,8 @@ const commandInfoSchema: v.GenericSchema = v.object({ /** * What ` commands --json` prints, in every CLI on cli-base. `scope` and `inherited_options` are * there only when one command path was asked for. Nothing else at the top: `cli-dev lint` refuses it. + * + * @experimental */ export const commandsDocumentSchema = v.strictObject({ cli: v.pipe(v.string(), v.nonEmpty()), @@ -101,6 +103,7 @@ export interface CommandsDocument { exit_codes: Record } +/** @experimental */ export const commandsDocumentJsonSchema = () => jsonSchemaOf(commandsDocumentSchema, { command: commandInfoSchema }) export const parseCommandsDocument = ( diff --git a/src/commands/page.ts b/src/commands/page.ts index c117a866..9d167d79 100644 --- a/src/commands/page.ts +++ b/src/commands/page.ts @@ -1,7 +1,11 @@ import { EXIT_CODES } from "../exit-codes.js" import type { ArgumentInfo, CommandInfo, OptionInfo } from "./registry.js" -/** The labels of the tables; the same for every CLI writing in one language. */ +/** + * The labels of the tables; the same for every CLI writing in one language. + * + * @experimental + */ export type CommandsPageLabels = { option: string does: string @@ -23,6 +27,7 @@ export type CommandsPageLabels = { readsOutside?: string } +/** @experimental */ export const COMMANDS_PAGE_LABELS = { en: { option: "Option", @@ -58,7 +63,11 @@ export const COMMANDS_PAGE_LABELS = { }, } as const satisfies Record -/** The CLI's own words: everything on the page that is not read out of the program. */ +/** + * The CLI's own words: everything on the page that is not read out of the program. + * + * @experimental + */ export type CommandsPageText = { /** The first line, an HTML comment saying the page is generated and by what. */ banner: string @@ -77,6 +86,7 @@ export type CommandsPageText = { outro: string } +/** @experimental */ export type CommandsPage = { cli: string commands: readonly CommandInfo[] @@ -100,6 +110,8 @@ const sentence = (text: string | undefined): string => { * The whole `docs/commands.md`: every command at any depth, every option and argument, the exit * codes. Descriptions are quoted as `--help` prints them, untranslated — a translation here would * give the sentence a second home, and the one on screen is the one that gets corrected. + * + * @experimental */ export const commandsPage = ({ cli, commands, options, labels, text, details }: CommandsPage): string => { // What a value may be and what it is when left out: Commander keeps both out of the description. diff --git a/src/completion/index.ts b/src/completion/index.ts index b60518f1..973c61f8 100644 --- a/src/completion/index.ts +++ b/src/completion/index.ts @@ -34,7 +34,11 @@ export interface CompletionRequest { sources?: CompletionSources } -/** Tells the shell not to fall back to file names when nothing matched. */ +/** + * Tells the shell not to fall back to file names when nothing matched. + * + * @experimental + */ export const NO_FILE_COMPLETION = 4 export const suggest = ({ commands, globalOptions = [], words, sources = {} }: CompletionRequest): Suggestion[] => { diff --git a/src/credentials.ts b/src/credentials.ts index 9bb6bb20..5b3aeaeb 100644 --- a/src/credentials.ts +++ b/src/credentials.ts @@ -47,6 +47,8 @@ export const keyringService = (service: string, _configDir?: string, _isolated?: /** * The temporary keyring service a moved run writes instead of the owner's entry: `:`, the * shape `bin/keyring-dedupe` already finds and removes. + * + * @experimental */ export const movedRunService = (service: string, configDir: string): string => `${service}:${resolve(configDir)}` diff --git a/src/dev/api-report.test.ts b/src/dev/api-report.test.ts new file mode 100644 index 00000000..61329388 --- /dev/null +++ b/src/dev/api-report.test.ts @@ -0,0 +1,184 @@ +import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs" +import { tmpdir } from "node:os" +import { dirname, join } from "node:path" +import { beforeEach, describe, expect, it } from "vitest" +import { apiReports, statementsOf } from "./api-report.js" +import { type DevIo, main } from "./main.js" + +let root: string +let out: string[] +let err: string[] +let io: DevIo + +const write = (path: string, text: string) => { + mkdirSync(dirname(join(root, path)), { recursive: true }) + writeFileSync(join(root, path), text) +} + +const pkg = (stable?: string[]) => + write( + "package.json", + JSON.stringify({ + name: "@acme/lib", + exports: { + ".": { types: "./dist/index.d.ts", default: "./dist/index.js" }, + "./extra": { types: "./dist/extra.d.ts", default: "./dist/extra.js" }, + "./biome": "./config/biome.json", + }, + ...(stable ? { wirecat: { stable } } : {}), + }), + ) + +const run = async (...args: string[]) => main(["api-report", "--skip-build", ...args], io) + +beforeEach(() => { + root = mkdtempSync(join(tmpdir(), "cli-dev-api-")) + out = [] + err = [] + io = { cwd: root, out: (text) => out.push(text), err: (text) => err.push(text) } + write( + "dist/index.d.ts", + [ + 'export { open, type Options, preview, Handle, renamed as alias } from "./open.js";', + '/** @experimental the whole re-export */ export { draft } from "./open.js";', + 'export type { Shape } from "valibot";', + ].join("\n"), + ) + write( + "dist/open.d.ts", + [ + "declare const schema: Inner;", + "type Inner = { size: number };", + "/** Opens it. */", + "export interface Options {", + " /** How long. */", + " timeout?: number;", + " shape: typeof schema;", + "}", + "export declare function open(path: string): void;", + "export declare function open(path: string, options: Options): void;", + "/**", + " * Not settled yet.", + " * @experimental", + " */", + "export declare const preview: () => void;", + "/** @deprecated use open */", + "export declare const renamed: string;", + "export declare const draft: number;", + "export declare class Handle {", + " private secret;", + " readonly id: T;", + "}", + "//# sourceMappingURL=open.d.ts.map", + ].join("\n"), + ) + write("dist/extra.d.ts", "export {};\n") +}) + +describe("api-report", () => { + it("does nothing for a package that lists no stable entry points", async () => { + pkg() + expect(await run("--check")).toBe(0) + expect(out.join("\n")).toMatch(/no "wirecat.stable"/) + expect(existsSync(join(root, "api"))).toBe(false) + }) + + it("writes one sorted report per stable entry, following re-exports and leaving out @experimental names", async () => { + pkg(["."]) + expect(await run()).toBe(0) + expect(readFileSync(join(root, "api/index.api.txt"), "utf8")).toBe( + [ + '# @acme/lib ".": the stable API, written by cli-dev api-report. Do not edit.', + "Handle · class · export declare class Handle {", + "Handle · class · readonly id: T;", + "Handle · class · }", + "Options · interface · export interface Options {", + "Options · interface · timeout?: number;", + "Options · interface · shape: typeof schema;", + "Options · interface · }", + "Options · interface · declare const schema: Inner;", + "Options · interface · type Inner = { size: number };", + 'Shape · re-export · Shape from "valibot"', + "alias · const · export declare const renamed: string;", + "open · function · export declare function open(path: string): void;", + "open · function · export declare function open(path: string, options: Options): void;", + "", + ].join("\n"), + ) + }) + + it("passes --check while the committed report matches, and fails a stale or leftover one", async () => { + pkg(["."]) + await run() + expect(await run("--check")).toBe(0) + write("dist/open.d.ts", readFileSync(join(root, "dist/open.d.ts"), "utf8").replace("timeout?", "timeoutMs?")) + write("api/old.api.txt", "# gone\n") + expect(await run("--check")).toBe(1) + expect(err).toEqual([ + "api/index.api.txt differs from the build: run cli-dev api-report and commit it", + "api/old.api.txt reports no stable entry point any more: run cli-dev api-report", + ]) + }) + + it("names a stable entry that is not an export, has no types, or is not built", () => { + pkg([".", "./biome", "./missing"]) + expect(apiReports(root).problems).toEqual([ + 'package.json: stable entry "./biome" has no "types" file to report on', + 'package.json: "wirecat.stable" lists "./missing", which is not an "exports" key', + ]) + pkg(["./extra"]) + write("dist/extra.d.ts", "declare const x: 1;\nexport = x;\n") + expect(apiReports(root).problems).toEqual([ + expect.stringMatching(/extra\.d\.ts: cli-dev api-report cannot read "export = x;"/), + ]) + }) + + it("follows an import exported again, export type *, a namespace, and a module augmentation the entry loads", () => { + pkg(["./extra"]) + write( + "dist/extra.d.ts", + [ + 'import type { Options as Settings } from "./open.js";', + 'import * as tools from "./tools.js";', + "export { Settings, tools };", + 'export type * from "./tools.js";', + 'export * as more from "./tools.js";', + ].join("\n"), + ) + write( + "dist/tools.d.ts", + [ + 'declare module "@acme/base" {', + " interface Meta {", + " flag?: boolean;", + " }", + "}", + "export declare const tool: () => void;", + ].join("\n"), + ) + expect(apiReports(root)).toEqual({ problems: [], files: expect.any(Map) }) + expect(apiReports(root).files.get("api/extra.api.txt")?.split("\n").slice(1, -1)).toEqual([ + "Settings · interface · export interface Options {", + "Settings · interface · timeout?: number;", + "Settings · interface · shape: typeof schema;", + "Settings · interface · }", + "Settings · interface · declare const schema: Inner;", + "Settings · interface · type Inner = { size: number };", + 'module "@acme/base" · augmentation · declare module "@acme/base" {', + 'module "@acme/base" · augmentation · interface Meta {', + 'module "@acme/base" · augmentation · flag?: boolean;', + 'module "@acme/base" · augmentation · }', + 'module "@acme/base" · augmentation · }', + "more · namespace · tool · const · export declare const tool: () => void;", + "tool · const · export declare const tool: () => void;", + "tools · namespace · tool · const · export declare const tool: () => void;", + ]) + }) + + it("splits statements at a body's closing brace and keeps each one's doc comment", () => { + expect(statementsOf("/** a */\nexport interface A {\n b: { c: 1 }\n}\nexport type D = 1;\n")).toEqual([ + { text: "export interface A {\n b: { c: 1 }\n}", doc: "/** a */" }, + { text: "export type D = 1;", doc: "" }, + ]) + }) +}) diff --git a/src/dev/api-report.ts b/src/dev/api-report.ts new file mode 100644 index 00000000..175074cd --- /dev/null +++ b/src/dev/api-report.ts @@ -0,0 +1,370 @@ +/** + * The stable API of a package, as text a pull request diffs: `package.json`'s `wirecat.stable` names the stable entry + * points, and inside them a declaration whose TSDoc says `@experimental` is left out. Read from the emitted `.d.ts` + * with a small scanner, because TypeScript 7 ships no compiler API to walk them with. + */ +import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs" +import { dirname, join } from "node:path" +import { parseArgs } from "node:util" +import spawn from "cross-spawn" +import type { DevIo } from "./main.js" +import { declarationOf, RELATIVE_MODULE, STRINGS_AND_COMMENTS, typesIn } from "./result-shape.js" + +export const API_REPORT_USAGE = ` api-report [--check] [--skip-build] + builds the package, then writes api/.api.txt for each + entry point package.json lists in "wirecat.stable", without + the names whose TSDoc says @experimental; --check fails when a + committed report differs. Does nothing without that list` + +export const API_DIR = "api" +export const API_SUFFIX = ".api.txt" + +interface Statement { + text: string + doc: string +} + +interface Name { + kinds: string[] + lines: string[] + experimental: boolean +} + +interface Module { + exports: Map + /** `declare module "x"` and `declare global` blocks: they apply wherever the file is loaded. */ + ambient: Map + /** The declaration files this one imports or re-exports from. */ + reaches: string[] +} + +const skipLiteral = (source: string, at: number): number => { + const char = source[at] + if (char === "/" && source[at + 1] === "*") { + const end = source.indexOf("*/", at + 2) + return end < 0 ? source.length : end + 2 + } + if (char === "/" && source[at + 1] === "/") { + const end = source.indexOf("\n", at) + return end < 0 ? source.length : end + } + if (char === '"' || char === "'" || char === "`") { + let end = at + 1 + while (end < source.length && source[end] !== char) end += source[end] === "\\" ? 2 : 1 + return end + 1 + } + return at +} + +const BLOCK = + /^(?:export\s+)?(?:declare\s+)?(?:default\s+)?(?:abstract\s+)?(?:interface|class|enum|const\s+enum|namespace|module|global)\b/ + +/** Top-level statements with the `/** … *\/` comment right before each. */ +export const statementsOf = (source: string): Statement[] => { + const found: Statement[] = [] + let doc = "" + let at = 0 + while (at < source.length) { + if (/\s/.test(source[at] as string)) { + at += 1 + continue + } + const skipped = skipLiteral(source, at) + if (skipped > at && source[at] === "/") { + if (source.startsWith("/**", at)) doc = source.slice(at, skipped) + at = skipped + continue + } + const start = at + const block = BLOCK.test(source.slice(start, start + 200)) + let depth = 0 + for (; at < source.length; at += 1) { + const past = skipLiteral(source, at) + if (past > at) { + at = past - 1 + continue + } + const char = source[at] as string + if ("{([".includes(char)) depth += 1 + else if ("})]".includes(char)) { + depth -= 1 + // A body closes at the end of its line; a `}` inside generics (``) does not. + if (depth === 0 && char === "}" && block && /^[ \t]*(?:\n|$)/.test(source.slice(at + 1, at + 80))) { + at += 1 + break + } + } else if (char === ";" && depth === 0) { + at += 1 + break + } + } + found.push({ text: source.slice(start, at), doc }) + doc = "" + } + return found +} + +const linesOf = (text: string): string[] => + text + .replace(STRINGS_AND_COMMENTS, (match) => (match.startsWith("/") ? "" : match)) + .split("\n") + .map((line) => line.trim().replace(/\s+/g, " ")) + .filter((line) => line !== "" && !/^(?:private\b|#private\b)/.test(line)) + +const EXPERIMENTAL = /@experimental\b/ +const DECLARATION = + /^(export\s+)?(?:declare\s+)?(?:abstract\s+)?(const\s+enum|const|let|var|function|class|interface|type|enum|namespace)\s+([\w$]+)/ +const STAR = /^export\s+(?:type\s+)?\*\s+(?:as\s+([\w$]+)\s+)?from\s*["']([^"']+)["']/ +const LIST = /^export\s+(?:type\s+)?\{([^}]*)\}(?:\s*from\s*["']([^"']+)["'])?/ +const IMPORT_LIST = /^import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/ +const IMPORT_ALL = /^import\s+(?:type\s+)?\*\s+as\s+([\w$]+)\s+from\s*["']([^"']+)["']/ +/** `declare module "x" { … }` changes another package's types for every caller, so it is API too. */ +const AMBIENT = /^declare\s+(module\s+["'][^"']+["']|global)/ + +const merge = (into: Name | undefined, add: Name): Name => + into === undefined + ? { kinds: [...add.kinds], lines: [...add.lines], experimental: add.experimental } + : { + kinds: [...new Set([...into.kinds, ...add.kinds])].sort(), + lines: [...into.lines, ...add.lines], + experimental: into.experimental || add.experimental, + } + +const byName = ([a]: [string, T], [b]: [string, T]) => (a < b ? -1 : a > b ? 1 : 0) + +const namespaceOf = (exports: Map): Name => ({ + kinds: ["namespace"], + lines: [...exports] + .filter(([, name]) => !name.experimental) + .sort(byName) + .flatMap(([member, { kinds, lines }]) => lines.map((line) => `${member} · ${kinds.join("+")} · ${line}`)), + experimental: false, +}) + +const itemsOf = (list: string) => + list + .split(",") + .map((item) => item.trim().replace(/^type\s+/, "")) + .filter(Boolean) + .map((item) => { + const [original = "", alias = original] = item.split(/\s+as\s+/) + return { original, alias } + }) + +/** The exports of one `.d.ts` file; a non-exported local a declaration names is reported with it. */ +const moduleOf = (file: string, cache: Map, problems: string[]): Module => { + const cached = cache.get(file) + if (cached) return cached + const text = readFileSync(file, "utf8") + const reaches = [...text.matchAll(RELATIVE_MODULE)].flatMap( + ([, from]) => declarationOf(dirname(file), from as string) ?? [], + ) + const module: Module = { exports: new Map(), ambient: new Map(), reaches: [...new Set(reaches)].sort() } + cache.set(file, module) + const locals = new Map() + const exported = new Set() + const imports = new Map() + const lists: { marked: boolean; flat: string }[] = [] + for (const statement of statementsOf(text)) { + const lines = linesOf(statement.text) + const flat = lines.join(" ") + const experimental = EXPERIMENTAL.test(statement.doc) + if (flat === "" || /^export\s*\{\s*\}\s*;?$/.test(flat)) continue + const declared = DECLARATION.exec(flat) + const imported = IMPORT_LIST.exec(flat) + const all = IMPORT_ALL.exec(flat) + const ambient = AMBIENT.exec(flat) + if (declared) { + const [, isExported, kind = "", name = ""] = declared + locals.set(name, merge(locals.get(name), { kinds: [kind.replace(/\s+/g, " ")], lines, experimental })) + if (isExported) exported.add(name) + } else if (imported) + for (const { original, alias } of itemsOf(imported[1] ?? "")) + imports.set(alias, { from: imported[2] ?? "", original }) + else if (all) imports.set(all[1] ?? "", { from: all[2] ?? "", original: "*" }) + else if (ambient) { + const key = ambient[1] ?? "" + module.ambient.set(key, merge(module.ambient.get(key), { kinds: ["augmentation"], lines, experimental })) + } else if (/^export\s+default\b/.test(flat)) + module.exports.set("default", { kinds: ["default"], lines, experimental }) + else if (STAR.test(flat) || LIST.test(flat)) lists.push({ marked: experimental, flat }) + else if (!/^import\b/.test(flat)) problems.push(`${file}: cli-dev api-report cannot read "${flat.slice(0, 80)}"`) + } + const withLocals = (name: string): Name => { + const own = locals.get(name) as Name + const lines = [...own.lines] + const seen = new Set([name]) + for (let at = 0; at < lines.length; at += 1) + for (const [word] of (lines[at] as string).matchAll(/[\w$]+/g)) { + const local = locals.get(word) + if (local === undefined || seen.has(word) || exported.has(word)) continue + seen.add(word) + for (const line of local.lines) lines.push(line) + } + return { ...own, lines } + } + /** Another package's name is reported by where it comes from: its types are that package's API. */ + const resolve = (from: string, original: string): Name | undefined => { + const outside = { kinds: ["re-export"], lines: [`${original} from "${from}"`], experimental: false } + if (!from.startsWith(".")) return outside + const target = declarationOf(dirname(file), from) + if (target === undefined) { + problems.push(`${file}: no declaration file for "${from}"`) + return undefined + } + const exports = moduleOf(target, cache, problems).exports + const found = original === "*" ? namespaceOf(exports) : exports.get(original) + if (found === undefined) problems.push(`${file}: exports "${original}", which ${from} does not declare`) + return found + } + for (const name of exported) module.exports.set(name, withLocals(name)) + for (const { marked, flat } of lists) { + const add = (alias: string, found: Name | undefined) => { + if (found) module.exports.set(alias, { ...found, experimental: found.experimental || marked }) + } + const star = STAR.exec(flat) + if (star) { + const [, namespace, from = ""] = star + if (namespace) add(namespace, resolve(from, "*")) + else if (!from.startsWith(".")) problems.push(`${file}: cli-dev api-report cannot follow "export * from ${from}"`) + else { + const target = declarationOf(dirname(file), from) + if (target === undefined) problems.push(`${file}: no declaration file for "${from}"`) + else for (const [name, found] of moduleOf(target, cache, problems).exports) add(name, found) + } + continue + } + const [, list = "", from] = LIST.exec(flat) ?? [] + for (const { original, alias } of itemsOf(list)) { + const via = imports.get(original) + if (from !== undefined) add(alias, resolve(from, original)) + else if (locals.has(original)) add(alias, withLocals(original)) + else if (via) add(alias, resolve(via.from, via.original)) + else problems.push(`${file}: exports "${original}", which the file does not declare`) + } + } + return module +} + +/** The augmentations of every declaration file the entry point loads, in file order. */ +const ambientFrom = (entry: string, cache: Map, problems: string[]): Map => { + const found = new Map() + const seen = new Set([entry]) + const queue = [entry] + for (let file = queue.shift(); file !== undefined; file = queue.shift()) { + const { ambient, reaches } = moduleOf(file, cache, problems) + for (const [key, name] of ambient) found.set(key, merge(found.get(key), name)) + for (const next of reaches.filter((one) => !seen.has(one))) { + seen.add(next) + queue.push(next) + } + } + return found +} + +export const reportFileOf = (entry: string): string => + `${API_DIR}/${entry === "." ? "index" : entry.replace(/^\.\//, "").replaceAll("/", "-")}${API_SUFFIX}` + +/** The stable entry points `package.json` lists, or undefined when it lists none (the package opted out). */ +export const stableEntries = (pkg: Record): unknown => + (pkg.wirecat as { stable?: unknown } | undefined)?.stable + +/** + * One report per stable entry point, keyed by its path under `api/`: ` · · ` for each line of each + * stable declaration, sorted by name, so a pull request that removes or changes a stable name shows a removed line. + */ +export const apiReports = (cwd: string): { files: Map; problems: string[] } => { + const pkg = JSON.parse(readFileSync(join(cwd, "package.json"), "utf8")) as Record + const stable = stableEntries(pkg) + const files = new Map() + const problems: string[] = [] + if (!Array.isArray(stable) || !stable.every((entry) => typeof entry === "string")) + return { + files, + problems: ['package.json: "wirecat.stable" must be a list of "exports" keys, such as [".", "./http"]'], + } + const exports = (typeof pkg.exports === "object" && pkg.exports !== null ? pkg.exports : {}) as Record< + string, + unknown + > + const cache = new Map() + for (const entry of stable) { + if (!(entry in exports)) { + problems.push(`package.json: "wirecat.stable" lists "${entry}", which is not an "exports" key`) + continue + } + const [types] = typesIn(exports[entry], typeof exports[entry] === "string" ? "types" : undefined).filter((path) => + path.endsWith(".d.ts"), + ) + if (types === undefined) { + problems.push(`package.json: stable entry "${entry}" has no "types" file to report on`) + continue + } + const file = join(cwd, types) + if (!existsSync(file)) { + problems.push(`${types} is not built: build the package before cli-dev api-report`) + continue + } + const names = [...moduleOf(file, cache, problems).exports, ...ambientFrom(file, cache, problems)] + .filter(([, name]) => !name.experimental) + .sort(byName) + const lines = names.flatMap(([name, { kinds, lines }]) => + lines.map((line) => `${name} · ${kinds.join("+")} · ${line}`), + ) + const header = `# ${String(pkg.name)} "${entry}": the stable API, written by cli-dev api-report. Do not edit.` + files.set(reportFileOf(entry), `${[header, ...lines].join("\n")}\n`) + } + return { files, problems } +} + +const report = (io: DevIo, problems: readonly string[], ok: string) => { + for (const problem of problems) io.err(problem) + if (problems.length > 0) return 1 + io.out(ok) + return 0 +} + +/** The stable API report under api/: written, or with `--check` compared with the committed one. */ +export const apiReportCommand = (args: string[], io: DevIo): number => { + const { values } = parseArgs({ + args, + options: { check: { type: "boolean", default: false }, "skip-build": { type: "boolean", default: false } }, + }) + const pkg = JSON.parse(readFileSync(join(io.cwd, "package.json"), "utf8")) as Record + if (stableEntries(pkg) === undefined) { + io.out('package.json lists no "wirecat.stable" entry points: no API report') + return 0 + } + if (!values["skip-build"]) { + const manager = String(pkg.packageManager ?? "npm").split("@")[0] || "npm" + const built = spawn.sync(manager, ["run", "build"], { cwd: io.cwd, stdio: ["ignore", "inherit", "inherit"] }) + if (built.status !== 0) { + io.err(`${manager} run build failed: the API report reads the built .d.ts files`) + return 1 + } + } + const { files, problems } = apiReports(io.cwd) + if (problems.length > 0) return report(io, problems, "") + const dir = join(io.cwd, API_DIR) + const committed = existsSync(dir) ? readdirSync(dir).filter((name) => name.endsWith(API_SUFFIX)) : [] + const stale = committed.map((name) => `${API_DIR}/${name}`).filter((path) => !files.has(path)) + if (values.check) { + const differ = [...files].filter(([path, text]) => { + const file = join(io.cwd, path) + return !existsSync(file) || readFileSync(file, "utf8") !== text + }) + return report( + io, + [ + ...differ.map(([path]) => `${path} differs from the build: run cli-dev api-report and commit it`), + ...stale.map((path) => `${path} reports no stable entry point any more: run cli-dev api-report`), + ], + `${API_DIR}/: ${files.size} API reports match the build`, + ) + } + mkdirSync(dir, { recursive: true }) + for (const [path, text] of files) writeFileSync(join(io.cwd, path), text) + for (const path of stale) rmSync(join(io.cwd, path)) + io.out(`${API_DIR}/: wrote ${files.size} API reports${stale.length > 0 ? `, removed ${stale.join(", ")}` : ""}`) + return 0 +} diff --git a/src/dev/main.ts b/src/dev/main.ts index 9ffc25cf..8b866a49 100644 --- a/src/dev/main.ts +++ b/src/dev/main.ts @@ -23,12 +23,10 @@ import { docsProblems, fragmentProblems, JOURNAL_IDS, - levelledVersion, markdownFiles, packageVersion, readFragments, structureProblems, - versionLevelProblem, versionScript, } from "../release/index.js" import { AUDIT_BLOCKS, defineParityGroups, PARITY_GROUPS, REQUIRED_ROOTS } from "../standards/audit.js" @@ -51,6 +49,7 @@ import { issuesOf, RegistryError } from "../standards/registry.js" import { VOCABULARY } from "../standards/vocabulary.js" import { buildManifest, MANIFEST_FILE, ManifestError, type ManifestIdentity, manifestText } from "../wcat/manifest.js" import { adopt } from "./adopt.js" +import { API_REPORT_USAGE, apiReportCommand } from "./api-report.js" import { type AuditInput, auditClis, scorecardTable, sharedDifferences, sharedReviews, snakeKeys } from "./audit.js" import { readCapabilities } from "./capabilities.js" import { CONFORMANCE_USAGE, conformanceCommand } from "./conformance.js" @@ -58,7 +57,7 @@ import { familyPackages, installFamily } from "./family.js" import { changelogChange, landChange, landFold, newestTag, processShell, restoreChange } from "./land.js" import { baselineOf, judge, lintCommands, misfiled, RUN_LOG_COMMANDS, type RunLogProbe, walk } from "./lint.js" import { type NetworkContext, readSources } from "./network.js" -import { nextVersion } from "./next-version.js" +import { levelCommand, nextVersion } from "./next-version.js" import { READY_USAGE, ready } from "./ready.js" import { readDeclarations } from "./result-shape.js" import type { ContractEdit } from "./shared-contracts.js" @@ -149,7 +148,8 @@ const USAGE = `usage: cli-dev [options] __dirname was read and found harmless. Fails when a bundled module would look for a file or package in the wrong place ${CONFORMANCE_USAGE} -${READY_USAGE}` +${READY_USAGE} +${API_REPORT_USAGE}` const load = async (cwd: string, path: string): Promise> => (await import(pathToFileURL(isAbsolute(path) ? path : join(cwd, path)).href)) as Record @@ -219,25 +219,10 @@ const fragments = (args: string[], io: DevIo) => { return 0 } -/** The top section's version level: with `--next `, the version it needs; without, whether it has it. */ -const level = (args: string[], io: DevIo) => { - const { values } = parseArgs({ - args, - options: { next: { type: "string" }, file: { type: "string", default: "CHANGELOG.md" } }, - }) - const text = readFileSync(isAbsolute(values.file) ? values.file : join(io.cwd, values.file), "utf8") - if (values.next) { - io.out(levelledVersion(text, values.next)) - return 0 - } - const problem = versionLevelProblem(text) - return report(io, problem ? [problem] : [], `${values.file}: the top section's version fits its headings`) -} - const changelog = (args: string[], io: DevIo) => { const [action, ...rest] = args if (action === "fragments") return fragments(rest, io) - if (action === "level") return level(rest, io) + if (action === "level") return levelCommand(rest, io) if (action !== "fold" && action !== "restore") { io.err(`cli-dev changelog: no action "${action ?? ""}" — the ones there are: fold, restore, fragments, level`) return 2 @@ -1045,6 +1030,8 @@ export const main = async (argv: readonly string[], io: DevIo): Promise } case "changelog": return changelog(args, io) + case "api-report": + return apiReportCommand(args, io) case "docs-check": return docsCheck(args, io) case "test-matrix": diff --git a/src/dev/next-version.ts b/src/dev/next-version.ts index 900520a8..ca65f175 100644 --- a/src/dev/next-version.ts +++ b/src/dev/next-version.ts @@ -1,3 +1,9 @@ +import { readFileSync } from "node:fs" +import { isAbsolute, join } from "node:path" +import { parseArgs } from "node:util" +import { levelledVersion, versionLevelProblem } from "../release/level.js" +import type { DevIo } from "./main.js" + /** * The version `bin/release` publishes: the one in package.json when npm has not taken it and it is * above npm's latest, else the next free one at the same bump level (x.0.0 → major from 1.0.0 on, x.y.0 → minor, @@ -43,3 +49,20 @@ export const nextVersion = ( while (taken.has(next.join("."))) next = step(next) return { version: next.join(".") } } + +/** The top section's version level: with `--next `, the version it needs; without, whether it has it. */ +export const levelCommand = (args: string[], io: DevIo): number => { + const { values } = parseArgs({ + args, + options: { next: { type: "string" }, file: { type: "string", default: "CHANGELOG.md" } }, + }) + const text = readFileSync(isAbsolute(values.file) ? values.file : join(io.cwd, values.file), "utf8") + if (values.next) { + io.out(levelledVersion(text, values.next)) + return 0 + } + const problem = versionLevelProblem(text) + if (problem) io.err(problem) + else io.out(`${values.file}: the top section's version fits its headings`) + return problem ? 1 : 0 +} diff --git a/src/dev/result-shape.ts b/src/dev/result-shape.ts index fc55c032..26d8d131 100644 --- a/src/dev/result-shape.ts +++ b/src/dev/result-shape.ts @@ -8,16 +8,16 @@ export interface Declarations { missing: readonly string[] } -const typesIn = (value: unknown, key?: string): string[] => { +export const typesIn = (value: unknown, key?: string): string[] => { if (typeof value === "string") return key === "types" || key === "typings" ? [value] : [] if (Array.isArray(value)) return value.flatMap((one) => typesIn(one)) if (typeof value === "object" && value !== null) return Object.entries(value).flatMap(([at, one]) => typesIn(one, at)) return [] } -const RELATIVE_MODULE = /(?:\bfrom\s*|\bimport\s*\(\s*)["'](\.{1,2}\/[^"']+)["']/g +export const RELATIVE_MODULE = /(?:\bfrom\s*|\bimport\s*\(\s*)["'](\.{1,2}\/[^"']+)["']/g -const declarationOf = (dir: string, specifier: string): string | undefined => { +export const declarationOf = (dir: string, specifier: string): string | undefined => { const base = join(dir, specifier) const candidates = /\.[cm]?js$/.test(base) ? [base.replace(/\.(c|m)?js$/, ".d.$1ts")] @@ -53,7 +53,8 @@ export const readDeclarations = (cwd: string): Declarations => { return { files, missing } } -const STRINGS_AND_COMMENTS = /\/\/[^\n]*|\/\*[\s\S]*?\*\/|"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'|`(?:[^`\\]|\\.)*`/g +export const STRINGS_AND_COMMENTS = + /\/\/[^\n]*|\/\*[\s\S]*?\*\/|"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'|`(?:[^`\\]|\\.)*`/g const OPEN = "([{<" const CLOSE = ")]}>" diff --git a/src/executable.ts b/src/executable.ts index 312939de..0dff3b89 100644 --- a/src/executable.ts +++ b/src/executable.ts @@ -4,6 +4,7 @@ import { win32 } from "node:path" const variable = (env: NodeJS.ProcessEnv, name: string) => Object.entries(env).find(([key]) => key.toUpperCase() === name)?.[1] +/** @experimental */ export const executableOnPath = ( command: string, env: NodeJS.ProcessEnv, @@ -25,6 +26,7 @@ export const executableOnPath = ( return command } +/** @experimental */ export const executableEnvironment = ( env: NodeJS.ProcessEnv, platform: NodeJS.Platform = process.platform, diff --git a/src/http/fetch.ts b/src/http/fetch.ts index 93c984ae..1d2e55a5 100644 --- a/src/http/fetch.ts +++ b/src/http/fetch.ts @@ -16,6 +16,7 @@ export interface HostFetchOptions { credentialScope?: string } +/** @experimental */ export const HOST_FETCH_TIMEOUT_MS = 30_000 const REDIRECTS = 5 const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]) diff --git a/src/http/hosts.ts b/src/http/hosts.ts index 21c02325..89259293 100644 --- a/src/http/hosts.ts +++ b/src/http/hosts.ts @@ -1,8 +1,13 @@ const LABEL = "[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?" -/** A lower-case hostname, or `*.` and at least two labels: `api.acme.example`, `*.cdn.acme.example`, never `*.com`. */ +/** + * A lower-case hostname, or `*.` and at least two labels: `api.acme.example`, `*.cdn.acme.example`, never `*.com`. + * + * @experimental + */ export const HOST_PATTERN = new RegExp(`^(?:${LABEL}(?:\\.${LABEL})*|\\*\\.${LABEL}(?:\\.${LABEL})+)$`) +/** @experimental */ export const hostProblems = (hosts: readonly string[]): string[] => [ ...hosts .filter((host) => !HOST_PATTERN.test(host) || host.length > 253) @@ -13,7 +18,11 @@ export const hostProblems = (hosts: readonly string[]): string[] => [ ...hosts.filter((host, at) => hosts.indexOf(host) !== at).map((host) => `${JSON.stringify(host)} is listed twice`), ] -/** `*.x` covers every name under `x`, but not `x` itself. */ +/** + * `*.x` covers every name under `x`, but not `x` itself. + * + * @experimental + */ export const hostCovered = (hostname: string, hosts: readonly string[]): boolean => { const name = hostname.toLowerCase().replace(/\.$/, "") return hosts.some((host) => (host.startsWith("*.") ? name.endsWith(host.slice(1)) : name === host)) diff --git a/src/http/index.ts b/src/http/index.ts index ab850044..823894c1 100644 --- a/src/http/index.ts +++ b/src/http/index.ts @@ -12,7 +12,11 @@ import { realSleep, type SleepLike, type WallClock, wallClock } from "../time.js /** The one function an HTTP client needs from its environment. A Worker, a browser, a test and Node all satisfy it. */ export type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise -/** `Retry-After` is either a number of seconds or an HTTP date. Both forms occur in the wild. */ +/** + * `Retry-After` is either a number of seconds or an HTTP date. Both forms occur in the wild. + * + * @experimental + */ export const parseRetryAfter = (header: string | null | undefined, now: WallClock): number | undefined => { if (!header) return undefined @@ -28,7 +32,11 @@ export const parseRetryAfter = (header: string | null | undefined, now: WallCloc return delta > 0 ? delta : undefined } -/** A Unix timestamp in seconds, the shape several providers use for `X-RateLimit-Reset`. */ +/** + * A Unix timestamp in seconds, the shape several providers use for `X-RateLimit-Reset`. + * + * @experimental + */ export const parseRateLimitReset = (header: string | null | undefined, now: WallClock): number | undefined => { if (!header) return undefined diff --git a/src/index.ts b/src/index.ts index 861fd889..30c0a7e2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,7 +37,6 @@ export { mcpErrorResult, type RenderErrorOptions, renderError, - retryOf, } from "./failure.js" export { brokenKeyring, type KeyringStore, memoryKeyring, systemKeyring } from "./keyring.js" export type { Logger } from "./logger.js" @@ -64,7 +63,6 @@ export { backoffMs, DEFAULT_RETRY, type RetryConfig } from "./retry.js" export { singleLine, visibleControls } from "./sanitize.js" export { captureStreams, processStreams, type Streams } from "./streams.js" export { - abortError, type MonotonicClock, monotonic, realSleep, diff --git a/src/logging.ts b/src/logging.ts index 188bcbab..45ac5ee9 100644 --- a/src/logging.ts +++ b/src/logging.ts @@ -6,6 +6,8 @@ import { isContentKey, LOG_ATTRIBUTE_KEYS, type LogRecord, type LogSeverity } fr * Field names whose value must never reach a log file. This is the **second** line of defence, not * the first: a secret should not be handed to a logger at all. Redaction catches the one that * slipped into a nested object nobody thought about. + * + * @experimental */ export const REDACTED_FIELDS = [ "authorization", @@ -43,6 +45,7 @@ export interface RecordLogOptions { now?: () => Date } +/** @experimental */ export const NOT_ALLOWED = "[not allowed]" export interface RecordInput { diff --git a/src/mcp/index.ts b/src/mcp/index.ts index eaa77068..4fe93673 100644 --- a/src/mcp/index.ts +++ b/src/mcp/index.ts @@ -38,6 +38,7 @@ const presentIn = (client: McpClient, name: string, run: RunCommand): boolean => return state === "registered" } +/** @experimental */ export const setupArguments = (client: McpClient, name: string, entry: StdioEntry): string[] => { const variables = Object.entries(entry.env ?? {}).flatMap(([key, value]) => ["--env", `${key}=${value}`]) if (client === "codex") return ["mcp", "add", name, ...variables, "--", entry.command, ...entry.args] @@ -48,7 +49,11 @@ const checkName = (name: string) => { if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(name)) throw new Error("the MCP name must be letters, digits, _ or -") } -/** `unavailable`: the client is not installed here, or could not be started. */ +/** + * `unavailable`: the client is not installed here, or could not be started. + * + * @experimental + */ export type StdioEntryState = "registered" | "missing" | "unavailable" const lookUp = (client: McpClient, name: string, run: RunCommand): StdioEntryState => { @@ -62,7 +67,11 @@ const lookUp = (client: McpClient, name: string, run: RunCommand): StdioEntrySta return "missing" } -/** Whether the client has a server by this name; reads only, through the client's own `mcp get`. */ +/** + * Whether the client has a server by this name; reads only, through the client's own `mcp get`. + * + * @experimental + */ export const stdioEntryStatus = ( client: McpClient, name: string, @@ -72,11 +81,16 @@ export const stdioEntryStatus = ( return { client, name, state: lookUp(client, name, run) } } +/** @experimental */ export const removeArguments = (client: McpClient, name: string): string[] => // Claude Code without a scope removes from whichever scope holds the name, which may be a project's own entry. client === "codex" ? ["mcp", "remove", name] : ["mcp", "remove", "--scope", "user", name] -/** Takes out what `installStdioEntry` added; a name the client does not have is left alone and reported. */ +/** + * Takes out what `installStdioEntry` added; a name the client does not have is left alone and reported. + * + * @experimental + */ export const removeStdioEntry = ( client: McpClient, name: string, diff --git a/src/output-buffer.ts b/src/output-buffer.ts index 788f0f1c..e030755d 100644 --- a/src/output-buffer.ts +++ b/src/output-buffer.ts @@ -2,11 +2,13 @@ import { CliError, isCliError } from "./errors.js" import type { RenderFormat } from "./renderer.js" import { fieldsOf, projectFields } from "./result-fields.js" +/** @experimental */ export interface OutputBufferOptions { maxOutputBytes?: number fields?: string format?: RenderFormat } +/** @experimental */ export interface OutputBuffer { readonly bytes: number /** Raw output chunks, including any delimiters. Projection requires complete JSON values/JSONL lines. */ @@ -16,6 +18,7 @@ export interface OutputBuffer { discard(): void } +/** @experimental */ export const createOutputBuffer = ({ maxOutputBytes = 4 * 1024 * 1024, fields, diff --git a/src/query/dates.ts b/src/query/dates.ts index 18164ef3..e463c4da 100644 --- a/src/query/dates.ts +++ b/src/query/dates.ts @@ -50,7 +50,11 @@ export const dayBoundary = (value: string, zone: string, next: boolean, span: Sp return lo } const WALL = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/u -/** A time with no zone, read in `zone`. A local time that daylight saving skips or repeats is refused. */ +/** + * A time with no zone, read in `zone`. A local time that daylight saving skips or repeats is refused. + * + * @experimental + */ export const wallTime = (value: string, zone: string, span: Span): number => { const [, year, month, day, hour, minute, second = "0", fraction = "0"] = WALL.exec(value) ?? [] if (year === undefined) queryError("query.invalid-date", span, "use YYYY-MM-DDTHH:mm, with optional seconds") @@ -131,6 +135,7 @@ export interface DateRange { lower_inclusive: boolean upper_inclusive: boolean } +/** @experimental */ export const dateEndpoint = ( value: string, zone: string, diff --git a/src/query/help.ts b/src/query/help.ts index 443c0cfb..640c3ad2 100644 --- a/src/query/help.ts +++ b/src/query/help.ts @@ -1,6 +1,7 @@ import type { QueryRegistry } from "./fields.js" import type { FieldInfo } from "./registry.js" +/** @experimental */ export const QUERY_SYNTAX = 'field:value · "a phrase" · word* · AND OR NOT · ( ) · [a TO b] · > >= < <=' const shownOf = (registry: Pick & Partial>) => diff --git a/src/query/registry.ts b/src/query/registry.ts index 2392d6bc..2559ffc5 100644 --- a/src/query/registry.ts +++ b/src/query/registry.ts @@ -12,6 +12,7 @@ export interface QueryInfo extends Omit { fields: FieldInfo[] } +/** @experimental */ export const describeQuery = (registry: QueryRegistry): QueryInfo => ({ entity: registry.entity, backend: registry.backend, @@ -19,7 +20,11 @@ export const describeQuery = (registry: QueryRegistry): QueryInfo => ({ ...(registry.defaults && registry.defaults.length > 0 ? { defaults: [...registry.defaults] } : {}), }) -/** Why an example or default term would not run against these fields, per field name; empty when every one runs. */ +/** + * Why an example or default term would not run against these fields, per field name; empty when every one runs. + * + * @experimental + */ export const exampleProblems = (registry: QueryRegistry): { field: string; problem: string }[] => { // An example proves syntax and type; whether a provider filters the field is the list's answer at run time. const syntaxOnly: QueryRegistry = { ...registry, backend: "sql" } diff --git a/src/query/types.ts b/src/query/types.ts index 7e79ebeb..9232066c 100644 --- a/src/query/types.ts +++ b/src/query/types.ts @@ -44,6 +44,7 @@ const predicateSchema = v.object({ implicit: v.optional(v.literal(true)), slop: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0))), }) +/** @experimental */ export const queryNodeSchema: v.GenericSchema = v.variant("kind", [ predicateSchema, v.object({ diff --git a/src/skill/index.ts b/src/skill/index.ts index 6198bd7d..b7a73340 100644 --- a/src/skill/index.ts +++ b/src/skill/index.ts @@ -37,7 +37,11 @@ const homeOf = (env: Env): string => { return env.HOME || env.USERPROFILE || homedir() } -/** `~/.claude/skills` is Claude Code's; `~/.agents/skills` is read by Codex, Gemini CLI and OpenClaw. */ +/** + * `~/.claude/skills` is Claude Code's; `~/.agents/skills` is read by Codex, Gemini CLI and OpenClaw. + * + * @experimental + */ export const skillPath = (target: SkillTarget, appName: string, env: Env): string => join(homeOf(env), target === "claude" ? ".claude" : ".agents", "skills", appName, "SKILL.md") @@ -76,7 +80,11 @@ const skillName = (content: string): string | undefined => { return line === undefined ? undefined : scalar("name", "").exec(line)?.[1] } -/** Adds or replaces `metadata.version` as a string; every other byte stays as it was. */ +/** + * Adds or replaces `metadata.version` as a string; every other byte stays as it was. + * + * @experimental + */ export const withVersion = (content: string, version: string): string => { const match = FRONTMATTER.exec(content) if (!match) return `---\nmetadata:\n version: "${version}"\n---\n${content}` @@ -103,6 +111,8 @@ export const withVersion = (content: string, version: string): string => { * The files beside SKILL.md that it links to or names (`references/tasks.md`), as `/`-separated paths relative to its * folder. A long skill keeps its core in SKILL.md and the rest in these, so an agent loads only what its task needs. * Dotfiles and symbolic links are left out: a link could point anywhere on the machine. + * + * @experimental */ export const skillFiles = (skill: URL): string[] => { const root = dirname(fileURLToPath(skill)) @@ -181,13 +191,18 @@ const copyStatus = (app: SkillApp, path: string): Omit ProgramResult const runProgram: RunProgram = (file, args, env) => { @@ -200,10 +215,18 @@ const runProgram: RunProgram = (file, args, env) => { return { status: result.status, ...(result.error ? { error: result.error } : {}), stdout: result.stdout ?? "" } } -/** How Hermes reads the skill: the `~/.agents/skills` folder listed in its `skills.external_dirs`, or a copy of its own. */ +/** + * How Hermes reads the skill: the `~/.agents/skills` folder listed in its `skills.external_dirs`, or a copy of its own. + * + * @experimental + */ export type HermesRoute = "external_dirs" | "copy" -/** `HERMES_HOME`, else the folder Hermes itself defaults to. */ +/** + * `HERMES_HOME`, else the folder Hermes itself defaults to. + * + * @experimental + */ export const hermesHome = (env: Env, platform: NodeJS.Platform = process.platform): string => { refuseOwnerHomeInTests(env, platform) const set = env.HERMES_HOME?.trim() @@ -246,6 +269,7 @@ const expanded = (entry: string, env: Env): string => const lists = (dirs: readonly string[], folder: string, env: Env): boolean => dirs.some((entry) => expanded(entry, env) === resolve(folder)) +/** @experimental */ export interface HermesInstall { via: HermesRoute /** The file Hermes reads. */ @@ -288,6 +312,8 @@ const readFolder = (folder: string, env: Env, run: RunProgram): string | undefin * with Hermes's own `config set`, keeping every folder already listed. When Hermes is not on PATH, cannot be asked, * or does not keep the folder, the skill is copied into `$HERMES_HOME/skills` instead — but only when that home exists: * with neither the program nor its home, Hermes is not installed, and nothing is written. + * + * @experimental */ export const installHermesSkill = ( app: SkillApp, @@ -306,6 +332,7 @@ export const installHermesSkill = ( return { written: [shared, copy], hermes: { via: "copy", path: copy, reason } } } +/** @experimental */ export interface HermesSkillStatus extends Omit { /** How Hermes reads the copy reported; `null` when it reads none. */ via: HermesRoute | null @@ -315,6 +342,8 @@ export interface HermesSkillStatus extends Omit { * The copy Hermes reads: its own `skills/` first, as Hermes scans it first, else the `~/.agents/skills` one when * `skills.external_dirs` lists that folder. Asks Hermes through `config get` when its home exists, so a host calls it * only when asked. + * + * @experimental */ export const hermesSkillStatus = ( app: SkillApp, diff --git a/src/skill/skill.test.ts b/src/skill/skill.test.ts index c36960e6..af3a364e 100644 --- a/src/skill/skill.test.ts +++ b/src/skill/skill.test.ts @@ -18,7 +18,8 @@ import { parse } from "yaml" import { metaOf } from "../commands/index.js" import { CliError } from "../errors.js" import { createRenderer } from "../renderer.js" -import { captureStreams, fakeClock } from "../testing/index.js" +import { captureStreams } from "../streams.js" +import { fakeClock } from "../testing/index.js" import { readUpdateState, writeUpdateState } from "../update/index.js" import { hermesCopyPath, diff --git a/src/standards/audit.ts b/src/standards/audit.ts index 9ca56ce4..35fc6e87 100644 --- a/src/standards/audit.ts +++ b/src/standards/audit.ts @@ -5,18 +5,26 @@ import { duplicates, parseRegistry, text, word } from "./registry.js" /** * Whether a new cross-CLI divergence fails `cli-dev audit`, as a new lint violation does (`"new"`), or only shows in * the scorecard (`"never"`). Lint rules always block on a new violation. + * + * @experimental */ export const AUDIT_BLOCKS: "new" | "never" = "new" const auditRuleSchema = v.strictObject({ id: word, severity: v.picklist(LINT_SEVERITIES), summary: text }) +/** @experimental */ export type AuditRule = v.InferOutput +/** @experimental */ export const defineAuditRules = (input: unknown): AuditRule[] => parseRegistry("audit rules", v.array(auditRuleSchema), input, (rules) => duplicates(rules.map((rule) => rule.id)).map((id) => `"${id}" is listed twice`), ) -/** The rules that compare CLIs; each CLI is also judged alone by every lint rule. */ +/** + * The rules that compare CLIs; each CLI is also judged alone by every lint rule. + * + * @experimental + */ export const AUDIT_RULES: AuditRule[] = defineAuditRules([ { id: "shared-command-contract", @@ -82,12 +90,14 @@ const parityGroupSchema = v.strictObject({ ), }) +/** @experimental */ export type ParityGroup = v.InferOutput /** Which of `absent`, `only` and `differs` a difference names: the CLI it measures by name. */ const kindOf = (entry: ParityGroup["differences"][number]) => (["absent", "only", "differs"] as const).filter((one) => entry[one] !== undefined) +/** @experimental */ export const defineParityGroups = (input: unknown): ParityGroup[] => parseRegistry("parity groups", v.array(parityGroupSchema), input, (groups) => [ ...duplicates(groups.map((group) => group.name)).map((name) => `"${name}" is listed twice`), @@ -179,6 +189,7 @@ const FAMILY_SINCE_0_98 = [ }, ] +/** @experimental */ export const PARITY_GROUPS: ParityGroup[] = defineParityGroups([ { name: "messengers", members: ["tg", "max"], covers: "tree", differences: MESSENGERS_SINCE_0_98 }, { @@ -273,13 +284,16 @@ export const SHARED_DIFFERENCES = [ ] const requiredRootSchema = v.strictObject({ path: v.pipe(v.array(segment), v.minLength(1)), meaning: text }) +/** @experimental */ export type RequiredRoot = v.InferOutput +/** @experimental */ export const defineRequiredRoots = (input: unknown): RequiredRoot[] => parseRegistry("required roots", v.array(requiredRootSchema), input, (roots) => duplicates(roots.map((root) => root.path.join(" "))).map((path) => `"${path}" is listed twice`), ) +/** @experimental */ export const REQUIRED_ROOTS: RequiredRoot[] = defineRequiredRoots([ { path: ["commands"], meaning: "the command tree as JSON, what agents and this audit read" }, { path: ["doctor"], meaning: "checks this machine and the profile, and says what to fix" }, diff --git a/src/standards/effects.ts b/src/standards/effects.ts index 8d28cd99..8a331e4c 100644 --- a/src/standards/effects.ts +++ b/src/standards/effects.ts @@ -1,5 +1,6 @@ import * as v from "valibot" +/** @experimental */ export const EFFECT_LEVELS = ["none", "read", "write"] as const /** What running a command touches: the service it talks to, and this machine (files, the keyring, the store). */ @@ -9,6 +10,7 @@ export const effectsSchema = v.strictObject({ }) export type Effects = v.InferOutput +/** @experimental */ export type EffectLevel = (typeof EFFECT_LEVELS)[number] /** Unknown effects count as a write: a command nobody described is never retried or run on its own. */ diff --git a/src/standards/errors.ts b/src/standards/errors.ts index 7ea98357..cdff4fe4 100644 --- a/src/standards/errors.ts +++ b/src/standards/errors.ts @@ -57,6 +57,8 @@ export const defineReasons = (input: unknown): ErrorReason[] => /** * Keys any reason's `details` may carry; the handler drops every other key it was not told about. `retryable`, * `retry_after_ms` and `sent` are read into `retry`, not repeated here. + * + * @experimental */ export const COMMON_DETAILS = ["attempts", "status", "request_id", "operation", "operation_id"] as const diff --git a/src/standards/fields.ts b/src/standards/fields.ts index 029c6d85..c68b7bcd 100644 --- a/src/standards/fields.ts +++ b/src/standards/fields.ts @@ -2,13 +2,16 @@ import * as v from "valibot" import { duplicates, parseRegistry, text, word } from "./registry.js" const fieldRuleSchema = v.strictObject({ id: word, rule: text }) +/** @experimental */ export type FieldRule = v.InferOutput +/** @experimental */ export const defineFieldRules = (input: unknown): FieldRule[] => parseRegistry("output field rules", v.array(fieldRuleSchema), input, (rules) => duplicates(rules.map((rule) => rule.id)).map((id) => `"${id}" is listed twice`), ) +/** @experimental */ export const FIELD_RULES: FieldRule[] = defineFieldRules([ { id: "envelope", rule: "every JSON answer is one object: a list `{items, page, …}`, one thing `{item, …}`" }, { id: "time", rule: "a time is an ISO 8601 string in UTC, ending in `Z`, never epoch milliseconds" }, diff --git a/src/standards/identifiers.ts b/src/standards/identifiers.ts index 58557514..b539a40c 100644 --- a/src/standards/identifiers.ts +++ b/src/standards/identifiers.ts @@ -5,8 +5,10 @@ const key = v.pipe(v.string(), v.regex(SNAKE_CASE, "a snake_case key")) const identifierSchema = v.strictObject({ key, meaning: text, replaces: v.optional(v.array(key)) }) +/** @experimental */ export type Identifier = v.InferOutput +/** @experimental */ export const defineIdentifiers = (input: unknown): Identifier[] => parseRegistry("identifiers", v.array(identifierSchema), input, (identifiers) => { const keys = identifiers.map((entry) => entry.key) @@ -17,7 +19,11 @@ export const defineIdentifiers = (input: unknown): Identifier[] => ] }) -/** The ids a CLI's answers, errors and logs carry; one name each. */ +/** + * The ids a CLI's answers, errors and logs carry; one name each. + * + * @experimental + */ export const IDENTIFIERS: Identifier[] = defineIdentifiers([ { key: "run_id", diff --git a/src/standards/lint.ts b/src/standards/lint.ts index 9bea71cf..8ad1bc92 100644 --- a/src/standards/lint.ts +++ b/src/standards/lint.ts @@ -1,6 +1,7 @@ import * as v from "valibot" import { duplicates, parseRegistry, text, word } from "./registry.js" +/** @experimental */ export const LINT_SEVERITIES = ["high", "medium", "low"] as const const lintRuleSchema = v.strictObject({ @@ -11,15 +12,22 @@ const lintRuleSchema = v.strictObject({ summary: text, }) +/** @experimental */ export type LintRule = v.InferOutput +/** @experimental */ export type LintSeverity = (typeof LINT_SEVERITIES)[number] +/** @experimental */ export const defineLintRules = (input: unknown): LintRule[] => parseRegistry("lint rules", v.array(lintRuleSchema), input, (rules) => duplicates(rules.map((rule) => rule.id)).map((id) => `"${id}" is listed twice`), ) -/** Ids and severities follow the Azure CLI linter (`azdev linter`): a rule is named after what it finds. */ +/** + * Ids and severities follow the Azure CLI linter (`azdev linter`): a rule is named after what it finds. + * + * @experimental + */ export const LINT_RULES: LintRule[] = defineLintRules([ { id: "unknown-verb", @@ -150,7 +158,11 @@ export const LINT_RULES: LintRule[] = defineLintRules([ }, ]) -/** `lint/baseline/.json`: today's violations of one rule, by target. It may only shrink. */ +/** + * `lint/baseline/.json`: today's violations of one rule, by target. It may only shrink. + * + * @experimental + */ export const baselineSchema = v.array(text) /** One `lint/overrides.json` entry: the exception, its reason, who keeps it and when to look again. */ @@ -163,18 +175,29 @@ export const overrideSchema = v.strictObject({ review_after: v.pipe(v.string(), v.isoDate("a date, YYYY-MM-DD")), }) -/** `lint/overrides.json`: exceptions, each with its reason, who keeps it and when to look again; counted against a budget. */ +/** + * `lint/overrides.json`: exceptions, each with its reason, who keeps it and when to look again; counted against a budget. + * + * @experimental + */ export const overridesSchema = v.array(overrideSchema) +/** @experimental */ export type Override = v.InferOutput[number] -/** What the schemas cannot say, so they stay convertible to JSON Schema: no entry twice. */ +/** + * What the schemas cannot say, so they stay convertible to JSON Schema: no entry twice. + * + * @experimental + */ export const baselineProblems = (targets: readonly string[]): string[] => duplicates(targets).map((target) => `"${target}" is listed twice`) /** * Days around an override's `review_after` that only warn: a review comes due without turning every CI run of the CLI * red on one morning, and a shared word due in several CLIs at once gets two weeks to land its fix. + * + * @experimental */ export const REVIEW_GRACE_DAYS = 14 @@ -197,13 +220,21 @@ export const overdue = (entries: readonly Dated[], today: string): string[] => .filter((entry) => entry.review_after !== undefined && shiftDays(entry.review_after, REVIEW_GRACE_DAYS) < today) .map((entry) => `"${entry.rule} ${entry.target}" was due for review on ${entry.review_after}${ask(entry)}`) -/** No entry twice, and none overdue. */ +/** + * No entry twice, and none overdue. + * + * @experimental + */ export const overridesProblems = (entries: readonly Override[], today: string): string[] => [ ...duplicates(entries.map((entry) => `${entry.rule} ${entry.target}`)).map((both) => `"${both}" is listed twice`), ...overdue(entries, today), ] -/** Entries whose `review_after` is at most `REVIEW_GRACE_DAYS` away on either side: due soon, or due and not failing yet. */ +/** + * Entries whose `review_after` is at most `REVIEW_GRACE_DAYS` away on either side: due soon, or due and not failing yet. + * + * @experimental + */ export const overridesDueSoon = (entries: readonly Dated[], today: string, check = "lint"): string[] => entries.flatMap((entry) => entry.review_after !== undefined && @@ -215,12 +246,21 @@ export const overridesDueSoon = (entries: readonly Dated[], today: string, check : [], ) +/** @experimental */ export const OVERRIDE_BUDGET = 10 -/** More overrides of one rule than this, across every CLI, and the rule itself is due for review. */ +/** + * More overrides of one rule than this, across every CLI, and the rule itself is due for review. + * + * @experimental + */ export const OVERRIDE_RULE_REVIEW = 3 -/** Rules overridden more than `OVERRIDE_RULE_REVIEW` times across the CLIs given, most first. */ +/** + * Rules overridden more than `OVERRIDE_RULE_REVIEW` times across the CLIs given, most first. + * + * @experimental + */ export const rulesForReview = (lists: readonly (readonly Override[])[]): { rule: string; overrides: number }[] => { const counts = new Map() for (const entry of lists.flat()) counts.set(entry.rule, (counts.get(entry.rule) ?? 0) + 1) diff --git a/src/standards/log.ts b/src/standards/log.ts index e496f8ac..6f3355b0 100644 --- a/src/standards/log.ts +++ b/src/standards/log.ts @@ -41,12 +41,20 @@ export const defineLogEvents = (input: unknown): LogEvent[] => ...events.flatMap((event) => duplicates(event.keys).map((key) => `${event.id}: key "${key}" is listed twice`)), ]) -/** The events cli-base logs itself. */ +/** + * The events cli-base logs itself. + * + * @experimental + */ export const LOG_EVENTS: LogEvent[] = defineLogEvents([ { id: "command.failed", meaning: "a command ended with an error", keys: ["code", "reason"] }, ]) -/** Why a record is not one of `events` (cli-base's are always known): an unknown `body`, or a required key missing. */ +/** + * Why a record is not one of `events` (cli-base's are always known): an unknown `body`, or a required key missing. + * + * @experimental + */ export const logEventProblems = (record: Pick, events: readonly LogEvent[]) => { const event = [...LOG_EVENTS, ...events].find((one) => one.id === record.body) if (!event) return [`"${record.body}" is not a registered log event`] @@ -56,7 +64,11 @@ export const logEventProblems = (record: Pick, } export type LogSeverity = (typeof LOG_SEVERITIES)[number] -/** Attribute keys every program may log; a program adds its own with `allow`. Keys are camelCase until §3.9 reaches logs. */ +/** + * Attribute keys every program may log; a program adds its own with `allow`. Keys are camelCase until §3.9 reaches logs. + * + * @experimental + */ export const LOG_ATTRIBUTE_KEYS = [ "code", "count", diff --git a/src/standards/monthly.ts b/src/standards/monthly.ts index d7a2406e..da9d028f 100644 --- a/src/standards/monthly.ts +++ b/src/standards/monthly.ts @@ -7,6 +7,8 @@ const CI_PAGE = join(dirname(fileURLToPath(import.meta.url)), "../../docs/standa /** * WC-CI-9's table of the WireCat repositories' monthly minutes, as `HH:MM → repository`: from the given text of * `docs/standards/ci.md`, or from the copy this package ships. + * + * @experimental */ export const takenMinutes = (ciPage: string = readFileSync(CI_PAGE, "utf8")): Map => new Map( diff --git a/src/standards/output.ts b/src/standards/output.ts index 6f8c2459..6a67643a 100644 --- a/src/standards/output.ts +++ b/src/standards/output.ts @@ -14,7 +14,11 @@ export const isoTime = v.pipe( v.endsWith("Z", "an ISO 8601 time in UTC, ending in `Z`"), ) -/** The same moment on the wall clock of a zone, with its offset: `2026-11-02T16:03:00.000+01:00` (WC-TIME-2). */ +/** + * The same moment on the wall clock of a zone, with its offset: `2026-11-02T16:03:00.000+01:00` (WC-TIME-2). + * + * @experimental + */ export const localTime = v.pipe( v.string(), v.regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}[+-]\d{2}:\d{2}$/, "an ISO 8601 time with its offset"), @@ -138,6 +142,8 @@ const count = v.pipe(v.number(), v.integer(), v.minValue(0)) * What a model a command calls on its own did in this run (mail's `inbox` sorting new threads): how many items it was * sent, how many it handled, how many wait for the next run, and what that cost. `usage` is absent when the provider * counted nothing; `cost_usd` is null when no price is known. + * + * @experimental */ export const modelRunSchema = v.strictObject({ provider: text, @@ -223,6 +229,7 @@ export type Page = v.InferOutput export type Issue = v.InferOutput export type Meta = v.InferOutput export type Ranking = v.InferOutput +/** @experimental */ export type ModelRun = v.InferOutput export type Query = v.InferOutput export interface ListEnvelope { diff --git a/src/standards/registry.ts b/src/standards/registry.ts index 8f13791f..98029fd0 100644 --- a/src/standards/registry.ts +++ b/src/standards/registry.ts @@ -11,6 +11,7 @@ export const dottedId = v.pipe( v.regex(/^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/, "dotted lower-case words, such as `page.next`"), ) +/** @experimental */ export class RegistryError extends Error { constructor( readonly registry: string, @@ -52,7 +53,11 @@ const PLACEHOLDER = /\{([a-z][a-z0-9]*(?:_[a-z0-9]+)*)\}/g export const placeholders = (template: string): string[] => [...template.matchAll(PLACEHOLDER)].map((match) => match[1] ?? "") -/** Fills `{name}` from `values`; a placeholder with no value throws, so a half-filled sentence never ships. */ +/** + * Fills `{name}` from `values`; a placeholder with no value throws, so a half-filled sentence never ships. + * + * @experimental + */ export const fill = (template: string, values: Readonly>): string => template.replace(PLACEHOLDER, (_, name: string) => { const value = values[name] diff --git a/src/standards/steps.ts b/src/standards/steps.ts index c2a1c81c..609b1443 100644 --- a/src/standards/steps.ts +++ b/src/standards/steps.ts @@ -3,7 +3,11 @@ import { type Effects, writes } from "./effects.js" import type { NextStep } from "./output.js" import { dottedId, duplicates, fill, parseRegistry, SNAKE_CASE, text } from "./registry.js" -/** A step's command: a path such as `messages sync`, or `*` for the command that gave the answer (`page.next`). */ +/** + * A step's command: a path such as `messages sync`, or `*` for the command that gave the answer (`page.next`). + * + * @experimental + */ export const SAME_COMMAND = "*" const commandPath = v.pipe( diff --git a/src/standards/vocabulary.ts b/src/standards/vocabulary.ts index 934bb713..816c0975 100644 --- a/src/standards/vocabulary.ts +++ b/src/standards/vocabulary.ts @@ -86,7 +86,11 @@ export type VocabularyNoun = Vocabulary["nouns"][number] export type VocabularyFlag = Vocabulary["flags"][number] export type FlagType = (typeof FLAG_TYPES)[number] -/** One word, one meaning within its kind: a second entry for the same verb, noun, view, root or flag is refused. */ +/** + * One word, one meaning within its kind: a second entry for the same verb, noun, view, root or flag is refused. + * + * @experimental + */ export const defineVocabulary = (input: unknown): Vocabulary => parseRegistry("vocabulary", vocabularySchema, input, (vocabulary) => { const problems: string[] = [] diff --git a/src/testing/index.ts b/src/testing/index.ts index 065b782e..3c8315a8 100644 --- a/src/testing/index.ts +++ b/src/testing/index.ts @@ -3,8 +3,7 @@ * rather than a hope about every test remembering to opt out. */ -export { brokenKeyring, memoryKeyring } from "../keyring.js" -export { captureStreams } from "../streams.js" +export { memoryKeyring } from "../keyring.js" export { allowNetwork } from "./network.js" import { type LogEvent, logEventProblems } from "../standards/log.js" diff --git a/src/update/index.ts b/src/update/index.ts index 69f019e8..bdc1a756 100644 --- a/src/update/index.ts +++ b/src/update/index.ts @@ -71,6 +71,7 @@ export const latestVersion = async ( } } +/** @experimental */ export const CHECK_EVERY_MS = 24 * 60 * 60 * 1000 export interface NotifyContext { @@ -86,7 +87,11 @@ export interface NotifyContext { offVariables?: readonly string[] } -/** Whether a person is at a terminal who could be told — the only case a check is worth making. */ +/** + * Whether a person is at a terminal who could be told — the only case a check is worth making. + * + * @experimental + */ export const mayNotify = ({ format, stderrIsTTY, @@ -111,9 +116,14 @@ const updateState = v.object({ /** When the skill hint (`cli-base/skill`) was last shown — the other daily notice kept in this file. */ skillHintAt: v.optional(v.number()), }) +/** @experimental */ export type UpdateState = v.InferOutput -/** The file as it is, `checkedAt: 0` when it is missing or unreadable. */ +/** + * The file as it is, `checkedAt: 0` when it is missing or unreadable. + * + * @experimental + */ export const readNoticeState = (path: string): UpdateState => { try { return loadConfigFile(path, updateState, () => ({ checkedAt: 0 })) @@ -122,7 +132,11 @@ export const readNoticeState = (path: string): UpdateState => { } } -/** What the last check found. A missing or unreadable file is "never checked", not an error. */ +/** + * What the last check found. A missing or unreadable file is "never checked", not an error. + * + * @experimental + */ export const readUpdateState = (path: string): UpdateState | undefined => { const state = readNoticeState(path) return state.checkedAt > 0 ? state : undefined @@ -131,6 +145,8 @@ export const readUpdateState = (path: string): UpdateState | undefined => { /** * Merged into the file as it is at the moment of writing: the update notice reads before it asks * npm and writes after, and the skill hint may have written in between. + * + * @experimental */ export const writeUpdateState = (path: string, state: Partial): void => { try { @@ -140,10 +156,15 @@ export const writeUpdateState = (path: string, state: Partial): voi } } +/** @experimental */ export const checkIsDue = (state: UpdateState | undefined, now: number): boolean => state === undefined || now - state.checkedAt >= CHECK_EVERY_MS -/** Resolve Windows shims from explicit PATH entries; cross-spawn quotes them through the trusted shell. */ +/** + * Resolve Windows shims from explicit PATH entries; cross-spawn quotes them through the trusted shell. + * + * @experimental + */ export const spawnPlan = ( [command, ...args]: readonly string[], platform: NodeJS.Platform = process.platform, diff --git a/src/wcat/manifest.ts b/src/wcat/manifest.ts index 26e5da7e..b300b203 100644 --- a/src/wcat/manifest.ts +++ b/src/wcat/manifest.ts @@ -12,6 +12,7 @@ import { issuesOf, jsonSchemaOf, SNAKE_CASE } from "../standards/registry.js" import type { WcatTool } from "./describe.js" import { PROGRAM_PREFIX, TOOL_NAME } from "./names.js" +/** @experimental */ export const MANIFEST_FORMAT = 2 export const MANIFEST_FILE = "contracts/wirecat.json" @@ -29,7 +30,11 @@ export const SHARED_HOSTS: readonly string[] = [ "*.githubusercontent.com", ] -/** Desktop's `plain_word`: letters, digits and `._:=,/+@-`, at most two leading dashes, `--` alone, `{name}` slots. */ +/** + * Desktop's `plain_word`: letters, digits and `._:=,/+@-`, at most two leading dashes, `--` alone, `{name}` slots. + * + * @experimental + */ export const PLAIN_WORD = /^(?:--|-{0,2}(?:[A-Za-z0-9]|\{[A-Za-z]+\})(?:[A-Za-z0-9._:=,/+@-]|\{[A-Za-z]+\})*)$/ const plainWord = v.pipe( @@ -47,6 +52,8 @@ const words = v.pipe(v.array(plainWord), v.minLength(1)) * The one word that is not plain: `runs list` matches `command:` exactly, so a ` sync` is found only as the * quoted phrase, `command:"meetings sync" status:success`. Desktop runs it without a shell and accepts this form in * `sync.last` only. + * + * @experimental */ export const SYNC_QUERY = /^command:"[a-z0-9][a-z0-9-]*(?: [a-z0-9][a-z0-9-]*)+" status:success$/ const lastWords = v.pipe(v.array(v.union([plainWord, v.pipe(v.string(), v.regex(SYNC_QUERY))])), v.minLength(1)) @@ -164,6 +171,7 @@ const desktopSchema = v.strictObject({ ), }) +/** @experimental */ export type ManifestDesktop = v.InferOutput const hostSchema = v.pipe( @@ -213,6 +221,7 @@ export const manifestSchema = v.strictObject({ export type Manifest = v.InferOutput +/** @experimental */ export const manifestJsonSchema = () => jsonSchemaOf(manifestSchema) /** @@ -260,6 +269,7 @@ export interface ManifestInput { skills: boolean } +/** @experimental */ export class ManifestError extends Error { constructor(readonly problems: readonly string[]) { super(`${MANIFEST_FILE} cannot be built: ${problems.join("; ")}`)