Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog.d/395.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
section: authoring
---

- **Every `--json` document has a published schema** (#395). The documents the CLI prints with `--json`, or writes with `--output`, now have JSON Schemas at `https://schemas.projections.githubnext.com/cli/<name>/v0.json`, such as `cli/sweep/v0.json` for `explore --sweep`, `cli/check/v0.json` for `check` and `cli/batch/v0.json` for `show --all`, `compare --all` and `bookmark run` (see [the schema reference](docs/reference/schemas/README.md)). The CLI's tests validate its output against them. Their TypeScript types are exported from `@githubnext/projections-sdk/schemas`, for example `CliSweep` and `CliBatch`.
- **More `--json` documents name their kind** (#395). The JSON from `adopt`, `extractor list`, `extractor view`, `workspace clean`, `view show`, `view current`, `view refresh` and `view screenshot` now starts with `format` (`projections.adopt`, `projections.extractors`, `projections.extractor`, `projections.workspace-clean`, `projections.view` and `projections.screenshot`) and `version` (`0`), as the other documents do. The other fields are unchanged.
6 changes: 5 additions & 1 deletion docs/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ the runtime validator together, so a hand-written type never stands in for a
checked one.

- **Published contracts** (`src/typebox`): the versioned documents listed above,
along with their `$id`s and reference pages.
along with their `$id`s and reference pages. They include every document the
CLI prints with `--json` or writes with `--output` (`cli/<name>/v0.json`, such
as `cli/sweep/v0.json` for `projections.sweep`), and
`packages/cli/test/json-output.test.mjs` validates the CLI's real output
against them, so a document's shape changes only with its schema.
- **The local runner's API** (`src/runner`, exported as
`@githubnext/projections-schemas/runner`): the responses from the Inspector
service (`projections view` and [`serve --stdio`](runner/stdio-backend.md))
Expand Down
17 changes: 17 additions & 0 deletions docs/reference/schemas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ domain schemas an extraction's `schema` field selects.
| [Domain schema architecture/v0](architecture.md) | `https://schemas.projections.githubnext.com/architecture/v0.json` | Components and their connections, as `graph/v0`, for architecture and infrastructure. |
| [CI artifact manifest](artifact.md) | `https://schemas.projections.githubnext.com/artifact/v0.json` | projections.artifact.json at the root of the `projections` Actions artifact: what one workflow run extracted or compared, and the full-byte SHA-256 of every document it uploaded. |
| [Bookmarks](bookmarks.md) | `https://schemas.projections.githubnext.com/bookmarks/v0.json` | `.projections-bookmarks.json` at the repository root: saved comparisons to revisit, each a projection and two revisions. `projections bookmark` reads it; bookmark IDs are unique within the file. |
| [CLI adopt](cli-adopt.md) | `https://schemas.projections.githubnext.com/cli/adopt/v0.json` | The definitions and bookmarks adopting projections writes (`projections adopt --json`). |
| [CLI batch](cli-batch.md) | `https://schemas.projections.githubnext.com/cli/batch/v0.json` | Every projection (or bookmark) at once: `show --all`, `compare --all` and `bookmark run` with `--json` or `--output`. |
| [CLI check](cli-check.md) | `https://schemas.projections.githubnext.com/cli/check/v0.json` | Projections verified end to end: extraction, comparison and renderer checks (`projections check --json`). |
| [CLI doctor](cli-doctor.md) | `https://schemas.projections.githubnext.com/cli/doctor/v0.json` | What the checkout needs to run its projections, found without running anything (`projections doctor --json`). |
| [CLI error](cli-error.md) | `https://schemas.projections.githubnext.com/cli/error/v0.json` | What a command run with `--json` or `--output` prints to stdout when it fails, besides its message on stderr. |
| [CLI explore candidates](cli-explore.md) | `https://schemas.projections.githubnext.com/cli/explore/v0.json` | The built-in projections that apply to the repository (`projections explore --list --json`). |
| [CLI extractor](cli-extractor.md) | `https://schemas.projections.githubnext.com/cli/extractor/v0.json` | One built-in extractor: its inputs, schema, renderer and definition template (`projections extractor view --json`). |
| [CLI extractor list](cli-extractors.md) | `https://schemas.projections.githubnext.com/cli/extractors/v0.json` | The built-in extractors (`projections extractor list --json`). |
| [CLI list](cli-list.md) | `https://schemas.projections.githubnext.com/cli/list/v0.json` | The projections a revision defines, read without running anything (`projections list --json`). |
| [CLI prepare](cli-prepare.md) | `https://schemas.projections.githubnext.com/cli/prepare/v0.json` | The environment's prepare steps, run in the working tree or a commit's workspace (`projections prepare --json`). |
| [CLI pull request review](cli-pull-request.md) | `https://schemas.projections.githubnext.com/cli/pull-request/v0.json` | A pull request reviewed without running its code, with the base's definitions (`projections pr --json`). |
| [CLI viewer screenshot](cli-screenshot.md) | `https://schemas.projections.githubnext.com/cli/screenshot/v0.json` | The PNG `projections view screenshot --json` wrote, and what it shows. |
| [CLI sweep](cli-sweep.md) | `https://schemas.projections.githubnext.com/cli/sweep/v0.json` | Each candidate and adopted projection tried on recent changes (`projections explore --sweep --json`). |
| [CLI validation](cli-validation.md) | `https://schemas.projections.githubnext.com/cli/validation/v0.json` | A valid saved extraction, comparison or scenarios document (`projections validate --json`). |
| [CLI viewer](cli-view.md) | `https://schemas.projections.githubnext.com/cli/view/v0.json` | What the viewer shows and what the person selected (`projections view show\|current\|refresh --json`). |
| [CLI workspace clean](cli-workspace-clean.md) | `https://schemas.projections.githubnext.com/cli/workspace-clean/v0.json` | The workspaces `projections workspace clean --json` removed. |
| [CLI workspace list](cli-workspaces.md) | `https://schemas.projections.githubnext.com/cli/workspaces/v0.json` | The workspaces Projections keeps for the repository (`projections workspace list --json`). |
| [Comparator tests](comparator-tests.md) | `https://schemas.projections.githubnext.com/comparator-tests/v0.json` | Tests for a custom comparator, in the file beside its comparator file (`X.comparator.test.yaml` for `X.comparator.yaml`), never part of the comparator or its digest. Each case gives two extractions and states what the comparator must make of them: partial expectations (step order, steps, changes, counts, metadata, or the error the comparator must fail with) and an optional snapshot of the whole comparison. `projections check` runs them. See docs/contracts.md, "Comparator tests". |
| [Comparator file](comparator.md) | `https://schemas.projections.githubnext.com/comparator/v0.json` | A custom comparator file (`<name>.comparator.yaml`): YAML declarations the rules interpreter runs over the default comparator, sandboxed. Identity passes add correspondences; comparator rules, CEL expressions checked against declared types when the file loads, classify changes, order them into steps and add metadata. See the guide's "Write a custom comparator" and docs/design/declarative-comparators.md. |
| [Saved comparison](comparison-document.md) | `https://schemas.projections.githubnext.com/comparison-document/v0.json` | Two saved extractions and the comparison between them, with the comparator that produced it. |
Expand Down
40 changes: 40 additions & 0 deletions docs/reference/schemas/cli-adopt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!-- Generated by tools/scripts/reference-docs.mjs from packages/schemas/schemas/cli/adopt/v0.json. Do not edit: run `npm run docs:generate`. -->

# CLI adopt

The definitions and bookmarks adopting projections writes (`projections adopt --json`). The schema is published at its ID, `https://schemas.projections.githubnext.com/cli/adopt/v0.json`; it is generated from TypeBox
definitions into [`packages/schemas/schemas/cli/adopt/v0.json`](../../../packages/schemas/schemas/cli/adopt/v0.json).

## Document

| Property | Type | Required | Description |
|---|---|---|---|
| `format` | `"projections.adopt"` | Yes | |
| `version` | `0` | Yes | |
| `files` | array of object | Yes | The definitions and the bookmarks file it writes, or would write. |
| `digest` | string | Yes | The files' contents before, which a write must still find. Pattern `^sha256:[0-9a-f]{64}$`. |
| `written` | boolean | Yes | `false` for `--dry-run`. |
| `adopted` | array of [`identifier`](definition.md#identifier) | Yes | |
| `bookmarked` | array of object | Yes | |
| `skipped` | array of [`skipped`](#skipped) | Yes | Changes too large to read, which adopt did not bookmark. |
| `notes` | array of [`note`](#note) | Yes | |

No other properties are allowed.

## Definitions

### `note`

Type: string.

### `skipped`

| Property | Type | Required | Description |
|---|---|---|---|
| `projection` | [`identifier`](definition.md#identifier) | Yes | |
| `change` | [`change`](cli-sweep.md#change) | Yes | |
| `changes` | integer | Yes | At least 0. At most 9007199254740991. |
| `reason` | `"changes"` or `"steps"` or `"items"` | Yes | Which bound it exceeds: more changed items than adopt bookmarks, more steps than `rendererLimits.steps`, or more drawn items than `rendererLimits.filterIds`. |
| `message` | string | Yes | |

No other properties are allowed.
42 changes: 42 additions & 0 deletions docs/reference/schemas/cli-batch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!-- Generated by tools/scripts/reference-docs.mjs from packages/schemas/schemas/cli/batch/v0.json. Do not edit: run `npm run docs:generate`. -->

# CLI batch

Every projection (or bookmark) at once: `show --all`, `compare --all` and `bookmark run` with `--json` or `--output`. The schema is published at its ID, `https://schemas.projections.githubnext.com/cli/batch/v0.json`; it is generated from TypeBox
definitions into [`packages/schemas/schemas/cli/batch/v0.json`](../../../packages/schemas/schemas/cli/batch/v0.json).

## Document

| Property | Type | Required | Description |
|---|---|---|---|
| `format` | `"projections.batch"` | Yes | |
| `version` | `0` | Yes | |
| `operation` | `"show"` or `"compare"` or `"bookmarks"` | Yes | |
| `results` | array of [`result`](#result) | Yes | Ordered by ID. |
| `failed` | integer | Yes | Results whose status is `error`. At least 0. At most 9007199254740991. |

No other properties are allowed.

## Definitions

### `result`

One projection's (or bookmark's) result: its document, or why it failed.

| Property | Type | Required | Description |
|---|---|---|---|
| `id` | string | Yes | The projection or bookmark, as requested: an error keeps an ID that names neither. |
| `status` | `"extracted"` or `"changed"` or `"unchanged"` or `"head-only"` or `"base-only"` or `"error"` | Yes | `extracted` (show), `changed` or `unchanged` (compared), `head-only` or `base-only` (one revision defines it, shown alone), or `error`. |
| `projectionId` | [`identifier`](definition.md#identifier) | | A bookmark's projection, for `bookmark run`, whose `id` is the bookmark's. |
| `extraction` | [Saved extraction](extraction-document.md) | | |
| `comparison` | [Saved comparison](comparison-document.md) | | |
| `notices` | array of string | | |
| `review` | object | | The engine's review counts of a comparison. |
| `review.reviewable` | integer | Yes | At least 0. At most 9007199254740991. |
| `review.content` | integer | Yes | At least 0. At most 9007199254740991. |
| `review.identity` | integer | Yes | At least 0. At most 9007199254740991. |
| `review.variation` | integer | Yes | At least 0. At most 9007199254740991. |
| `diagnostics` | array of [`diagnostic`](cli-error.md#diagnostic) | | Why it failed, for `error`. |
| `definition` | [Projection definition](definition.md) | | Its definition, for `error` once it resolved. |

No other properties are allowed.
121 changes: 121 additions & 0 deletions docs/reference/schemas/cli-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<!-- Generated by tools/scripts/reference-docs.mjs from packages/schemas/schemas/cli/check/v0.json. Do not edit: run `npm run docs:generate`. -->

# CLI check

Projections verified end to end: extraction, comparison and renderer checks (`projections check --json`). The schema is published at its ID, `https://schemas.projections.githubnext.com/cli/check/v0.json`; it is generated from TypeBox
definitions into [`packages/schemas/schemas/cli/check/v0.json`](../../../packages/schemas/schemas/cli/check/v0.json).

## Document

| Property | Type | Required | Description |
|---|---|---|---|
| `format` | `"projections.check"` | Yes | |
| `version` | `0` | Yes | |
| `ok` | boolean | Yes | |
| `projections` | array of [`projection`](#projection) or [`invalidProjection`](#invalidprojection) | Yes | |

No other properties are allowed.

## Definitions

### `rendererCheck`

| Property | Type | Required | Description |
|---|---|---|---|
| `id` | string | Yes | |
| `title` | string | Yes | |
| `status` | `"pass"` or `"fail"` or `"skip"` or `"advice"` | Yes | |
| `details` | array of string | Yes | |
| `durationMs` | number | Yes | At least 0. |

No other properties are allowed.

### `comparatorTestDiagnostic`

| Property | Type | Required | Description |
|---|---|---|---|
| `pointer` | string | Yes | |
| `message` | string | Yes | |
| `location` | object | Yes | |
| `location.path` | string | Yes | |
| `location.line` | integer | Yes | At least 0. At most 9007199254740991. |
| `location.column` | integer | Yes | At least 0. At most 9007199254740991. |

No other properties are allowed.

### `comparatorTestCase`

| Property | Type | Required | Description |
|---|---|---|---|
| `id` | string | Yes | |
| `name` | string | Yes | |
| `status` | `"pass"` or `"fail"` or `"skip"` | Yes | |
| `location` | object | Yes | |
| `location.path` | string | Yes | |
| `location.line` | integer | Yes | At least 0. At most 9007199254740991. |
| `location.column` | integer | Yes | At least 0. At most 9007199254740991. |
| `failures` | array of object | Yes | |
| `message` | string | | Why it failed or was skipped. |
| `durationMs` | integer | Yes | At least 0. At most 9007199254740991. |

No other properties are allowed.

### `comparatorCoverage`

| Property | Type | Required | Description |
|---|---|---|---|
| `comparator` | string | Yes | The comparator file. |
| `summary` | map of object or null | Yes | Covered of total, by category (functions, expressions, branches); `null` when nothing ran. |
| `uncovered` | array of object | | |
| `excluded` | array of object | | |
| `entries` | any | | The rules interpreter's raw coverage. |

No other properties are allowed.

### `step`

| Property | Type | Required | Description |
|---|---|---|---|
| `id` | string | Yes | |
| `title` | string | Yes | |
| `status` | `"pass"` or `"fail"` or `"warn"` or `"skip"` | Yes | |
| `message` | string | Yes | |
| `error` | [`report`](cli-error.md#report) | | |
| `details` | array of string | | |
| `rerun` | string | | The command that runs the failed renderer checks again. |
| `checks` | array of [`rendererCheck`](#renderercheck) | | Every renderer check, on a renderer step. |
| `file` | string | | The comparator test file, on a comparator tests step, whether or not it exists. |
| `cases` | array of [`comparatorTestCase`](#comparatortestcase) | | |
| `diagnostics` | array of [`comparatorTestDiagnostic`](#comparatortestdiagnostic) | | Why the comparator test file is invalid. |
| `written` | array of string | | The snapshots `--update` wrote. |
| `coverage` | [`comparatorCoverage`](#comparatorcoverage) | | |

No other properties are allowed.

### `projection`

A projection checked: each step of its check.

| Property | Type | Required | Description |
|---|---|---|---|
| `id` | [`identifier`](definition.md#identifier) | Yes | |
| `title` | string | Yes | |
| `ok` | boolean | Yes | |
| `steps` | array of [`step`](#step) | Yes | |

No other properties are allowed.

### `invalidProjection`

A definition file that failed to load.

| Property | Type | Required | Description |
|---|---|---|---|
| `id` | string | Yes | |
| `title` | string | Yes | |
| `path` | string | Yes | |
| `ok` | `false` | Yes | |
| `steps` | array of [`step`](#step) | Yes | |
| `diagnostics` | array of [`definitionDiagnostic`](cli-list.md#definitiondiagnostic) | Yes | |

No other properties are allowed.
69 changes: 69 additions & 0 deletions docs/reference/schemas/cli-doctor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!-- Generated by tools/scripts/reference-docs.mjs from packages/schemas/schemas/cli/doctor/v0.json. Do not edit: run `npm run docs:generate`. -->

# CLI doctor

What the checkout needs to run its projections, found without running anything (`projections doctor --json`). The schema is published at its ID, `https://schemas.projections.githubnext.com/cli/doctor/v0.json`; it is generated from TypeBox
definitions into [`packages/schemas/schemas/cli/doctor/v0.json`](../../../packages/schemas/schemas/cli/doctor/v0.json).

## Document

| Property | Type | Required | Description |
|---|---|---|---|
| `format` | `"projections.doctor"` | Yes | |
| `version` | `0` | Yes | |
| `ok` | boolean | Yes | |
| `items` | array of [`item`](#item) | Yes | |
| `projections` | array of object | Yes | |
| `environment` | [`environment`](#environment) | | |

No other properties are allowed.

## Definitions

### `workspaceStrategy`

The workspace strategy in effect, where it was set, and why.

| Property | Type | Required | Description |
|---|---|---|---|
| `strategy` | `"fresh"` or `"worktree"` or `"clone"` or `"sparse"` or `"none"` | Yes | |
| `source` | `"flag"` or `"config"` or `"environment"` or `"automatic"` | Yes | |
| `reason` | string | Yes | |

No other properties are allowed.

### `workspaceError`

Why the workspace strategy couldn't be chosen.

| Property | Type | Required | Description |
|---|---|---|---|
| `error` | string | Yes | |

No other properties are allowed.

### `environment`

| Property | Type | Required | Description |
|---|---|---|---|
| `workspace` | [`workspaceStrategy`](#workspacestrategy) or [`workspaceError`](#workspaceerror) | Yes | |
| `workspaces` | array of [`workspace`](cli-workspaces.md#workspace) | | |
| `workspacesError` | string | | |
| `declared` | string or null | | The environment file, or `null` when none is declared. |
| `error` | string | | |
| `prepare` | array of object | | |
| `toolchain` | array of array of string | | |
| `devcontainer` | string or null | | |
| `missing` | array of string | | |

No other properties are allowed.

### `item`

| Property | Type | Required | Description |
|---|---|---|---|
| `status` | `"pass"` or `"warn"` or `"fail"` | Yes | |
| `title` | string | Yes | |
| `message` | string | Yes | |

No other properties are allowed.
Loading
Loading