Skip to content

feat: [PR-1797] add sf migrate command and Rust CLI migration banner#266

Merged
sigmachirality merged 10 commits into
mainfrom
indent-2026-05-21-migrate-banner
May 27, 2026
Merged

feat: [PR-1797] add sf migrate command and Rust CLI migration banner#266
sigmachirality merged 10 commits into
mainfrom
indent-2026-05-21-migrate-banner

Conversation

@sigmachirality
Copy link
Copy Markdown
Member

@sigmachirality sigmachirality commented May 21, 2026

Summary

When no upgrade banner is shown on startup, the legacy CLI now nudges users to migrate to the new Rust-based sf (blueprint/preview docs). Adds a sf migrate subcommand that runs the new install script from https://cli.sfcompute.com.

Motivation

sf-cli (the Rust replacement living in sfcompute/sfcompute) is the path forward. We want every invocation of the legacy CLI to surface that path — but only when we're not already asking the user to upgrade the current binary, to avoid double-stacking banners.

The new install script at cli.sfcompute.com already moves the existing sf binary to sf-old, so users keep access to the legacy CLI during the transition. The banner and sf migrate output both call that out.

Changes

Screenshot 2026-05-26 at 5 01 12 PM

Show a cyan migration banner when the upgrade banner isn't being shown
to nudge users toward the new Rust-based sf CLI, and add a `sf migrate`
command that runs the new install script.

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
@indent
Copy link
Copy Markdown
Contributor

indent Bot commented May 21, 2026

PR Summary

Introduces a nudge toward a new Rust-based sf CLI by adding a sf migrate command (which downloads https://cli.sfcompute.com and pipes it into bash) and a recurring cyan banner shown when no upgrade banner is printed. checkVersion() is refactored to return a boolean so the caller can decide whether to print the migrate banner. The follow-up commit hardens both surfaces based on review feedback.

  • Refactored checkVersion() to Promise<boolean> (returns true when an upgrade banner or auto-upgrade ran) and updated every early-return path accordingly.
  • Added src/lib/migrate.ts with showMigrateBanner, handleMigrate, and registerMigrate; runInstallScript now uses a Promise.race over close/error with a try/catch around stdin.write, so missing/non-executable bash surfaces as a clean failure instead of an unhandled crash.
  • Gated the migrate banner in src/index.ts on process.argv[2] (tighter scoping), excluded both migrate and upgrade subcommands, and added an SF_CLI_DISABLE_MIGRATE_BANNER opt-out which is also surfaced inside the banner text.
  • Registered the new migrate command on the Commander program.

Issues

All clear! No issues remaining. 🎉

4 issues already resolved
  • Migrate banner prints during sf upgrade: checkVersion returns false early when args[0] === "upgrade", and the gate in index.ts only excludes migrate, so users running sf upgrade see the cyan "switch to the Rust CLI" banner above their upgrade output — the opposite of what the inline comment promises. (fixed by commit 8f91f5f)
  • spawn("bash", [], ...) in handleMigrate has no error listener — if bash is missing or non-executable (ENOENT/EACCES) the child emits an unhandled error event and crashes the CLI instead of returning a clean failure from runInstallScript. (fixed by commit 8f91f5f)
  • process.argv.slice(2).includes("migrate") matches the string migrate anywhere in argv (e.g. as a flag value or positional arg of another command), and diverges from the args[0] === "upgrade" pattern used a few lines away in checkVersion.ts. Use process.argv[2] === "migrate" for consistency and tighter scoping. (fixed by commit 8f91f5f)
  • No opt-out for the migrate banner: it prints on essentially every sf invocation forever, with no env var (compare SF_CLI_DISABLE_AUTO_UPGRADE in checkVersion.ts) and no cooldown like the 1h version cache. Power users running sf in scripts/shells will get spammed with no way to silence it. (fixed by commit 8f91f5f)

CI Checks

All CI checks passed on commit 63fd7bd.

@sigmachirality sigmachirality added the indent label May 21, 2026 — with indent
@capy-ai
Copy link
Copy Markdown

capy-ai Bot commented May 21, 2026

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

Comment thread src/index.ts Outdated
Comment thread src/lib/migrate.ts Outdated
sigmachirality and others added 3 commits May 21, 2026 22:13
- Skip migrate banner when running `sf upgrade` (was showing above
  upgrade output because checkVersion returns false early for it)
- Add SF_CLI_DISABLE_MIGRATE_BANNER opt-out, surfaced in the banner
- Use process.argv[2] === "migrate" for tighter scoping, matching
  the existing pattern in checkVersion.ts
- Handle spawn errors in handleMigrate so ENOENT/EACCES on bash
  surface as a clean failure instead of crashing the CLI

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
Lead with the Rust rewrite and new commands, then surface the
reselling story (the most important reason to migrate, per the
April 7 changelog) before the action and fallback text.

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
Per DTao.

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
@sigmachirality sigmachirality requested review from Sladuca and joshi4 May 22, 2026 03:19
Copy link
Copy Markdown
Contributor

@joshi4 joshi4 left a comment

Choose a reason for hiding this comment

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

LGTM.

you can consider the alternative banner copy I suggested or ship as is, I leave that up to you.

Comment thread src/lib/migrate.ts Outdated
sigmachirality and others added 3 commits May 26, 2026 16:57
The legacy installer hardcodes ~/.local/bin/sf, which clobbers the new
Rust sf when running as sf-old and silently drops a duplicate when sf
lives elsewhere (e.g. /usr/local/bin). Honor SF_CLI_TARGET_DIR and
SF_CLI_BINARY_NAME so upgrade.ts can point the installer at
process.execPath. Skip the PATH onboarding nudge for in-place upgrades
since the user is already invoking the binary.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The legacy auto-upgrade and 'sf migrate' both target ~/.local/bin/sf,
so running them back-to-back risks clobbering the freshly installed
Rust binary. Set SF_CLI_DISABLE_AUTO_UPGRADE=1 before dispatching
'sf migrate' so the upgrade path is skipped entirely.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Banner now leads with the Rust rewrite and frames the orderbook value
prop as recouping up to 20% of spend. Migration guide URL switches
from the docs preview path to sfcompute.com/migrate. Inlines the
install-script helpers back into the command action.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@sigmachirality sigmachirality changed the title feat: add sf migrate command and Rust CLI migration banner feat: [PR-1797] add sf migrate command and Rust CLI migration banner May 27, 2026
sigmachirality and others added 3 commits May 26, 2026 17:05
Both nudge banners now use yellow so they read as the same class of
prompt rather than two competing visual treatments.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Running 'sf migrate' under IS_DEVELOPMENT_CLI_ENV now prints a short
'[dev] Skipping install script execution' notice in place of the bash
spawn, while still showing the spinner, install heading, and success
boxen. This lets us iterate on the migrate UI copy without touching
the local sf binary.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Matches the 'Docs:' label already used in the startup migrate banner.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@sigmachirality sigmachirality merged commit 06230a2 into main May 27, 2026
2 checks passed
@sigmachirality sigmachirality deleted the indent-2026-05-21-migrate-banner branch May 27, 2026 00:07
sigmachirality added a commit that referenced this pull request May 27, 2026
…ion banner (#266)" (#267)

Co-authored-by: Indent <noreply@indent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants