Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ target to profile `rails-sketch/2026-11` and the accepted API contract to `0.9.x
`untrusted` list names the fields that can hold end users' text, and what done means. `maintain resolve <item-id>`
resolves it with a `--reason`, a `--cause` that says what caused the error (`unknown` when the agent could not
tell), and an optional `--detail`, such as the pull request. Each takes `--environment`, `production` by default,
runs from the generated application's root or the Project's directory, uses the Project's pinned origin, and changes
no local state.
and changes no local state. They run from the application's folder or the Project's directory: without the
Project's state there, as in a fresh clone of the application, they read the Project ID from the application's
`.firstdraft/gaps.json`, use the origin `login` would select, and say so on standard error.
- `report failure --kind deployed_error --item <item-id>` reports an error in a deployed application that
`maintain resolve` traced to code First Draft generated. It names the item and takes no `--message`.
- After an ambiguous push, from `plan push` or `plan compile`, or an ambiguous direct Compilation start,
Expand Down
44 changes: 34 additions & 10 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,11 @@ A failure report needs only `--kind` (`spec_failure`, `setup_failure`, `boot_err
[`firstdraft maintain`](#maintain-a-deployed-application) resolved with `--cause generated_code`: it also needs
`--item <item-id>`, sent as `maintenance_item_id`, and takes no `--message`, because the item's evidence can hold end
users' text. Another kind with `--item`, or a `deployed_error` without a lowercase item ID or with `--message`, is
`invalid_arguments`, and nothing is read or sent. Each other field is sent only in its shape, and left out otherwise:
`invalid_arguments`, and nothing is read or sent. A `deployed_error` finds its Project as
[`firstdraft maintain`](#maintain-a-deployed-application) does, from the application's `.firstdraft/gaps.json` too.
Those files record no Compilation. The command reads the account first: with reports off it exits 0 as usual, and
with reports on, without a Compilation given right after `report failure`, it ends with `compilation_not_recorded` and
sends nothing. Each other field is sent only in its shape, and left out otherwise:

| Option | Field | What it may contain |
| ----------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -794,11 +798,13 @@ Free text keeps plain words only: the CLI takes the first line, replaces everyth
quote character (`'`, `"`, or a backtick, including an apostrophe inside a word) to the end of the line with one `[…]`,
replaces each earlier word that contains `=`, `/`, `\`, or `@` or is longer than 24 characters with `[…]`, and keeps the
words that fit the length limit. A `lint_failure` therefore sends no rule name, and a rerun command that is not an
RSpec run is left out. Besides the Project's state and the Compilation record, the CLI reads no file for a failure
report and attaches no diff or environment variable, but
RSpec run is left out. Besides the Project's state and the Compilation record, or, for a `deployed_error` without
planning state, the application's `.firstdraft/gaps.json`, of which it uses only the Project ID, the CLI reads no file
for a failure report and attaches no diff or environment variable, but
the plain words of a message or fix summary it is given can still quote code, so pass only text that may be sent.

Each command first reads the account with a `GET` of `/v1/account` at the origin pinned by a successful push. Unless
Each command first reads the account with a `GET` of `/v1/account` at the origin pinned by a successful push, or,
for a `deployed_error` without planning state, the origin `login` selects. Unless
First Draft answers `{"reports": "on"}`, no report is sent. With reports off, the command writes a line that says so
and exits 0, so the agent's work continues; it reads no Compilation record first. When the account read fails, no report is sent either. The command then
ends with `account_unavailable`, with `invalid_server_response` when the answer breaks the account's contract, or with
Expand Down Expand Up @@ -892,7 +898,7 @@ firstdraft maintain resolve 3f2c9a4e-8d1b-4c7a-9e5f-0a1b2c3d4e5f --reason pull_r
--cause generated_code --detail https://github.com/acme/app/pull/7
```

`firstdraft maintain` first reads the account with a `GET` of `/v1/account` at the pinned origin, as a report
`firstdraft maintain` first reads the account with a `GET` of `/v1/account` at the Project's origin, as a report
command does, then prints one page of the Environment's open items, most severe first, 200 per page. Each item has
`id`, `kind`, `severity`, `title`, `occurrences`, `first_seen_at`, `last_seen_at`, `last_release`, `status`,
`resolution_reason`, `resolution_cause`, and `issue_url`, the GitHub issue First Draft filed and keeps current for
Expand Down Expand Up @@ -929,10 +935,27 @@ only while the item stays resolved, so after an unconfirmed resolution run `main
resolving again.

Each command takes `--environment`, which defaults to `production`: a lowercase name of letters, digits, and hyphens
that starts with a letter. Item IDs are lowercase UUIDs. The commands use the Project ID and API origin in
`.firstdraft/state.json`. Run them from the generated application's root, where the CLI finds that state archived at
`.firstdraft/design` after root adoption, as the report commands do, or from the Project's directory. `show` and
`resolve` make one request, and the index two. Each request has a
that starts with a letter. Item IDs are lowercase UUIDs. Run the commands in the application's folder or in the
Project's directory. They find the Project in this order:

1. The Project's `.firstdraft/state.json` in the current directory, or its archive at `.firstdraft/design` after root
adoption, as the report commands do. It pins both the Project ID and the API origin.
2. Without that state, as in a fresh clone of the application or one compiled with `--output`, the Project ID in the
application's own `.firstdraft/gaps.json`, which every Compilation writes and which keeps the same Project ID
across recompiles. That file holds no origin, so the commands use the one `login` would select: `--staging`,
`FIRSTDRAFT_API_URL`, or `https://firstdraft.com`. They need a login for that origin on this computer, and after a
successful response they write this line on standard error, after any update line and before the reports
sentence:

```text
No First Draft planning folder is here, so the CLI read the Project from .firstdraft/gaps.json and used <origin>: if the Project is on another First Draft origin, add --staging or set FIRSTDRAFT_API_URL.
```

It is `applicationProjectLine` in `src/agent-sentences.js`. A Project on another origin answers
`environment_not_found`.

Without either, or with a `gaps.json` that names no Project, the command ends with `local_input_unreadable`. `show`
and `resolve` make one request, and the index two. Each request has a
bounded timeout and refuses redirects; the commands change no local state, and print only a response that matches the
contract exactly, including its Project ID, Environment name, and item ID. See
[maintenance recovery](errors.md#maintenance-recovery).
Expand All @@ -941,7 +964,8 @@ contract exactly, including its Project ID, Environment name, and item ID. See

The CLI calls these Service API routes. The `/v1` routes send the selected token as a Bearer credential;
`account` and `start` read `/v1/account` at the origin selected as for `login`; the report and note commands and the `maintain` index read it, and every other
`/v1` request goes, to the origin pinned for the Project. The `/oauth` routes go to the origin selected for `login` or `logout` and send form-encoded OAuth parameters
`/v1` request goes, to the origin pinned for the Project, or, for a maintain command or a `deployed_error` without
planning state, the origin selected as for `login`. The `/oauth` routes go to the origin selected for `login` or `logout` and send form-encoded OAuth parameters
without a Bearer credential. Every request refuses redirects and has a bounded
timeout. Each request takes its method and path from one
`SERVICE_ROUTES` entry in `src/api-response.js`. `test/service-endpoints.test.js` fails when this table and
Expand Down
Loading
Loading