Repository navigation
Add start and a two-step device login - #66
Merged
Merged
Conversation
The Skill's first step was 'firstdraft --help', which told the agent nothing about versions, the login, or whether the person agreed to reports, and only the person could log in, by holding a terminal open while they approved in a browser. 'firstdraft start' reads the account once with the saved login and prints fixed sentences from src/agent-sentences.js: the versions, the update line, whether this computer is logged in and how to log in if not, whether an environment token takes the saved login's place, and, only when reports are on, when to send them and with which command. First Draft's answer only chooses among the sentences. It exits 0 only when First Draft accepted the token; a setup below the minimum fails with update_required although the account read was its only request. 'login --no-wait' saves a device grant in device-login.json (0600) and prints the link and the code; 'login --finish' polls for at most 15 seconds and says whether the computer is logged in, still waiting, expired, or refused. The file keeps the next poll time so a repeated --finish never polls early and lengthens the grant's interval. The browser login and the one-process device login are unchanged.
Review found that start gave login steps instead of the update refusal when a rejected account read also named a newer minimum, and that its errors repeated the problem text First Draft sent, which can name the person. A retry it printed for staging dropped --staging. login --finish could run past its 15 seconds when the last poll was recent, could call a grant that expired during the request pending, and reported a failed login when only the spent grant file could not be removed after the token was saved. It now measures the wait from its start and bounds each request by it, removes the spent grant before saving the token, and says a refused or expired attempt saved no new login rather than that the computer is logged out.
A second review found that a timer waking late could still send a poll after the 15 seconds, and that the pending and expired lines said the person had not approved when the CLI had not asked or had asked too late to redeem the grant. They now say First Draft has not confirmed an approval, and that the grant expired before this computer finished. A credentials file that cannot be read now names the login step, with --staging, instead of a bare 'firstdraft login'.
The error reference still said a pending login meant the person had not approved and an expired one ended before approval, though the CLI can stop without asking or redeem too late. It now says First Draft had not confirmed an approval, or the grant ended before the CLI received a token, matching what the commands print.
raghubetina
marked this pull request as ready for review
November 21, 2026 23:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
firstdraft start, the Skill's first step in place of the--helpcheck, and lets an agent run the device login in two short commands.firstdraft startreads the account once with the saved login (no request without a token) and prints fixed sentences fromsrc/agent-sentences.json standard output: the CLI version and, when known, the plugin's; the shared update line; whether this computer has a saved login and whether an environment token takes its place; how to log in when it is not logged in; and, only when reports are on, when to send progress and failure reports and with which command. It exits 0 only when First Draft accepted the token. Not logged in or a rejected token isauthentication_required; a version or contract refusal wins over a failed account read. Its handled errors carry no problem text from First Draft.firstdraft login --no-waitasks for a device grant, prints the link, the user code, and when they expire, saves the waiting login indevice-login.jsonbesidecredentials.json(mode 0600), and exits.firstdraft login --finishpolls for at most 15 seconds from its start, each request included, never sooner than the grant's interval, and says whether the computer is now logged in, still waiting (authorization_pending), expired, or refused. It removes the spent grant before saving the token. The device code is never printed. The browser login and the one-processlogin --interactiveare unchanged.authorization_pendingandlogin_not_started(both exit 1), and thelogin_failedreasonsdevice_login_invalidanddevice_login_unavailable.The service needed no change: its device endpoints answer a grant's first poll at any time and enforce the interval between later polls, which the saved next-poll time respects.
Docs: updated docs/commands.md, docs/errors.md, the root and
loginhelp, and the 0.10.0 entry in CHANGELOG.md.Review: Codex, approve (4 rounds, 10 findings fixed, 3 deferred). Antigravity, 1 round, approve, 0 findings.
Known limits
--no-waitrun while an older--finishis still polling can be overwritten or removed by that older run. Trigger: running the two steps at the same time instead of one after the other.--finishinterrupted during its request and rerun at once polls early and earns oneslow_down, which the CLI absorbs by lengthening its interval. Trigger: killing--finishmid-request and rerunning within the interval.credentials.jsonis. Trigger: a pre-existingfirstdraftconfiguration directory with a broader mode.login --interactive. Trigger: a First Draft answer naming another host for/device.device-login.jsonis removed only when--finishor--no-waitnext runs;startnever reads it.src/service-client.js, shared with every command.Validation
npm audit: 0 vulnerabilitiesnpm run check: passes (362 tests, pack check, packed-package smoke)