@firstdraft.com/cli 0.2.1 → 0.3.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/RELEASING.md CHANGED
@@ -39,7 +39,19 @@ declarations from exact, clean checkouts of `firstdraft/firstdraft` and `firstdr
39
39
  precedence. CLI `0.2.x` requires the service's `0.3.x` API contract because Analysis now returns the complete reviewed
40
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
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
42
+ Analysis and Compilation artifacts dedicated 128 MiB bounds. CLI `0.3.x` retains those bounds and requires API
43
+ `0.4.x`, Plan `firstdraft.foundation-plan.sketch/0.20`, and target profile `rails-sketch/2026-09`. Its new minor line
44
+ combines that contract transition with the incompatible root archive-path change to `.firstdraft/design`; Skills
45
+ and other callers require the matching CLI line. Existing applications are not migrated.
46
+
47
+ The API `0.4.x` transition keeps `/v1` paths, authentication, statuses, and ETag behavior. Its breaking boundary is
48
+ the new Plan and target identity, including removal of record-wide Validation targets, normalization order,
49
+ optional Home selection, and target realization changes. The Service owns those semantics. The CLI initializes
50
+ the current identity, preserves authored bytes when pushing, and validates the current artifact identity; it does
51
+ not translate earlier Plans or artifacts. The proposed CLI `0.3.0` may retain that version while unpublished and
52
+ untagged under the policy above. This source declaration does not establish package availability or deployment.
53
+
54
+ Comparator arrays form one conjunction, while
43
55
  `foundation_plan_formats` lists alternatives. A prerelease satisfies a comparator set only when a comparator
44
56
  explicitly names a prerelease with the same major, minor, and patch numbers. Skills names the candidate CLI version
45
57
  explicitly, so a stale comparator makes the three-repository candidate ineligible.
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.3.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.3.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
@@ -44,9 +44,10 @@ From the project that the Plan describes:
44
44
  firstdraft plan init --name "Oscar Party"
45
45
  ```
46
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.
47
+ This creates an empty `firstdraft.foundation-plan.sketch/0.20` Plan targeting `rails-sketch/2026-09` and a
48
+ client-generated Project ID under `.firstdraft/`. A nested ignore file keeps that local scratch area out of Git
49
+ without changing the project's own `.gitignore`. Initialization makes no network request and refuses to replace an
50
+ existing `.firstdraft` path.
50
51
 
51
52
  Provide either `--name`, `--application-key`, or both. Name-only initialization derives a lower-snake key. Key-only
52
53
  initialization derives a humanized display name. Supplying both preserves both values exactly after validating them
@@ -153,9 +154,102 @@ the accepted source SHA-256 from the saved ETag, hashes the current local bytes,
153
154
 
154
155
  ### Materialize a direct Compilation
155
156
 
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.
157
+ With `--output`, the CLI accepts either an explicit absent destination beneath an existing real directory or a path
158
+ that resolves to the physical current directory. It validates either destination before pushing the Plan. An absent
159
+ destination is checked again after analysis; root adoption instead holds its owned lock and performs the exact
160
+ pre-move identity recheck described below. Other existing destinations remain invalid, so
161
+ `--output ./application` retains its absent-directory contract.
162
+
163
+ The nested archive layout below describes the unreleased `0.3.0` candidate.
164
+ [Published CLI `0.2.2`](release-history.md#022-publication-and-registry-observation) archives at top-level `design/`;
165
+ existing applications are not migrated automatically.
166
+
167
+ `--output .` is the noninteractive root-adoption mode. `./`, an absolute spelling of the current directory, and
168
+ another spelling that resolves to that same physical directory select the same mode. It works at any real current
169
+ directory that meets the preconditions below and does not recognize Drawing Board or another repository layout
170
+ specially. This first root-adoption contract supports POSIX filesystems; Windows retains absent-directory output
171
+ and refuses root adoption as `root_platform_unsupported`. Before starting Compilation, the CLI requires:
172
+
173
+ - the current directory to be a real, writable, non-filesystem-root directory;
174
+ - no existing `.firstdraft/design` archive or top-level `.firstdraft-root-output` transaction path, including
175
+ portable, case-insensitive spellings;
176
+ - every top-level entry other than `.git` to be a regular file or real directory on the current directory's
177
+ filesystem. Interior symlinks, dependency trees, sockets, and nested repositories move opaquely with their
178
+ top-level directory; the CLI neither follows nor repairs them; and
179
+ - when the current directory is the root of a Git worktree, a clean tracked worktree and index with no unmerged
180
+ entries, sparse checkout, or in-progress merge, rebase, cherry-pick, or revert. Untracked and ignored design
181
+ material may remain present. Submodules and tracked `.gitmodules` files are refused in this first root-adoption
182
+ contract rather than moved with broken Git wiring. A directory nested inside a higher Git worktree is refused
183
+ rather than treated as non-Git. A valid top-level `.git` file for a linked worktree is retained like a `.git`
184
+ directory.
185
+
186
+ Git-backed root adoption invokes the installed Git executable explicitly. Read-only discovery uses
187
+ `git --no-optional-locks` with stable NUL-delimited porcelain so it does not refresh the index. Before remote work,
188
+ the CLI verifies in a temporary preview that every currently ignored entry remains ignored after its path and
189
+ applicable worktree `.gitignore` files move beneath `.firstdraft/design`; repository-local and configured global
190
+ exclusions are both honored. A refusal is `invalid_output_path` with a machine-readable `reason` and happens before Plan push.
191
+
192
+ The CLI creates `.firstdraft-root-output` with exclusive creation during the pre-push output check and holds it
193
+ through analysis, Compilation, and materialization. That directory is both the single-writer lock and the owned
194
+ transaction journal, so a concurrent root adoption is refused before either command sends a request. Immediately
195
+ after acquiring it, the CLI captures every other top-level entry's exact name, entry type, device, and inode. After
196
+ staging the artifact and any replacement Git index, it rechecks that set immediately before moving anything. Size,
197
+ modification time, and contents are deliberately not part of this identity: interior changes are not recursively
198
+ inventoried, and a top-level directory moves intact at the transaction boundary. A replaced, added, or removed
199
+ top-level entry stops materialization. The reserved-path precondition ignores only the transaction directory
200
+ created and still held by this invocation.
201
+
202
+ `compilation download --output .` acquires the same lock before its first status request and holds it through
203
+ artifact download and materialization. Either command removes its own transaction directory on every ordinary exit
204
+ before the journal records an irreversible move or index installation. Its signal handlers do the same when Node
205
+ dispatches the signal before that boundary. A journal whose phase records no irreversible operation is likewise
206
+ safe to remove; the manual reconciliation rule below applies only after `root_rollback_incomplete`.
207
+
208
+ The complete generated artifact is written and verified inside that in-root transaction directory before any
209
+ existing path moves. Staging inside the destination makes every later rename same-filesystem even when the current
210
+ directory itself is a container mount point. The artifact may not own `.firstdraft/design`, its descendants, or
211
+ the top-level `.firstdraft-root-output` path, including portable, case-insensitive spellings. `.firstdraft` must be
212
+ a directory with that exact spelling when present; artifact validation already excludes `.git` at any depth.
213
+
214
+ The transaction creates `.firstdraft/design` inside the verified artifact stage with mode `0755` on POSIX and moves
215
+ every preexisting non-Git top-level entry beneath it. It keeps an existing top-level `.git` file or directory at the
216
+ root, then installs the artifact's top-level entries there. Installing the staged `.firstdraft` places the archive
217
+ directly at `.firstdraft/design`; there is no intermediate top-level `design` directory. The original planning
218
+ `.firstdraft` remains intact at `.firstdraft/design/.firstdraft`, separate from the generated submitted Plan and
219
+ gaps at `.firstdraft/`.
220
+
221
+ Immediately before each artifact entry is installed, its root destination must still be absent; an unexpected
222
+ entry stops the transaction and is never overwritten. If the root contains no entry other than `.git`, it does not
223
+ retain an empty archive. A nested mount that cannot travel with its top-level directory may make its rename fail;
224
+ that is a transactional failure, not permission to copy or traverse the mount.
225
+
226
+ For a Git root, the CLI first prepares a replacement index that stages each formerly tracked path at
227
+ `.firstdraft/design/<old-path>` and stages every exact generated artifact path at the root. This handles overlapping
228
+ names such as `README.md` and `.gitignore` without leaving the old design blob indexed at a generated path. Previously
229
+ untracked and ignored paths are never added to the index. Preparing that index writes the generated blobs into the
230
+ Git object database; a rollback may therefore leave unreachable blobs for ordinary Git garbage collection, while
231
+ `HEAD`, refs, configuration, and history remain unchanged. After the worktree renames finish, the CLI installs the
232
+ prepared index through Git's actual index lock path and atomic lock-file commit protocol, including in a linked
233
+ worktree whose index is outside the adopted root. The transaction journal retains whether an index existed plus an
234
+ exact private copy, mode, and digest of its prior bytes until final verification succeeds. The preflighted ignore
235
+ protection is rechecked after the move. The caller should inspect and commit this staged root-adoption change before
236
+ using destructive worktree or index restoration commands. A non-Git root remains non-Git and is not initialized.
237
+
238
+ The journal is a versioned private JSON record plus owned staging files. It records the physical root and original
239
+ top-level identity set, the transaction phase, completed design and artifact renames, and, for Git, the resolved
240
+ index path and original and prepared index digests. Each irreversible phase is recorded before the next one starts.
241
+ On any failure after a move, index installation, or post-install verification, the CLI first restores the exact
242
+ prior index through the same Git lock boundary, then reverses artifact moves in reverse recorded order, followed
243
+ by design moves in reverse recorded order. Reversing the installed `.firstdraft` first returns the archive to
244
+ staging so the original planning `.firstdraft` can move back to its original root path. A fully
245
+ successful rollback removes only the owned transaction. If rollback itself cannot finish,
246
+ `materialization_failed` reports `reason: "root_rollback_incomplete"` and includes
247
+ `recovery_path: ".firstdraft-root-output"`; it leaves the journal and owned copies in place rather than guessing.
248
+ Do not delete that directory or run Git restoration commands. Follow the
249
+ [manual recovery order](errors.md#direct-compilation-recovery), reconcile the versioned journal with the current
250
+ path identities, and verify its original snapshot before removing the transaction directory. Another root adoption
251
+ reports `root_busy` until that state is reconciled; a foreign preexisting directory with the same reserved name
252
+ reports `root_reserved_path`.
159
253
 
160
254
  After valid analysis, the CLI requests one Compilation for that exact reviewed Head and never starts GitHub
161
255
  Publication. It validates that the `202` response identifies the same Project, graph version, Head, Analysis,
@@ -166,10 +260,17 @@ and materialization failures retain the last validated Compilation projection so
166
260
  without starting duplicate work. Follow the [direct Compilation recovery procedure](errors.md#direct-compilation-recovery).
167
261
 
168
262
  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.
263
+ Root adoption additionally reports `root_adoption.design_path` (or `null` when no design directory was needed), its
264
+ top-level moved-entry count, whether a Git repository was preserved, and whether its index was replaced.
265
+ After final verification succeeds, the CLI removes its owned `.firstdraft-root-output` transaction directory.
266
+ An absent output directory contains exactly the artifact files and modes. Root adoption additionally contains the
267
+ preserved `.firstdraft/design` archive and an existing root `.git`, when present. Verification skips only the
268
+ archive and retained Git/transaction paths; it still checks every generated file, including
269
+ `.firstdraft/submitted-foundation-plan.json` and `.firstdraft/gaps.json`, and rejects unexpected generated paths. The
270
+ CLI does not add a Git repository, run a formatter, or repair generated source. When an absent output is nested
271
+ inside another Git worktree, initialize the application as its own repository before running generated checks that
272
+ inspect Git; otherwise Git resolves to the parent worktree. Progress on stderr reports analysis and Compilation
273
+ only.
173
274
 
174
275
  ### Publish through GitHub
175
276
 
@@ -188,7 +289,7 @@ local paths, or environment values. Success writes exactly the validated private
188
289
  newline to stdout. If the command fails after progress has begun, its structured JSON error envelope is the final
189
290
  stderr document after the progress lines.
190
291
 
191
- The closed API `0.3.x` progress-reason allowlist is `github.configuration_missing`, `github.oauth_unavailable`,
292
+ The closed API `0.4.x` progress-reason allowlist is `github.configuration_missing`, `github.oauth_unavailable`,
192
293
  `github.api_unavailable`, `github.reauthorization_required`, `github.account_mismatch`,
193
294
  `github.installation_unavailable`, `github.installation_not_ready`, `github.preflight_unavailable`, the legacy-only
194
295
  `github.preflight_unclassified`, and these stage-specific fallbacks: `github.preflight_unavailable.configuration`,
@@ -232,6 +333,22 @@ Materialize an already successful Compilation into an absent path:
232
333
  firstdraft compilation download 01900000-0000-7000-8000-000000000001 --output ../movie-catalog
233
334
  ```
234
335
 
336
+ The same command accepts `--output .` and applies the root-adoption transaction above. This is the recovery path
337
+ when a retained direct Compilation succeeded but an earlier root materialization failed _and fully rolled back_; it
338
+ never starts replacement work. An incomplete rollback leaves `.firstdraft-root-output` and requires journal
339
+ reconciliation before this command can run again.
340
+
341
+ Artifact validation accepts only Plan format `firstdraft.foundation-plan.sketch/0.20` and target profile
342
+ `rails-sketch/2026-09`, in addition to matching the retained Compilation's provenance and verifying file integrity.
343
+ An earlier format or profile is rejected before materialization, even when the retained status names that profile.
344
+
345
+ Successful root adoption is intentionally one-way. The original `.firstdraft` authoring state moves under
346
+ `.firstdraft/design/.firstdraft`; run later First Draft commands from `.firstdraft/design`. Run ordinary Rails
347
+ setup, preview, and tests from the generated application root. Retain the archive when further First Draft
348
+ authoring is useful. The CLI does not run or qualify the generated application's setup, preview, or test commands.
349
+ Compiling a later Plan revision does not overwrite an already adopted root: choose a new absent output and
350
+ deliberately reconcile it with application work.
351
+
235
352
  The command validates the UUID and output path before network access, makes one status `GET`, requires `succeeded`,
236
353
  and makes one artifact `GET`. It never starts work or polls. Historical artifact validation uses the retained
237
354
  `compilation.head_source_sha256`, not the current local Plan or ETag, to pin the artifact's exact
package/docs/errors.md CHANGED
@@ -68,7 +68,20 @@ materialization failure envelopes include that last validated projection as `cur
68
68
  - after `artifact_unavailable`, wait if appropriate and use
69
69
  `firstdraft compilation download <current.compilation.id> --output <new-absent-path>`; and
70
70
  - after `materialization_failed`, repair the destination condition, then use the same lower-level download command
71
- with a new absent path.
71
+ with a new absent path. A root-output attempt whose transaction fully rolled back may instead retry that retained
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
+
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.
72
85
 
73
86
  After `compilation_wait_timed_out`, retained work may still continue. Use
74
87
  `firstdraft compilation status <current.compilation.id>` for one read-only status check; do not rerun
@@ -118,5 +131,13 @@ stopped without following the replacement.
118
131
  | `compilation status --wait` | `compilation_changed`, `compilation_wait_timed_out` | 1 | Retained identity/provenance changed or the wait ended. |
119
132
  | `compilation download` | `compilation_not_succeeded` | 1 | Status was not `succeeded`; no artifact request was made. |
120
133
  | 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`. |
134
+ | Download commands | `invalid_output_path` | 2 | The absent destination or root-adoption preconditions failed; `reason` identifies the stable refusal. |
135
+ | Download commands | `materialization_failed` | 1 | The output changed or its transaction failed; `reason` identifies incomplete rollback when applicable. |
136
+
137
+ Root-output `invalid_output_path.reason` values are `destination_exists`, `root_not_real`, `root_not_writable`,
138
+ `root_platform_unsupported`, `root_reserved_path`, `root_entry_unsupported`, `root_enclosing_worktree`,
139
+ `root_git_unavailable`, `root_git_unsupported`, `root_git_dirty`, `root_ignore_not_preserved`, and `root_busy`. Git
140
+ refusing discovery, including a `safe.directory` refusal, is `root_git_unavailable`; a discovered but unsupported
141
+ Git shape such as a submodule is `root_git_unsupported`. Root-output `materialization_failed.reason` values are
142
+ `output_changed`, `root_artifact_collision`, `root_ignore_changed`, `root_transaction_failed`, and
143
+ `root_rollback_incomplete`.
@@ -38,3 +38,24 @@ source or documentation does not mutate either dist-tag.
38
38
  promoted stable release.
39
39
  - Package version `0.2.0` and protected tag `v0.2.0` are consumed and immutable. A backward-compatible addition to
40
40
  the `0.2.x` line therefore requires a higher patch version rather than reusing those identities.
41
+
42
+ ## 0.2.1 candidate publication
43
+
44
+ - On August 28, 2026, protected tag `v0.2.1` published ordinary version `0.2.1` under `next`; `latest` remained
45
+ `0.1.0`. The patch hardened direct Compilation recovery while preserving the `0.2.x` compatibility line.
46
+ - Package version `0.2.1` and protected tag `v0.2.1` are consumed and immutable. As observed on August 29, 2026,
47
+ current-directory root-output had integrated to `main` at `4352f64baf673ad93457e8bc84273e9d1d9a9501` (tree
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.1",
3
+ "version": "0.3.0",
4
4
  "description": "Command-line interface for First Draft",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/cli.js CHANGED
@@ -181,11 +181,11 @@ const PLAN_COMPILE_HELP = `First Draft CLI
181
181
 
182
182
  Usage:
183
183
  firstdraft plan compile
184
- firstdraft plan compile --output <absent-directory>
184
+ firstdraft plan compile --output <absent-directory|.>
185
185
 
186
186
  Options:
187
- --output <absent-directory> Materialize the generated application here
188
- -h, --help Show help
187
+ --output <absent-directory|.> Materialize the generated application here
188
+ -h, --help Show help
189
189
 
190
190
  Environment:
191
191
  FIRSTDRAFT_API_TOKEN Authenticate API requests
@@ -195,7 +195,8 @@ The command submits the exact current whole-file Plan, waits for its analysis,
195
195
  and proceeds only when that analysis is valid. Without --output, it conditionally
196
196
  creates or replays the internal GitHub Publication lifecycle and prints the
197
197
  private repository URL. With --output, it starts one direct Compilation and
198
- atomically materializes the verified artifact into an absent directory without
198
+ atomically materializes the verified artifact into an absent directory, or
199
+ preserves existing root material under .firstdraft/design when the output is ., without
199
200
  starting GitHub Publication. Progress is written to stderr.
200
201
  `;
201
202
 
@@ -232,18 +233,19 @@ cancelled terminal states are successful status reads.
232
233
  const COMPILATION_DOWNLOAD_HELP = `First Draft CLI
233
234
 
234
235
  Usage:
235
- firstdraft compilation download <compilation-id> --output <absent-path>
236
+ firstdraft compilation download <compilation-id> --output <absent-path|.>
236
237
 
237
238
  Options:
238
- --output <absent-path> Materialize the generated application here
239
- -h, --help Show help
239
+ --output <absent-path|.> Materialize the generated application here
240
+ -h, --help Show help
240
241
 
241
242
  Environment:
242
243
  FIRSTDRAFT_API_TOKEN Authenticate API requests
243
244
 
244
245
  The command reads the retained Compilation once, requires it to have
245
246
  succeeded, downloads and verifies its exact artifact once, and atomically
246
- renames the verified files into an absent output path. It never starts work.
247
+ materializes it into an absent output path or adopts the current directory
248
+ while preserving existing material under .firstdraft/design. It never starts work.
247
249
  `;
248
250
 
249
251
  const PLAN_INIT_HELP = `First Draft CLI
@@ -386,7 +388,7 @@ const COMPILATION_ARTIFACT_UNAVAILABLE_DETAIL =
386
388
  const COMPILATION_ARTIFACT_INVALID_DETAIL =
387
389
  "The downloaded Compilation artifact did not satisfy the integrity contract. No files were materialized.";
388
390
  const COMPILATION_MATERIALIZATION_FAILED_DETAIL =
389
- "The validated Compilation artifact could not be materialized at the requested absent output path.";
391
+ "The validated Compilation artifact could not be materialized at the requested output path.";
390
392
  const PLAN_COMPILE_DIRECT_ARTIFACT_UNAVAILABLE_DETAIL =
391
393
  "Could not download the retained Compilation artifact. Use current.compilation.id with 'firstdraft compilation download'; do not start another Compilation.";
392
394
  const PLAN_COMPILE_DIRECT_ARTIFACT_INVALID_DETAIL =
@@ -394,7 +396,7 @@ const PLAN_COMPILE_DIRECT_ARTIFACT_INVALID_DETAIL =
394
396
  const PLAN_COMPILE_DIRECT_MATERIALIZATION_FAILED_DETAIL =
395
397
  "The retained Compilation artifact was validated but could not be materialized. Use current.compilation.id with 'firstdraft compilation download' after repairing the output path; do not start another Compilation.";
396
398
  const COMPILATION_INVALID_OUTPUT_PATH_DETAIL =
397
- "The compilation output path must be absent beneath an existing real directory. No network request was made.";
399
+ "The compilation output must be an absent path beneath an existing real directory or the eligible current directory.";
398
400
  const GENERATE_UUID_INVALID_ARGUMENTS_DETAIL =
399
401
  "Invalid arguments. Run 'firstdraft generate uuid --help' for usage.";
400
402
  const GENERATE_APPLICATION_KEY_INVALID_ARGUMENTS_DETAIL =
@@ -994,6 +996,7 @@ async function runCompilationDownload({
994
996
  writeJson(stderr, {
995
997
  error: "invalid_output_path",
996
998
  detail: COMPILATION_INVALID_OUTPUT_PATH_DETAIL,
999
+ ...(error.reason ? { reason: error.reason } : {}),
997
1000
  });
998
1001
  return 2;
999
1002
  }
@@ -1002,6 +1005,8 @@ async function runCompilationDownload({
1002
1005
  writeJson(stderr, {
1003
1006
  error: "materialization_failed",
1004
1007
  detail: COMPILATION_MATERIALIZATION_FAILED_DETAIL,
1008
+ ...(error.reason ? { reason: error.reason } : {}),
1009
+ ...(error.recoveryPath ? { recovery_path: error.recoveryPath } : {}),
1005
1010
  });
1006
1011
  return 1;
1007
1012
  }
@@ -1928,6 +1933,7 @@ function writePlanCompileError(writer, error) {
1928
1933
  writeJson(writer, {
1929
1934
  error: "invalid_output_path",
1930
1935
  detail: COMPILATION_INVALID_OUTPUT_PATH_DETAIL,
1936
+ ...(compilationError.reason ? { reason: compilationError.reason } : {}),
1931
1937
  });
1932
1938
  return 2;
1933
1939
  }
@@ -1936,6 +1942,10 @@ function writePlanCompileError(writer, error) {
1936
1942
  writeJson(writer, {
1937
1943
  error: "materialization_failed",
1938
1944
  detail: PLAN_COMPILE_DIRECT_MATERIALIZATION_FAILED_DETAIL,
1945
+ ...(compilationError.reason ? { reason: compilationError.reason } : {}),
1946
+ ...(compilationError.recoveryPath
1947
+ ? { recovery_path: compilationError.recoveryPath }
1948
+ : {}),
1939
1949
  ...(retainedCompilation ? { current: retainedCompilation } : {}),
1940
1950
  });
1941
1951
  return 1;