Skip to content
Merged
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.12.2

- `firstdraft sketches publish` now uploads the working Plan, screen HTML and declared assets. The Project
displays each screen at the reviewer’s chosen width. Chrome is no longer required on the computer that publishes.
Declare each HTML screen and all of its local assets in `sketches/board.json` and keep the files for Compile.
- Fresh publications require live screen support, introduced in API contract 0.10.2. Other CLI commands keep
their API 0.10.x range and Plan format 0.24. An interrupted publication can still replay its original request,
including a capture created by an earlier CLI.

## 0.12.1

- Run `firstdraft sketches publish` in a hosted interview or in a Project that already has a pushed Plan.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ is the Codespaces fallback.
- direct Compile-and-materialize;
- retained Compilation inspection, cancellation, and artifact download;
- terminal output, exit status, and recovery contracts;
- the npm package with local Chrome screen capture; and
- the npm package with live screen publication; and
- package provenance and publication.

The Service owns Foundation Plan meaning and server-side lifecycle. Skills own the agent conversation. This
Expand Down Expand Up @@ -95,7 +95,7 @@ The published package:

- installs the firstdraft executable;
- runs reviewed JavaScript source directly;
- uses Playwright Core for local screen capture and has no install scripts;
- publishes declared HTML and assets without a browser installation;
- sends nothing in the background or beyond the command the caller runs. [What the CLI sends](docs/commands.md#what-the-cli-sends)
lists each command's requests and their `FirstDraft-Client` header: CLI and plugin versions, agent, and operating
system. `report` and `note` read the account first and, only with reports on, print their exact body and then send it;
Expand Down
136 changes: 64 additions & 72 deletions docs/commands.md

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ remain human-readable text on standard error with exit 2. Unexpected programming

## Screen review recovery

When a screen capture fails, the detail gives its screen ID and viewport dimensions. Correct the indicated Plan
binding, image, asset URL, or layout and publish again.
If the service does not advertise live screen files, update it to API 0.10.2 or a later patch on that API line. The CLI
stops before uploading a new board. A pending publication replays its saved request.

`sketch_review_failed` describes a Project-start, capture, publication or reviewed-source problem. Retry an interrupted
`sketch_review_failed` describes a Project-start, publication or reviewed-source problem. Retry an interrupted
start from the same directory. A fresh publication refused with a client error other than an HTTP 408 clears its
pending request. Correct the rejected draft or login, or wait for the rate limit, then publish again.

Expand Down Expand Up @@ -60,13 +60,13 @@ The service problem appears in `response` when the CLI can verify its shape:
requested review and Plan. Inspect the current revision and Head, reconcile and publish any changes, and obtain
approval for the revision before passing it to `plan compile --revision`. When graph versions differ, the Plan
passed through another generation even if its current bytes match an older review.
- `422 invalid_review_theme` in `sketch_review_failed` means the service could not preview the working Plan’s
`application.appearance.web_theme`. Set all three presets together when using them, and use supported tokens
and values for overrides. Correct the theme in the Plan and run `firstdraft sketches publish` again.
- A CLI that publishes captured images can receive `422 invalid_review_theme` when previewing the working Plan.
Correct the presets or override tokens in `application.appearance.web_theme` and publish again.
- `422 invalid_sketch_review` in `sketch_review_failed` means the service rejected the review bundle. Read
`response.detail`, correct the indicated board, capture or reference, and publish the corrected draft. A rejected Plan can instead return `response.diagnostics`; use those to fix the Plan.
`response.detail`. If a file is missing, add the referenced local asset to `sketches/board.json` or correct the
path in the indicated screen or stylesheet. Correct the draft and publish again. A rejected Plan can instead return `response.diagnostics`; use those to fix the Plan.
- `413 sketch_quota_reached` in `sketch_review_failed` means the Project reached its stored review limit. A
smaller capture may fit if only the stored byte budget is limiting it. At the revision-count limit, continue
smaller source bundle may fit if only the stored byte budget is limiting it. At the revision-count limit, continue
the walkthrough using local HTML.

Restore missing approved source from the planning folder or review a reconstruction. When an older service lacks
Expand Down Expand Up @@ -343,7 +343,7 @@ again. First Draft refuses to resolve an item that is still resolved, with `main

| Commands | `error` | Exit | Meaning |
| ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ---: | ---------------------------------------------------------------------------------------------------------------------------- |
| Hosted screens commands and reviewed source handoff | `sketch_review_failed` | 1 | Repair the Project, capture, publication or source handoff ([recovery](#screen-review-recovery)). |
| Hosted screens commands and reviewed source handoff | `sketch_review_failed` | 1 | Repair the Project, publication or source handoff ([recovery](#screen-review-recovery)). |
| Any leaf command | `invalid_arguments` | 2 | Syntax was invalid; no request was made. |
| Network commands except `logout` | `update_required`, `api_contract_unsupported` | 1 | First Draft needs a newer plugin or CLI, or serves another API contract ([recovery](#update-and-limit-errors)). |
| Network commands except `logout` | `rate_limited` | 1 | First Draft refused a request at a limit; `retry_at` says when to try again. |
Expand Down
19 changes: 3 additions & 16 deletions package-lock.json

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

5 changes: 2 additions & 3 deletions 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.12.2",
"description": "Command-line interface for First Draft",
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -55,7 +55,6 @@
"minimatch": "^11.0.5"
},
"dependencies": {
"jsonc-parser": "3.3.1",
"playwright-core": "1.65.1"
"jsonc-parser": "3.3.1"
}
}
2 changes: 1 addition & 1 deletion release/compatibility.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"format": "firstdraft.release-compatibility/1",
"component": "cli",
"version": "0.12.1",
"version": "0.12.2",
"requires": {
"api_contract": [">= 0.10.0", "< 0.11.0"],
"foundation_plan_formats": ["firstdraft.foundation-plan.sketch/0.24"]
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if (result.status !== 0) {
"src/review-theme.js",
"src/root-output.js",
"src/service-client.js",
"src/sketch-capture.js",
"src/sketch-sources.js",
"src/uuid-v7.js",
"src/version.js",
]);
Expand Down
8 changes: 0 additions & 8 deletions src/api-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,10 @@ export class FirstDraftProtocolError extends Error {
*/
export const SERVICE_ROUTES = {
startProject: { method: "PUT", path: "/v1/projects/{project_id}" },
reviewFontAsset: {
method: "GET",
path: "/theme-fonts/{family}/{version}/{asset}",
},
readReviewTheme: {
method: "GET",
path: "/v1/projects/{project_id}/review-theme",
},
previewReviewTheme: {
method: "POST",
path: "/v1/projects/{project_id}/review-theme/preview",
},
publishSketches: {
method: "PUT",
path: "/v1/projects/{project_id}/sketch-reviews/{revision_id}",
Expand Down
3 changes: 1 addition & 2 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5259,7 +5259,7 @@ async function runSketchCommand({
const subcommand = start ? "start" : "publish";
const group = start ? "project" : "sketches";
const command = `firstdraft ${group} ${subcommand}`;
const help = `Usage: ${command} [--staging]${start ? "" : " [--after <revision> --head <sha256>]"}\n${start ? "Create or reopen this directory's hosted Project before drafting its Plan." : "Capture sketches/board.json and publish its screens with the local Foundation Plan."}\n`;
const help = `Usage: ${command} [--staging]${start ? "" : " [--after <revision> --head <sha256>]"}\n${start ? "Create or reopen this directory's hosted Project before drafting its Plan." : "Publish the screen files declared in sketches/board.json with the local Foundation Plan."}\n`;
if (argv[1] !== subcommand)
return runCommandGroup(
{ argv: argv.slice(1), stdout, stderr },
Expand Down Expand Up @@ -5321,7 +5321,6 @@ async function runSketchCommand({
start
? startProject({ cwd: cwd ?? getCwd(), ...auth })
: publishSketches({
publicFetch: service.fetch(fetchFunction),
throwIfStopped: service.throwIfStopped,
cwd: cwd ?? getCwd(),
...auth,
Expand Down
34 changes: 10 additions & 24 deletions src/commands/sketches.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import {
import { resolveApiUrl } from "./plan-push.js";
import {
digest,
captureBoard,
sourceManifest,
loadSources,
SketchError,
} from "../sketch-capture.js";
} from "../sketch-sources.js";
import { publicationTheme } from "../review-theme.js";
export { SketchError };
const privateWrite = { flag: "wx", mode: 0o600, flush: true };
Expand Down Expand Up @@ -131,7 +131,7 @@ function readReview(cwd, revision) {
throw new SketchError("Invalid local screen review receipt.");
return receipt;
}
/** @typedef {Options & {capture?:typeof captureBoard, publicFetch?:typeof fetch,throwIfStopped?:()=>void, after?:string, head?:string}} PublishOptions */
/** @typedef {Options & {throwIfStopped?:()=>void, after?:string, head?:string}} PublishOptions */
/** @param {PublishOptions} options */
export async function publishSketches(options) {
return withPlanStateLock(path.join(options.cwd, ".firstdraft"), () =>
Expand All @@ -145,8 +145,6 @@ async function publishCurrentSketches({
apiUrl,
fetchFunction,
hasTokenFor,
capture = captureBoard,
publicFetch,
throwIfStopped,
after,
head,
Expand All @@ -168,12 +166,7 @@ async function publishCurrentSketches({
const planBytes = readLocalFile(planFile, 1024 * 1024);
if (!isUtf8(planBytes))
throw new SketchError("The Foundation Plan must contain valid UTF-8.");
const {
source: plan_source,
theme,
includeLinks,
includeSelectors,
} = await publicationTheme(
const { source: plan_source } = await publicationTheme(
planBytes.toString("utf8"),
origin,
state.project_id,
Expand All @@ -184,15 +177,8 @@ async function publishCurrentSketches({
throw new SketchError(
"The working Foundation Plan exceeds 1 MiB after applying its theme.",
);
const sources = loadSources(cwd);
const manifest = await capture(
sources,
plan_source,
theme,
publicFetch,
includeLinks,
includeSelectors,
);
const sources = loadSources(cwd, true);
const manifest = sourceManifest(sources, plan_source);
throwIfStopped?.();
const body = JSON.stringify({
previous_revision_id: previous ?? null,
Expand All @@ -207,7 +193,7 @@ async function publishCurrentSketches({
throw new SketchError("The review bundle exceeds 24 MiB.");
if (!readLocalFile(planFile, 1024 * 1024).equals(planBytes))
throw new SketchError(
"The working Plan changed during capture. Publish the current draft again.",
"The working Plan changed during publication. Publish the current draft again.",
);
save(
pendingFile,
Expand Down Expand Up @@ -339,8 +325,8 @@ async function publishCurrentSketches({
let nextStep;
if (localPlanChanged)
nextStep =
"The working Plan changed after capture. Reconcile published_web_theme with application.appearance.web_theme in the current draft, then run firstdraft sketches publish again.";
else if (replay) {
"The working Plan changed after publication began. Reconcile published_web_theme with application.appearance.web_theme in the current draft, then run firstdraft sketches publish again.";
else {
try {
reviewedSources(cwd, pending.id);
} catch (error) {
Expand All @@ -349,7 +335,7 @@ async function publishCurrentSketches({
))
throw error;
nextStep =
"Recovered the saved publication. The current planning files do not match this review. Run firstdraft sketches publish again to capture and publish the current draft.";
"The current planning files differ from this review. Run firstdraft sketches publish again to publish the current draft.";
}
}
return {
Expand Down
2 changes: 1 addition & 1 deletion src/plan-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ function arraysEqual(left, right) {
}

/**
* Serialize hosted writes from capture through durable local receipt. A response
* Serialize hosted writes from source preparation through durable local receipt. A response
* can arrive after a later writer commits, even when the Plan digest repeats.
* @template T
* @param {string} directory @param {() => Promise<T>} update
Expand Down
Loading
Loading