{
  "skill": "uking-install-windows",
  "version": 30,
  "updated": "2026-07-10",
  "notes": "v30: 修 Hermes「假失败」——v29 那个删 shim 的 `python -c \"...\"` 步骤在 Windows 下必崩(干净机真机复现)：run 步骤经 cmd /C 执行，Rust `Command::args([/C, cmdline])` 把整条命令用双引号包起来、内部 `\"` 转义成 `\\\"`，cmd.exe 剥外层引号但不认反斜杠转义，python 的 MSVCRT 又把 `\\\"` 当字面量引号 → python -c 收到以 `\"` 开头的代码 → `SyntaxError: unterminated string literal` → 步骤退出码 1 → 整个 Hermes 安装被判失败并自动上报 bug——**可 Hermes 其实装好了、能跑**(hermes v0.18.2, `from utils import fast_safe_load` OK)。近3天 issue #123-126 全是这个假失败。修法：把两处 python -c 换成同 skill line 211 已验证可跑的 PowerShell 写法(纯 PowerShell 删 shim 包，`exit 0` 永不误判失败；本就是 install-windows 专用 skill，用 PowerShell 无跨平台问题)。凡 `python -c \"带引号\"` 走 run 步骤都会中此坑，以后一律用 PowerShell 或写临时 .py 文件。v29: 修 Hermes 一启动就崩 `ImportError: cannot import name 'fast_safe_load' from 'utils'`（真机复现坐实）。真因：U-King 早期版本会写一个 `utils/` shim **包**，而 Python 里同名的**包**会盖过 hermes-agent 自带的 `utils.py` **模块**——后者才是完整的(含 fast_safe_load/atomic_replace/atomic_yaml_write/is_truthy_value 全套，hermes 0.16~0.18 都随 wheel 发货)；于是 hermes 一 import 就崩。修法=hermes steps+repair 各加一步 `python -c` 删掉这个挡路的 shim 包(只在 hermes 真身 utils.py 同时存在时删，防误删；`python -c` 跨平台，不像 PowerShell 步骤在 Mac 上 abort)，让 hermes 自己的 utils.py 生效。客户端 Rust 侧 ensure_hermes_utils_shim 也要改成 heal(删shim而非建shim)，随下次发版(installer.rs 有并行终端未提交改动，暂只走 skill 热更)。v28: 修 Codex CLI 慢网/Mac 装不上的真因（真机复现）——①codex 现在(0.143.0)主包只 9.7KB，真身在平台子包，Win 要下 145MB/Mac 119-128MB 大二进制，慢/抖动客户宽带下不全→npm 报 -4058(ENOENT)/EEXIST(issue #29/#1)，而 npm 不断点续传一断从头再来。②二进制兜底现在 OSS 国内镜像**主源**(原来 GitHub 排第一，国内常不通)+`-C -` 断点续传+`--retry`+超时放宽到 30 分钟；③GitHub 兜底 URL 从钉死的旧版 rust-v0.140.0 刷到 0.143.0；④**关键**：兜底装好 ~/bin/codex.exe 后，清掉 portable-node/APPDATA\\npm 里半装坏掉的 codex/codex.cmd/codex.ps1 启动器——它排在 ~/bin 之前(search_paths 顺序)，会一直挡住兜底的好二进制让 verify 永败(这就是 v24 修了 backspace bug 后 Windows 兜底仍不生效的隐藏原因)，并把 ~/bin 显式加进用户 PATH；⑤OSS 新增 codex-mac-arm64.tar.gz / codex-mac-x64.tar.gz(原来 404)。Mac 的跨平台兜底走客户端 Rust ensure_codex_binary(skill 的 run 步骤是 Windows 命令，Mac 上 sh 跑不了，只能在 exe 里做)，随新版发布。v27: Hermes repair 第一步「清理损坏的便携 Python 目录」加重试——原来只 Remove-Item 一次且 -ErrorAction SilentlyContinue 静默吞错，刚解压/正在被杀软实时扫描的 vcruntime140.dll 等文件删不掉时不报错也不重试，导致后面重新解压直接撞 tar「Can't unlink already-existing object: Permission denied」（issue #107/#113 实锤，同一台机器两次不同版本都中招）。现在删除失败会等 2s/3s 再各重试一次，通常锁一两秒内就释放，对齐已修复的自升级 rename 重试同款思路。v26: 便携 Node/Python 下载加完整性校验——node/python 各平台包新增 sha256 字段（官方 nodejs.org + astral-sh 双源核对），下载后先查最小字节(5MB兜底,挡代理错误页/半包)再比对 SHA-256(挡代理缓存损坏/篡改包)；校验不过自动回退 mirror_fallback 备用源重试。真因：公共镜像+客户机代理常出现 HTTP 200 但包损坏/是错误页，解压出垃圾后 node/python 装上却跑不起来，且此前无从发现。字段留空则只走最小字节兜底，向后兼容老清单。v25: 下载/解压链路不再依赖客户机 PATH——skill 内所有裸 curl / powershell 调用换成 %SystemRoot% 绝对路径（curl.exe、WindowsPowerShell\\v1.0\\powershell.exe）。真因：pc-6977 实锤客户手改系统 PATH 把 C:\\Windows\\system32 写坏成 C:\\;indows\\system32 → System32 整个失联 → 凡走 PATH 找 curl/tar 的安装步骤全军覆没。npm/python 不改（走 U-King 注入的便携目录，不吃客户 PATH）。v24: ①修 Codex GitHub 二进制兜底的致命转义 bug——repair 最后一步 cmd 里 '\\bin' 在 JSON 源文件里写成了单反斜杠 \\b（=backspace 0x08 控制符），解码后目标目录变成非法文件名，New-Item/Copy-Item 必败→npm 链路一失败兜底永远救不回（pc-8357 排查实锤，手动按正确路径执行同一步骤 codex 0.140.0 装通）。②npm cache clean --force 改 call…&(exit /b 0) 容错——它是 best-effort 清理，此前一报 EPERM/-4048 整条 repair 中断，根本轮不到后面的强制重装和二进制兜底（issue #104/#105 实锤）。v23: Hermes repair 先清理半截便携 Python 目录并重新 ensure_python，避免 tar 解压中断后直接跑 python -m pip 触发 9009；OpenClaw repair 先停掉 .uking/runtime/node 下的占用进程，降低 npm EBUSY rename。v21: Hermes 对齐 Claude Code 稳定链路——pip 安装后由客户端自动创建配置目录并写虾盘云；repair 增加 pip 缓存清理后再强制重装，降低坏 wheel/半包导致的复装失败。v20: Hermes 改装 hermes-agent[web]——带 web extra 才有 `hermes dashboard` 网页版控制台（FastAPI@127.0.0.1:9119，预编译 React 前端随 wheel 走，无需 Node/npm）。U-King 把网页版设为 Hermes 主推入口（小白怕 TUI，网页里点点就能聊）。装包带 [web] 后 `hermes dashboard` 不再现场 build。v17: 修死链——mirror_fallback 原 cloud.u-claw.org/uking/runtimes 实测 404(并不映射到 OSS),便携 Node/Python 主源(npmmirror)挂时兜底其实是哑的。改成阿里云深圳 OSS 直链(u-claw-updates/uking/runtimes,国内 5MB/s),并把 node/python 运行时同名文件镜像上去。 v16: Codex CLI 加 GitHub 官方二进制兜底——npm 链路(npmmirror 滞后/代理抖动/optional 包被跳)全失败时，直接下 openai/codex 官方 release 单文件 exe(rust-v0.140.0)，GitHub 主源→阿里云深圳 OSS 国内镜像(u-claw-updates/uking/runtimes/codex-win-x64.zip, 实测 200/99MB/5MB-s)两路兜底，解压装到 %USERPROFILE%\\bin\\codex.exe(已在 search_paths)。GitHub 一键脚本 chatgpt.com 国内不通已弃。 v15: Codex CLI 装不上的真因修复——@openai/codex 的平台原生二进制（@openai/codex-win32-x64）是 optionalDependency，npmmirror 滞后/客户机代理抖动时被悄悄跳过，导致 codex 包装上了但 `codex --version` 崩。现在主装步骤加 --include=optional 强制拉可选依赖 + 单独补装 win32-x64 子包；repair 增加「放开 npm optional」+「单独补装平台二进制」两步。installer.rs 加 npm_install 的 with_optional 字段。v14: Codex桌面版兜底源修正——原第三条 cloud.u-claw.org/uking/codex-app.msix 实测 404（死链，客户装不上的隐患），换成 agentsmirror R2 直链（codexapp-r2.agentsmirror.com，实测 200/648MB），现两路全活：镜像主域→R2直链。配合 U-King「一键全安装」按钮。v13: 代理自愈——客户机 clash 式代理把 npm proxy 写死全局 npmrc 时，npm install 卡死/报 lookup\"\"。每个 npm 工具的 repair 第一步先清全局 npmrc 代理（--location=global）；底层 installer 也已默认 --proxy=\"\" 绕代理 + 子进程清代理环境变量（实战 DESKTOP-PBDJJB6）。v12: Codex桌面版MSIX下载三级兜底——微软商店winget(主)→第三方镜像agentsmirror(兜底)→自有源cloud.u-claw.org(最后防线，减轻自有服务器负荷)；curl 加 -f 让HTTP错误触发回落。v10: 装前磁盘空间预检（满盘时 curl 报错是天书，us-server 实测仅剩20MB）。v9: Codex桌面版MSIX实际约550MB，修正提示文案+下载超时放宽到40分钟。v8: Codex CLI 解锁到最新版（虾盘云已支持 /v1/responses，不再需要锁 0.80）+ 新增 Codex 桌面版（winget 微软商店渠道，失败回退国内镜像 MSIX）。v7: 运行时下载加服务器备用源。v6: 便携 Python + Hermes。v5: OpenClaw + Node 22.20。",
  "mirror_fallback": "https://u-claw-updates.oss-cn-shenzhen.aliyuncs.com/uking/runtimes",
  "python": {
    "url": "https://registry.npmmirror.com/-/binary/python-build-standalone/20241016/cpython-3.12.7+20241016-x86_64-pc-windows-msvc-install_only.tar.gz",
    "url_mac_arm64": "https://registry.npmmirror.com/-/binary/python-build-standalone/20241016/cpython-3.12.7+20241016-aarch64-apple-darwin-install_only.tar.gz",
    "url_mac_x64": "https://registry.npmmirror.com/-/binary/python-build-standalone/20241016/cpython-3.12.7+20241016-x86_64-apple-darwin-install_only.tar.gz",
    "sha256": "f05531bff16fa77b53be0776587b97b466070e768e6d5920894de988bdcd547a",
    "sha256_mac_arm64": "4c18852bf9c1a11b56f21bcf0df1946f7e98ee43e9e4c0c5374b2b3765cf9508",
    "sha256_mac_x64": "60c5271e7edc3c2ab47440b7abf4ed50fbc693880b474f74f05768f5b657045a"
  },
  "pip_index": "https://mirrors.aliyun.com/pypi/simple/",
  "node": {
    "version": "v22.20.0",
    "url": "https://registry.npmmirror.com/-/binary/node/v22.20.0/node-v22.20.0-win-x64.zip",
    "dir_name": "node-v22.20.0-win-x64",
    "url_mac_arm64": "https://registry.npmmirror.com/-/binary/node/v22.20.0/node-v22.20.0-darwin-arm64.tar.gz",
    "dir_name_mac_arm64": "node-v22.20.0-darwin-arm64",
    "url_mac_x64": "https://registry.npmmirror.com/-/binary/node/v22.20.0/node-v22.20.0-darwin-x64.tar.gz",
    "dir_name_mac_x64": "node-v22.20.0-darwin-x64",
    "sha256": "bb819d6eb8f5bfda294bbc83a7e4ec6539da67c4233d54b0d655b9248b15e29d",
    "sha256_mac_arm64": "cc04a76a09f79290194c0646f48fec40354d88969bec467789a5d55dd097f949",
    "sha256_mac_x64": "00df9c5df3e4ec6848c26b70fb47bf96492f342f4bed6b17f12d99b3a45eeecc"
  },
  "npm_registry": "https://registry.npmmirror.com",
  "tools": {
    "claude-code": {
      "name": "Claude Code CLI",
      "bin": "claude",
      "verify_cmd": "claude --version",
      "steps": [
        {
          "type": "ensure_node",
          "label": "检查 Node.js 运行时（缺失则自动装便携版）"
        },
        {
          "type": "npm_install",
          "label": "安装 Claude Code（npmmirror 国内加速）",
          "package": "@anthropic-ai/claude-code"
        }
      ],
      "repair": [
        {
          "type": "run",
          "label": "清除 npm 全局代理配置（客户机代理常把 npm 拦死）",
          "cmd": "call npm config delete proxy --location=global & call npm config delete https-proxy --location=global & call npm config delete proxy & call npm config delete https-proxy & (exit /b 0)"
        },
        {
          "type": "run",
          "label": "清理 npm 缓存",
          "cmd": "call npm cache clean --force & (exit /b 0)"
        },
        {
          "type": "npm_install",
          "label": "强制重装 Claude Code",
          "package": "@anthropic-ai/claude-code",
          "force": true
        }
      ],
      "min_free_mb": 400
    },
    "codex": {
      "name": "Codex CLI",
      "bin": "codex",
      "verify_cmd": "codex --version",
      "steps": [
        {
          "type": "ensure_node",
          "label": "检查 Node.js 运行时（缺失则自动装便携版）"
        },
        {
          "type": "npm_install",
          "label": "安装 Codex CLI 最新版（npmmirror 国内加速；0.141+ 二进制已打包进主包，--include=optional 兜旧版平台子包）",
          "package": "@openai/codex",
          "with_optional": true
        }
      ],
      "repair": [
        {
          "type": "run",
          "label": "停止占用 OpenClaw/npm 全局目录的旧进程（修 EBUSY rename）",
          "cmd": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -NonInteractive -Command \"$nodeRoot=(Join-Path $env:USERPROFILE '.uking\\runtime\\node'); Get-CimInstance Win32_Process | Where-Object { $_.ExecutablePath -and $_.ExecutablePath.StartsWith($nodeRoot,[StringComparison]::OrdinalIgnoreCase) } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }; exit 0\""
        },
        {
          "type": "run",
          "label": "清除 npm 全局代理配置（客户机代理常把 npm 拦死）",
          "cmd": "call npm config delete proxy --location=global & call npm config delete https-proxy --location=global & call npm config delete proxy & call npm config delete https-proxy & (exit /b 0)"
        },
        {
          "type": "run",
          "label": "放开 npm 拉取可选依赖（平台二进制是 optionalDependency，被关掉就装不上 codex 内核）",
          "cmd": "npm config delete optional --location=global & npm config set optional true & exit 0"
        },
        {
          "type": "run",
          "label": "清理 npm 缓存",
          "cmd": "call npm cache clean --force & (exit /b 0)"
        },
        {
          "type": "npm_install",
          "label": "强制重装 Codex CLI（含平台二进制）",
          "package": "@openai/codex",
          "with_optional": true,
          "force": true
        },
        {
          "type": "run",
          "label": "兜底：下 OpenAI 官方 Codex 单文件二进制（npm 全失败时的最后防线；阿里云深圳 OSS 国内镜像主源→GitHub 兜底，断点续传）",
          "cmd": "%SystemRoot%\\System32\\curl.exe -fL -sS -C - --retry 3 --retry-delay 3 -m 1800 --proxy \"\" -o \"%TEMP%\\codex-cli.zip\" https://u-claw-updates.oss-cn-shenzhen.aliyuncs.com/uking/runtimes/codex-win-x64.zip || %SystemRoot%\\System32\\curl.exe -fL -sS -C - --retry 3 --retry-delay 3 -m 1800 --proxy \"\" -o \"%TEMP%\\codex-cli.zip\" https://github.com/openai/codex/releases/download/rust-v0.143.0/codex-x86_64-pc-windows-msvc.exe.zip"
        },
        {
          "type": "run",
          "label": "解压装到 %USERPROFILE%\\bin\\codex.exe + 清掉半装坏掉的 codex 启动器（否则它在 PATH 里挡住好二进制，verify 永远失败）+ 把 ~/bin 加进用户 PATH",
          "cmd": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -NonInteractive -Command \"$d=$env:USERPROFILE+'\\bin'; New-Item -ItemType Directory -Force -Path $d | Out-Null; $tmp=($env:TEMP+'\\codex-cli'); Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue; New-Item -ItemType Directory -Force -Path $tmp | Out-Null; & ($env:SystemRoot+'\\System32\\tar.exe') -xf ($env:TEMP+'\\codex-cli.zip') -C $tmp; Copy-Item -Force ($tmp+'\\codex-x86_64-pc-windows-msvc.exe') ($d+'\\codex.exe'); foreach($dir in @((Join-Path $env:USERPROFILE '.uking\\runtime\\node'),(Join-Path $env:APPDATA 'npm'))){ foreach($n in @('codex','codex.cmd','codex.ps1')){ $p=Join-Path $dir $n; if(Test-Path $p){ Remove-Item -Force $p -ErrorAction SilentlyContinue } } }; $u=[Environment]::GetEnvironmentVariable('Path','User'); if(($u -split ';') -notcontains $d){ [Environment]::SetEnvironmentVariable('Path',($u.TrimEnd(';')+';'+$d),'User') }; if (Test-Path ($d+'\\codex.exe')) { exit 0 } else { exit 1 }\""
        }
      ],
      "min_free_mb": 400
    },
    "codex-app": {
      "name": "Codex 桌面版",
      "bin": "codex-app",
      "verify_cmd": "powershell -NoProfile -NonInteractive -Command \"if (Get-AppxPackage -Name OpenAI.Codex) { (Get-AppxPackage -Name OpenAI.Codex).Version } else { exit 1 }\"",
      "steps": [
        {
          "type": "run",
          "label": "通过微软商店安装 Codex 桌面版（已装则跳过；商店安装较慢，请耐心等待）",
          "cmd": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -NonInteractive -Command \"if (Get-AppxPackage -Name OpenAI.Codex) { Write-Host 'Codex 桌面版已安装，跳过'; exit 0 }; if (-not (Get-Command winget -ErrorAction SilentlyContinue)) { Write-Host 'winget 不可用，转兜底 MSIX'; exit 1 }; winget install --id 9PLM9XGG6VKS --source msstore --accept-package-agreements --accept-source-agreements --disable-interactivity; for ($i=0; $i -lt 12; $i++) { if (Get-AppxPackage -Name OpenAI.Codex) { Write-Host 'Codex 桌面版安装成功'; exit 0 }; Start-Sleep -Seconds 5 }; exit 1\""
        }
      ],
      "repair": [
        {
          "type": "run",
          "label": "下载官方 MSIX 安装包（约 650MB，慢网请耐心等待；镜像主域→镜像 R2 直链 两路兜底）",
          "cmd": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command \"$ErrorActionPreference='Stop'; $p=Join-Path $env:TEMP 'codex-app.msix'; Remove-Item $p -Force -ErrorAction SilentlyContinue; $urls=@('https://codexapp.agentsmirror.com/latest/win','https://codexapp-r2.agentsmirror.com/latest/win'); $ok=$false; foreach($u in $urls){ Write-Host ('下载 '+$u); & ($env:SystemRoot+'\\System32\\curl.exe') -fL -sS -m 2400 -o $p $u; if($LASTEXITCODE -eq 0 -and (Test-Path $p) -and (Get-Item $p).Length -gt 100MB){ $ok=$true; break } }; if(-not $ok){ throw 'Codex MSIX 下载失败或文件不完整，请点手动教程下载' }; Write-Host ('MSIX 已下载 '+[Math]::Round((Get-Item $p).Length/1MB)+' MB')\""
        },
        {
          "type": "run",
          "label": "安装 MSIX（免管理员，按用户安装）",
          "cmd": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command \"$p=Join-Path $env:TEMP 'codex-app.msix'; if(-not (Test-Path $p)){ throw '找不到 codex-app.msix，请重新下载安装包' }; Add-AppxPackage -Path $p -ErrorAction Stop; for($i=0; $i -lt 12; $i++){ if(Get-AppxPackage -Name OpenAI.Codex){ Write-Host 'Codex 桌面版安装成功'; exit 0 }; Start-Sleep -Seconds 5 }; throw 'MSIX 安装后未检测到 OpenAI.Codex，请重启 U-King 或按手动教程确认安装状态'\""
        }
      ],
      "min_free_mb": 1500
    },
    "openclaw": {
      "name": "OpenClaw 龙虾",
      "bin": "openclaw",
      "verify_cmd": "openclaw --version",
      "steps": [
        {
          "type": "ensure_node",
          "label": "检查 Node.js 运行时（OpenClaw 需 Node 22.19+）"
        },
        {
          "type": "npm_install",
          "label": "安装 OpenClaw（npm 国内源，绕开官方 git 安装）",
          "package": "openclaw"
        }
      ],
      "repair": [
        {
          "type": "run",
          "label": "停止占用 OpenClaw/npm 全局目录的旧进程（修 EBUSY rename）",
          "cmd": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -NonInteractive -Command \"$nodeRoot=(Join-Path $env:USERPROFILE '.uking\\runtime\\node'); Get-CimInstance Win32_Process | Where-Object { $_.ExecutablePath -and $_.ExecutablePath.StartsWith($nodeRoot,[StringComparison]::OrdinalIgnoreCase) } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }; exit 0\""
        },
        {
          "type": "run",
          "label": "清除 npm 全局代理配置（客户机代理常把 npm 拦死）",
          "cmd": "call npm config delete proxy --location=global & call npm config delete https-proxy --location=global & call npm config delete proxy & call npm config delete https-proxy & (exit /b 0)"
        },
        {
          "type": "run",
          "label": "清理 npm 缓存",
          "cmd": "call npm cache clean --force & (exit /b 0)"
        },
        {
          "type": "npm_install",
          "label": "强制重装 OpenClaw",
          "package": "openclaw",
          "force": true
        }
      ],
      "min_free_mb": 500
    },
    "hermes": {
      "name": "Hermes Agent",
      "bin": "hermes",
      "verify_cmd": "hermes --version",
      "steps": [
        {
          "type": "ensure_python",
          "label": "检查 Python 运行时（缺失则自动装便携版）"
        },
        {
          "type": "pip_install",
          "label": "安装 Hermes（pip 阿里源，绕开官方 git 安装）",
          "package": "hermes-agent[web]"
        },
        {
          "type": "run",
          "label": "清掉挡住 hermes 自带 utils.py 的旧版 utils/ shim 包（修 fast_safe_load ImportError；PowerShell 版，exit 0 永不误判失败）",
          "cmd": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -NonInteractive -Command \"$base=Join-Path $env:USERPROFILE '.uking\\runtime\\python'; if(Test-Path $base){ Get-ChildItem -LiteralPath $base -Filter site-packages -Recurse -Directory -ErrorAction SilentlyContinue | ForEach-Object { $sp=$_.FullName; if((Test-Path (Join-Path $sp 'utils\\__init__.py')) -and (Test-Path (Join-Path $sp 'utils.py'))){ Remove-Item -LiteralPath (Join-Path $sp 'utils') -Recurse -Force -ErrorAction SilentlyContinue } } }; exit 0\""
        }
      ],
      "repair": [
        {
          "type": "run",
          "label": "清理损坏的便携 Python 目录（修解压中断 / Truncated tar archive；带重试防杀软瞬时锁住刚落盘文件）",
          "cmd": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -NonInteractive -Command \"$p=Join-Path $env:USERPROFILE '.uking\\runtime\\python'; Remove-Item -LiteralPath $p -Recurse -Force -ErrorAction SilentlyContinue; if (Test-Path $p) { Start-Sleep -Seconds 2; Remove-Item -LiteralPath $p -Recurse -Force -ErrorAction SilentlyContinue }; if (Test-Path $p) { Start-Sleep -Seconds 3; Remove-Item -LiteralPath $p -Recurse -Force -ErrorAction SilentlyContinue }; exit 0\""
        },
        {
          "type": "ensure_python",
          "label": "重新下载并解压便携 Python"
        },
        {
          "type": "run",
          "label": "清理 pip 缓存（避免坏 wheel / 半包复用）",
          "cmd": "python -m pip cache purge || exit /b 0"
        },
        {
          "type": "pip_install",
          "label": "强制重装 Hermes",
          "package": "hermes-agent[web]",
          "force": true
        },
        {
          "type": "run",
          "label": "清掉挡住 hermes 自带 utils.py 的旧版 utils/ shim 包（修 fast_safe_load ImportError；PowerShell 版，exit 0 永不误判失败）",
          "cmd": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -NonInteractive -Command \"$base=Join-Path $env:USERPROFILE '.uking\\runtime\\python'; if(Test-Path $base){ Get-ChildItem -LiteralPath $base -Filter site-packages -Recurse -Directory -ErrorAction SilentlyContinue | ForEach-Object { $sp=$_.FullName; if((Test-Path (Join-Path $sp 'utils\\__init__.py')) -and (Test-Path (Join-Path $sp 'utils.py'))){ Remove-Item -LiteralPath (Join-Path $sp 'utils') -Recurse -Force -ErrorAction SilentlyContinue } } }; exit 0\""
        }
      ],
      "min_free_mb": 700
    }
  }
}
