@wendongfly/myhi 1.3.128 → 1.3.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/installer/install-myhi.ps1 +28 -4
- package/package.json +1 -1
|
@@ -72,15 +72,39 @@ try {
|
|
|
72
72
|
|
|
73
73
|
# ---------- 2b) Claude Code CLI(myhi 的 AI 引擎,@anthropic-ai/claude-code)----------
|
|
74
74
|
if (-not $SkipClaude) {
|
|
75
|
-
Info "安装/更新 Claude CLI(npm i -g @anthropic-ai/claude-code@latest,稍候)..."
|
|
76
75
|
$eaC = $ErrorActionPreference; $ErrorActionPreference = 'Continue'
|
|
76
|
+
# 停掉可能在跑的 claude.exe(升级时它锁着 ~250MB 原生二进制会 EBUSY),并清 .claude-code-<hash>
|
|
77
|
+
# 残留(防 npm 原子替换 ENOTEMPTY)——与前面停 myhi/清 .myhi-* 同款。
|
|
78
|
+
taskkill /IM claude.exe /F /T 2>$null | Out-Null
|
|
79
|
+
$npmRc = (npm.cmd root -g | Select-Object -Last 1).ToString().Trim()
|
|
80
|
+
Get-ChildItem (Join-Path $npmRc '@anthropic-ai') -Filter '.claude-code-*' -Directory -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
|
|
81
|
+
Info "安装/更新 Claude CLI(npm i -g @anthropic-ai/claude-code@latest,稍候)..."
|
|
77
82
|
npm.cmd i -g '@anthropic-ai/claude-code@latest' --allow-scripts=@anthropic-ai/claude-code
|
|
78
83
|
if ($LASTEXITCODE -ne 0) { npm.cmd i -g '@anthropic-ai/claude-code@latest' }
|
|
79
|
-
|
|
84
|
+
|
|
85
|
+
# 校验 claude 真能跑:claude-code 2.x 是平台原生二进制,其平台包(optionalDependencies,
|
|
86
|
+
# 如 @anthropic-ai/claude-code-win32-x64)可能在安装时【静默失败】没装上 → bin/claude 只剩
|
|
87
|
+
# 500B 报错占位 → 用时才发现坏。故装完立即验证,坏了【自动补装对应平台包】自愈。
|
|
88
|
+
function Test-ClaudeVer {
|
|
89
|
+
try { $v = (& claude --version 2>&1 | Select-Object -First 1); if ("$v" -match '\d+\.\d+\.\d+') { return "$v" } } catch {}
|
|
90
|
+
return $null
|
|
91
|
+
}
|
|
92
|
+
$cv = Test-ClaudeVer
|
|
93
|
+
if (-not $cv) {
|
|
94
|
+
Warn "Claude 原生二进制缺失(平台包静默失败),补装平台包..."
|
|
95
|
+
$npmRootC = (npm.cmd root -g | Select-Object -Last 1).ToString().Trim()
|
|
96
|
+
$ccPkg = Join-Path $npmRootC '@anthropic-ai\claude-code\package.json'
|
|
97
|
+
$ccVer = if (Test-Path $ccPkg) { (Get-Content $ccPkg -Raw | ConvertFrom-Json).version } else { 'latest' }
|
|
98
|
+
$arch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'x64' }
|
|
99
|
+
# 清 .claude-code-<hash> 残留,防补装时 ENOTEMPTY
|
|
100
|
+
Get-ChildItem (Join-Path $npmRootC '@anthropic-ai') -Filter '.claude-code-*' -Directory -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
|
|
101
|
+
npm.cmd i -g "@anthropic-ai/claude-code-win32-$arch@$ccVer"
|
|
102
|
+
$cv = Test-ClaudeVer
|
|
103
|
+
}
|
|
80
104
|
$ErrorActionPreference = $eaC
|
|
81
105
|
# 不因 claude 装失败而中断整体部署(可事后手动补)
|
|
82
|
-
if ($
|
|
83
|
-
else { Warn "Claude CLI
|
|
106
|
+
if ($cv) { Ok "Claude CLI 可用:$cv" }
|
|
107
|
+
else { Warn "Claude CLI 仍不可用,请手动排查:claude --version(或补装 @anthropic-ai/claude-code-win32-x64)" }
|
|
84
108
|
}
|
|
85
109
|
$pkgDir = Join-Path $npmRoot '@wendongfly\myhi'
|
|
86
110
|
$daemon = Join-Path $pkgDir 'bin\daemon.js'
|
package/package.json
CHANGED