Skip to content

fix(cli): keep first-run commands from hanging or faking success without a terminal - #339

Open
erikengervall wants to merge 10 commits into
mainfrom
capy/first-run-friction
Open

erikengervall wants to merge 10 commits into
mainfrom
capy/first-run-friction

Conversation

@erikengervall

@erikengervall erikengervall commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Three first-run fixes for people and agents running the CLI without a terminal. This builds on #338, which makes the login prompt fail when stdin ends; until #338 merges, this diff also shows its two files.

Bare firecrawl without a terminal

With no API key, firecrawl with no arguments opened the onboarding auth picker even when stdin was not a terminal. The picker could not read input, printed Error: User force closed the prompt with 0 null, and the process exited 0. Agents that probe firecrawl saw a false success and no usage. Without a terminal, it now prints the banner and help, as it already does for an authenticated user. Interactive terminals keep the picker.

One shared prompt

setup.ts and launch.ts each had their own copy of the readline prompt that the login flow used, with the same problem: when the input closed (Ctrl+D) the promise never settled and the process exited 0 mid-question. The prompt from #338 moves to src/utils/prompt.ts and all three callers use it. A closed input now rejects with a caller-specific message (setup defaults points at --agent/--yes, launch at passing the app name), and Ctrl+C exits 130.

Skills before login in init -y/--all

The documented agent setup line, npx -y firecrawl-cli@latest init --all --browser, ran authentication first. Browser login waits up to five minutes for the user, so an agent whose shell command times out sooner never reached the skills step. Non-interactive init now installs the CLI and the skills first and authenticates last, and the step numbers follow that order. The interactive wizard is unchanged.

Before and after, with an empty HOME and no FIRECRAWL_API_KEY:

$ firecrawl </dev/null; echo $?
# before: auth picker, "User force closed the prompt", 0
# after:  banner and help, 0

$ firecrawl init --all --skip-install </dev/null
# before: [1/2] Authenticating... (blocks or fails first)
# after:  [1/2] Installing firecrawl skills... then [2/2] Authenticating with Firecrawl...

Bumps the version to 1.26.16, on top of the 1.26.15 that #336 shipped.

Testing

  • New test in src/__tests__/commands/init.test.ts: in non-interactive init, the skills install runs before login, and a failed login still exits 1. It fails without the reorder.
  • src/__tests__/utils/auth.test.ts covers the shared prompt through the login flow.
  • pnpm test, pnpm type-check, pnpm format:check, pnpm build. I also ran the two commands above by hand on the built CLI.

Open in Capy


Summary by cubic

Fixes first-run CLI commands hanging or falsely succeeding when run without a terminal.

  • Bare firecrawl with no API key skips the interactive auth picker when stdin isn't a TTY and prints the banner and help instead.
  • Login prompts now share one prompt utility that rejects when stdin ends, so commands exit non-zero with messages pointing at the flags that skip the prompt (Ctrl+C exits 130). One shared piped-stdin reader lets a single pipe answer successive prompts.
  • Non-interactive init now installs the CLI and skills before authenticating, so an auth timeout can't prevent the skills step.

Written for commit a885b63. Summary will update on new commits.

View guided diff Turn on auto-fix

Found by Wildfire, Firecrawl's integration testing: these first-run hangs surfaced while reproducing the failing cli-setup-mcp check.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files

Shadow auto-approve: would not auto-approve because issues were found.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/__tests__/commands/init.test.ts Outdated
Comment thread src/utils/prompt.ts
Comment thread src/index.ts
Comment thread src/__tests__/utils/auth.test.ts Outdated
@capy-ai

capy-ai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

@capy-ai[bot] I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Shadow auto-approve: would auto-approve. Focused first-run CLI fix: bare firecrawl shows help without a TTY, the shared login prompt rejects on closed stdin, and non-interactive init installs skills before auth. Tests pin the reorder and prompt rejections.

View guided diff | Turn on auto-fix | Re-trigger cubic

@capy-ai

capy-ai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

@capy-ai[bot] I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 8 files

Confidence score: 4/5

  • In src/utils/auth.ts, the stdin-closed message recommends firecrawl login --browser, but that flow ignores the custom API URL. Use a custom-URL-specific message that recommends --api-key or FIRECRAWL_API_KEY instead.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/utils/auth.ts">

<violation number="1" location="src/utils/auth.ts:658">
P3: The custom-API manual flow now recommends `firecrawl login --browser` when stdin closes, but that browser path ignores the custom API URL. Use a custom-URL-specific message that recommends `--api-key`/`FIRECRAWL_API_KEY` or rerunning without `--method manual` to save the URL without a key.</violation>
</file>

Shadow auto-approve: would not auto-approve because issues were found.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread package.json
Comment thread src/commands/setup.ts Outdated
Comment thread src/utils/auth.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Shadow auto-approve: would require human review. Non-TTY first-run fixes (shared prompt, help fallback, init reorder) plus version bump, but a dismissed finding about the custom-API login error message is still unaddressed in the diff.

View guided diff | Turn on auto-fix | Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant