feat(setup): the curl|sh path can offer the browser login too — prompt via /dev/tty

Merged
TO
3mo ago
+76-11

Tony's ask: the installation script should let you run the OAuth login as well. It couldn't: under curl … | sh stdin is the script pipe, so the 0.0.39 login offer never fired on the curl path (and agents.sh forwards -y).

The standard installer solution (Homebrew prompts the same way):

  • openPromptInput() — read the Y/n answer from stdin when it's a TTY, else from /dev/tty (POSIX only; never on Windows, where the curl path doesn't exist). defaultAsk declines instead of hanging if the terminal vanishes between the gate and the question.
  • canPromptViaTty() feeds the LoginFlow gate. The stdout-TTY requirement in shouldOfferLogin is unchanged and load-bearing: an agent or CI piping our output is never prompted, even though its process may technically have a controlling terminal.
  • install.sh: keep -y for setup agent only when /dev/tty does not answer — a human running curl | sh gets the login offer; unattended runs (CI, cron, docker: no controlling terminal) stay fully non-interactive.

Gate: sh -n clean, typecheck clean, 480/480 tests (prompt plumbing is injected in tests as before; the pure gate stays covered). Ships in 0.0.44 with #128.

🤖 Generated with Claude Code


Summary by cubic

Enables browser OAuth login during curl|sh installs by reading the prompt from /dev/tty. Previously the login offer never appeared because stdin was the script pipe or -y forced non-interactive; now humans are prompted, unattended runs stay non-interactive, and -y is a hard non-interactive request.

  • Add makePromptSource, openPromptInput, and canPromptViaTty in setup.ts; LoginFlow.stdinTty now uses canPromptViaTty. The stdout‑TTY check in shouldOfferLogin is unchanged, so agents/CI piping stdout never prompt.
  • Improve robustness: makePromptSource provides single‑owner fd cleanup; defaultAsk declines instead of hanging if the terminal disappears.
  • Update installers and docs: agents.sh and agents-staging.sh stop forwarding -y; install.sh honors -y only when explicitly provided and never drops it; the CLI decides promptability via /dev/tty. README staging curl example drops -y. Tests add a regression for makePromptSource and clean up temp dirs. POSIX only; Windows unaffected.