feat(cli): run the init wizard when e2e explore finds no config

Merged
KA
20d ago
+231-18

e2e explore in a project without a config used to stop with CONFIG_NOT_FOUND. In a terminal it now runs the e2e init wizard first, then explores if the new project can run an exploration straight away.

flowchart TD
  A[e2e explore] --> B{config found, or --config given?}
  B -- yes --> X[explore]
  B -- no --> C{stdin and stdout a TTY?}
  C -- no --> E[CONFIG_NOT_FOUND, nothing written]
  C -- yes --> D[init wizard]
  D --> F{anything left to do by hand?}
  F -- no --> G["Starting e2e explore ... on http://localhost:3000"] --> X
  F -- yes --> H["Next: steps left, then e2e explore as typed"]
  • init takes a continueWith command as words (packages/e2e/src/cli/init.ts). The closing line ends with that command, shell-quoted, instead of e2e run. ready is true only if nothing is left: dependencies installed, a model whose key is set or whose sign-in is done, and an engine target that isn't the mobile placeholder (continueSteps).
  • Gateway presets now list the environment variables they authenticate with (keys in init/gateways.ts), so a missing AI_GATEWAY_API_KEY or OPENROUTER_API_KEY shows up as a step left instead of a failed model call.
  • initBeforeExplore in packages/e2e/src/cli/index.ts runs before the explore action. It skips the wizard when there is no terminal, when --config is given, and when discovery finds a config or refuses one (CONFIG_AMBIGUOUS falls through to explore's own error). It records the usual e2e_init_completed event; docs/telemetry.mdx now says so.
  • Docs: docs/explore.mdx, the --config row in docs/reference/cli.mdx, skills/e2e/references/explore.md.

Fresh-context review findings, all fixed: gateway None claimed to be ready, as did a missing API key and the Settings placeholder on mobile. The ready path also hid the URL it explores, and the Next line dropped the goal and flags. The telemetry docs were missing the new init event.

Verified

Ran it locally: yes. I ran the built CLI in a scratch git repo under a pseudo-terminal, using expect to answer the wizard with its defaults (web, Vercel AI Gateway, every skill and MCP location).

e2e explore "Check the cart's totals" --max-steps 2, no key set, install declined:

└  Next: npm install, then set AI_GATEWAY_API_KEY, then APP_URL=http://localhost:3000 npm exec -- e2e explore 'Check the cart'\''s totals' --max-steps 2
EXIT 0

Same command, AI_GATEWAY_API_KEY=fake-key, install accepted: npm installed the published packages and the exploration started in the same process. It ran with the typed goal and 2 steps, then failed at the gateway because the key is fake:

└  Starting e2e explore 'Check the cart'\''s totals' --max-steps 2 on http://localhost:3000 (set APP_URL for another URL)
 ❯  web  Exploring  Check the cart's totals
MODEL_PROVIDER_FAILED: model provider failed: Unauthenticated request to AI Gateway.
      Steps  0 done of 2
EXIT 3

No terminal (e2e explore < /dev/null | cat): CONFIG_NOT_FOUND: no e2e.config.ts ... run e2e init to create one, or pass --config <path>, exit 2, and the directory still held only .git.