@firstdraft.com/cli 0.1.0 → 0.2.0
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/README.md +52 -270
- package/RELEASING.md +210 -0
- package/SECURITY.md +18 -0
- package/docs/README.md +60 -0
- package/docs/commands.md +220 -0
- package/docs/errors.md +87 -0
- package/docs/release-history.md +32 -0
- package/package.json +5 -2
- package/src/api-response.js +3 -3
- package/src/commands/plan-compile.js +5 -1
- package/src/commands/plan-status.js +311 -9
- package/src/compilation-artifact.js +1 -1
package/README.md
CHANGED
|
@@ -1,302 +1,84 @@
|
|
|
1
1
|
# First Draft CLI
|
|
2
2
|
|
|
3
|
-
`firstdraft` is the command-line client for
|
|
4
|
-
|
|
3
|
+
`firstdraft` is the command-line client for First Draft. It helps agents author and review
|
|
4
|
+
Foundation Plans with their users, then submit a valid Plan for the current bounded compilation and private GitHub
|
|
5
|
+
publication journey.
|
|
5
6
|
|
|
6
|
-
The current `0.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
guarantees. `0.1.0` intentionally supersedes `0.1.0-alpha.2` and requires the service's `0.2.x` API contract.
|
|
12
|
-
Publishing the CLI does not make the wider First Draft service generally available.
|
|
7
|
+
The current `0.2.x` source line includes local Plan initialization, application-key and UUID generation, conditional
|
|
8
|
+
whole-document push, whole-graph analysis polling, compile-and-publish orchestration, and read-only retained
|
|
9
|
+
Compilation download. Analysis status exposes the complete reviewed GapSet before Compile. Remote commands require
|
|
10
|
+
a compatible First Draft service and are intended for coordinated trials; publishing this CLI does not make the
|
|
11
|
+
wider service generally available.
|
|
13
12
|
|
|
14
|
-
##
|
|
13
|
+
## Install
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
- Working on this repository: Node.js 24.18.0 (pinned in `.tool-versions`)
|
|
18
|
-
|
|
19
|
-
## Installation
|
|
20
|
-
|
|
21
|
-
Once npm reports an approved coordinated release, install it from the approval-gated `next` channel:
|
|
15
|
+
Running the CLI requires Node.js 22.0.0 or newer. Install the stable release selected by npm's `latest` dist-tag:
|
|
22
16
|
|
|
23
17
|
```sh
|
|
24
|
-
npm install --global @firstdraft.com/cli
|
|
18
|
+
npm install --global @firstdraft.com/cli
|
|
25
19
|
firstdraft --version
|
|
26
20
|
```
|
|
27
21
|
|
|
28
|
-
The
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
`next` when a repeatable installation matters. Moving npm's `latest` tag is a separate approval-gated promotion
|
|
33
|
-
after qualification; the initial release workflow does not move it. As observed on August 7, 2026, `latest` still
|
|
34
|
-
identifies `0.1.0-alpha.2`. After `0.1.0` is published under `next`, an untagged npm install will continue to select
|
|
35
|
-
that historical alpha rather than `0.1.0` until the separate promotion occurs. Remote Plan and Compilation commands
|
|
36
|
-
require a compatible First Draft service and are currently intended for coordinated trials.
|
|
37
|
-
|
|
38
|
-
Before the first ordinary `v0.1.0` release tag is created, an operator must inspect npm's exact listed
|
|
39
|
-
[GitHub Actions trusted-publisher](https://docs.npmjs.com/trusted-publishers/) relationship for
|
|
40
|
-
`@firstdraft.com/cli`, type `github`, the `firstdraft/cli` repository, `publish.yml`, the protected `npm` environment,
|
|
41
|
-
and permission `createPackage` (npm's trust-list vocabulary for the allowed publish operation). The release workflow
|
|
42
|
-
authenticates only with a short-lived GitHub OIDC credential. A persistent npm token, `NODE_AUTH_TOKEN`, or GitHub
|
|
43
|
-
Actions secret is not permitted as a publication fallback.
|
|
44
|
-
|
|
45
|
-
## Authenticate API commands
|
|
46
|
-
|
|
47
|
-
Create an API token in First Draft and provide it only through the environment when running a network command:
|
|
48
|
-
|
|
49
|
-
```sh
|
|
50
|
-
export FIRSTDRAFT_API_TOKEN="your-token"
|
|
51
|
-
firstdraft plan push
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
`plan push`, `plan status`, `plan compile`, and `compilation` subcommands send the token as a Bearer credential on
|
|
55
|
-
every API request. The CLI does not save it in `.firstdraft`, print it, or require it for local commands such as
|
|
56
|
-
`plan init` and `generate`. Revoke the token in First Draft if it is exposed. A missing token, or First Draft's validated
|
|
57
|
-
`401` problem response with the `authentication_required` code, produces that stable CLI error.
|
|
58
|
-
|
|
59
|
-
## Development
|
|
60
|
-
|
|
61
|
-
```sh
|
|
62
|
-
npm ci
|
|
63
|
-
npm run check
|
|
64
|
-
npm run pack:check
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
To reproduce the length-delimited SHA-256 used by external evidence to identify the packaged JavaScript runtime
|
|
68
|
-
inputs (`package.json`, `bin/firstdraft.js`, and every `.js` file under `src/`), run from the repository root:
|
|
69
|
-
|
|
70
|
-
```sh
|
|
71
|
-
node scripts/runtime-digest.js
|
|
72
|
-
```
|
|
22
|
+
The package installs the `firstdraft` executable. Pin an exact compatible version, such as
|
|
23
|
+
`@firstdraft.com/cli@0.1.0`, when a repeatable installation matters. Candidate publication under `next` is not stable
|
|
24
|
+
release completion and does not displace the supported `latest` release before promotion; see the
|
|
25
|
+
[release policy](RELEASING.md) and [dated release history](docs/release-history.md).
|
|
73
26
|
|
|
74
|
-
##
|
|
27
|
+
## Shortest current journey
|
|
75
28
|
|
|
76
|
-
From the project that the Plan describes:
|
|
29
|
+
From the project that the Foundation Plan describes:
|
|
77
30
|
|
|
78
31
|
```sh
|
|
79
32
|
firstdraft plan init --name "Oscar Party"
|
|
80
33
|
```
|
|
81
34
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
network request and refuses to replace an existing `.firstdraft` path.
|
|
85
|
-
|
|
86
|
-
Provide either `--name`, `--application-key`, or both. Name-only initialization derives a lower-snake key. Key-only
|
|
87
|
-
initialization derives a humanized display name. Supplying both preserves both values exactly after
|
|
88
|
-
validating them against the Foundation Plan schema. To inspect the name-to-key derivation without initializing a
|
|
89
|
-
project, run:
|
|
90
|
-
|
|
91
|
-
```sh
|
|
92
|
-
firstdraft generate application-key --name "Oscar Party"
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
The generated key is deterministic, starts with a letter, contains only lowercase ASCII letters, digits, and
|
|
96
|
-
underscores, and is at most 63 bytes so it can lower to the current iOS application identifier component. Names
|
|
97
|
-
without a readable ASCII form receive a stable digest-based key. Longer readable names are shortened to a readable
|
|
98
|
-
prefix plus a stable digest suffix. Explicit application keys retain the Foundation Plan's broader
|
|
99
|
-
`^[a-z][a-z0-9_]*$` boundary and are left for target analysis rather than silently rewritten.
|
|
100
|
-
|
|
101
|
-
## Add Foundation Plan subjects
|
|
102
|
-
|
|
103
|
-
Generate an identity before adding each new independently mutable authored subject:
|
|
35
|
+
Edit `.firstdraft/foundation-plan.json`, preserving each authored subject's UUID across renames and moves that do not
|
|
36
|
+
replace the concept. Generate new subject identities locally as needed:
|
|
104
37
|
|
|
105
38
|
```sh
|
|
106
39
|
firstdraft generate uuid
|
|
107
40
|
```
|
|
108
41
|
|
|
109
|
-
|
|
110
|
-
value, or make a network request. Preserve that UUID when renaming the subject or moving it to a different semantic
|
|
111
|
-
owner without changing its kind. Use a new UUID for a replacement concept. Readable keys and paths may change and
|
|
112
|
-
remain the document's links; the UUID preserves continuity between complete-document pushes.
|
|
113
|
-
|
|
114
|
-
Use `--count <n>` to print several independently generated UUIDv7 values, one per line.
|
|
115
|
-
|
|
116
|
-
## Push a Foundation Plan
|
|
117
|
-
|
|
118
|
-
From the initialized project:
|
|
119
|
-
|
|
120
|
-
```sh
|
|
121
|
-
firstdraft plan push
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
The command sends the exact bytes in `.firstdraft/foundation-plan.json`. The first push conditionally creates the
|
|
125
|
-
Project; later pushes replay the complete ETag saved in `.firstdraft/state.json` so a stale writer cannot replace a
|
|
126
|
-
newer Plan. Successful responses and server diagnostics are printed as JSON for an agent to inspect.
|
|
127
|
-
|
|
128
|
-
The initial API origin defaults to `https://firstdraft.com`. Set `FIRSTDRAFT_API_URL` to use another HTTPS origin
|
|
129
|
-
or a loopback HTTP development server. The first successful push pins the normalized origin in local state, and a
|
|
130
|
-
later override must match it.
|
|
131
|
-
|
|
132
|
-
If a failure happens after sending the request, the CLI reports that the outcome may be ambiguous and leaves local
|
|
133
|
-
state unchanged. It never constructs an ETag from the Plan digest or trusts an ETag from a response it could not
|
|
134
|
-
fully verify. Until First Draft has a Foundation Plan head reconciliation endpoint, an accepted request whose
|
|
135
|
-
response cannot be verified may require manual recovery. If a verified response cannot replace local state,
|
|
136
|
-
preserve the printed recovery state; an adjacent `.tmp` file may contain the same private recovery copy.
|
|
137
|
-
|
|
138
|
-
## Read analysis status
|
|
139
|
-
|
|
140
|
-
After a successful push:
|
|
141
|
-
|
|
142
|
-
```sh
|
|
143
|
-
firstdraft plan status
|
|
144
|
-
firstdraft plan status --wait
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
Without `--wait`, the command makes one `GET` and prints the current analysis as one JSON object. With `--wait`, it
|
|
148
|
-
polls sequentially once per second for at most two minutes and stops at `valid`, `issues_found`, `analysis_failed`,
|
|
149
|
-
or `superseded`. Every validated analysis status is a successful read with exit 0; agents should branch on the
|
|
150
|
-
`analysis.status` value and inspect `analysis.diagnostics` rather than treating a completed analysis with issues as
|
|
151
|
-
a transport failure.
|
|
152
|
-
|
|
153
|
-
Status reads require the API origin pinned by a successful push. They never select an origin from the current
|
|
154
|
-
environment, expose the private ETag, follow redirects, or modify local state. Each request has a bounded timeout,
|
|
155
|
-
every response is byte-bounded and fully validated, and polling will not silently switch to a replacement analysis.
|
|
156
|
-
The wait repeats only validated `processing` responses and stops on its first failed read. A network failure is safe
|
|
157
|
-
to retry a bounded number of times because the command sends only `GET` requests. If `status_unavailable` persists,
|
|
158
|
-
inspect the API origin pinned in `.firstdraft/state.json`; an invalid server response instead requires reconciling the
|
|
159
|
-
CLI and server contract.
|
|
160
|
-
|
|
161
|
-
## Compile and publish the current Plan
|
|
162
|
-
|
|
163
|
-
When the candidate is ready, run:
|
|
42
|
+
Provide an API token only through the environment, then submit, analyze, compile, and publish the exact current Plan:
|
|
164
43
|
|
|
165
44
|
```sh
|
|
45
|
+
export FIRSTDRAFT_API_TOKEN="your-token"
|
|
166
46
|
firstdraft plan compile
|
|
167
47
|
```
|
|
168
48
|
|
|
169
|
-
`plan compile`
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
structured output; no Compilation or Publication is requested.
|
|
175
|
-
|
|
176
|
-
Only a `valid` analysis proceeds to the internal GitHub Publication lifecycle. Invoking `plan compile` is the
|
|
177
|
-
authorization to request that lifecycle. Immediately before its conditional mutation, the CLI re-reads the local
|
|
178
|
-
Plan and requires its exact bytes to match the accepted Head, so bytes changed after analysis cannot be published.
|
|
179
|
-
It extracts the accepted source SHA-256 from the saved ETag, hashes the current local bytes, and then sends that
|
|
180
|
-
complete ETag in `If-Match`.
|
|
181
|
-
The command writes stable human-readable progress to stderr, with every line prefixed by `First Draft:`. It reports
|
|
182
|
-
analysis, compilation completion or terminal failure or cancellation, the current GitHub phase, and an allowlisted
|
|
183
|
-
reason, retry count, and exact UTC retry time when a GitHub preflight check is delayed. A retained retry with no next
|
|
184
|
-
time is reported as paused and requiring operator recovery. Progress never includes IDs, hashes, repository names or
|
|
185
|
-
URLs, raw server projections, local paths, or environment values. Success writes exactly the validated private
|
|
186
|
-
GitHub repository URL plus a newline to stdout. If the command fails after progress has begun, its existing
|
|
187
|
-
structured JSON error envelope is the final stderr document after the progress lines.
|
|
188
|
-
|
|
189
|
-
The closed API `0.2.x` progress-reason allowlist is `github.configuration_missing`, `github.oauth_unavailable`,
|
|
190
|
-
`github.api_unavailable`, `github.reauthorization_required`, `github.account_mismatch`,
|
|
191
|
-
`github.installation_unavailable`, `github.installation_not_ready`, `github.preflight_unavailable`, the legacy-only
|
|
192
|
-
`github.preflight_unclassified`, and these stage-specific fallbacks: `github.preflight_unavailable.configuration`,
|
|
193
|
-
`github.preflight_unavailable.authorization`, `github.preflight_unavailable.repository_client`,
|
|
194
|
-
`github.preflight_unavailable.artifact_preparation`, `github.preflight_unavailable.installation_token`,
|
|
195
|
-
`github.preflight_unavailable.publication_preparation`, and `github.preflight_unavailable.repository_ref_client`.
|
|
196
|
-
Other values make the response invalid rather than becoming terminal output.
|
|
49
|
+
Invoking `plan compile` authorizes the internal GitHub Publication lifecycle. It proceeds only after the accepted
|
|
50
|
+
Plan's analysis is valid, writes allowlisted progress to standard error, and on success writes only the validated
|
|
51
|
+
private GitHub repository URL to standard output. The current Publication is a Project singleton and cannot be
|
|
52
|
+
repointed to a later accepted Head. Read the [complete command contract](docs/commands.md#compile-and-publish-the-current-plan)
|
|
53
|
+
before using it and follow [phase-specific recovery](docs/errors.md#ambiguous-mutations) after an ambiguous mutation.
|
|
197
54
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
concurrent Compile commands. After an invocation exits because the initial outcome or a later status read is
|
|
202
|
-
unavailable, wait and rerun `plan compile` with unchanged Plan bytes; its conditional request safely reconciles or
|
|
203
|
-
resumes the same retained singleton without creating another Compilation, repository, or push. Publication polling
|
|
204
|
-
is sequential, bounded to ten minutes, and pinned to the retained Project Head, Compilation input, Publication
|
|
205
|
-
identity, and repository identity.
|
|
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 and no local-start `plan compile --output` mode. It retains lower-level Compilation commands
|
|
209
|
-
for operational callers that acquire an ID separately, but they are intentionally not a continuation of the
|
|
210
|
-
URL-only `plan compile` journey.
|
|
211
|
-
|
|
212
|
-
## Inspect a retained Compilation
|
|
213
|
-
|
|
214
|
-
These lower-level commands are for callers that already hold a retained Compilation ID from authenticated API
|
|
215
|
-
metadata or operational tooling; `plan compile` prints only the final repository URL:
|
|
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
|
|
223
|
-
Compilation sequentially for at most ten minutes and rejects changes to its identity, Head provenance, target, or
|
|
224
|
-
lifecycle 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
|
|
236
|
-
`succeeded`, and makes one artifact `GET`. It never starts work or polls. Historical artifact validation uses
|
|
237
|
-
the retained `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
|
|
240
|
-
the 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
|
|
245
|
-
created sibling directory, verifies the complete tree, and atomically renames it into the still-absent destination.
|
|
246
|
-
On POSIX, directories use mode `0755` and files use artifact-declared `0644` or `0755`; Windows verifies
|
|
247
|
-
structure, contents, and digests without claiming POSIX mode bits.
|
|
248
|
-
|
|
249
|
-
## Handled failures
|
|
250
|
-
|
|
251
|
-
Every handled subcommand failure ends with exactly one JSON object on standard error. `plan compile` may first write
|
|
252
|
-
progress lines; machine consumers can remove only lines beginning with the exact `First Draft: ` prefix and parse
|
|
253
|
-
the remaining JSON document. Branch on its stable `error` value rather than the human-readable `detail`; `plan
|
|
254
|
-
compile` also supplies `phase: "push" | "publication"` when `request_outcome_unknown` requires phase-specific
|
|
255
|
-
recovery:
|
|
256
|
-
|
|
257
|
-
- `phase: "push"` means the Plan mutation may have been accepted; stop and reconcile local Head state.
|
|
258
|
-
- `phase: "publication"` means the singleton Publication mutation was not resolved. Do not run concurrent Compile
|
|
259
|
-
commands. After the prior invocation exits, wait and rerun `plan compile` with unchanged Plan bytes to safely
|
|
260
|
-
reconcile or resume the retained singleton.
|
|
261
|
-
|
|
262
|
-
| Commands | `error` | Exit | Meaning |
|
|
263
|
-
| -------------------------------------------- | -------------------------------------------------------------------------------------------------- | ---: | -------------------------------------------------------------------------------------------------------------- |
|
|
264
|
-
| Any leaf command | `invalid_arguments` | 2 | Syntax was invalid; no request was made. |
|
|
265
|
-
| `plan init` | `local_initialization_failed` | 1 | Initialization failed without overwriting an existing path. |
|
|
266
|
-
| `plan push`, `plan compile` | `invalid_configuration` | 2 | API origin or saved Head state is incompatible. |
|
|
267
|
-
| Network commands | `authentication_required` | 1 | The token is missing or First Draft returned a validated authentication problem. |
|
|
268
|
-
| Plan commands, `compilation *` | `local_input_unreadable` | 1 | Required local Plan or private state could not be read. |
|
|
269
|
-
| Status, Compile, Compilation commands | `project_not_pushed` | 1 | No API origin is pinned for the local Project. |
|
|
270
|
-
| `plan push`, `plan compile` | `request_outcome_unknown` | 1 | A mutation or its response could not be verified; `plan compile` identifies its `push` or `publication` phase. |
|
|
271
|
-
| `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`. |
|
|
272
|
-
| `plan push`, `plan compile` | `server_rejected` | 1 | First Draft returned validated Plan diagnostics or a validated problem. |
|
|
273
|
-
| `plan status` | `status_unavailable`, `invalid_server_response` | 1 | The analysis read failed or violated its protocol. |
|
|
274
|
-
| `plan compile` | `analysis_status_unavailable`, `invalid_analysis_status`, `analysis_status_rejected` | 1 | The bounded analysis read failed, was invalid, or was rejected. |
|
|
275
|
-
| Analysis waits | `analysis_changed`, `wait_timed_out`, `analysis_wait_timed_out` | 1 | The pinned analysis changed or remained processing at the deadline. |
|
|
276
|
-
| `plan compile` | `plan_not_valid` | 1 | Analysis completed without `valid`; `current` contains diagnostics and status. |
|
|
277
|
-
| `plan compile` | `local_plan_changed` | 1 | Local bytes changed after acceptance or analysis, before Publication mutation. |
|
|
278
|
-
| `plan compile` | `publication_start_rejected`, `publication_status_unavailable`, `invalid_publication_status` | 1 | Publication start or status failed its validated transport contract. |
|
|
279
|
-
| `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. |
|
|
280
|
-
| `compilation status`, `compilation download` | `compilation_status_unavailable`, `invalid_compilation_status` | 1 | The retained status could not be read or violated its exact contract. |
|
|
281
|
-
| `compilation status --wait` | `compilation_changed`, `compilation_wait_timed_out` | 1 | Retained identity/provenance changed or the wait ended. |
|
|
282
|
-
| `compilation download` | `compilation_not_succeeded` | 1 | Status was not `succeeded`; no artifact request was made. |
|
|
283
|
-
| `compilation download` | `artifact_unavailable`, `invalid_artifact` | 1 | Artifact transport or integrity validation failed before materialization. |
|
|
284
|
-
| `compilation download` | `invalid_output_path` | 2 | The destination was not an absent path beneath an existing real directory. |
|
|
285
|
-
| `compilation download` | `materialization_failed` | 1 | The output raced or the verified tree could not be atomically installed. |
|
|
286
|
-
|
|
287
|
-
Handled output never includes command arguments, local Plan bytes, raw artifact bytes, raw filesystem or network
|
|
288
|
-
errors, or unvalidated response bodies. `local_state_not_saved` is the sole exception to private-state redaction:
|
|
289
|
-
its `recovery_state` is required to repair the accepted ETag locally. Root-level and command-group usage failures
|
|
290
|
-
remain human-readable text on standard error with exit 2. Unexpected programming defects remain loud.
|
|
55
|
+
To review analysis before that terminal action, use `firstdraft plan push` followed by
|
|
56
|
+
`firstdraft plan status --wait`. See [Command reference](docs/commands.md) for all supported commands, flags, output
|
|
57
|
+
contracts, and retained-Compilation operations.
|
|
291
58
|
|
|
292
59
|
## Trust model
|
|
293
60
|
|
|
294
|
-
- The published CLI
|
|
295
|
-
-
|
|
296
|
-
|
|
297
|
-
-
|
|
61
|
+
- The published CLI runs the reviewed JavaScript source directly, without generated or bundled code.
|
|
62
|
+
- It has no runtime dependencies, install scripts, telemetry, update checks, or network activity except an explicitly
|
|
63
|
+
invoked API command.
|
|
64
|
+
- API tokens are read from `FIRSTDRAFT_API_TOKEN`, sent as Bearer credentials, and never saved in `.firstdraft` or
|
|
65
|
+
printed. Revoke an exposed token in First Draft.
|
|
66
|
+
- Package contents are allowlisted and checked before release. The public documentation graph is packaged with the
|
|
67
|
+
exact CLI version; agent instructions and source-only release metadata remain repository-only.
|
|
298
68
|
- CI exercises the exact minimum Node.js version separately from current development tooling.
|
|
299
|
-
- Public packages carry npm provenance linking
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
69
|
+
- Public packages carry npm provenance linking registry bytes to the reviewed GitHub workflow and commit.
|
|
70
|
+
|
|
71
|
+
## Find the right documentation
|
|
72
|
+
|
|
73
|
+
| Task | Read |
|
|
74
|
+
| ------------------------------------------------------- | ------------------------------------------ |
|
|
75
|
+
| Install and complete the shortest current journey | This README |
|
|
76
|
+
| Choose a command or inspect its exact behavior | [Command reference](docs/commands.md) |
|
|
77
|
+
| Interpret an error or recover safely | [Errors and recovery](docs/errors.md) |
|
|
78
|
+
| Contribute to this repository | [Documentation map](docs/README.md) |
|
|
79
|
+
| Prepare, publish, verify, recover, or promote a release | [Release policy and runbook](RELEASING.md) |
|
|
80
|
+
| Check dated package, tag, or channel observations | [Release history](docs/release-history.md) |
|
|
81
|
+
| Report a vulnerability | [Security policy](SECURITY.md) |
|
|
82
|
+
|
|
83
|
+
Run `firstdraft --help` or a command group's `--help` for concise terminal syntax. The documentation map explains
|
|
84
|
+
which source owns each longer-lived contract.
|
package/RELEASING.md
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Releasing First Draft CLI
|
|
2
|
+
|
|
3
|
+
This document owns living release policy and the operator runbook. Dated tag, package, qualification, and dist-tag
|
|
4
|
+
observations belong in [release history](docs/release-history.md) and must be rechecked before an operation.
|
|
5
|
+
|
|
6
|
+
Publishing is a separate, explicit action after a release-preparation pull request has merged. npm registry bytes
|
|
7
|
+
and package versions cannot be replaced, so do not create or push a release tag as a dry run.
|
|
8
|
+
|
|
9
|
+
Only a version that npm reports as published or a protected release tag that exists is immutable. Before either
|
|
10
|
+
exists, an unpublished candidate may be revised without changing its proposed version; its exact source SHA and
|
|
11
|
+
reviewed digests identify it. Reconcile the registry and remote tags before deciding that a version was consumed.
|
|
12
|
+
|
|
13
|
+
## Pre-1.0 version and channel policy
|
|
14
|
+
|
|
15
|
+
Before `1.0.0`, First Draft CLI uses ordinary `0.MINOR.PATCH` versions. Increase `MINOR` for a breaking
|
|
16
|
+
compatibility-line change. Increase `PATCH` for a change that is otherwise backward-compatible within the current
|
|
17
|
+
minor line. Never reuse a published version to preserve compatibility; publish the next version required by this
|
|
18
|
+
policy. Do not add aliases or shims solely to make a breaking compatibility line look patch-compatible. The policy
|
|
19
|
+
applies to ordinary versions; historical prereleases do not establish an ordinary compatibility line.
|
|
20
|
+
|
|
21
|
+
Version semantics and npm distribution channels are independent. An approved candidate is published first under
|
|
22
|
+
the approval-gated `next` tag even when it has an ordinary version such as `0.1.0`. The release workflow does not
|
|
23
|
+
move `latest`. Moving `latest` requires a later, separate approval after the exact `next` candidate has completed
|
|
24
|
+
its explicitly named release-specific qualification. Candidate publication is not stable release completion. A
|
|
25
|
+
stable CLI release is complete only when that separately approved candidate is selected by npm's `latest` dist-tag.
|
|
26
|
+
Release-specific qualification means the exact gate named for that candidate; it does not imply unrelated or full
|
|
27
|
+
service qualification. Until promotion, `latest` remains the supported stable release; a distinct `next` candidate
|
|
28
|
+
is supported only for its named qualification. When both tags identify one version, that version fills both roles.
|
|
29
|
+
|
|
30
|
+
## Coordinated candidate eligibility
|
|
31
|
+
|
|
32
|
+
`release/compatibility.json` declares this package's SemVer version, the First Draft API-contract range it accepts,
|
|
33
|
+
and the exact Foundation Plan formats it accepts. It is source-only release metadata and is intentionally absent from
|
|
34
|
+
the npm tarball. The normal test suite validates the manifest's shape, keeps its version equal to `package.json`, and
|
|
35
|
+
binds its Foundation Plan format to the implemented CLI constant.
|
|
36
|
+
|
|
37
|
+
The `script/release_compatibility_check` evaluator in `firstdraft/firstdraft` reads this declaration with the matching
|
|
38
|
+
declarations from exact, clean checkouts of `firstdraft/firstdraft` and `firstdraft/skills`. It implements SemVer 2.0
|
|
39
|
+
precedence. CLI `0.2.x` requires the service's `0.3.x` API contract because Analysis now returns the complete reviewed
|
|
40
|
+
GapSet and digest. The released CLI `0.1.0` accepts only API `0.2.x`, uses a generic 2 MiB response bound for Analysis,
|
|
41
|
+
and cannot safely consume every schema-valid API `0.3.x` result. CLI `0.2.x` retains that generic bound but gives
|
|
42
|
+
Analysis and Compilation artifacts dedicated 128 MiB bounds. Comparator arrays form one conjunction, while
|
|
43
|
+
`foundation_plan_formats` lists alternatives. A prerelease satisfies a comparator set only when a comparator
|
|
44
|
+
explicitly names a prerelease with the same major, minor, and patch numbers. Skills names the candidate CLI version
|
|
45
|
+
explicitly, so a stale comparator makes the three-repository candidate ineligible.
|
|
46
|
+
`firstdraft.release-compatibility/1` is intentionally closed. The evaluator in `firstdraft/firstdraft` rejects an
|
|
47
|
+
unrecognized format and unknown keys, so adding a key requires a coordinated compatibility-format bump rather than
|
|
48
|
+
silently changing version 1.
|
|
49
|
+
|
|
50
|
+
A compatible result establishes candidate eligibility, not authorization or runtime proof. Exact Git SHAs identify
|
|
51
|
+
the three-repository candidate. A merge to `main` is integration only: report the merged SHA and ask the user whether
|
|
52
|
+
to coordinate the three repositories and promote that candidate. If promotion is declined, record the SHA as
|
|
53
|
+
unpromoted.
|
|
54
|
+
|
|
55
|
+
Promotion is manual and approval-gated. One operator serializes mutations: qualify the exact candidate on staging,
|
|
56
|
+
obtain human approval, and only then promote the approved service revision to production or authorize the
|
|
57
|
+
corresponding npm and plugin releases. Do not publish npm, deploy either environment, or release the plugin merely
|
|
58
|
+
because the compatibility check passes.
|
|
59
|
+
|
|
60
|
+
## Repository and registry controls
|
|
61
|
+
|
|
62
|
+
Before a release, a repository administrator must confirm:
|
|
63
|
+
|
|
64
|
+
1. Confirm `firstdraft/cli` is public. The release workflow deliberately removes checkout credentials and re-fetches
|
|
65
|
+
the public release refs anonymously.
|
|
66
|
+
2. Confirm `main` has pull-request and CI requirements and a `v*` tag ruleset restricts tag creation, update, and
|
|
67
|
+
deletion.
|
|
68
|
+
3. Confirm the GitHub environment named `npm` is restricted to release tags, requires an explicit reviewer, disables
|
|
69
|
+
administrator bypass, and defines `NPM_RELEASE_ENABLED=true`. The workflow fails before publishing when this
|
|
70
|
+
variable is absent.
|
|
71
|
+
4. Confirm that the `firstdraft.com` npm organization and `@firstdraft.com/cli` package still identify the intended
|
|
72
|
+
publisher and repository. The publisher account must have write-protecting 2FA enabled. Verify authenticated
|
|
73
|
+
identity, organization membership, package identity, and current tags:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
npm whoami
|
|
77
|
+
npm org ls firstdraft.com --json
|
|
78
|
+
npm view '@firstdraft.com/cli' name repository.url versions dist-tags --json
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
5. Before creating a `v<package-version>` tag, verify [npm trusted publishing](https://docs.npmjs.com/trusted-publishers/)
|
|
82
|
+
for the exact package, repository, workflow, protected environment, and allowed publish operation. No persistent
|
|
83
|
+
npm credential is permitted for a release workflow.
|
|
84
|
+
|
|
85
|
+
Use the repository-pinned Node.js 24.18.0 toolchain with npm 11.16.0 to verify the organization's durable read/write
|
|
86
|
+
access:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
npm --version
|
|
90
|
+
npm access list packages firstdraft.com:developers '@firstdraft.com/cli' --json
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Require the package to report `read-write` access for the `developers` team. If access is missing or changed, stop:
|
|
94
|
+
restoring it is a separate administrator and security mutation, not a routine release step.
|
|
95
|
+
|
|
96
|
+
For every release, inspect the existing trusted-publisher relationship read-only:
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
npm trust list '@firstdraft.com/cli'
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Confirm `npm trust list` reports type `github`, repository `firstdraft/cli`, file `publish.yml`, environment `npm`,
|
|
103
|
+
and permission `createPackage`, which is npm's trust-list vocabulary for the allowed publish operation. npm does not
|
|
104
|
+
validate the saved relationship by attempting an exchange, so each case-sensitive value must be inspected. If the
|
|
105
|
+
relationship is missing or changed, stop: restoring it is a separate administrator and security mutation, not a
|
|
106
|
+
routine release step. The publish job must remain on a GitHub-hosted runner with `id-token: write` and must not read
|
|
107
|
+
`NODE_AUTH_TOKEN`, an npm token, or any GitHub Actions secret. Confirm the repository and `npm` environment secret
|
|
108
|
+
lists contain no npm automation secret. Trusted publishing's short-lived OIDC exchange is the sole workflow
|
|
109
|
+
publication credential; an authentication failure stops the release and must never fall back to a persistent token.
|
|
110
|
+
|
|
111
|
+
As optional defense-in-depth after trusted publication is operationally proven, an npm administrator may complete
|
|
112
|
+
the separate security-key ceremony and set package **Publishing access** to **Require two-factor authentication and
|
|
113
|
+
disallow tokens**. Do not report that setting as enabled until it is directly observed.
|
|
114
|
+
|
|
115
|
+
## Prepare a release
|
|
116
|
+
|
|
117
|
+
1. Update `package.json`, `package-lock.json`, and `release/compatibility.json` to the exact release version.
|
|
118
|
+
2. When that version changes, coordinate the matching explicit CLI comparator in `firstdraft/skills` before
|
|
119
|
+
qualification; a stale comparator intentionally makes the three-repository candidate ineligible.
|
|
120
|
+
3. Apply the pre-1.0 policy: use a minor increment for a breaking compatibility line and a patch increment for a
|
|
121
|
+
change that is otherwise backward-compatible. Keep the initial distribution under `next` independently of that
|
|
122
|
+
version choice. Do not move `latest` during release publication.
|
|
123
|
+
4. Confirm neither the exact package version nor its `v<package-version>` tag already exists. If both remain absent,
|
|
124
|
+
the unpublished candidate may retain its proposed version while its exact SHA and digests are revised.
|
|
125
|
+
5. Re-run `npm trust list '@firstdraft.com/cli'`, verify the exact `github`/repository/file/environment/`createPackage`
|
|
126
|
+
relationship described above, and confirm the workflow contains no persistent npm credential or GitHub Actions
|
|
127
|
+
secret.
|
|
128
|
+
6. Update user-facing documentation and release notes for behavior changes.
|
|
129
|
+
7. Run:
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
npm ci --ignore-scripts
|
|
133
|
+
npm audit
|
|
134
|
+
npm run check
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
8. Merge the reviewed pull request only after local and hosted checks pass.
|
|
138
|
+
|
|
139
|
+
## Publish
|
|
140
|
+
|
|
141
|
+
The manual boundary is creation of the version tag. From an up-to-date, clean `main`, verify the intended commit and
|
|
142
|
+
confirm that both the intended package version and `v<package-version>` tag are absent. If either identity is already
|
|
143
|
+
consumed, prepare the next version required by the pre-1.0 policy rather than moving or reusing it. Otherwise create
|
|
144
|
+
and push the tag. Push one release tag at a time; the workflow serializes publication, but GitHub retains at most one
|
|
145
|
+
pending run in a concurrency group.
|
|
146
|
+
|
|
147
|
+
The workflow rejects accidental or stale inputs unless they use a protected `v*` tag in `firstdraft/cli`, the tag
|
|
148
|
+
equals `v` plus the version in `package.json`, the remote tag still identifies the triggering commit, and that commit
|
|
149
|
+
appears in the first-parent history of `origin/main`. First-parent membership allows an older reviewed `main` state
|
|
150
|
+
after another change lands while rejecting intermediate commits from a merged side branch. The workflow reruns the
|
|
151
|
+
complete check, waits for approval in the `npm` environment, reverifies the remote refs, and publishes to the public
|
|
152
|
+
registry with provenance under `next`. It authenticates only through the exact npm trusted-publisher relationship and
|
|
153
|
+
the job's short-lived GitHub OIDC token; it reads no persistent npm credential or GitHub Actions secret.
|
|
154
|
+
|
|
155
|
+
The tag ruleset and `npm` environment approval are the external trust boundary because a tag-push run loads its
|
|
156
|
+
workflow from the tagged commit. Before approving the `npm` deployment, the reviewer must confirm:
|
|
157
|
+
|
|
158
|
+
- The tag, package version, and commit SHA are the intended release.
|
|
159
|
+
- The commit is a known reviewed state in protected `main` history and its required checks passed.
|
|
160
|
+
- `.github/workflows/publish.yml` at that commit is the reviewed workflow, still selects the `npm` environment, and
|
|
161
|
+
publishes the public `@firstdraft.com/cli` package only under `next` with provenance.
|
|
162
|
+
- npm lists the exact `github`/`firstdraft/cli`/`publish.yml`/`npm`/`createPackage` trusted-publisher relationship,
|
|
163
|
+
and the GitHub repository and `npm` environment contain no npm automation secret.
|
|
164
|
+
- The unprivileged verification job passed for that exact commit.
|
|
165
|
+
|
|
166
|
+
Do not move or reuse a release tag. If the tagged commit is not a first-parent state of `main`, merge the intended
|
|
167
|
+
change and prepare a new version rather than moving an already shared tag.
|
|
168
|
+
|
|
169
|
+
## Verify and recover
|
|
170
|
+
|
|
171
|
+
After publication, inspect the registry before retrying any reported failure; the package may already exist. From
|
|
172
|
+
the tagged checkout, verify the exact version, `next` dist-tag, unchanged `latest` dist-tag, integrity metadata, and
|
|
173
|
+
provenance metadata:
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
FD_CLI_RELEASE_VERSION="$(node -p "require('./package.json').version")"
|
|
177
|
+
npm view "@firstdraft.com/cli@$FD_CLI_RELEASE_VERSION" \
|
|
178
|
+
version dist.integrity dist.shasum repository.url engines bin --json
|
|
179
|
+
npm dist-tag ls '@firstdraft.com/cli'
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Install that exact version into a fresh temporary prefix, confirm `firstdraft --version`, compare the
|
|
183
|
+
packed file list with the release workflow, and run `npm audit signatures` after an exact installation.
|
|
184
|
+
|
|
185
|
+
If OIDC authentication fails, reconcile both the registry version and protected remote tag first. If only npm's
|
|
186
|
+
listed relationship is wrong, correct it on npm and rerun the existing workflow's failed jobs without changing the
|
|
187
|
+
tagged source. If the workflow filename, environment, permissions, or other identity at the tagged commit is wrong,
|
|
188
|
+
the protected tag is immutable: prepare the next version rather than moving the tag. Never add a token fallback.
|
|
189
|
+
|
|
190
|
+
A published version cannot be overwritten or reused. For a bad release, move `next` only to a known-good compatible
|
|
191
|
+
version if one exists; otherwise deprecate the bad version and publish a corrected higher version. Treat
|
|
192
|
+
unpublishing as an exceptional incident response, not a routine rollback.
|
|
193
|
+
|
|
194
|
+
## Promote the release-specific qualified candidate
|
|
195
|
+
|
|
196
|
+
Publishing under `next` is not promotion to the default install channel. After the exact `next` version completes
|
|
197
|
+
its named release-specific qualification and a human separately approves promotion, one operator may move `latest`
|
|
198
|
+
to that exact version from the tagged checkout:
|
|
199
|
+
|
|
200
|
+
```sh
|
|
201
|
+
FD_CLI_RELEASE_VERSION="$(node -p "require('./package.json').version")"
|
|
202
|
+
npm dist-tag add "@firstdraft.com/cli@$FD_CLI_RELEASE_VERSION" latest
|
|
203
|
+
npm dist-tag ls '@firstdraft.com/cli'
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Verify both tags after the mutation, then append the exact dated observation and qualification boundary to
|
|
207
|
+
[release history](docs/release-history.md). The stable CLI release is complete only after `next` and `latest` both
|
|
208
|
+
name the exact release-specific qualified version. Do not call a candidate fully promoted before that equality is
|
|
209
|
+
observed. Do not move `latest` merely because a release merged, published successfully, or passed candidate
|
|
210
|
+
compatibility checks, and do not use a dist-tag change to repair or disguise a bad immutable version.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
Please report suspected vulnerabilities through a
|
|
4
|
+
[private GitHub security advisory](https://github.com/firstdraft/cli/security/advisories/new). Do not include
|
|
5
|
+
sensitive details in a public Issue.
|
|
6
|
+
|
|
7
|
+
## Supported versions
|
|
8
|
+
|
|
9
|
+
During coordinated trials, the stable release currently identified by npm's `latest` tag receives security fixes. A
|
|
10
|
+
different version under the approval-gated `next` tag is supported only for its explicitly named release-specific
|
|
11
|
+
qualification; it does not displace the stable release before separate promotion approval. When `next` and `latest`
|
|
12
|
+
identify the same version, that release fills both roles.
|
|
13
|
+
|
|
14
|
+
Distribution channels are independent of version syntax. Before `1.0.0`, increasing the minor version starts a
|
|
15
|
+
breaking compatibility line; increasing the patch version is otherwise backward-compatible within that line. All
|
|
16
|
+
other older ordinary versions, historical prereleases, and unreleased source snapshots are not supported unless a
|
|
17
|
+
separate support policy says otherwise. Historical prereleases remain outside the ordinary version compatibility
|
|
18
|
+
guarantee.
|