Skip to content

refactor: 整合还原机房一条龙装机指南,标记 kimi-cli 旧文弃用#20

Merged
yang12535 merged 5 commits into
mainfrom
feat/restore-workflow
Jun 3, 2026
Merged

refactor: 整合还原机房一条龙装机指南,标记 kimi-cli 旧文弃用#20
yang12535 merged 5 commits into
mainfrom
feat/restore-workflow

Conversation

@yang12535

Copy link
Copy Markdown
Owner

变更摘要

新增

  • win-restore-workflow.md:还原机房一条龙装机指南
    • PowerShell 7 + Git + Node.js + npm + Bun + Kimi Code
    • 统一 PATH 管理函数(根治还原机房 PATH 丢失)
    • 代理下载自动 fallback(优先 v4.gh-proxy.org)
    • 全面适配 Windows PowerShell 5.1(单引号防解析、null 安全)
    • 已实测 Kimi Code 包名:@moonshot-ai/kimi-code(bun add -g 安装)

修改

  • kimi-cli-install-win.md:标记弃用(官方已迁移,仍可用),链接到新文
  • kimi-cli-install-centos9.md:改为迁移提醒,附新版安装命令

已验证

  • Windows PowerShell 5.1 环境完整跑通
  • 所有组件版本号正确输出
  • PATH 统一管理函数工作正常

- 新增 win-restore-workflow.md:PS7 + Git + Node.js + npm + Bun + Kimi Code
  - 统一 PATH 管理函数,根治还原机房 PATH 丢失
  - 代理下载自动 fallback(优先 v4.gh-proxy.org)
  - 全面适配 Windows PowerShell 5.1
  - 已实测 Kimi Code 包名 @moonshot-ai/kimi-code(bun add -g 安装)

- kimi-cli-install-win.md:标记弃用(官方已迁移,仍可用),链接到新文
- kimi-cli-install-centos9.md:改为迁移提醒,附新版安装命令

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates Windows “restore lab” setup instructions into a single end-to-end guide and updates older Kimi CLI installation posts to reflect the upstream migration to Kimi Code.

Changes:

  • Added a new Windows “one-script” workflow post covering PS7, Git, Node.js/npm, Bun, and Kimi Code, with proxy download fallback and unified PATH handling.
  • Marked the Windows Kimi CLI post as deprecated and linked it to the new consolidated guide.
  • Added a migration notice to the CentOS 9 Kimi CLI post with updated installation commands for the new Kimi Code package.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
content/posts/win-restore-workflow.md New consolidated Windows restore-room provisioning guide + one-click PowerShell script.
content/posts/kimi-cli-install-win.md Marks the old Windows Kimi CLI guide as deprecated and points readers to the new guide.
content/posts/kimi-cli-install-centos9.md Adds a migration notice and suggests updated Kimi Code install commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread content/posts/win-restore-workflow.md Outdated
Comment on lines +7 to +12
> 本文替代并整合了以下旧文,旧文已标记弃用,不再维护:
> - [~~Windows 一键安装 Kimi CLI~~](./kimi-cli-install-win.md)
> - [~~国内网络环境 Windows 安装 Bun~~](./install-bun-china.md)
> - [~~还原机房 PowerShell 7 + Windows Terminal 极速配置~~](./win-terminal-setup.md)
>
> 如果你只需要其中某个组件,仍可参考旧文,但请注意 kimi-cli 已停止维护,且本文的 **统一 PATH 管理方案** 更可靠。
Comment on lines +63 to +74
function Add-ToPath {
param([string]$Dir)
# 当前会话立即生效
if ($env:Path -notlike "*$Dir*") {
$env:Path = "$Dir;$env:Path"
}
# 用户注册表(尽量持久化)
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$Dir*") {
[Environment]::SetEnvironmentVariable("Path", "$userPath;$Dir", "User")
}
}
Comment on lines +279 to +285
foreach ($dir in $pathList) {
if (Test-Path $dir) {
Add-ToPath -Dir $dir
} else {
Write-Warn "PATH 目录不存在,跳过: $dir"
}
}
Comment on lines +144 to +146
Get-WithProxy -Url $gitUrl -OutFile $gitOut
# Git 安装包没有内置哈希校验文件,跳过 SHA256
$proc = Start-Process -FilePath $gitOut -ArgumentList "/VERYSILENT", "/NORESTART", "/NOCANCEL", "/SP-", "/CLOSEAPPLICATIONS", "/RESTARTAPPLICATIONS", "/COMPONENTS=icons,ext\reg\shellhere,assoc,assoc_sh" -Wait -PassThru

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da74324d95

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread content/posts/win-restore-workflow.md Outdated
Comment on lines +93 to +96
Invoke-WebRequest -Uri $proxyUrl -OutFile $OutFile -UseBasicParsing -TimeoutSec 120 -ErrorAction Stop
if ((Get-Item $OutFile).Length -gt 1024) {
Write-Host "Success via $p" -ForegroundColor Green
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep trying proxies after invalid downloads

When a proxy returns a 200 response containing an HTML error/captive-portal page larger than 1 KB, this treats it as a successful download and returns without trying the remaining proxies or direct URL. In this script that causes PowerShell/Node to fail at the later hash check instead of falling back, and Git has no hash check so it attempts to execute the bad download; validate the expected file/hash before returning or continue on non-installer responses.

Useful? React with 👍 / 👎.

Comment on lines +170 to +172
$proc = Start-Process -FilePath "msiexec.exe" -ArgumentList "/i", "`"$nodeOut`"", "/qn", "/norestart" -Wait -PassThru
if ($proc.ExitCode -ne 0) {
throw "Node.js 安装失败,退出码: $($proc.ExitCode)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat Node MSI reboot-required as success

In environments where the Node MSI completes but returns 3010 because a reboot is required, this branch throws and stops before npm/Bun/Kimi are configured even though the install succeeded; Microsoft documents msiexec 3010 as ERROR_SUCCESS_REBOOT_REQUIRED, and the PowerShell install above already handles that case. Accept 3010 here as well so the workflow can continue after successful quiet installs that require a later reboot.

Useful? React with 👍 / 👎.

Comment thread content/posts/win-restore-workflow.md Outdated

**正常**。还原卡环境,关机后 C 盘自动还原。

**解决**:把一键脚本保存为 `.ps1` 文件,放到 **D 盘或 U 盘**。每次开机后右键"使用 PowerShell 运行"一遍(约 30 秒,已下载的组件会自动跳过)。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Tell users to rerun the saved script elevated

The FAQ tells users to recover after a reboot by right-clicking the saved .ps1 and choosing “使用 PowerShell 运行”, but that launches a normal, non-elevated PowerShell session in the usual Windows shell flow. Since the script explicitly throws unless it is run as Administrator, following this recovery instruction will fail before installing PS7/Git/Node; direct users to open an elevated PowerShell and run the saved file, or provide an elevated shortcut/task.

Useful? React with 👍 / 👎.

1. 文首弃用声明:仅 kimi-cli 标记弃用,bun/terminal 改为普通参考链接

2. Add-ToPath:改为按 ; 拆分精确匹配,空 Path 避免前导分号

3. PATH 遍历:反向遍历保持前插优先级顺序

4. Node.js MSI:接受 3010 为成功

5. Get-WithProxy:增加文件头魔数校验(MSI/EXE/ZIP)

6. FAQ:修正为管理员 PowerShell 运行

7. Git 安装包:补充文件大小 + PE 头校验

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment on lines +424 to +435
function Add-ToPath {
param([string]$Dir)
# 当前会话立即生效
if ($env:Path -notlike "*$Dir*") {
$env:Path = "$Dir;$env:Path"
}
# 用户注册表(尽量持久化)
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$Dir*") {
[Environment]::SetEnvironmentVariable("Path", "$userPath;$Dir", "User")
}
}

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f1d6a5ef9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread content/posts/win-restore-workflow.md Outdated
$nodeExe = "$nodeDir\node.exe"
if (-not (Test-Path $nodeExe)) {
Write-Info "从清华 TUNA 镜像下载并安装 Node.js..."
$nodeVer = "v22.14.0"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use a Node version supported by Kimi Code

On a fresh machine this provisions Node.js v22.14.0, then later installs and runs @moonshot-ai/kimi-code; Kimi Code's current package metadata requires at least Node 22.19.0, and the official npm install docs now say Node 24.15.0+ is required, so the postinstall or generated kimi shim can fail or run under an unsupported runtime despite the script reporting a complete setup. Bump the Node MSI to a supported release, or switch the Kimi step to the official standalone install script that does not depend on this Node version.

Useful? React with 👍 / 👎.

1. 分步详解 Add-ToPath 示例改为精确匹配(与脚本一致)

2. Node.js v22.14.0 → v22.16.0(满足 kimi-code engines 要求)

3. 同步更新 SHA256、分步详解 URL、附录便携版版本号

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

Comment thread content/posts/win-restore-workflow.md Outdated
Comment on lines +106 to +114
# 校验文件头魔数,避免代理返回 HTML 错误页
$header = [System.IO.File]::ReadAllBytes($OutFile)[0..1]
if (($header[0] -eq 0xD0 -and $header[1] -eq 0xCF) -or # MSI (OLE)
($header[0] -eq 0x4D -and $header[1] -eq 0x5A) -or # EXE (MZ)
($header[0] -eq 0x50 -and $header[1] -eq 0x4B)) { # ZIP (PK)
Write-Host "Success via $p" -ForegroundColor Green
return
}
Write-Warn "下载内容非安装包(文件头不匹配),继续尝试其他代理..."
Comment on lines +9 to +12
> 以下旧文仍可独立参考:
> - [~~Windows 一键安装 Kimi CLI~~](./kimi-cli-install-win.md)(`kimi-cli` 官方已迁移为 `kimi-code`,仍可用但不再维护)
> - [国内网络环境 Windows 安装 Bun](./install-bun-china.md)
> - [还原机房 PowerShell 7 + Windows Terminal 极速配置](./win-terminal-setup.md)

> ⚠️ **官方已迁移**:`kimi-cli` 已品牌迁移为 `kimi-code`,包名与安装方式均有变化。本文所述的 `kimi-cli` 目前仍可正常使用,但不再更新维护。
>
> 如需安装新版 Kimi Code,请参考新文:[还原机房一条龙:PS7 + Git + Node.js + npm + Bun + Kimi Code 极速装机](./win-restore-workflow.md)
Comment on lines 7 to 16
> 📌 **官方已迁移**:`kimi-cli` 已品牌迁移为 `kimi-code`,包名与安装方式均有变化。本文所述的 `kimi-cli` 目前仍可正常使用,但后续建议自行安装新版:
> ```bash
> npm install -g @moonshot-ai/kimi-code
> # 或
> bun add -g @moonshot-ai/kimi-code
> ```

# CentOS Stream 9 / RHEL 9 无订阅版安装 Kimi CLI

> 对应 Windows 版:[Windows 下安装 Kimi CLI,PowerShell 一键指令](https://bash.yang125.fun/posts/kimi-cli-install-win/)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 74e2fd6762

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (-not ($gitHeader[0] -eq 0x4D -and $gitHeader[1] -eq 0x5A)) {
throw "Git 安装包文件头异常(非 PE 可执行文件),可能下载了损坏/被篡改的文件"
}
$proc = Start-Process -FilePath $gitOut -ArgumentList "/VERYSILENT", "/NORESTART", "/NOCANCEL", "/SP-", "/CLOSEAPPLICATIONS", "/RESTARTAPPLICATIONS", "/COMPONENTS=icons,ext\reg\shellhere,assoc,assoc_sh" -Wait -PassThru

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Verify Git installer before running it elevated

Fresh evidence in this revision is the new size/header-only validation plus the comment claiming no official SHA; for Git for Windows 2.54.0.windows.1 the release metadata publishes SHA-256 2b96e7854f0520f0f6b709c21041d9801b1be44d5e1a0d9fa621b2fbc40f1983 for Git-2.54.0-64-bit.exe. In the documented proxy/campus-network path, any compromised proxy or captive portal that returns a large PE file still passes the current checks and is then executed as Administrator, so this should be hash-checked before Start-Process just like the PS/Node installers.

Useful? React with 👍 / 👎.


# 删除 npm/bun 的 ps1 wrapper,防止 PS5.1 Restricted 策略拦截
$wrappers = @(
"$env:APPDATA\npm\npm.ps1"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove the Node MSI npm.ps1 wrappers too

In the documented Windows PowerShell 5.1 Restricted environment, the Node MSI also leaves npm.ps1/npx.ps1 under C:\Program Files\nodejs, and the later PATH ordering puts $nodeDir before %APPDATA%\npm. This cleanup only removes AppData wrappers, so users typing npm or npx after the script can still hit the blocked Node-install-directory .ps1 shim instead of the .cmd; include $nodeDir\npm.ps1 and $nodeDir\npx.ps1 in the cleanup or put a safe shim earlier.

Useful? React with 👍 / 👎.

1. Get-WithProxy 空文件保护:ReadAllBytes 前先检查长度

2. Git SHA256 校验:补上官方值 2b96e7854...,去掉大小/PE头兜底

3. npm.ps1 清理:加入 (MSI 安装目录)路径

4. 站内链接统一格式:./xxx.md → /posts/xxx/(3个文件)

5. centos9 对应 Windows 版改为指向新文

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

Comment thread content/posts/win-restore-workflow.md Outdated
Comment on lines +107 to +110
$bytes = [System.IO.File]::ReadAllBytes($OutFile)
if ($bytes.Length -lt 2) {
Write-Warn "下载文件为空(可能代理返回了空响应),继续尝试..."
continue
Comment on lines +217 to +218
& $npmCmd.Source config set registry https://registry.npmmirror.com/ 2>$null
Write-Ok "npm registry 已设置为 https://registry.npmmirror.com/"
Comment thread content/posts/win-restore-workflow.md Outdated
Comment on lines +10 to +12
> - [~~Windows 一键安装 Kimi CLI~~](/posts/kimi-cli-install-win/)(`kimi-cli` 官方已迁移为 `kimi-code`,仍可用但不再维护)
> - [国内网络环境 Windows 安装 Bun](/posts/install-bun-china/)
> - [还原机房 PowerShell 7 + Windows Terminal 极速配置](/posts/win-terminal-setup/)
Comment thread content/posts/kimi-cli-install-win.md Outdated

> ⚠️ **官方已迁移**:`kimi-cli` 已品牌迁移为 `kimi-code`,包名与安装方式均有变化。本文所述的 `kimi-cli` 目前仍可正常使用,但不再更新维护。
>
> 如需安装新版 Kimi Code,请参考新文:[还原机房一条龙:PS7 + Git + Node.js + npm + Bun + Kimi Code 极速装机](/posts/win-restore-workflow/)
# CentOS Stream 9 / RHEL 9 无订阅版安装 Kimi CLI

> 对应 Windows 版:[Windows 下安装 Kimi CLI,PowerShell 一键指令](https://bash.yang125.fun/posts/kimi-cli-install-win/)
> 对应 Windows 版:[还原机房一条龙:PS7 + Git + Node.js + npm + Bun + Kimi Code 极速装机](/posts/win-restore-workflow/)
Comment thread content/posts/win-restore-workflow.md Outdated
Comment on lines +67 to +70
# 标准化路径(去掉尾部反斜杠,统一大小写)用于精确比较
$normDir = $Dir.TrimEnd('\').ToLower()
# 当前会话:按 ; 拆分后精确匹配
$sessionPaths = $env:Path -split ';' | ForEach-Object { $_.TrimEnd('\').ToLower() }
Comment on lines +75 to +80
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath) {
$userPaths = $userPath -split ';' | ForEach-Object { $_.TrimEnd('\').ToLower() }
if ($normDir -notin $userPaths) {
[Environment]::SetEnvironmentVariable("Path", "$userPath;$Dir", "User")
}
1. Get-WithProxy: ReadAllBytes → FileStream 只读2字节,避免大文件内存占用

2. npm registry: 0 检查,失败时 throw

3. 站内链接: /posts/xxx/ → ./xxx.md(仓库约定,构建时自动改写)

4. Add-ToPath: Trim() + ToLowerInvariant() + Where-Object过滤空段

5. Add-ToPath: 用户注册表也前插(;),保持与会话优先级一致

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@yang12535 yang12535 merged commit 619684e into main Jun 3, 2026
4 checks passed
@yang12535 yang12535 deleted the feat/restore-workflow branch June 3, 2026 08:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 60206bf6b2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# ==================== 3. Node.js(清华 TUNA 镜像)====================
$nodeDir = "C:\Program Files\nodejs"
$nodeExe = "$nodeDir\node.exe"
if (-not (Test-Path $nodeExe)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Upgrade Node when an older install exists

When a machine already has any Node.js installed (for example v18/v20 in a lab image, or after the user follows Q5 and only changes $nodeVer), this check skips the MSI solely because node.exe exists. The rest of the workflow then runs npm/Kimi against the preexisting runtime instead of the requested version, so Kimi can fail under an unsupported Node and the documented “change the version and rerun” upgrade path does nothing; compare the installed version to $nodeVer or reinstall on mismatch.

Useful? React with 👍 / 👎.

Comment on lines +9 to +11
> npm install -g @moonshot-ai/kimi-code
> # 或
> bun add -g @moonshot-ai/kimi-code

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add the Node/Bun prerequisite before Kimi Code

On this CentOS/RHEL guide the documented one-liner still installs only Python, pip, uv, and kimi-cli, so readers following the new migration note on a fresh system will hit npm: command not found (or no bun) before Kimi Code is installed. Either include the required Node/Bun installation steps here or point to a prerequisite first so the replacement command is actually runnable in the environment this page sets up.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants