@firstdraft.com/cli 0.2.2 → 0.4.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/docs/commands.md CHANGED
@@ -3,10 +3,10 @@
3
3
  This page owns the detailed public semantics of the current command surface. Run `firstdraft --help` or a command
4
4
  group's `--help` for concise executable syntax. See [Errors and recovery](errors.md) before retrying a failed mutation.
5
5
 
6
- The current `0.2.x` source line contains the auditable command shell, local Foundation Plan initialization, local
6
+ The current `0.4.x` source line contains the auditable command shell, local Foundation Plan initialization, local
7
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
8
+ Compile-and-materialize and private publish orchestration, and retained-Compilation inspection. CLI `0.4.x`
9
+ requires the service's `0.4.x` API contract. See the [release policy](../RELEASING.md) for versioning and channel
10
10
  semantics and [release history](release-history.md) for the transition from prereleases.
11
11
 
12
12
  ## Command map
@@ -18,7 +18,8 @@ semantics and [release history](release-history.md) for the transition from prer
18
18
  | `firstdraft generate uuid` | No | Generate one or more Foundation Plan subject identities |
19
19
  | `firstdraft plan push` | Yes | Conditionally submit the exact whole Plan |
20
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 |
21
+ | `firstdraft plan compile` | Yes | Push and analyze, then materialize in the current folder |
22
+ | `firstdraft plan compile --github` | Yes | Push and analyze, then publish to private GitHub |
22
23
  | `firstdraft compilation status` | Yes | Inspect a retained Compilation by ID |
23
24
  | `firstdraft compilation download` | Yes | Verify and materialize a successful retained Compilation |
24
25
 
@@ -44,9 +45,10 @@ From the project that the Plan describes:
44
45
  firstdraft plan init --name "Oscar Party"
45
46
  ```
46
47
 
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.
48
+ This creates an empty `firstdraft.foundation-plan.sketch/0.20` Plan targeting `rails-sketch/2026-09` and a
49
+ client-generated Project ID under `.firstdraft/`. A nested ignore file keeps that local scratch area out of Git
50
+ without changing the project's own `.gitignore`. Initialization makes no network request and refuses to replace an
51
+ existing `.firstdraft` path.
50
52
 
51
53
  Provide either `--name`, `--application-key`, or both. Name-only initialization derives a lower-snake key. Key-only
52
54
  initialization derives a humanized display name. Supplying both preserves both values exactly after validating them
@@ -133,14 +135,20 @@ a bounded number of times because the command sends only `GET` requests. See
133
135
 
134
136
  ## Compile the current Plan
135
137
 
136
- To compile into a local application directory, run:
138
+ Compile into the current local folder:
137
139
 
138
140
  ```sh
139
- firstdraft plan compile --output ./application
141
+ firstdraft plan compile
140
142
  ```
141
143
 
144
+ This is equivalent to `firstdraft plan compile --output .`. Use `--output ./application` for another absent
145
+ directory, or `--github` to publish to a private GitHub repository. `--github` and `--output` are mutually exclusive.
146
+ No GitHub connection, repository clone, or push is required for local compilation. Compilation runs on the First
147
+ Draft service; output and the application runtime are local. CLI `0.3.x` used GitHub Publication as its default;
148
+ scripts that require that behavior must add `--github` when upgrading to `0.4.x`.
149
+
142
150
  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
151
+ `.firstdraft/foundation-plan.json`, even when those bytes are unchanged, and save the accepted ETag using the same
144
152
  contract as `plan push`. It then waits up to two minutes for an analysis whose graph version and
145
153
  `head_source_sha256` exactly match that accepted push, polling past a terminal result retained for an older Head.
146
154
  Invalid JSON, schema diagnostics, semantic diagnostics, a failed analysis, a superseded analysis, or a recurring
@@ -153,21 +161,25 @@ the accepted source SHA-256 from the saved ETag, hashes the current local bytes,
153
161
 
154
162
  ### Materialize a direct Compilation
155
163
 
156
- With `--output`, the CLI accepts either an explicit absent destination beneath an existing real directory or a path
164
+ Without `--github`, the CLI accepts either an explicit absent destination beneath an existing real directory or a path
157
165
  that resolves to the physical current directory. It validates either destination before pushing the Plan. An absent
158
166
  destination is checked again after analysis; root adoption instead holds its owned lock and performs the exact
159
167
  pre-move identity recheck described below. Other existing destinations remain invalid, so
160
168
  `--output ./application` retains its absent-directory contract.
161
169
 
162
- `--output .` is the noninteractive root-adoption mode. `./`, an absolute spelling of the current directory, and
170
+ The nested archive layout below is shared by CLI `0.3.x` and `0.4.x`.
171
+ [Published CLI `0.2.2`](release-history.md#022-publication-and-registry-observation) archives at top-level `design/`;
172
+ existing applications are not migrated automatically.
173
+
174
+ The default `--output .` is the noninteractive root-adoption mode. `./`, an absolute spelling of the current directory, and
163
175
  another spelling that resolves to that same physical directory select the same mode. It works at any real current
164
176
  directory that meets the preconditions below and does not recognize Drawing Board or another repository layout
165
- specially. This first root-adoption contract supports POSIX filesystems; Windows retains absent-directory output
166
- and refuses root adoption as `root_platform_unsupported`. Before starting Compilation, the CLI requires:
177
+ specially. Root adoption supports POSIX filesystems; on Windows, use `--output ./application` because current-folder
178
+ output returns `root_platform_unsupported`. Before starting Compilation, the CLI requires:
167
179
 
168
180
  - the current directory to be a real, writable, non-filesystem-root directory;
169
- - no existing top-level path whose portable, case-insensitive name is `design` or the reserved
170
- `.firstdraft-root-output` transaction path;
181
+ - no existing `.firstdraft/design` archive or top-level `.firstdraft-root-output` transaction path, including
182
+ portable, case-insensitive spellings;
171
183
  - every top-level entry other than `.git` to be a regular file or real directory on the current directory's
172
184
  filesystem. Interior symlinks, dependency trees, sockets, and nested repositories move opaquely with their
173
185
  top-level directory; the CLI neither follows nor repairs them; and
@@ -181,8 +193,8 @@ and refuses root adoption as `root_platform_unsupported`. Before starting Compil
181
193
  Git-backed root adoption invokes the installed Git executable explicitly. Read-only discovery uses
182
194
  `git --no-optional-locks` with stable NUL-delimited porcelain so it does not refresh the index. Before remote work,
183
195
  the CLI verifies in a temporary preview that every currently ignored entry remains ignored after its path and
184
- applicable worktree `.gitignore` files move beneath `design`; repository-local and configured global exclusions are
185
- both honored. A refusal is `invalid_output_path` with a machine-readable `reason` and happens before Plan push.
196
+ applicable worktree `.gitignore` files move beneath `.firstdraft/design`; repository-local and configured global
197
+ exclusions are both honored. A refusal is `invalid_output_path` with a machine-readable `reason` and happens before Plan push.
186
198
 
187
199
  The CLI creates `.firstdraft-root-output` with exclusive creation during the pre-push output check and holds it
188
200
  through analysis, Compilation, and materialization. That directory is both the single-writer lock and the owned
@@ -202,21 +214,25 @@ safe to remove; the manual reconciliation rule below applies only after `root_ro
202
214
 
203
215
  The complete generated artifact is written and verified inside that in-root transaction directory before any
204
216
  existing path moves. Staging inside the destination makes every later rename same-filesystem even when the current
205
- directory itself is a container mount point. The artifact may not own a top-level path whose portable,
206
- case-insensitive name is `design` or `.firstdraft-root-output`; artifact validation already excludes `.git` at any
207
- depth.
208
-
209
- The transaction creates `./design` with mode `0755` on POSIX, moves every preexisting non-Git top-level entry under
210
- it, keeps an existing top-level `.git` file or directory at the root, and installs the artifact's top-level entries
211
- at the root. Immediately before each artifact entry is installed, its root destination must still be absent; an
212
- unexpected entry stops the transaction and is never overwritten. If the root contains no entry other than `.git`,
213
- it does not retain an empty `design` directory. A
214
- nested mount that cannot travel with its top-level directory may make its rename fail; that is a transactional
215
- failure, not permission to copy or traverse the mount.
217
+ directory itself is a container mount point. The artifact may not own `.firstdraft/design`, its descendants, or
218
+ the top-level `.firstdraft-root-output` path, including portable, case-insensitive spellings. `.firstdraft` must be
219
+ a directory with that exact spelling when present; artifact validation already excludes `.git` at any depth.
220
+
221
+ The transaction creates `.firstdraft/design` inside the verified artifact stage with mode `0755` on POSIX and moves
222
+ every preexisting non-Git top-level entry beneath it. It keeps an existing top-level `.git` file or directory at the
223
+ root, then installs the artifact's top-level entries there. Installing the staged `.firstdraft` places the archive
224
+ directly at `.firstdraft/design`; there is no intermediate top-level `design` directory. The original planning
225
+ `.firstdraft` remains intact at `.firstdraft/design/.firstdraft`, separate from the generated submitted Plan and
226
+ gaps at `.firstdraft/`.
227
+
228
+ Immediately before each artifact entry is installed, its root destination must still be absent; an unexpected
229
+ entry stops the transaction and is never overwritten. If the root contains no entry other than `.git`, it does not
230
+ retain an empty archive. A nested mount that cannot travel with its top-level directory may make its rename fail;
231
+ that is a transactional failure, not permission to copy or traverse the mount.
216
232
 
217
233
  For a Git root, the CLI first prepares a replacement index that stages each formerly tracked path at
218
- `design/<old-path>` and stages every exact generated artifact path at the root. This handles overlapping names such
219
- as `README.md` and `.gitignore` without leaving the old design blob indexed at a generated path. Previously
234
+ `.firstdraft/design/<old-path>` and stages every exact generated artifact path at the root. This handles overlapping
235
+ names such as `README.md` and `.gitignore` without leaving the old design blob indexed at a generated path. Previously
220
236
  untracked and ignored paths are never added to the index. Preparing that index writes the generated blobs into the
221
237
  Git object database; a rollback may therefore leave unreachable blobs for ordinary Git garbage collection, while
222
238
  `HEAD`, refs, configuration, and history remain unchanged. After the worktree renames finish, the CLI installs the
@@ -230,14 +246,17 @@ The journal is a versioned private JSON record plus owned staging files. It reco
230
246
  top-level identity set, the transaction phase, completed design and artifact renames, and, for Git, the resolved
231
247
  index path and original and prepared index digests. Each irreversible phase is recorded before the next one starts.
232
248
  On any failure after a move, index installation, or post-install verification, the CLI first restores the exact
233
- prior index through the same Git lock boundary, then reverses artifact and design renames in journal order. A fully
249
+ prior index through the same Git lock boundary, then reverses artifact moves in reverse recorded order, followed
250
+ by design moves in reverse recorded order. Reversing the installed `.firstdraft` first returns the archive to
251
+ staging so the original planning `.firstdraft` can move back to its original root path. A fully
234
252
  successful rollback removes only the owned transaction. If rollback itself cannot finish,
235
253
  `materialization_failed` reports `reason: "root_rollback_incomplete"` and includes
236
254
  `recovery_path: ".firstdraft-root-output"`; it leaves the journal and owned copies in place rather than guessing.
237
- Do not delete that directory or run Git restoration commands. Inspect the versioned journal, restore the listed
238
- index and paths to its recorded original identities, verify that snapshot, and only then remove the transaction
239
- directory. Another root adoption reports `root_busy` until that state is reconciled; a foreign preexisting directory
240
- with the same reserved name reports `root_reserved_path`.
255
+ Do not delete that directory or run Git restoration commands. Follow the
256
+ [manual recovery order](errors.md#direct-compilation-recovery), reconcile the versioned journal with the current
257
+ path identities, and verify its original snapshot before removing the transaction directory. Another root adoption
258
+ reports `root_busy` until that state is reconciled; a foreign preexisting directory with the same reserved name
259
+ reports `root_reserved_path`.
241
260
 
242
261
  After valid analysis, the CLI requests one Compilation for that exact reviewed Head and never starts GitHub
243
262
  Publication. It validates that the `202` response identifies the same Project, graph version, Head, Analysis,
@@ -252,7 +271,9 @@ Root adoption additionally reports `root_adoption.design_path` (or `null` when n
252
271
  top-level moved-entry count, whether a Git repository was preserved, and whether its index was replaced.
253
272
  After final verification succeeds, the CLI removes its owned `.firstdraft-root-output` transaction directory.
254
273
  An absent output directory contains exactly the artifact files and modes. Root adoption additionally contains the
255
- preserved `design` directory and an existing root `.git`, when present; every artifact-owned path remains exact. The
274
+ preserved `.firstdraft/design` archive and an existing root `.git`, when present. Verification skips only the
275
+ archive and retained Git/transaction paths; it still checks every generated file, including
276
+ `.firstdraft/submitted-foundation-plan.json` and `.firstdraft/gaps.json`, and rejects unexpected generated paths. The
256
277
  CLI does not add a Git repository, run a formatter, or repair generated source. When an absent output is nested
257
278
  inside another Git worktree, initialize the application as its own repository before running generated checks that
258
279
  inspect Git; otherwise Git resolves to the parent worktree. Progress on stderr reports analysis and Compilation
@@ -260,10 +281,10 @@ only.
260
281
 
261
282
  ### Publish through GitHub
262
283
 
263
- Without `--output`, the existing GitHub Publication journey remains unchanged:
284
+ Use the explicit GitHub option for the Publication journey:
264
285
 
265
286
  ```sh
266
- firstdraft plan compile
287
+ firstdraft plan compile --github
267
288
  ```
268
289
 
269
290
  Invoking this form authorizes the internal GitHub Publication lifecycle. The command writes stable human-readable
@@ -275,7 +296,7 @@ local paths, or environment values. Success writes exactly the validated private
275
296
  newline to stdout. If the command fails after progress has begun, its structured JSON error envelope is the final
276
297
  stderr document after the progress lines.
277
298
 
278
- The closed API `0.3.x` progress-reason allowlist is `github.configuration_missing`, `github.oauth_unavailable`,
299
+ The closed API `0.4.x` progress-reason allowlist is `github.configuration_missing`, `github.oauth_unavailable`,
279
300
  `github.api_unavailable`, `github.reauthorization_required`, `github.account_mismatch`,
280
301
  `github.installation_unavailable`, `github.installation_not_ready`, `github.preflight_unavailable`, the legacy-only
281
302
  `github.preflight_unclassified`, and these stage-specific fallbacks: `github.preflight_unavailable.configuration`,
@@ -298,8 +319,8 @@ exact Plan push and valid Analysis.
298
319
  ## Inspect a retained Compilation
299
320
 
300
321
  These lower-level commands are for callers that already hold a retained Compilation ID from authenticated API
301
- metadata or operational tooling. The no-output `plan compile` form prints only the final repository URL, while
302
- `plan compile --output` waits for and downloads its own direct Compilation:
322
+ metadata or operational tooling. `plan compile --github` prints only the final repository URL, while the default
323
+ `plan compile` form waits for and downloads its own direct Compilation:
303
324
 
304
325
  ```sh
305
326
  firstdraft compilation status 01900000-0000-7000-8000-000000000001
@@ -324,10 +345,16 @@ when a retained direct Compilation succeeded but an earlier root materialization
324
345
  never starts replacement work. An incomplete rollback leaves `.firstdraft-root-output` and requires journal
325
346
  reconciliation before this command can run again.
326
347
 
348
+ Artifact validation accepts only Plan format `firstdraft.foundation-plan.sketch/0.20` and target profile
349
+ `rails-sketch/2026-09`, in addition to matching the retained Compilation's provenance and verifying file integrity.
350
+ An earlier format or profile is rejected before materialization, even when the retained status names that profile.
351
+
327
352
  Successful root adoption is intentionally one-way. The original `.firstdraft` authoring state moves under
328
- `design/.firstdraft`; run later Plan commands from `design`, not from the generated application root. Compiling a
329
- later Plan revision does not overwrite an already adopted root: choose a new absent output and deliberately
330
- reconcile it with application work.
353
+ `.firstdraft/design/.firstdraft`; run later First Draft commands from `.firstdraft/design`. Run ordinary Rails
354
+ setup, preview, and tests from the generated application root. Retain the archive when further First Draft
355
+ authoring is useful. The CLI does not run or qualify the generated application's setup, preview, or test commands.
356
+ Compiling a later Plan revision does not overwrite an already adopted root: choose a new absent output and
357
+ deliberately reconcile it with application work.
331
358
 
332
359
  The command validates the UUID and output path before network access, makes one status `GET`, requires `succeeded`,
333
360
  and makes one artifact `GET`. It never starts work or polls. Historical artifact validation uses the retained
package/docs/errors.md CHANGED
@@ -22,11 +22,11 @@ phase-specific recovery:
22
22
  - `phase: "push"` means the Plan mutation may have been accepted. Stop and reconcile local Head state. Until First
23
23
  Draft has a Foundation Plan Head reconciliation endpoint, an accepted request whose response cannot be verified
24
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.
25
+ - `phase: "compilation"` means a local Compilation (the default mode, with optional `--output`) may have started, but its retained identity is unknown.
26
26
  The CLI never repeats that `POST`. Do not start another Compilation until the Project is reconciled through First
27
27
  Draft or an operator can identify the retained work.
28
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
29
+ commands. After the prior invocation exits, wait and rerun `plan compile --github` with unchanged Plan bytes to safely
30
30
  reconcile or resume the retained singleton.
31
31
 
32
32
  `plan push` also reports `request_outcome_unknown` if a failure happens after sending its request. Local state remains
@@ -45,12 +45,12 @@ will not repair it.
45
45
  Only the lower-level `compilation status <compilation-id>` command is read-only. Its
46
46
  `compilation_status_unavailable` result is safe to retry a bounded number of times;
47
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
48
+ analysis or Compilation identity. This read-only retry guidance does not apply to `plan compile`, which
49
49
  starts a new Compilation after analysis.
50
50
 
51
51
  ## Direct Compilation recovery
52
52
 
53
- Do not blindly rerun `plan compile --output` after its Compilation start was accepted or may have been accepted.
53
+ Do not blindly rerun `plan compile` after its Compilation start was accepted or may have been accepted.
54
54
  That command creates new work; it is not a retained-Compilation reconciliation command.
55
55
 
56
56
  If `request_outcome_unknown` reports `phase: "compilation"`, the start request did not yield a validated retained
@@ -70,15 +70,22 @@ materialization failure envelopes include that last validated projection as `cur
70
70
  - after `materialization_failed`, repair the destination condition, then use the same lower-level download command
71
71
  with a new absent path. A root-output attempt whose transaction fully rolled back may instead retry that retained
72
72
  download with `--output .`; `reason: "root_rollback_incomplete"` requires reconciliation of the retained
73
- `.firstdraft-root-output` journal before another root attempt. Only that reason requires manual reconciliation:
74
- do not delete its journal or run Git restoration commands; read its versioned record, restore the exact listed
75
- index and path identities, verify its original snapshot, and then remove the transaction directory. A journal
76
- whose phase records no irreversible operation is safe to remove. After `.firstdraft` has moved successfully under
77
- `design`, run retained status and later Plan commands from `design`, not from the generated application root.
73
+ `.firstdraft-root-output` journal before another root attempt. Only that reason requires manual reconciliation.
74
+
75
+ For an incomplete root rollback, preserve the journal and avoid Git restoration commands. Reconcile its recorded
76
+ identities with the current tree: some moves may already have been reversed. Restore the exact original index
77
+ through Git's index lock when applicable. Reverse the remaining `artifact_moves` in reverse recorded order, moving
78
+ each destination back to its source; only then reverse the remaining `design_moves` in reverse recorded order.
79
+ The recorded design destinations are inside transaction staging. While the generated `.firstdraft` remains at the
80
+ root, its archive is at `.firstdraft/design`; reversing that artifact move returns the archive to staging before the
81
+ original planning `.firstdraft` can return to the root. Do not merge or overwrite either directory. Verify the
82
+ original snapshot before removing the transaction directory. A journal whose phase records no irreversible
83
+ operation is safe to remove. After successful adoption, run retained status and later Plan commands from
84
+ `.firstdraft/design`, and ordinary Rails commands from the generated application root.
78
85
 
79
86
  After `compilation_wait_timed_out`, retained work may still continue. Use
80
87
  `firstdraft compilation status <current.compilation.id>` for one read-only status check; do not rerun
81
- `plan compile --output`. `compilation_failed`, `compilation_cancelled`, and `compilation_changed` already carry the
88
+ `plan compile`. `compilation_failed`, `compilation_cancelled`, and `compilation_changed` already carry the
82
89
  validated `current` projection appropriate to their stopping boundary. Authentication recovery may refresh the
83
90
  credential, but it must continue from the retained ID rather than starting another Compilation.
84
91
 
@@ -88,7 +95,7 @@ The Publication is a Project singleton. If its initial conditional `PUT` is ambi
88
95
  read-only singleton `GET` and never automatically repeats the mutation in that invocation.
89
96
 
90
97
  After `publication_status_unavailable` or `publication_wait_timed_out`, retained work may still continue. Do not run
91
- concurrent Compile commands. Wait, then rerun `plan compile` with unchanged Plan bytes; the conditional request
98
+ concurrent Compile commands. Wait, then rerun `plan compile --github` with unchanged Plan bytes; the conditional request
92
99
  safely reconciles or resumes the same retained singleton without creating another Compilation, repository, or push.
93
100
  The same recovery applies when an invocation exits after an unresolved Publication start.
94
101
 
@@ -116,10 +123,10 @@ stopped without following the replacement.
116
123
  | Analysis waits | `analysis_changed`, `wait_timed_out`, `analysis_wait_timed_out` | 1 | The pinned analysis changed or remained processing at the deadline. |
117
124
  | `plan compile` | `plan_not_valid` | 1 | Analysis completed without `valid`; `current` contains diagnostics and status. |
118
125
  | `plan compile` | `local_plan_changed` | 1 | Local bytes or saved state changed after acceptance, before the selected mutation. |
119
- | `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`. |
120
- | `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. |
121
- | `plan compile` | `publication_start_rejected`, `publication_status_unavailable`, `invalid_publication_status` | 1 | Publication start or status failed its validated transport contract. |
122
- | `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. |
126
+ | `plan compile` | `compilation_start_rejected`, `compilation_status_unavailable`, `invalid_compilation_status` | 1 | Direct start was rejected or retained status failed; post-start errors include `current`. |
127
+ | `plan compile` | `compilation_changed`, `compilation_wait_timed_out`, `compilation_failed`, `compilation_cancelled` | 1 | The pinned direct Compilation changed, timed out, failed, or was cancelled. |
128
+ | `plan compile --github` | `publication_start_rejected`, `publication_status_unavailable`, `invalid_publication_status` | 1 | Publication start or status failed its validated transport contract. |
129
+ | `plan compile --github` | `publication_changed`, `publication_wait_timed_out`, `publication_failed`, `publication_cancelled` | 1 | The pinned Publication changed, timed out, or reached a non-success terminal state. |
123
130
  | `compilation status`, `compilation download` | `compilation_status_unavailable`, `invalid_compilation_status` | 1 | The retained status could not be read or violated its exact contract. |
124
131
  | `compilation status --wait` | `compilation_changed`, `compilation_wait_timed_out` | 1 | Retained identity/provenance changed or the wait ended. |
125
132
  | `compilation download` | `compilation_not_succeeded` | 1 | Status was not `succeeded`; no artifact request was made. |
@@ -46,3 +46,16 @@ source or documentation does not mutate either dist-tag.
46
46
  - Package version `0.2.1` and protected tag `v0.2.1` are consumed and immutable. As observed on August 29, 2026,
47
47
  current-directory root-output had integrated to `main` at `4352f64baf673ad93457e8bc84273e9d1d9a9501` (tree
48
48
  `b43ba6de98e27328e548cc3410ba9f39dfa9fcee`) but was not part of those registry bytes.
49
+
50
+ ## 0.2.2 publication and registry observation
51
+
52
+ - The [npm registry](https://registry.npmjs.org/@firstdraft.com%2fcli) records version `0.2.2` published at
53
+ `2026-08-30T04:40:13.459Z`.
54
+ [Tag `v0.2.2`](https://github.com/firstdraft/cli/releases/tag/v0.2.2) resolves to
55
+ `799a184cb2453ceadf5575f7b46ba975e084f192`. That source implements current-root adoption with the archive at
56
+ top-level `design/`.
57
+ - On September 18, 2026, a read-only registry check found both `next` and `latest` selecting `0.2.2`. This is an
58
+ observation of their selection, not evidence of the time or approval of the earlier promotion. The check ran no
59
+ fresh package parity, service, authenticated user-journey, or Codespaces qualification.
60
+ - Package version `0.2.2` and protected tag `v0.2.2` are consumed and immutable. The nested `.firstdraft/design`
61
+ archive belongs to the unpublished `0.3.0` source candidate; preparing it does not change installed `0.2.2` bytes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firstdraft.com/cli",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "description": "Command-line interface for First Draft",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,7 +29,7 @@
29
29
  "access": "public",
30
30
  "provenance": true,
31
31
  "registry": "https://registry.npmjs.org/",
32
- "tag": "next"
32
+ "tag": "latest"
33
33
  },
34
34
  "scripts": {
35
35
  "check": "npm run typecheck && npm run lint && npm run format:check && npm test && npm run pack:check && npm run pack:smoke",
package/src/cli.js CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  PlanCompileAnalysisRejectedError,
39
39
  PlanCompileAnalysisUnavailableError,
40
40
  PlanCompilePushRejectedError,
41
- compilePlan,
41
+ compilePlanToGitHub,
42
42
  compilePlanToDirectory,
43
43
  } from "./commands/plan-compile.js";
44
44
  import { initializePlan } from "./commands/plan-init.js";
@@ -182,9 +182,11 @@ const PLAN_COMPILE_HELP = `First Draft CLI
182
182
  Usage:
183
183
  firstdraft plan compile
184
184
  firstdraft plan compile --output <absent-directory|.>
185
+ firstdraft plan compile --github
185
186
 
186
187
  Options:
187
- --output <absent-directory|.> Materialize the generated application here
188
+ --output <absent-directory|.> Materialize here (default: .)
189
+ --github Publish to a private GitHub repository
188
190
  -h, --help Show help
189
191
 
190
192
  Environment:
@@ -192,12 +194,11 @@ Environment:
192
194
  FIRSTDRAFT_API_URL Override the initial API origin
193
195
 
194
196
  The command submits the exact current whole-file Plan, waits for its analysis,
195
- and proceeds only when that analysis is valid. Without --output, it conditionally
196
- creates or replays the internal GitHub Publication lifecycle and prints the
197
- private repository URL. With --output, it starts one direct Compilation and
198
- atomically materializes the verified artifact into an absent directory, or
199
- preserves existing root material under ./design when the output is ., without
200
- starting GitHub Publication. Progress is written to stderr.
197
+ and proceeds only when that analysis is valid. By default it materializes the
198
+ verified application in the current directory, preserving existing root material
199
+ under .firstdraft/design. --output can select another absent directory.
200
+ --github selects the GitHub Publication lifecycle and prints the private repository
201
+ URL; it cannot be combined with --output. Progress is written to stderr.
201
202
  `;
202
203
 
203
204
  const COMPILATION_HELP = `First Draft CLI
@@ -245,7 +246,7 @@ Environment:
245
246
  The command reads the retained Compilation once, requires it to have
246
247
  succeeded, downloads and verifies its exact artifact once, and atomically
247
248
  materializes it into an absent output path or adopts the current directory
248
- while preserving existing material under ./design. It never starts work.
249
+ while preserving existing material under .firstdraft/design. It never starts work.
249
250
  `;
250
251
 
251
252
  const PLAN_INIT_HELP = `First Draft CLI
@@ -329,7 +330,7 @@ const PLAN_COMPILE_ANALYSIS_NOT_VALID_DETAIL =
329
330
  const PLAN_COMPILE_LOCAL_PLAN_CHANGED_DETAIL =
330
331
  "The local Foundation Plan changed after validation. Run 'firstdraft plan compile' again to submit the current bytes.";
331
332
  const PLAN_COMPILE_DIRECT_REQUEST_OUTCOME_UNKNOWN_DETAIL =
332
- "A Compilation may have started, but its response could not be verified. Do not rerun 'firstdraft plan compile --output' or start another Compilation until the current Project is reconciled.";
333
+ "A Compilation may have started, but its response could not be verified. Do not rerun 'firstdraft plan compile' or start another Compilation until the current Project is reconciled.";
333
334
  const PLAN_COMPILE_DIRECT_START_REJECTED_DETAIL =
334
335
  "First Draft rejected the direct Compilation request.";
335
336
  const PLAN_COMPILE_DIRECT_STATUS_UNAVAILABLE_DETAIL =
@@ -339,7 +340,7 @@ const PLAN_COMPILE_DIRECT_STATUS_INVALID_DETAIL =
339
340
  const PLAN_COMPILE_DIRECT_CHANGED_DETAIL =
340
341
  "The pinned Compilation changed while being polled. The command stopped without downloading an artifact.";
341
342
  const PLAN_COMPILE_DIRECT_TIMEOUT_DETAIL =
342
- "The retained Compilation is still processing after the bounded ten-minute wait. Use current.compilation.id with 'firstdraft compilation status'; do not rerun 'firstdraft plan compile --output' or start another Compilation.";
343
+ "The retained Compilation is still processing after the bounded ten-minute wait. Use current.compilation.id with 'firstdraft compilation status'; do not rerun 'firstdraft plan compile' or start another Compilation.";
343
344
  const PLAN_COMPILE_DIRECT_FAILED_DETAIL =
344
345
  "The pinned Compilation failed. No artifact was downloaded or materialized.";
345
346
  const PLAN_COMPILE_DIRECT_CANCELLED_DETAIL =
@@ -349,19 +350,19 @@ const PLAN_PUBLISH_INCOMPATIBLE_STATE_DETAIL =
349
350
  const PLAN_PUBLISH_NOT_PUSHED_DETAIL =
350
351
  "The current Foundation Plan was not retained before the Publication request.";
351
352
  const PLAN_PUBLISH_LOCAL_PLAN_CHANGED_DETAIL =
352
- "The local Foundation Plan changed after validation. Run 'firstdraft plan compile' again to submit the current bytes.";
353
+ "The local Foundation Plan changed after validation. Run 'firstdraft plan compile --github' again to submit the current bytes.";
353
354
  const PLAN_PUBLISH_REQUEST_OUTCOME_UNKNOWN_DETAIL =
354
- "The Publication may have started, but its retained singleton status could not be verified. No mutation was retried. Do not run concurrent Compile commands. Wait, then rerun 'firstdraft plan compile' with unchanged Plan bytes to safely reconcile or resume the retained singleton.";
355
+ "The Publication may have started, but its retained singleton status could not be verified. No mutation was retried. Do not run concurrent Compile commands. Wait, then rerun 'firstdraft plan compile --github' with unchanged Plan bytes to safely reconcile or resume the retained singleton.";
355
356
  const PLAN_PUBLISH_START_REJECTED_DETAIL =
356
357
  "First Draft rejected the publication request.";
357
358
  const PLAN_PUBLISH_STATUS_UNAVAILABLE_DETAIL =
358
- "Could not read the retained Publication status. The command stopped without starting another Publication. Do not run concurrent Compile commands. Wait, then rerun 'firstdraft plan compile' with unchanged Plan bytes to safely resume the retained singleton.";
359
+ "Could not read the retained Publication status. The command stopped without starting another Publication. Do not run concurrent Compile commands. Wait, then rerun 'firstdraft plan compile --github' with unchanged Plan bytes to safely resume the retained singleton.";
359
360
  const PLAN_PUBLISH_STATUS_INVALID_DETAIL =
360
361
  "First Draft returned an invalid publication status response. Retrying unchanged will not repair this protocol mismatch.";
361
362
  const PLAN_PUBLISH_CHANGED_DETAIL =
362
363
  "The pinned Publication changed while being polled. The command stopped without following a replacement.";
363
364
  const PLAN_PUBLISH_TIMEOUT_DETAIL =
364
- "The retained Publication is still processing after the bounded ten-minute wait. This invocation stopped waiting, but retained work may continue. Do not run concurrent Compile commands. Wait, then rerun 'firstdraft plan compile' with unchanged Plan bytes to safely resume the retained singleton.";
365
+ "The retained Publication is still processing after the bounded ten-minute wait. This invocation stopped waiting, but retained work may continue. Do not run concurrent Compile commands. Wait, then rerun 'firstdraft plan compile --github' with unchanged Plan bytes to safely resume the retained singleton.";
365
366
  const PLAN_PUBLISH_FAILED_DETAIL =
366
367
  "The pinned Publication failed. Its validated status identifies the failed phase.";
367
368
  const PLAN_PUBLISH_CANCELLED_DETAIL = "The pinned Publication was cancelled.";
@@ -1527,6 +1528,7 @@ async function runPlanCompile({
1527
1528
  args: [...argv],
1528
1529
  options: {
1529
1530
  output: { type: "string" },
1531
+ github: { type: "boolean" },
1530
1532
  help: { type: "boolean", short: "h" },
1531
1533
  },
1532
1534
  allowPositionals: false,
@@ -1548,8 +1550,8 @@ async function runPlanCompile({
1548
1550
  return 0;
1549
1551
  }
1550
1552
 
1551
- const output = parsed.values.output;
1552
- if (output !== undefined && output.length === 0) {
1553
+ const { output, github } = parsed.values;
1554
+ if (output !== undefined && (output.length === 0 || github)) {
1553
1555
  writeJson(stderr, {
1554
1556
  error: "invalid_arguments",
1555
1557
  detail: PLAN_COMPILE_INVALID_ARGUMENTS_DETAIL,
@@ -1577,11 +1579,11 @@ async function runPlanCompile({
1577
1579
  readStatus: planCompileReadStatus,
1578
1580
  onProgress: reportProgress,
1579
1581
  };
1580
- if (output !== undefined) {
1582
+ if (!github) {
1581
1583
  try {
1582
1584
  const result = await compilePlanToDirectory({
1583
1585
  ...shared,
1584
- output,
1586
+ output: output ?? ".",
1585
1587
  compilationSleep,
1586
1588
  compilationNow,
1587
1589
  compile: planCompileDownload,
@@ -1594,7 +1596,7 @@ async function runPlanCompile({
1594
1596
  }
1595
1597
 
1596
1598
  try {
1597
- const result = await compilePlan({
1599
+ const result = await compilePlanToGitHub({
1598
1600
  ...shared,
1599
1601
  publicationSleep: planPublishSleep,
1600
1602
  publicationNow: planPublishNow,
@@ -80,7 +80,7 @@ export class PlanCompileAnalysisInvalidError extends Error {
80
80
  *
81
81
  * @param {CompilePlanOptions} options
82
82
  */
83
- export async function compilePlan({
83
+ export async function compilePlanToGitHub({
84
84
  cwd,
85
85
  apiUrl,
86
86
  fetchFunction,
@@ -134,8 +134,8 @@ export async function compilePlan({
134
134
  /**
135
135
  * Submit and analyze the exact current local Plan, then start one direct
136
136
  * Compilation and materialize its verified artifact into an absent directory
137
- * or the eligible current directory. GitHub Publication remains the no-output
138
- * mode owned by compilePlan.
137
+ * or the eligible current directory. GitHub Publication is the explicit
138
+ * --github mode owned by compilePlanToGitHub.
139
139
  *
140
140
  * @param {CompilePlanToDirectoryOptions} options
141
141
  */
@@ -1,7 +1,10 @@
1
1
  import { mkdirSync, writeFileSync } from "node:fs";
2
2
  import path from "node:path";
3
3
 
4
- import { FOUNDATION_PLAN_FORMAT } from "../compilation-artifact.js";
4
+ import {
5
+ FOUNDATION_PLAN_FORMAT,
6
+ RAILS_TARGET_PROFILE,
7
+ } from "../compilation-artifact.js";
5
8
 
6
9
  /**
7
10
  * @typedef {object} FileSystem
@@ -58,7 +61,7 @@ function emptyPlan(applicationKey, name) {
58
61
  format: FOUNDATION_PLAN_FORMAT,
59
62
  target: {
60
63
  id: "rails",
61
- profile: "rails-sketch/2026-08",
64
+ profile: RAILS_TARGET_PROFILE,
62
65
  },
63
66
  application: {
64
67
  key: applicationKey,
@@ -26,7 +26,8 @@ import {
26
26
  export const ARTIFACT_MEDIA_TYPE =
27
27
  "application/vnd.firstdraft.compilation-artifact+json";
28
28
  export const ARTIFACT_FORMAT = "firstdraft.compilation-artifact/1";
29
- export const FOUNDATION_PLAN_FORMAT = "firstdraft.foundation-plan.sketch/0.19";
29
+ export const FOUNDATION_PLAN_FORMAT = "firstdraft.foundation-plan.sketch/0.20";
30
+ export const RAILS_TARGET_PROFILE = "rails-sketch/2026-09";
30
31
  export const MAX_ARTIFACT_BYTES = 128 * 1024 * 1024;
31
32
 
32
33
  const ARTIFACT_KEYS = ["format", "provenance", "manifest_sha256", "files"];
@@ -283,9 +284,9 @@ export function materializeCompilationArtifact(artifact, target) {
283
284
  writeArtifactTree(artifact.files, root);
284
285
  applyMode(root, DIRECTORY_MODE);
285
286
  },
286
- verifyArtifact: (root, ignoredRootEntries) =>
287
- verifyArtifactTree(artifact.files, root, ignoredRootEntries, {
288
- verifyRootMode: ignoredRootEntries === undefined,
287
+ verifyArtifact: (root, ignoredPaths) =>
288
+ verifyArtifactTree(artifact.files, root, ignoredPaths, {
289
+ verifyRootMode: ignoredPaths === undefined,
289
290
  }),
290
291
  });
291
292
  } catch (error) {
@@ -361,6 +362,7 @@ function parseProvenance(value, expected) {
361
362
  !hasExactKeys(value.target, TARGET_KEYS) ||
362
363
  value.target.id !== expected.target.id ||
363
364
  value.target.profile !== expected.target.profile ||
365
+ value.target.profile !== RAILS_TARGET_PROFILE ||
364
366
  !hasExactKeys(value.core, CORE_KEYS) ||
365
367
  !isRepository(value.core.repository) ||
366
368
  typeof value.core.revision !== "string" ||
@@ -595,19 +597,19 @@ function writeArtifactTree(files, root) {
595
597
  /**
596
598
  * @param {ValidatedArtifactFile[]} files
597
599
  * @param {string} root
598
- * @param {Set<string>} [ignoredRootEntries]
600
+ * @param {Set<string>} [ignoredPaths]
599
601
  * @param {{verifyRootMode?: boolean}} [options]
600
602
  */
601
603
  function verifyArtifactTree(
602
604
  files,
603
605
  root,
604
- ignoredRootEntries = new Set(),
606
+ ignoredPaths = new Set(),
605
607
  { verifyRootMode = true } = {},
606
608
  ) {
607
609
  const expectedFiles = new Map(files.map((file) => [file.path, file]));
608
610
  const expectedDirectories = new Set();
609
- for (const file of files) {
610
- const components = file.path.split("/");
611
+ for (const relativePath of [...expectedFiles.keys(), ...ignoredPaths]) {
612
+ const components = relativePath.split("/");
611
613
  for (let index = 1; index < components.length; index += 1) {
612
614
  expectedDirectories.add(components.slice(0, index).join("/"));
613
615
  }
@@ -625,7 +627,7 @@ function verifyArtifactTree(
625
627
  "The materialized compilation root is invalid.",
626
628
  );
627
629
  }
628
- walkTree(root, "", actualFiles, actualDirectories, ignoredRootEntries);
630
+ walkTree(root, "", actualFiles, actualDirectories, ignoredPaths);
629
631
  if (
630
632
  !setsEqual(actualFiles, new Set(expectedFiles.keys())) ||
631
633
  !setsEqual(actualDirectories, expectedDirectories)
@@ -681,18 +683,18 @@ function hasExpectedMode(actual, expected) {
681
683
  * @param {string} relative
682
684
  * @param {Set<string>} files
683
685
  * @param {Set<string>} directories
684
- * @param {Set<string>} ignoredRootEntries
686
+ * @param {Set<string>} ignoredPaths
685
687
  */
686
- function walkTree(root, relative, files, directories, ignoredRootEntries) {
688
+ function walkTree(root, relative, files, directories, ignoredPaths) {
687
689
  const directory = relative ? path.join(root, ...relative.split("/")) : root;
688
690
  const entries = readdirSync(directory, { withFileTypes: true });
689
691
 
690
692
  for (const entry of entries) {
691
- if (relative === "" && ignoredRootEntries.has(entry.name)) continue;
692
693
  const entryRelative = relative ? `${relative}/${entry.name}` : entry.name;
694
+ if (ignoredPaths.has(entryRelative)) continue;
693
695
  if (entry.isDirectory()) {
694
696
  directories.add(entryRelative);
695
- walkTree(root, entryRelative, files, directories, ignoredRootEntries);
697
+ walkTree(root, entryRelative, files, directories, ignoredPaths);
696
698
  } else if (entry.isFile()) {
697
699
  files.add(entryRelative);
698
700
  } else {