fix: preserve saved environment and login during upgrade

FE
2mo ago
+0-0

A temporary INSTA_ENV=prod still reaches the binary installer during insta upgrade. With staging saved on disk, the installer runs env use prod, overwrites the saved API URL, and drops the session.

Mark the binary installer invocation as an upgrade and skip its environment-persistence step in that mode. Keep the inherited environment available for release-channel selection. Both the pinned install and unpinned fallback preserve the saved config; ordinary explicit installer environment selection retains its existing behavior.

Closes #145.

Validation: reproduced the staging-to-prod switch and loss of access/refresh/user fields before the fix. The regression runs the checked-in installer's environment step with the real CLI in an isolated home, checks the saved config byte-for-byte for absent/prod/staging overrides and retry, and verifies ordinary installation can still switch environments. Typecheck, shell syntax, whitespace checks and all 1,999 tests pass. Independent review and targeted mutation checks pass; Linux/Windows CI is required before merge. No separate lint/format scripts are configured.

First push: 3 files, +59/-2. No public command or flag changes. The binary-caller change requires a CLI release; no release is included in this PR.


Summary by cubic

Fixes insta upgrade overwriting the saved environment and dropping the session. During a binary upgrade, the installer previously ran env use prod from a temporary INSTA_ENV var, replacing the saved API URL and clearing login fields.

Marks the binary installer invocation as an upgrade (INSTA_UPGRADE=1) so install.sh skips its environment-persistence step. The inherited environment is still available for release-channel selection, and both the pinned install and unpinned fallback preserve the saved config. Ordinary explicit installer environment selection behaves as before.

Adds a regression test that reproduces the staging-to-prod switch and verifies the saved config stays byte-for-byte intact during upgrades while still allowing explicit environment changes.

Closes #145. No public command or flag changes; the binary-caller change requires a CLI release, which is not included here.