Repository navigation
feat(shell): deprecation-aware update flow with one-key migration to Kimi Code - #2630
Conversation
There was a problem hiding this comment.
Devin Review found 5 potential issues.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| KIMI_CODE_BIN_DIR.mkdir(parents=True, exist_ok=True) | ||
| dest_path = KIMI_CODE_BIN_DIR / "kimi" | ||
| shutil.copy2(binary_path, dest_path) | ||
| os.chmod( | ||
| dest_path, | ||
| os.stat(dest_path).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH, | ||
| ) | ||
| except Exception: | ||
| logger.exception("Failed to install:") | ||
| console.print("[red]Failed to install.[/red]") | ||
| return False |
There was a problem hiding this comment.
🟡 Failed installs suppress future migration
When copying or chmod fails after KIMI_CODE_BIN_DIR.mkdir, the partial directory remains. kimi_code_installed then suppresses future prompts despite no usable installation.
Prompt for agents
A failed direct installation can leave ~/.kimi-code behind because _download_and_install creates that directory before copying and chmodding the binary. migration_nudge.kimi_code_installed currently considers any ~/.kimi-code directory a completed installation, so subsequent startup gates and notices disappear. Make installation detection require a usable Kimi Code installation, or clean up only directories/artifacts created by the failed attempt without deleting pre-existing user data. Add a regression test covering copy or chmod failure followed by should_show_migration.
Was this helpful? React with 👍 or 👎 to provide feedback.
| if not _link_path_shim(KIMI_CODE_BIN_DIR / "kimi"): | ||
| console.print( | ||
| f"[yellow]Installed to {KIMI_CODE_BIN_DIR}/kimi but could not update PATH.[/yellow]" | ||
| ) | ||
| return True |
There was a problem hiding this comment.
🟡 Broken PATH setup reports success
When _link_path_shim fails, _download_and_install still returns success. The gate tells users to run kimi, which can resolve to the legacy CLI or nothing.
Prompt for agents
The direct migration reports success even when creating ~/.local/bin/kimi fails. The caller then exits successfully and instructs the user to run kimi, although PATH can still select the legacy executable or no executable. Treat PATH setup as an incomplete migration: either invoke the install-script fallback, verify that kimi resolves to the new binary before returning success, or present an actionable non-success result that does not claim the command is ready. Add coverage for shim failure with and without an existing legacy kimi command.
Was this helpful? React with 👍 or 👎 to provide feedback.
| if sys.platform == "win32": | ||
| cmd = [ | ||
| "powershell", | ||
| "-NoProfile", | ||
| "-ExecutionPolicy", | ||
| "Bypass", | ||
| "-Command", | ||
| tips.install_ps1, | ||
| ] | ||
| else: | ||
| cmd = ["bash", "-c", tips.install_sh] | ||
| console.print("[grey50]Running install script...[/grey50]") | ||
| try: | ||
| result = subprocess.run(cmd) |
There was a problem hiding this comment.
| if download.sha256 and not _sha256_matches(tar_path, download.sha256): | ||
| logger.error("Checksum mismatch for {url}", url=download.url) | ||
| console.print("[red]Downloaded file checksum mismatch.[/red]") | ||
| return False |
| with tarfile.open(tar_path, "r:gz") as tar: | ||
| tar.extractall(tmpdir) |
There was a problem hiding this comment.
64eb2a3 to
02e7ff9
Compare
02e7ff9 to
0f519ee
Compare
Related Issue
Part of the kimi-cli → Kimi Code migration effort (no tracking issue on this repo).
Description
When the CDN publishes a deprecation/migration notice (
https://cdn.kimi.com/kimi-code-tips/kimi_cli/migration.json), the CLI now treats the Python release as deprecated and drives migration to the new Kimi Code:check_update_gate, now async): a pending newer Python release still takes precedence and shows the existing update gate; otherwise, when the notice is enabled and applies (min_cli_version, new Kimi Code not yet installed), a red "no longer maintained" panel blocks startup and offers one-key migration. The panel reappears on every launch — there is no skip.platformsmap keyed by<arch>-<os>target, optional sha256, tar.gz extracted to~/.kimi-code/bin/kimi+ PATH shim) with automatic fallback to the official install script (install.sh/install.ps1, overridable from the notice).enabledkill switch, localizedmessage(zh/en), and arbitrarylinks; a failed fetch keeps the previous cache.tests/ui/test_update_gate.py).The companion CDN payload lives in the kimi-cli-cdn-sync repo. Changelog entry intentionally omitted for now.
Checklist
make gen-changelogto update the changelog.make gen-docsto update the user documentation.