Skip to content
Draft
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ carry no release status. The `v<version>` tag and npm show whether a version is
Entries start with the first version prepared after this file was added, and earlier versions have none. The
repository's [tags](https://github.com/firstdraft/cli/tags) identify the source of each published version.

## 0.13.0

- `plan init` writes Plan `firstdraft.foundation-plan.sketch/0.25`, which supports the email and slug Fields.
Compile and download validate artifacts for that exact format. The CLI requires service API contract 0.11.0 or a
later patch on that minor line. Use CLI 0.12.x for API 0.10.x and Plan 0.24.
- To start a new Compile from an older Plan, republish it in Plan 0.25 in the same Project and approve the updated
Plan. Published screen reviews still open with their original Plan bytes, and `compilation status` can read
earlier terminal Compilations retained by the service.

## 0.12.1

- Run `firstdraft sketches publish` in a hosted interview or in a Project that already has a pushed Plan.
Expand Down
13 changes: 7 additions & 6 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
This page owns the detailed public semantics of the current command surface. Run `firstdraft --help` or a command
group's `--help` for concise executable syntax. See [Errors and recovery](errors.md) before retrying a failed mutation.

The current `0.12.x` source line contains the auditable command shell, the agent's `start` check, browser and device
The CLI contains the auditable command shell, the agent's `start` check, browser and device
login in one command or in two steps that an agent runs, local Foundation Plan
initialization, hosted Project creation and screen review, local application-key and UUID generation, conditional whole-document push, whole-graph analysis
status polling, direct Compile-and-materialize, retained-Compilation inspection and
cancellation, the account's report setting, progress and failure reports, notes, and maintenance-item listing,
inspection, resolution, deferral, and owner questions. It requires API contract `0.10.0` or a later patch on the same minor line. The [changelog](https://github.com/firstdraft/cli/blob/main/CHANGELOG.md) describes each version.
inspection, resolution, deferral, and owner questions. It requires API contract `0.11.0` or a later patch on the same minor line. The [changelog](https://github.com/firstdraft/cli/blob/main/CHANGELOG.md) describes each version.
[What the CLI sends](#what-the-cli-sends) lists every request and what it carries.

## Command map
Expand Down Expand Up @@ -414,7 +414,7 @@ From the project that the Plan describes:
firstdraft plan init --name "Oscar Party"
```

This creates an empty `firstdraft.foundation-plan.sketch/0.24` Plan targeting `rails-sketch/2026-11`. In a fresh
This creates an empty `firstdraft.foundation-plan.sketch/0.25` Plan targeting `rails-sketch/2026-11`. In a fresh
folder it creates the Project ID and an ignored `.firstdraft/` directory. In a folder reserved by `project start`,
it writes the Plan for the existing Project ID and origin. Initialization runs locally and preserves any existing Plan.

Expand Down Expand Up @@ -731,9 +731,10 @@ when a retained direct Compilation succeeded but an earlier root materialization
never starts replacement work. An incomplete rollback leaves `.firstdraft-root-output` and requires journal
reconciliation before this command can run again.

Artifact validation accepts only Plan format `firstdraft.foundation-plan.sketch/0.24` and target profile
Artifact validation accepts only Plan format `firstdraft.foundation-plan.sketch/0.25` and target profile
`rails-sketch/2026-11`, in addition to matching the retained Compilation's provenance and verifying file integrity.
An earlier format or profile is rejected before materialization, even when the retained status names that profile.
Use `compilation status` to read earlier terminal Compilations the service retains. A download whose artifact
uses an earlier format or profile is rejected before materialization, even when its status is `succeeded`.

Successful root adoption is intentionally one-way. The original `.firstdraft` authoring state moves under
`.firstdraft/design/.firstdraft`; run later Plan and Compilation commands from `.firstdraft/design`. Run ordinary
Expand Down Expand Up @@ -1089,7 +1090,7 @@ The first push sends `If-None-Match: *`. Later pushes and the Compilation start
`If-Match`. The cancel `POST` sends no precondition header. The resolution, deferral, and owner-question `POST`s send
a JSON body and no precondition header.

The `/v1` routes require API contract `0.10.0` or a later patch on the same minor line. `API_CONTRACT_RANGE` in `src/service-client.js` declares that range,
The `/v1` routes require API contract `0.11.0` or a later patch on the same minor line. `API_CONTRACT_RANGE` in `src/service-client.js` declares that range,
`release/compatibility.json` declares it for the Service's release compatibility check, and
`test/release-compatibility.test.js` keeps the two equal. The CLI reads `FirstDraft-API-Contract` on every response
and stops at a Service outside the range, as [update line and refusals](#update-line-and-refusals) describes: with
Expand Down
4 changes: 4 additions & 0 deletions docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ format. Update the local Plan to the format named in `response.detail`. Republis
check the new analysis and obtain approval for the updated Plan before compiling. For a screen review, use the new
revision ID. A previously published screen review still opens with its original Plan.

If `compilation download` encounters an artifact in an earlier Plan format, it reports `invalid_artifact`.
`compilation status` can still show the retained result. To create an artifact in the current format, republish
the Plan and approve a new Compile as above.

A Project allows one active Compilation. While one is queued or running, `plan push` and `plan compile` report
`server_rejected` with First Draft's `409 compilation_active` problem in `response`, because the Plan cannot be
replaced. `plan compile` can also meet it at the Compilation start, as `compilation_start_rejected`. Either problem's
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firstdraft.com/cli",
"version": "0.12.1",
"version": "0.13.0",
"description": "Command-line interface for First Draft",
"license": "MIT",
"type": "module",
Expand Down
6 changes: 3 additions & 3 deletions release/compatibility.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"format": "firstdraft.release-compatibility/1",
"component": "cli",
"version": "0.12.1",
"version": "0.13.0",
"requires": {
"api_contract": [">= 0.10.0", "< 0.11.0"],
"foundation_plan_formats": ["firstdraft.foundation-plan.sketch/0.24"]
"api_contract": [">= 0.11.0", "< 0.12.0"],
"foundation_plan_formats": ["firstdraft.foundation-plan.sketch/0.25"]
}
}
2 changes: 1 addition & 1 deletion src/compilation-artifact.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
export const ARTIFACT_MEDIA_TYPE =
"application/vnd.firstdraft.compilation-artifact+json";
export const ARTIFACT_FORMAT = "firstdraft.compilation-artifact/1";
export const FOUNDATION_PLAN_FORMAT = "firstdraft.foundation-plan.sketch/0.24";
export const FOUNDATION_PLAN_FORMAT = "firstdraft.foundation-plan.sketch/0.25";
// The one place the CLI names the Rails target profile: plan init writes it,
// artifact validation accepts only it, and the documentation test requires
// the docs to name only it. The value is the profile of this release.
Expand Down
4 changes: 2 additions & 2 deletions src/service-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const UPDATE_URL = "https://firstdraft.com/update";
* declares the same range for the release check, and
* test/release-compatibility.test.js keeps the two equal.
*/
export const API_CONTRACT_RANGE = Object.freeze([">= 0.10.0", "< 0.11.0"]);
export const API_CONTRACT_RANGE = Object.freeze([">= 0.11.0", "< 0.12.0"]);

/** Set by the plugin's launcher; docs/commands.md names them for wrappers. */
export const PLUGIN_VERSION_VARIABLE = "FIRSTDRAFT_PLUGIN_VERSION";
Expand Down Expand Up @@ -424,7 +424,7 @@ const API_CONTRACT_FLOOR = /** @type {Version} */ (

/**
* As in npm ranges, a prerelease contract is outside a range whose bounds
* name none, so `0.10.0-rc.1` is refused like `0.10.0`.
* name none. For example, `0.11.2-rc.1` is refused even though `0.11.2` is accepted.
*
* @param {Version} contract
*/
Expand Down
2 changes: 1 addition & 1 deletion test/compilation-artifact.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ test("pins external provenance identities and validates nested metadata", () =>
artifactFixture({
provenance: {
foundation_plan: {
format: "firstdraft.foundation-plan.sketch/0.22",
format: "firstdraft.foundation-plan.sketch/0.24",
sha256: FOUNDATION_PLAN_SHA256,
},
},
Expand Down
2 changes: 1 addition & 1 deletion test/compilation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const ARTIFACT_PATH = `${STATUS_PATH}/artifact`;

test("direct Compilation pins the reviewed Plan and materializes one retained artifact", async (context) => {
const planSource = Buffer.from(
'{"format":"firstdraft.foundation-plan.sketch/0.24"}\n',
'{"format":"firstdraft.foundation-plan.sketch/0.25"}\n',
);
const headSourceSha256 = sha256(planSource);
const etag = `"sha256:${headSourceSha256}"`;
Expand Down
4 changes: 2 additions & 2 deletions test/plan-compile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const STALE_ANALYSIS_ID = "01900000-0000-7000-8000-000000002005";
const COMPILATION_ID = "01900000-0000-7000-8000-000000002003";
const API_TOKEN = `fd_${"a".repeat(43)}`;
const PLAN_SOURCE = Buffer.from(
'{"format":"firstdraft.foundation-plan.sketch/0.24","application":{"key":"movie_catalog","name":"Movie Catalog"}}\n',
'{"format":"firstdraft.foundation-plan.sketch/0.25","application":{"key":"movie_catalog","name":"Movie Catalog"}}\n',
);
const HEAD_SHA256 = sha256(PLAN_SOURCE);
const ETAG = `"sha256:${HEAD_SHA256}"`;
Expand Down Expand Up @@ -1121,7 +1121,7 @@ function acceptedPlanBody(graphVersion = 1) {
return {
project: { id: PROJECT_ID, graph_version: graphVersion },
foundation_plan: {
format: "firstdraft.foundation-plan.sketch/0.24",
format: "firstdraft.foundation-plan.sketch/0.25",
source_sha256: HEAD_SHA256,
},
diagnostics: [],
Expand Down
2 changes: 1 addition & 1 deletion test/plan-push.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ function acceptedBody(source, diagnostics = []) {
return {
project: { id: PROJECT_ID, graph_version: 1 },
foundation_plan: {
format: "firstdraft.foundation-plan.sketch/0.24",
format: "firstdraft.foundation-plan.sketch/0.25",
source_sha256: sha256(source),
},
diagnostics,
Expand Down
38 changes: 19 additions & 19 deletions test/service-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,15 @@ test("a stop that did not cut the command short keeps its result and names the s
});

test("the CLI accepts only its declared API contract range", async () => {
assert.deepEqual(API_CONTRACT_RANGE, [">= 0.10.0", "< 0.11.0"]);
assert.deepEqual(API_CONTRACT_RANGE, [">= 0.11.0", "< 0.12.0"]);

for (const contract of [
"0.10.0",
"0.10.7",
" 0.10.0 ",
"0.10.2+build.7",
"0.11.0",
"0.11.7",
" 0.11.0 ",
"0.11.2+build.7",
"unknown",
"0.10",
"0.11",
]) {
const session = createServiceSession({
env: {},
Expand All @@ -315,15 +315,15 @@ test("the CLI accepts only its declared API contract range", async () => {
}

for (const [contract, kind] of /** @type {[string, string][]} */ ([
["0.11.0", "newer"],
["0.11.0+build.7", "newer"],
["0.11.0-rc.1", "newer"],
["0.12.0", "newer"],
["0.12.0+build.7", "newer"],
["0.12.0-rc.1", "newer"],
["1.0.0", "newer"],
["0.8.1", "older"],
["0.9.0-rc.1", "older"],
["0.9.1", "older"],
["0.10.0-rc.1", "older"],
["0.10.2-rc.1", "prerelease"],
["0.10.0", "older"],
["0.11.0-rc.1", "older"],
["0.11.2-rc.1", "prerelease"],
])) {
const session = createServiceSession({ env: {}, notify: () => undefined });
const request = session.fetch(async () => versionedResponse({ contract }));
Expand Down Expand Up @@ -407,7 +407,7 @@ test("a 429 without Retry-After or a problem says to wait a minute", async () =>
test("a 429 reports the limit even when the response also requires an update", async () => {
for (const headers of [
{ "FirstDraft-Minimum-CLI": "99.0.0" },
{ "FirstDraft-API-Contract": "0.10.0" },
{ "FirstDraft-API-Contract": "0.12.0" },
]) {
const session = createServiceSession({
env: {},
Expand All @@ -433,7 +433,7 @@ test("a 429 reports the limit even when the response also requires an update", a
test("the stop line for an older or prerelease contract does not advise updating", async () => {
for (const [contract, sentence] of /** @type {[string, string][]} */ ([
["0.8.7", "serves API contract 0.8.7, which is older than"],
["0.10.2-rc.1", "serves prerelease API contract 0.10.2-rc.1, which"],
["0.11.2-rc.1", "serves prerelease API contract 0.11.2-rc.1, which"],
])) {
/** @type {string[]} */
const lines = [];
Expand Down Expand Up @@ -650,15 +650,15 @@ test("a Service outside the API contract range is refused with both versions", a
const cwd = await initializedProject(context);
const result = await invoke(["plan", "compile", "--output", "application"], {
cwd,
fetchFunction: async () => acceptedPush(cwd, { contract: "0.11.0" }),
fetchFunction: async () => acceptedPush(cwd, { contract: "0.12.0" }),
});

assert.equal(result.status, 1);
assert.deepEqual(errorEnvelope(result.stderr), {
error: "api_contract_unsupported",
detail: `First Draft at ${ORIGIN} serves API contract 0.11.0, which is newer than CLI ${VERSION} accepts. The CLI stopped before the command finished and sent nothing more. Tell the person to update with the steps at ${UPDATE_URL}, then run the same command again, with the same options.`,
api_contract: "0.11.0",
accepted_api_contract: [">= 0.10.0", "< 0.11.0"],
detail: `First Draft at ${ORIGIN} serves API contract 0.12.0, which is newer than CLI ${VERSION} accepts. The CLI stopped before the command finished and sent nothing more. Tell the person to update with the steps at ${UPDATE_URL}, then run the same command again, with the same options.`,
api_contract: "0.12.0",
accepted_api_contract: [">= 0.11.0", "< 0.12.0"],
cli_version: VERSION,
update_url: UPDATE_URL,
});
Expand Down Expand Up @@ -765,7 +765,7 @@ function acceptedPush(cwd, versions) {
JSON.stringify({
project: { id: PROJECT_ID, graph_version: 1 },
foundation_plan: {
format: "firstdraft.foundation-plan.sketch/0.24",
format: "firstdraft.foundation-plan.sketch/0.25",
source_sha256: createHash("sha256").update(source).digest("hex"),
},
diagnostics: [],
Expand Down
10 changes: 6 additions & 4 deletions test/sketches.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import path from "node:path";
import { tmpdir } from "node:os";
import test from "node:test";
import { FOUNDATION_PLAN_FORMAT } from "../src/compilation-artifact.js";
import {
startProject,
publishSketches as publishWithTheme,
Expand Down Expand Up @@ -1308,10 +1309,11 @@ test(
acceptedSource = plan_source;
const sha = digest(plan_source);
assert.equal(manifest.plan_sha256, sha);
assert.deepEqual(
JSON.parse(plan_source).application.appearance.web_theme,
{ overrides: selected },
);
const publishedPlan = JSON.parse(plan_source);
assert.equal(publishedPlan.format, FOUNDATION_PLAN_FORMAT);
assert.deepEqual(publishedPlan.application.appearance.web_theme, {
overrides: selected,
});
assert.equal(manifest.version, 3);
for (const [device, width] of Object.entries({
desktop: 1280,
Expand Down
6 changes: 3 additions & 3 deletions test/start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ test("below the minimum, start gives the handled refusal instead of ready", asyn
});

test("an API contract outside the accepted range is not ready", async (context) => {
for (const contract of ["0.9.1", "0.11.0"]) {
for (const contract of ["0.10.0", "0.12.0"]) {
const result = await invoke(context, ["start"], {
saved: { [PRODUCTION]: SAVED_TOKEN },
fetchFunction: async () =>
Expand Down Expand Up @@ -433,7 +433,7 @@ test("a version refusal wins over a failed account read", async (context) => {
status: 200,
headers: {
"Content-Type": "application/json",
"FirstDraft-API-Contract": "0.11.0",
"FirstDraft-API-Contract": "0.12.0",
},
}),
"api_contract_unsupported",
Expand Down Expand Up @@ -516,7 +516,7 @@ function account(reports, headers = {}) {
status: 200,
headers: {
"Content-Type": "application/json",
"FirstDraft-API-Contract": "0.10.0",
"FirstDraft-API-Contract": "0.11.0",
...headers,
},
},
Expand Down
Loading