@firstdraft.com/cli 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # First Draft CLI documentation
2
+
3
+ Use this page to find the narrowest authoritative document for a task. Runtime source and tests remain the final
4
+ evidence for implemented behavior; if they contradict a document, surface the contradiction instead of guessing.
5
+
6
+ | If the task concerns... | Read first |
7
+ | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
8
+ | Beginner tester journey | [Drawing Board guide](https://github.com/firstdraft/drawing-board#build-an-app-with-first-draft) |
9
+ | Direct CLI installation, repository orientation, or package contract | [Root README](../README.md) |
10
+ | Commands, options, environment variables, API behavior, output, or materialization | [Command reference](commands.md) |
11
+ | Stable errors, exit codes, retry safety, ambiguous outcomes, or local recovery | [Errors and recovery](errors.md) |
12
+ | Version policy, release preparation, publication, verification, rollback, or promotion | [Release policy and runbook](../RELEASING.md) |
13
+ | What was observed for an earlier tag, package, or dist-tag | [Release history](release-history.md) |
14
+ | Vulnerability reporting | [Security policy](../SECURITY.md) |
15
+
16
+ ## Authority boundaries
17
+
18
+ - [README.md](../README.md) owns repository orientation, direct installation, package boundaries, and routes.
19
+ - [commands.md](commands.md) owns detailed command semantics. Built-in `--help`, runtime source, and tests own exact
20
+ executable syntax and behavior.
21
+ - [errors.md](errors.md) owns handled-error interpretation and recovery guidance.
22
+ - [RELEASING.md](../RELEASING.md) owns living release policy and the operator runbook.
23
+ - [release-history.md](release-history.md) preserves dated release observations. Recheck live tags, package versions,
24
+ dist-tags, access, and trusted-publisher state before relying on them operationally.
25
+ - The source repository's `AGENTS.md` routes agent work; it should stay compact rather than duplicate these documents.
26
+
27
+ ## Retrieval quality
28
+
29
+ Start here, then load the one owning document for the task. Follow a cross-link only when the task crosses an
30
+ authority boundary. Create another page only for a distinct audience, task, or authority.
31
+
32
+ The documentation tests keep `AGENTS.md` at or below 2 KiB, the root README at or below 6 KiB, and this map at or
33
+ below 4 KiB. They also require every public topic to remain reachable from this map or the root README and verify
34
+ repository-local links and fragments. The package check separately verifies that every relative link in the
35
+ packaged Markdown resolves inside that exact package.
36
+
37
+ ## Work on the repository
38
+
39
+ Development uses Node.js 24.18.0 and npm 11.16.0, pinned in `.tool-versions`. From a fresh checkout:
40
+
41
+ ```sh
42
+ npm ci --ignore-scripts
43
+ npm audit
44
+ npm run check
45
+ ```
46
+
47
+ `npm run check` runs type checking, linting, formatting, tests, the exact package allowlist check, and a packed-package
48
+ smoke test. To inspect the package manifest without writing a tarball:
49
+
50
+ ```sh
51
+ npm pack --dry-run --json --ignore-scripts
52
+ ```
53
+
54
+ To reproduce the length-delimited SHA-256 used by external evidence to identify packaged JavaScript runtime inputs
55
+ (`package.json`, `bin/firstdraft.js`, and every `.js` file under `src/`), run:
56
+
57
+ ```sh
58
+ node scripts/runtime-digest.js
59
+ ```
@@ -0,0 +1,248 @@
1
+ # First Draft CLI command reference
2
+
3
+ This page owns the detailed public semantics of the current command surface. Run `firstdraft --help` or a command
4
+ group's `--help` for concise executable syntax. See [Errors and recovery](errors.md) before retrying a failed mutation.
5
+
6
+ The current `0.2.x` source line contains the auditable command shell, local Foundation Plan initialization, local
7
+ application-key and UUID generation, conditional whole-document push, whole-graph analysis status polling, direct
8
+ Compile-and-materialize and private publish orchestration, and retained-Compilation inspection. CLI `0.2.x`
9
+ requires the service's `0.3.x` API contract. See the [release policy](../RELEASING.md) for versioning and channel
10
+ semantics and [release history](release-history.md) for the transition from prereleases.
11
+
12
+ ## Command map
13
+
14
+ | Command | Network | Purpose |
15
+ | ------------------------------------- | ------- | ---------------------------------------------------------- |
16
+ | `firstdraft plan init` | No | Create an empty local Foundation Plan and Project identity |
17
+ | `firstdraft generate application-key` | No | Preview deterministic name-to-key derivation |
18
+ | `firstdraft generate uuid` | No | Generate one or more Foundation Plan subject identities |
19
+ | `firstdraft plan push` | Yes | Conditionally submit the exact whole Plan |
20
+ | `firstdraft plan status` | Yes | Read or wait for the current whole-graph analysis |
21
+ | `firstdraft plan compile` | Yes | Push and analyze, then materialize or publish |
22
+ | `firstdraft compilation status` | Yes | Inspect a retained Compilation by ID |
23
+ | `firstdraft compilation download` | Yes | Verify and materialize a successful retained Compilation |
24
+
25
+ ## Authenticate API commands
26
+
27
+ Create an API token in First Draft and provide it only through the environment when running a network command:
28
+
29
+ ```sh
30
+ export FIRSTDRAFT_API_TOKEN="your-token"
31
+ firstdraft plan push
32
+ ```
33
+
34
+ `plan push`, `plan status`, `plan compile`, and `compilation` subcommands send the token as a Bearer credential on
35
+ every API request. The CLI does not save it in `.firstdraft`, print it, or require it for local commands such as
36
+ `plan init` and `generate`. Revoke the token in First Draft if it is exposed. A missing token, or First Draft's
37
+ validated `401` problem response with the `authentication_required` code, produces that stable CLI error.
38
+
39
+ ## Start a Foundation Plan
40
+
41
+ From the project that the Plan describes:
42
+
43
+ ```sh
44
+ firstdraft plan init --name "Oscar Party"
45
+ ```
46
+
47
+ This creates an empty `sketch/0.19` Plan and client-generated Project ID under `.firstdraft/`. A nested ignore file
48
+ keeps that local scratch area out of Git without changing the project's own `.gitignore`. Initialization makes no
49
+ network request and refuses to replace an existing `.firstdraft` path.
50
+
51
+ Provide either `--name`, `--application-key`, or both. Name-only initialization derives a lower-snake key. Key-only
52
+ initialization derives a humanized display name. Supplying both preserves both values exactly after validating them
53
+ against the Foundation Plan schema.
54
+
55
+ ### Generate an application key
56
+
57
+ To inspect the name-to-key derivation without initializing a project, run:
58
+
59
+ ```sh
60
+ firstdraft generate application-key --name "Oscar Party"
61
+ ```
62
+
63
+ The generated key is deterministic, starts with a letter, contains only lowercase ASCII letters, digits, and
64
+ underscores, and is at most 63 bytes so it can lower to the current iOS application identifier component. Names
65
+ without a readable ASCII form receive a stable digest-based key. Longer readable names are shortened to a readable
66
+ prefix plus a stable digest suffix. Explicit application keys retain the Foundation Plan's broader
67
+ `^[a-z][a-z0-9_]*$` boundary and are left for target analysis rather than silently rewritten.
68
+
69
+ ### Generate Foundation Plan subject identities
70
+
71
+ Generate an identity before adding each new independently mutable authored subject:
72
+
73
+ ```sh
74
+ firstdraft generate uuid
75
+ ```
76
+
77
+ The command prints one UUIDv7 for the subject's `subject_uuid`. It does not read or modify the Plan, reserve the
78
+ value, or make a network request. Preserve that UUID when renaming the subject or moving it to a different semantic
79
+ owner without changing its kind. Use a new UUID for a replacement concept. Readable keys and paths may change and
80
+ remain the document's links; the UUID preserves continuity between complete-document pushes.
81
+
82
+ Use `--count <n>` to print several independently generated UUIDv7 values, one per line.
83
+
84
+ ## Push a Foundation Plan
85
+
86
+ From the initialized project:
87
+
88
+ ```sh
89
+ firstdraft plan push
90
+ ```
91
+
92
+ The command sends the exact bytes in `.firstdraft/foundation-plan.json`. The first push conditionally creates the
93
+ Project; later pushes replay the complete ETag saved in `.firstdraft/state.json` so a stale writer cannot replace a
94
+ newer Plan. Successful responses and server diagnostics are printed as JSON for an agent to inspect.
95
+
96
+ The initial API origin defaults to `https://firstdraft.com`. Set `FIRSTDRAFT_API_URL` to use another HTTPS origin or
97
+ a loopback HTTP development server. The first successful push pins the normalized origin in local state, and a later
98
+ override must match it.
99
+
100
+ If a failure happens after sending the request, the CLI leaves local state unchanged. It never constructs an ETag
101
+ from the Plan digest or trusts an ETag from a response it could not fully verify. Follow
102
+ [ambiguous-mutation recovery](errors.md#ambiguous-mutations) rather than blindly retrying.
103
+
104
+ ## Read analysis status
105
+
106
+ After a successful push:
107
+
108
+ ```sh
109
+ firstdraft plan status
110
+ firstdraft plan status --wait
111
+ ```
112
+
113
+ Without `--wait`, the command makes one `GET` and prints the current analysis as one JSON object. With `--wait`, it
114
+ polls sequentially once per second for at most two minutes and stops at `valid`, `issues_found`, `analysis_failed`,
115
+ or `superseded`. Every validated analysis status is a successful read with exit 0; agents should branch on the
116
+ `analysis.status` value and inspect `analysis.diagnostics` rather than treating a completed analysis with issues as
117
+ a transport failure.
118
+
119
+ The projection includes the exact Head digest, Analyzer and Compiler releases, selected target, and
120
+ `analysis.gap_set` plus `analysis.gap_set_sha256`. A `valid` run always returns the complete parsed canonical
121
+ `firstdraft.foundation-gaps/2` object, including every ordered gap record and an empty `gaps` array when nothing is
122
+ missing. Both GapSet fields are `null` for every other status. The CLI validates the GapSet's Head, Project,
123
+ generation, releases, target, canonical digest, and complete record shapes, then prints the records without
124
+ truncating or rewriting them.
125
+
126
+ Status reads require the API origin pinned by a successful push. They never select an origin from the current
127
+ environment, expose the private ETag, follow redirects, or modify local state. Each request has a bounded timeout,
128
+ ordinary response reads retain a 2 MiB bound, while this potentially gap-heavy response has a dedicated 128 MiB
129
+ bound. Every response is fully validated, and polling will not silently switch to a replacement analysis. The wait
130
+ repeats only validated `processing` responses and stops on its first failed read. A network failure is safe to retry
131
+ a bounded number of times because the command sends only `GET` requests. See
132
+ [read-only failures](errors.md#read-only-status-failures) if the problem persists.
133
+
134
+ ## Compile the current Plan
135
+
136
+ To compile into a local application directory, run:
137
+
138
+ ```sh
139
+ firstdraft plan compile --output ./application
140
+ ```
141
+
142
+ Both `plan compile` modes first push the exact current bytes in
143
+ `.firstdraft/foundation-plan.json`, even when those bytes are unchanged, and saves the accepted ETag using the same
144
+ contract as `plan push`. It then waits up to two minutes for an analysis whose graph version and
145
+ `head_source_sha256` exactly match that accepted push, polling past a terminal result retained for an older Head.
146
+ Invalid JSON, schema diagnostics, semantic diagnostics, a failed analysis, a superseded analysis, or a recurring
147
+ diagnostic stop the command with structured output; no Compilation or Publication is requested.
148
+
149
+ Only a `valid` analysis proceeds to the selected completion mode. Immediately before either conditional mutation,
150
+ the CLI re-reads the local Plan and requires its exact bytes and saved state to match the accepted Head. It extracts
151
+ the accepted source SHA-256 from the saved ETag, hashes the current local bytes, and sends that complete ETag in
152
+ `If-Match`.
153
+
154
+ ### Materialize a direct Compilation
155
+
156
+ With `--output`, the CLI requires an explicit absent destination beneath an existing real directory. It validates
157
+ that destination before pushing the Plan, checks it again after analysis, and never overwrites, merges into, or
158
+ repairs an existing path.
159
+
160
+ After valid analysis, the CLI requests one Compilation for that exact reviewed Head and never starts GitHub
161
+ Publication. It validates that the `202` response identifies the same Project, graph version, Head, Analysis,
162
+ Compiler release, and target; polls only that retained Compilation for up to ten minutes; downloads its exact
163
+ artifact; and applies the same integrity and atomic materialization contract as `compilation download`. An ambiguous
164
+ Compilation start is not retried automatically. After a validated `202`, later status, artifact, authentication,
165
+ and materialization failures retain the last validated Compilation projection so the caller can recover by ID
166
+ without starting duplicate work. Follow the [direct Compilation recovery procedure](errors.md#direct-compilation-recovery).
167
+
168
+ Success writes one JSON object to stdout containing the validated Project, Compilation, and absolute output path.
169
+ The installed directory contains exactly the artifact files and modes; the CLI does not add a Git repository, run a
170
+ formatter, or repair generated source. When the output is nested inside another Git worktree, initialize the
171
+ application as its own repository before running generated checks that inspect Git; otherwise Git resolves to the
172
+ parent worktree. Progress on stderr reports analysis and Compilation only.
173
+
174
+ ### Publish through GitHub
175
+
176
+ Without `--output`, the existing GitHub Publication journey remains unchanged:
177
+
178
+ ```sh
179
+ firstdraft plan compile
180
+ ```
181
+
182
+ Invoking this form authorizes the internal GitHub Publication lifecycle. The command writes stable human-readable
183
+ progress to stderr, with every line prefixed by `First Draft:`. It reports analysis, Compilation completion or
184
+ terminal failure or cancellation, the current GitHub phase, and an allowlisted reason, retry count, and exact UTC
185
+ retry time when a GitHub preflight check is delayed. A retained retry with no next time is reported as paused and
186
+ requiring operator recovery. Progress never includes IDs, hashes, repository names or URLs, raw server projections,
187
+ local paths, or environment values. Success writes exactly the validated private GitHub repository URL plus a
188
+ newline to stdout. If the command fails after progress has begun, its structured JSON error envelope is the final
189
+ stderr document after the progress lines.
190
+
191
+ The closed API `0.3.x` progress-reason allowlist is `github.configuration_missing`, `github.oauth_unavailable`,
192
+ `github.api_unavailable`, `github.reauthorization_required`, `github.account_mismatch`,
193
+ `github.installation_unavailable`, `github.installation_not_ready`, `github.preflight_unavailable`, the legacy-only
194
+ `github.preflight_unclassified`, and these stage-specific fallbacks: `github.preflight_unavailable.configuration`,
195
+ `github.preflight_unavailable.authorization`, `github.preflight_unavailable.repository_client`,
196
+ `github.preflight_unavailable.artifact_preparation`, `github.preflight_unavailable.installation_token`,
197
+ `github.preflight_unavailable.publication_preparation`, and `github.preflight_unavailable.repository_ref_client`.
198
+ Other values make the response invalid rather than becoming terminal output.
199
+
200
+ The internal Publication is a Project singleton in this release. A repeat safely receives the same Publication
201
+ instead of creating another. If the first conditional `PUT` has an ambiguous result, the CLI reconciles it with one
202
+ read-only singleton `GET` and never automatically repeats the mutation within that invocation. Publication polling
203
+ is sequential, bounded to ten minutes, and pinned to the retained Project Head, Compilation input, Publication
204
+ identity, and repository identity. Do not run concurrent Compile commands; use the
205
+ [publication recovery procedure](errors.md#publication-recovery) after an invocation exits.
206
+
207
+ This release cannot repoint a Project's Publication to a later accepted Head. The public CLI therefore has no
208
+ `plan publish` command. Direct local Compilation and GitHub Publication are separate completion modes after the same
209
+ exact Plan push and valid Analysis.
210
+
211
+ ## Inspect a retained Compilation
212
+
213
+ These lower-level commands are for callers that already hold a retained Compilation ID from authenticated API
214
+ metadata or operational tooling. The no-output `plan compile` form prints only the final repository URL, while
215
+ `plan compile --output` waits for and downloads its own direct Compilation:
216
+
217
+ ```sh
218
+ firstdraft compilation status 01900000-0000-7000-8000-000000000001
219
+ firstdraft compilation status 01900000-0000-7000-8000-000000000001 --wait
220
+ ```
221
+
222
+ Without `--wait`, the command makes exactly one metadata-only `GET`. With `--wait`, it polls that same Compilation
223
+ sequentially for at most ten minutes and rejects changes to its identity, Head provenance, target, or lifecycle
224
+ progression. `failed` and `cancelled` are successfully read terminal states with exit 0; branch on
225
+ `compilation.status` and inspect its validated `failure`.
226
+
227
+ ## Download a retained Compilation
228
+
229
+ Materialize an already successful Compilation into an absent path:
230
+
231
+ ```sh
232
+ firstdraft compilation download 01900000-0000-7000-8000-000000000001 --output ../movie-catalog
233
+ ```
234
+
235
+ The command validates the UUID and output path before network access, makes one status `GET`, requires `succeeded`,
236
+ and makes one artifact `GET`. It never starts work or polls. Historical artifact validation uses the retained
237
+ `compilation.head_source_sha256`, not the current local Plan or ETag, to pin the artifact's exact
238
+ `head_source_sha256`. The artifact's canonical `foundation_plan.sha256` may differ because it identifies the
239
+ normalized Compiler input. It is validated as a SHA-256 digest inside the exact artifact bytes authenticated by the
240
+ status response's `artifact.sha256`; it is not equated to the submitted Head digest.
241
+
242
+ Before materialization, the CLI verifies the artifact media type, declared and actual byte sizes, strong digest
243
+ ETag, exact-byte SHA-256, canonical UTF-8 JSON envelope, provenance, metadata-only manifest digest, portable paths,
244
+ strict Base64 contents, file digests, modes, owners, and source-subject UUIDs. It writes only into a uniquely created
245
+ sibling directory, verifies the complete tree, and atomically renames it into the still-absent destination. On
246
+ POSIX, directories use mode `0755` and files use artifact-declared `0644` or `0755`; Windows verifies structure,
247
+ contents, and digests without claiming POSIX mode bits. The declared and streamed artifact envelope is bounded at
248
+ 128 MiB.
package/docs/errors.md ADDED
@@ -0,0 +1,122 @@
1
+ # First Draft CLI errors and recovery
2
+
3
+ This page owns handled-error interpretation, retry safety, and recovery guidance. Read the
4
+ [command reference](commands.md) for successful command behavior.
5
+
6
+ ## Handled output contract
7
+
8
+ Every handled subcommand failure ends with exactly one JSON object on standard error. `plan compile` may first write
9
+ progress lines; machine consumers can remove only lines beginning with the exact `First Draft: ` prefix and parse the
10
+ remaining JSON document. Branch on the stable `error` value rather than the human-readable `detail`.
11
+
12
+ Handled output never includes command arguments, local Plan bytes, raw artifact bytes, raw filesystem or network
13
+ errors, or unvalidated response bodies. `local_state_not_saved` is the sole exception to private-state redaction:
14
+ its `recovery_state` is required to repair the accepted ETag locally. Root-level and command-group usage failures
15
+ remain human-readable text on standard error with exit 2. Unexpected programming defects remain loud.
16
+
17
+ ## Ambiguous mutations
18
+
19
+ `plan compile` supplies `phase: "push" | "compilation" | "publication"` when `request_outcome_unknown` requires
20
+ phase-specific recovery:
21
+
22
+ - `phase: "push"` means the Plan mutation may have been accepted. Stop and reconcile local Head state. Until First
23
+ Draft has a Foundation Plan Head reconciliation endpoint, an accepted request whose response cannot be verified
24
+ may require manual recovery. Do not construct an ETag from the Plan digest or trust an unverified response.
25
+ - `phase: "compilation"` means a direct `--output` Compilation may have started, but its retained identity is unknown.
26
+ The CLI never repeats that `POST`. Do not start another Compilation until the Project is reconciled through First
27
+ Draft or an operator can identify the retained work.
28
+ - `phase: "publication"` means the singleton Publication mutation was not resolved. Do not run concurrent Compile
29
+ commands. After the prior invocation exits, wait and rerun `plan compile` with unchanged Plan bytes to safely
30
+ reconcile or resume the retained singleton.
31
+
32
+ `plan push` also reports `request_outcome_unknown` if a failure happens after sending its request. Local state remains
33
+ unchanged. Stop and reconcile rather than assuming the request failed and repeating the mutation.
34
+
35
+ If a verified Plan response cannot replace local state, preserve the printed `recovery_state`; an adjacent `.tmp`
36
+ file may contain the same private recovery copy. Do not push again until the accepted ETag state is repaired.
37
+
38
+ ## Read-only status failures
39
+
40
+ A network failure from `plan status` is safe to retry a bounded number of times because the command sends only
41
+ `GET` requests. If `status_unavailable` persists, inspect the API origin pinned in `.firstdraft/state.json`.
42
+ `invalid_server_response` instead means the response violated the CLI/server contract; retrying the unchanged read
43
+ will not repair it.
44
+
45
+ Only the lower-level `compilation status <compilation-id>` command is read-only. Its
46
+ `compilation_status_unavailable` result is safe to retry a bounded number of times;
47
+ `invalid_compilation_status` requires contract reconciliation. A wait stops rather than following a changed
48
+ analysis or Compilation identity. This read-only retry guidance does not apply to `plan compile --output`, which
49
+ starts a new Compilation after analysis.
50
+
51
+ ## Direct Compilation recovery
52
+
53
+ Do not blindly rerun `plan compile --output` after its Compilation start was accepted or may have been accepted.
54
+ That command creates new work; it is not a retained-Compilation reconciliation command.
55
+
56
+ If `request_outcome_unknown` reports `phase: "compilation"`, the start request did not yield a validated retained
57
+ ID. The CLI sent exactly one `POST` and did not retry it. Stop until First Draft or an operator can reconcile the
58
+ Project and identify whether work was retained.
59
+
60
+ Once the start response has yielded a validated retained Compilation, later status, artifact, authentication, and
61
+ materialization failure envelopes include that last validated projection as `current`. Preserve
62
+ `current.compilation.id` and recover without creating duplicate work:
63
+
64
+ - after `compilation_status_unavailable`, use
65
+ `firstdraft compilation status <current.compilation.id>`; this lower-level read is safe to retry boundedly;
66
+ - after `invalid_compilation_status` or `invalid_artifact`, preserve the retained ID and reconcile the CLI/Service
67
+ contract instead of retrying the unchanged invalid read;
68
+ - after `artifact_unavailable`, wait if appropriate and use
69
+ `firstdraft compilation download <current.compilation.id> --output <new-absent-path>`; and
70
+ - after `materialization_failed`, repair the destination condition, then use the same lower-level download command
71
+ with a new absent path.
72
+
73
+ After `compilation_wait_timed_out`, retained work may still continue. Use
74
+ `firstdraft compilation status <current.compilation.id>` for one read-only status check; do not rerun
75
+ `plan compile --output`. `compilation_failed`, `compilation_cancelled`, and `compilation_changed` already carry the
76
+ validated `current` projection appropriate to their stopping boundary. Authentication recovery may refresh the
77
+ credential, but it must continue from the retained ID rather than starting another Compilation.
78
+
79
+ ## Publication recovery
80
+
81
+ The Publication is a Project singleton. If its initial conditional `PUT` is ambiguous, the CLI attempts one
82
+ read-only singleton `GET` and never automatically repeats the mutation in that invocation.
83
+
84
+ After `publication_status_unavailable` or `publication_wait_timed_out`, retained work may still continue. Do not run
85
+ concurrent Compile commands. Wait, then rerun `plan compile` with unchanged Plan bytes; the conditional request
86
+ safely reconciles or resumes the same retained singleton without creating another Compilation, repository, or push.
87
+ The same recovery applies when an invocation exits after an unresolved Publication start.
88
+
89
+ A GitHub preflight retry with no `retry_at` is paused and requires operator recovery. `publication_failed` and
90
+ `publication_cancelled` are terminal; inspect the validated phase and failure information rather than blindly
91
+ retrying. `publication_changed` means the pinned Publication identity or provenance changed, so the CLI deliberately
92
+ stopped without following the replacement.
93
+
94
+ ## Error index
95
+
96
+ | Commands | `error` | Exit | Meaning |
97
+ | -------------------------------------------- | -------------------------------------------------------------------------------------------------- | ---: | ------------------------------------------------------------------------------------------------------ |
98
+ | Any leaf command | `invalid_arguments` | 2 | Syntax was invalid; no request was made. |
99
+ | `plan init` | `local_initialization_failed` | 1 | Initialization failed without overwriting an existing path. |
100
+ | `plan push`, `plan compile` | `invalid_configuration` | 2 | API origin or saved Head state is incompatible. |
101
+ | Network commands | `authentication_required` | 1 | The token is missing or First Draft returned a validated authentication problem. |
102
+ | Plan commands, `compilation *` | `local_input_unreadable` | 1 | Required local Plan or private state could not be read. |
103
+ | Status, Compile, Compilation commands | `project_not_pushed` | 1 | No API origin is pinned for the local Project. |
104
+ | `plan push`, `plan compile` | `request_outcome_unknown` | 1 | A mutation or its response could not be verified; `plan compile` identifies its mutation phase. |
105
+ | `plan push`, `plan compile` | `local_state_not_saved` | 1 | The Plan was accepted but the private ETag state could not be replaced; includes `recovery_state`. |
106
+ | `plan push`, `plan compile` | `server_rejected` | 1 | First Draft returned validated Plan diagnostics or rejected the request with a validated problem. |
107
+ | `plan status` | `server_rejected` | 1 | First Draft rejected the analysis status request with a validated non-authentication problem. |
108
+ | `plan status` | `status_unavailable`, `invalid_server_response` | 1 | The analysis read failed or violated its protocol. |
109
+ | `plan compile` | `analysis_status_unavailable`, `invalid_analysis_status`, `analysis_status_rejected` | 1 | The bounded analysis read failed, was invalid, or was rejected. |
110
+ | Analysis waits | `analysis_changed`, `wait_timed_out`, `analysis_wait_timed_out` | 1 | The pinned analysis changed or remained processing at the deadline. |
111
+ | `plan compile` | `plan_not_valid` | 1 | Analysis completed without `valid`; `current` contains diagnostics and status. |
112
+ | `plan compile` | `local_plan_changed` | 1 | Local bytes or saved state changed after acceptance, before the selected mutation. |
113
+ | `plan compile --output` | `compilation_start_rejected`, `compilation_status_unavailable`, `invalid_compilation_status` | 1 | Direct start was rejected or retained status failed; post-start errors include `current`. |
114
+ | `plan compile --output` | `compilation_changed`, `compilation_wait_timed_out`, `compilation_failed`, `compilation_cancelled` | 1 | The pinned direct Compilation changed, timed out, failed, or was cancelled. |
115
+ | `plan compile` | `publication_start_rejected`, `publication_status_unavailable`, `invalid_publication_status` | 1 | Publication start or status failed its validated transport contract. |
116
+ | `plan compile` | `publication_changed`, `publication_wait_timed_out`, `publication_failed`, `publication_cancelled` | 1 | The pinned Publication changed, timed out, or reached a non-success terminal state. |
117
+ | `compilation status`, `compilation download` | `compilation_status_unavailable`, `invalid_compilation_status` | 1 | The retained status could not be read or violated its exact contract. |
118
+ | `compilation status --wait` | `compilation_changed`, `compilation_wait_timed_out` | 1 | Retained identity/provenance changed or the wait ended. |
119
+ | `compilation download` | `compilation_not_succeeded` | 1 | Status was not `succeeded`; no artifact request was made. |
120
+ | Download commands | `artifact_unavailable`, `invalid_artifact` | 1 | Artifact transport or integrity validation failed; direct Compile post-start errors include `current`. |
121
+ | Download commands | `invalid_output_path` | 2 | The destination was not an absent path beneath an existing real directory. |
122
+ | Download commands | `materialization_failed` | 1 | The output raced or installation failed; direct Compile post-start errors include `current`. |
@@ -0,0 +1,40 @@
1
+ # First Draft CLI release history
2
+
3
+ This page preserves dated release and registry observations. It is historical evidence, not a statement of current
4
+ npm, GitHub, service, or qualification state. Before acting, recheck the registry, protected tags, exact source SHA,
5
+ compatibility declarations, trusted-publisher relationship, and named release-specific qualification by following
6
+ the living [release policy and runbook](../RELEASING.md).
7
+
8
+ ## 0.1.0 alpha publications
9
+
10
+ - On July 31, 2026, npm rejected the unscoped `firstdraft` name for `v0.1.0-alpha.1` as too similar to the existing
11
+ `first-draft` package before creating a registry package. The tag records the first reviewed release candidate and
12
+ is immutable; neither its tag nor version may be moved or reused.
13
+ - On August 5, 2026, `v0.1.0-alpha.2` became the first organization-scoped publication,
14
+ `@firstdraft.com/cli@0.1.0-alpha.2`.
15
+ - As observed earlier on August 7, 2026, `0.1.0-alpha.2` was the only published scoped version and both npm's `next`
16
+ and `latest` dist-tags identified it.
17
+
18
+ ## 0.1.0 ordinary release and promotion
19
+
20
+ - Later on August 7, 2026, protected tag `v0.1.0` published ordinary version `0.1.0` under `next`, while `latest`
21
+ continued to identify `0.1.0-alpha.2`. The ordinary release intentionally superseded the alpha and required the
22
+ service's `0.2.x` API contract; the historical prerelease did not define an ordinary compatibility line.
23
+ - The first ordinary release established the npm trusted-publisher relationship used by the release workflow.
24
+ - On August 12, 2026, the selected bounded CLI `0.1.0` user-journey smoke passed and separate promotion approval was
25
+ granted. `latest` was promoted to `0.1.0`; both `next` and `latest` then identified ordinary version `0.1.0`. Full
26
+ v14 service qualification remained separate and incomplete.
27
+ - Requiring two-factor authentication while disallowing tokens at the package publishing-access layer was not a
28
+ `v0.1.0` release prerequisite and was not established by that release evidence.
29
+
30
+ The alpha versions remain immutable registry history but, as of the August 12 observation, neither distribution
31
+ channel selected them. Protected tag `v0.1.0` and package version `0.1.0` were consumed and immutable. Preparing
32
+ source or documentation does not mutate either dist-tag.
33
+
34
+ ## 0.2.0 candidate publication
35
+
36
+ - On August 27, 2026, protected tag `v0.2.0` published ordinary version `0.2.0` under `next`; `latest` remained
37
+ `0.1.0`. The candidate established compatibility with API contract `0.3.x` but did not displace the separately
38
+ promoted stable release.
39
+ - Package version `0.2.0` and protected tag `v0.2.0` are consumed and immutable. A backward-compatible addition to
40
+ the `0.2.x` line therefore requires a higher patch version rather than reusing those identities.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firstdraft.com/cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Command-line interface for First Draft",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -9,7 +9,10 @@
9
9
  },
10
10
  "files": [
11
11
  "bin",
12
- "src"
12
+ "docs",
13
+ "src",
14
+ "RELEASING.md",
15
+ "SECURITY.md"
13
16
  ],
14
17
  "engines": {
15
18
  "node": ">=22.0.0"
@@ -36,9 +36,9 @@ export async function sendRequest(fetchFunction, endpoint, request) {
36
36
  }
37
37
  }
38
38
 
39
- /** @param {Response} response */
40
- export async function readResponseBody(response) {
41
- const bytes = await readResponseBytes(response);
39
+ /** @param {Response} response @param {number} [maximumBytes] */
40
+ export async function readResponseBody(response, maximumBytes) {
41
+ const bytes = await readResponseBytes(response, maximumBytes);
42
42
 
43
43
  let text;
44
44
  try {