You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(init): skip API key prompt when credentials already exist
Add --skip-if-configured to testsprite setup (and the deprecated init
alias). When the active profile already has a saved API key and no
explicit key source (--api-key or --from-env) is given, the interactive
prompt is skipped and the existing key is reused.
Motivation: re-running setup to refresh the agent skill -- a common
pattern in dotfiles, onboarding scripts, and CI bootstraps -- currently
always re-prompts for the key, even when credentials were already
configured. The flag makes setup idempotent for the credential step.
Behaviour:
- runConfigure short-circuits with status:already_configured when
skipIfConfigured is true and existingProfile.apiKey is present.
- runInit relaxes the non-interactive guard and the --output json guard
when skipWillApply is true, so the flag works in CI (isTTY=false)
and JSON mode without requiring a separate --api-key.
- --api-key always overwrites, regardless of --skip-if-configured.
- --from-env always overwrites, regardless of --skip-if-configured.
- --dry-run is unaffected (no network, no writes; preview only).
New tests (8 cases across auth.test.ts and init.test.ts):
- skips prompt and returns early when credentials exist (text + JSON)
- proceeds to prompt when no credentials exist
- allows isTTY=false CI runs when skip applies
- --api-key overwrites despite skip flag
- --from-env overwrites despite skip flag
Closes#206
0 commit comments