refactor: 移除代理检测逻辑(WSL2 镜像模式自动继承 Windows 代理)
WSL2 mirror mode + autoProxy=true 下,WSL2 自动继承 Windows 代理状态 无需脚本干预,是否使用代理由 Windows 侧决定 移除内容: - -ProxyPort 参数 - Get-V2RayNProxyPort / Set-WindowsProxy / Clear-WindowsProxy 函数 - Step 0 代理检测配置块 - ~/.mcp-proxy.env 生成及所有 source 调用 - git proxy save/restore 逻辑 - npm proxy 配置 - 最终摘要代理信息行 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
WSL2 + Claude Code CLI + Unity MCP + Rust Token Killer **全栈一键部署方案**,适用于 Windows 11 开发环境。
|
WSL2 + Claude Code CLI + Unity MCP + Rust Token Killer **全栈一键部署方案**,适用于 Windows 11 开发环境。
|
||||||
|
|
||||||
支持 **v2rayN 代理自动检测**、**WSL2 代理透传**、**防火墙自动放行**。
|
支持 **WSL2 镜像网络模式**(`autoProxy=true`),WSL2 自动继承 Windows 代理状态,无需脚本干预。
|
||||||
|
|
||||||
## 组件清单
|
## 组件清单
|
||||||
|
|
||||||
@@ -47,14 +47,8 @@ cd path\to\claude-dev-stack
|
|||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
notepad .env
|
notepad .env
|
||||||
|
|
||||||
# 3. 运行部署脚本(灵眸模式自动跳过代理检测)
|
# 3. 运行部署脚本
|
||||||
pwsh .\deploy.ps1
|
pwsh .\deploy.ps1
|
||||||
|
|
||||||
# 手动指定代理端口(使用官方 Anthropic API 时需要)
|
|
||||||
pwsh .\deploy.ps1 -ProxyPort 10809
|
|
||||||
|
|
||||||
# 不使用代理(直连)
|
|
||||||
pwsh .\deploy.ps1 -ProxyPort -1
|
|
||||||
```
|
```
|
||||||
|
|
||||||
首次安装 WSL2 特性后可能需要**重启系统**,重启后重新执行脚本。
|
首次安装 WSL2 特性后可能需要**重启系统**,重启后重新执行脚本。
|
||||||
@@ -71,45 +65,25 @@ pwsh .\deploy.ps1 -SkipWSL
|
|||||||
# 在 WSL2 Ubuntu 终端中执行
|
# 在 WSL2 Ubuntu 终端中执行
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
nano .env
|
nano .env
|
||||||
# 如需代理(端口由 deploy.ps1 写入 ~/.mcp-proxy.env,或手动指定)
|
bash wsl-setup.sh
|
||||||
PROXY_PORT=10809 bash wsl-setup.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 代理说明(v2rayN)
|
## 代理说明
|
||||||
|
|
||||||
### 自动检测顺序
|
### WSL2 镜像模式自动继承 Windows 代理
|
||||||
|
|
||||||
1. Windows 系统代理注册表(v2rayN「设为系统代理」时写入)
|
脚本自动配置 `~/.wslconfig` 启用 WSL2 镜像网络模式:
|
||||||
2. v2rayN 配置文件(`%APPDATA%\v2rayN\guiNConfig.json`)
|
|
||||||
3. 探测常用端口:`10809, 10808, 7890, 1080, 8080`
|
|
||||||
|
|
||||||
### WSL2 代理透传原理
|
```ini
|
||||||
|
[wsl2]
|
||||||
```
|
networkingMode=mirrored
|
||||||
WSL2 Ubuntu
|
autoProxy=true
|
||||||
→ [Windows 主机 vEthernet(WSL) IP]:10809
|
|
||||||
→ v2rayN
|
|
||||||
→ 互联网
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**必须**在 v2rayN 中开启:
|
`autoProxy=true` 下,WSL2 自动继承 Windows 系统代理状态。
|
||||||
> 参数设置 → **「允许来自局域网的连接」** ✅
|
**是否使用代理由 Windows 侧决定**(例如通过 v2rayN「设为系统代理」),无需脚本干预。
|
||||||
|
|
||||||
脚本自动完成:
|
|
||||||
- 写入 WSL2 `~/.mcp-proxy.env`(每次 shell 启动自动生效)
|
|
||||||
- 配置 WSL2 `git` + `npm` 代理
|
|
||||||
- `apt-get` 安装阶段同样走代理
|
|
||||||
|
|
||||||
### 代理覆盖范围
|
|
||||||
|
|
||||||
| 操作 | 是否走代理 |
|
|
||||||
|------|-----------|
|
|
||||||
| Windows `git clone` / `npm install` | ✅ |
|
|
||||||
| WSL2 `apt-get` / `git clone` / `npm install` / `cargo install` | ✅ |
|
|
||||||
| MCP Server ↔ AI 客户端(stdio) | ❌ 本地通信,无需代理 |
|
|
||||||
| MCP Server ↔ Unity Plugin(localhost) | ❌ 本地通信,无需代理 |
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -133,7 +107,6 @@ WSL2 Ubuntu
|
|||||||
> | `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | `1` | 关闭遥测/自动更新检查 |
|
> | `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | `1` | 关闭遥测/自动更新检查 |
|
||||||
>
|
>
|
||||||
> - Token 写入 `settings.json` 的 `env` 块(不写入 `~/.bashrc`,避免与 `ANTHROPIC_API_KEY` 冲突)
|
> - Token 写入 `settings.json` 的 `env` 块(不写入 `~/.bashrc`,避免与 `ANTHROPIC_API_KEY` 冲突)
|
||||||
> - 部署脚本自动跳过代理检测(国内直连无需代理)
|
|
||||||
> - 旧 `ANTHROPIC_API_KEY` / `ANTHROPIC_BASE_URL` 变量从 `~/.bashrc` 自动清除
|
> - 旧 `ANTHROPIC_API_KEY` / `ANTHROPIC_BASE_URL` 变量从 `~/.bashrc` 自动清除
|
||||||
|
|
||||||
### 备选:Anthropic 官方 API
|
### 备选:Anthropic 官方 API
|
||||||
@@ -367,19 +340,17 @@ wsl -d Ubuntu -- bash -c "cd ~/.mcp-servers/unity-mcp-server && git pull && npm
|
|||||||
|
|
||||||
**问题:npm install 安装超时(国内网络)**
|
**问题:npm install 安装超时(国内网络)**
|
||||||
```bash
|
```bash
|
||||||
# 方案一:通过 v2rayN 代理(推荐)
|
# 方案一:在 Windows 侧开启系统代理(v2rayN「设为系统代理」),WSL2 自动继承
|
||||||
pwsh .\deploy.ps1 -ProxyPort 10809
|
|
||||||
|
|
||||||
# 方案二:WSL2 内配置镜像
|
# 方案二:WSL2 内配置镜像
|
||||||
npm config set registry https://registry.npmmirror.com
|
npm config set registry https://registry.npmmirror.com
|
||||||
```
|
```
|
||||||
|
|
||||||
**问题:WSL2 无法连接 v2rayN 代理**
|
**问题:WSL2 无法访问外网**
|
||||||
```
|
```
|
||||||
解决:
|
解决:
|
||||||
1. v2rayN → 参数设置 → 勾选「允许来自局域网的连接」
|
1. 确认 Windows 侧代理已开启系统代理(v2rayN → 参数设置 → 勾选「允许来自局域网的连接」)
|
||||||
2. 确认防火墙未拦截 v2rayN 监听端口
|
2. 确认 ~/.wslconfig 包含 networkingMode=mirrored 和 autoProxy=true
|
||||||
3. WSL2 内测试:curl -I https://github.com --proxy http://$(ip route | grep default | awk '{print $3}'):10809
|
3. 重启 WSL2:wsl --shutdown,再重新启动
|
||||||
```
|
```
|
||||||
|
|
||||||
**问题:Unity 版本兼容性**
|
**问题:Unity 版本兼容性**
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
WSL2 + Claude Code CLI + Unity MCP + Rust Token Killer 全栈一键部署脚本
|
WSL2 + Claude Code CLI + Unity MCP + Rust Token Killer 全栈一键部署脚本
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
自动完成以下步骤:
|
自动完成以下步骤:
|
||||||
0. 检测 v2rayN 代理端口,配置 Windows & WSL2 两侧代理
|
|
||||||
1. 启用 WSL2 功能 & 安装 Ubuntu 发行版
|
1. 启用 WSL2 功能 & 安装 Ubuntu 发行版
|
||||||
2. 检测/安装 Windows 本机 Node.js(AI 客户端 MCP 需要)
|
2. 检测/安装 Windows 本机 Node.js(AI 客户端 MCP 需要)
|
||||||
3. WSL2 内安装 Node.js LTS(Claude Code CLI 需要)
|
3. WSL2 内安装 Node.js LTS(Claude Code CLI 需要)
|
||||||
@@ -13,8 +12,6 @@
|
|||||||
6. 配置 Windows 防火墙放行 MCP Bridge 端口
|
6. 配置 Windows 防火墙放行 MCP Bridge 端口
|
||||||
7. 安装 Rust 工具链 & Token Killer (rtk)
|
7. 安装 Rust 工具链 & Token Killer (rtk)
|
||||||
8. 写入 PowerShell Profile 快捷命令
|
8. 写入 PowerShell Profile 快捷命令
|
||||||
.PARAMETER ProxyPort
|
|
||||||
v2rayN HTTP 代理端口;0 = 自动检测;-1 = 跳过代理
|
|
||||||
.PARAMETER BridgePort
|
.PARAMETER BridgePort
|
||||||
Unity MCP Bridge 端口,默认 7890
|
Unity MCP Bridge 端口,默认 7890
|
||||||
.PARAMETER InstallDir
|
.PARAMETER InstallDir
|
||||||
@@ -30,7 +27,6 @@
|
|||||||
已有 WSL2 可普通终端运行,加 -SkipWSL 跳过 WSL2 安装检查。
|
已有 WSL2 可普通终端运行,加 -SkipWSL 跳过 WSL2 安装检查。
|
||||||
#>
|
#>
|
||||||
param(
|
param(
|
||||||
[int] $ProxyPort = 0,
|
|
||||||
[int] $BridgePort = 7890,
|
[int] $BridgePort = 7890,
|
||||||
[string]$InstallDir = "$env:USERPROFILE\unity-mcp-server",
|
[string]$InstallDir = "$env:USERPROFILE\unity-mcp-server",
|
||||||
[string]$UnityHubPath = "C:\Program Files\Unity Hub\Unity Hub.exe",
|
[string]$UnityHubPath = "C:\Program Files\Unity Hub\Unity Hub.exe",
|
||||||
@@ -93,104 +89,10 @@ $UseLmuAuth = ($ANTHROPIC_AUTH_TOKEN -ne "" -and $ANTHROPIC_BASE_URL -ne "https:
|
|||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "╔══════════════════════════════════════════════════════════╗" -ForegroundColor Cyan
|
Write-Host "╔══════════════════════════════════════════════════════════╗" -ForegroundColor Cyan
|
||||||
Write-Host "║ WSL2 + Claude Code CLI + Unity MCP + RTK 全栈部署 ║" -ForegroundColor Cyan
|
Write-Host "║ WSL2 + Claude Code CLI + Unity MCP + RTK 全栈部署 ║" -ForegroundColor Cyan
|
||||||
Write-Host "║ AnkleBreaker Unity MCP · v2rayN 代理自动检测 ║" -ForegroundColor Cyan
|
Write-Host "║ AnkleBreaker Unity MCP · WSL2 Mirror Mode ║" -ForegroundColor Cyan
|
||||||
Write-Host "╚══════════════════════════════════════════════════════════╝" -ForegroundColor Cyan
|
Write-Host "╚══════════════════════════════════════════════════════════╝" -ForegroundColor Cyan
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# ══════════════════════════════════════════════════════════════
|
|
||||||
# Step 0: v2rayN 代理检测与配置
|
|
||||||
# ══════════════════════════════════════════════════════════════
|
|
||||||
Write-Step "0/8 v2rayN 代理检测"
|
|
||||||
|
|
||||||
# ── 检测代理端口 ──────────────────────────────────────────────
|
|
||||||
function Get-V2RayNProxyPort {
|
|
||||||
# 1. Windows 系统代理注册表(v2rayN"设为系统代理"时写入)
|
|
||||||
try {
|
|
||||||
$ie = Get-ItemProperty `
|
|
||||||
"HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" `
|
|
||||||
-ErrorAction SilentlyContinue
|
|
||||||
if ($ie.ProxyEnable -eq 1 -and $ie.ProxyServer -match ":(\d+)") {
|
|
||||||
return [int]$Matches[1]
|
|
||||||
}
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
# 2. v2rayN 配置文件
|
|
||||||
$cfgPaths = @(
|
|
||||||
"$env:APPDATA\v2rayN\guiNConfig.json",
|
|
||||||
"$env:LOCALAPPDATA\v2rayN\guiNConfig.json"
|
|
||||||
)
|
|
||||||
foreach ($p in $cfgPaths) {
|
|
||||||
if (Test-Path $p) {
|
|
||||||
try {
|
|
||||||
$j = Get-Content $p -Raw | ConvertFrom-Json
|
|
||||||
if ($j.localPort) { return [int]$j.localPort }
|
|
||||||
if ($j.httpPort) { return [int]$j.httpPort }
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# 3. 探测常用端口
|
|
||||||
foreach ($port in @(10809, 10808, 7890, 1080, 8080)) {
|
|
||||||
try {
|
|
||||||
$tcp = New-Object System.Net.Sockets.TcpClient
|
|
||||||
$ar = $tcp.BeginConnect("127.0.0.1", $port, $null, $null)
|
|
||||||
if ($ar.AsyncWaitHandle.WaitOne(300, $false)) {
|
|
||||||
$tcp.EndConnect($ar); $tcp.Close(); return $port
|
|
||||||
}
|
|
||||||
$tcp.Close()
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function Set-WindowsProxy {
|
|
||||||
param([int]$Port)
|
|
||||||
$url = "http://127.0.0.1:$Port"
|
|
||||||
git config --global http.proxy $url 2>$null
|
|
||||||
git config --global https.proxy $url 2>$null
|
|
||||||
& npm config set proxy $url --location global 2>$null
|
|
||||||
& npm config set https-proxy $url --location global 2>$null
|
|
||||||
$env:http_proxy = $url; $env:https_proxy = $url
|
|
||||||
$env:HTTP_PROXY = $url; $env:HTTPS_PROXY = $url
|
|
||||||
Write-OK "Windows git/npm/env 代理 -> $url"
|
|
||||||
}
|
|
||||||
|
|
||||||
function Clear-WindowsProxy {
|
|
||||||
git config --global --unset http.proxy 2>$null
|
|
||||||
git config --global --unset https.proxy 2>$null
|
|
||||||
& npm config delete proxy --location global 2>$null
|
|
||||||
& npm config delete https-proxy --location global 2>$null
|
|
||||||
"http_proxy","https_proxy","HTTP_PROXY","HTTPS_PROXY" |
|
|
||||||
ForEach-Object { Remove-Item "Env:\$_" -ErrorAction SilentlyContinue }
|
|
||||||
}
|
|
||||||
|
|
||||||
$resolvedProxyPort = 0
|
|
||||||
|
|
||||||
# 灵眸 AI 国内直连无需代理,主动跳过
|
|
||||||
if ($UseLmuAuth -and $ProxyPort -ne -1) {
|
|
||||||
Write-Info "灵眸 AI 模式:国内直连,自动跳过代理配置"
|
|
||||||
Write-Info "如需为其他服务(git/npm)使用代理,请手动指定 -ProxyPort"
|
|
||||||
$ProxyPort = -1
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ProxyPort -eq -1) {
|
|
||||||
Write-Warn "已跳过代理配置(-ProxyPort -1)"
|
|
||||||
} elseif ($ProxyPort -gt 0) {
|
|
||||||
$resolvedProxyPort = $ProxyPort
|
|
||||||
Set-WindowsProxy -Port $resolvedProxyPort
|
|
||||||
Write-OK "使用指定代理端口: $resolvedProxyPort"
|
|
||||||
} else {
|
|
||||||
$resolvedProxyPort = Get-V2RayNProxyPort
|
|
||||||
if ($resolvedProxyPort -gt 0) {
|
|
||||||
Set-WindowsProxy -Port $resolvedProxyPort
|
|
||||||
Write-OK "自动检测到 v2rayN 代理端口: $resolvedProxyPort"
|
|
||||||
} else {
|
|
||||||
Write-Warn "未检测到活跃代理,将使用直连网络"
|
|
||||||
Write-Warn "如需代理,请指定: pwsh deploy.ps1 -ProxyPort 10809"
|
|
||||||
Write-Warn "⚠ 确保 v2rayN 已开启「允许来自局域网的连接」(WSL2 需要)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ══════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════
|
||||||
# Step 1: WSL2 安装
|
# Step 1: WSL2 安装
|
||||||
# ══════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════
|
||||||
@@ -302,39 +204,6 @@ if ($needRestart) {
|
|||||||
Start-Sleep 3
|
Start-Sleep 3
|
||||||
}
|
}
|
||||||
|
|
||||||
# ── 配置 WSL2 侧代理(持久化到 ~/.bashrc) ───────────────────
|
|
||||||
if ($resolvedProxyPort -gt 0) {
|
|
||||||
Write-Info "配置 WSL2 代理(端口 $resolvedProxyPort)..."
|
|
||||||
|
|
||||||
# mirrored 模式下 127.0.0.1 即 Windows,直接用即可
|
|
||||||
$proxyEnvContent = "# WSL2 mirrored networking: 127.0.0.1 = Windows host`nexport http_proxy=`"http://127.0.0.1:$resolvedProxyPort`"`nexport https_proxy=`"http://127.0.0.1:$resolvedProxyPort`"`nexport HTTP_PROXY=`"http://127.0.0.1:$resolvedProxyPort`"`nexport HTTPS_PROXY=`"http://127.0.0.1:$resolvedProxyPort`"`nexport no_proxy=`"localhost,127.0.0.1,::1`"`n"
|
|
||||||
|
|
||||||
$tmpFile = "$env:TEMP\mcp-proxy.env"
|
|
||||||
$bytes = [System.Text.Encoding]::UTF8.GetBytes($proxyEnvContent)
|
|
||||||
[System.IO.File]::WriteAllBytes($tmpFile, $bytes)
|
|
||||||
Copy-Item $tmpFile "\\wsl.localhost\$WSL_DISTRO\tmp\mcp-proxy-deploy.env" -Force 2>$null
|
|
||||||
|
|
||||||
Invoke-WSL "cp /tmp/mcp-proxy-deploy.env ~/.mcp-proxy.env && chmod 644 ~/.mcp-proxy.env && echo OK" | Out-Null
|
|
||||||
|
|
||||||
# 写入 ~/.bashrc(幂等)
|
|
||||||
Invoke-WSL @'
|
|
||||||
if ! grep -q 'mcp-proxy.env' ~/.bashrc 2>/dev/null; then
|
|
||||||
printf '\n# Unity MCP WSL2 proxy (generated by deploy.ps1)\n[ -f ~/.mcp-proxy.env ] && . ~/.mcp-proxy.env\n' >> ~/.bashrc
|
|
||||||
fi
|
|
||||||
# 立即应用代理并配置 git
|
|
||||||
. ~/.mcp-proxy.env 2>/dev/null || true
|
|
||||||
if [ -n "$http_proxy" ]; then
|
|
||||||
git config --global http.proxy "$http_proxy"
|
|
||||||
git config --global https.proxy "$https_proxy"
|
|
||||||
echo "WSL2 git proxy set: $http_proxy"
|
|
||||||
fi
|
|
||||||
true
|
|
||||||
'@ -IgnoreError | Out-Null
|
|
||||||
|
|
||||||
Write-OK "WSL2 代理已写入 ~/.mcp-proxy.env + ~/.bashrc"
|
|
||||||
Write-Warn "⚠ 请确保 v2rayN 已开启「允许来自局域网的连接」!"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ══════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════
|
||||||
# Step 2: Windows 本机 Node.js 检查(AI 客户端 MCP 需要)
|
# Step 2: Windows 本机 Node.js 检查(AI 客户端 MCP 需要)
|
||||||
# ══════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════
|
||||||
@@ -367,13 +236,6 @@ if ($winNode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# 对 Windows npm 设置代理
|
|
||||||
if ($resolvedProxyPort -gt 0 -and (Get-Command npm -ErrorAction SilentlyContinue)) {
|
|
||||||
$proxyUrl = "http://127.0.0.1:$resolvedProxyPort"
|
|
||||||
& npm config set proxy $proxyUrl --location global 2>$null
|
|
||||||
& npm config set https-proxy $proxyUrl --location global 2>$null
|
|
||||||
}
|
|
||||||
|
|
||||||
# ══════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════
|
||||||
# Step 3: WSL2 系统依赖 & Node.js
|
# Step 3: WSL2 系统依赖 & Node.js
|
||||||
# ══════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════
|
||||||
@@ -396,7 +258,6 @@ if ($nodeVer -match "v\d+") {
|
|||||||
} else {
|
} else {
|
||||||
Write-Info "安装 WSL2 Node.js LTS (via nvm)..."
|
Write-Info "安装 WSL2 Node.js LTS (via nvm)..."
|
||||||
$installNodeCmd = @'
|
$installNodeCmd = @'
|
||||||
. ~/.mcp-proxy.env 2>/dev/null || true
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
sudo apt-get install -y -qq curl ca-certificates 2>/dev/null
|
sudo apt-get install -y -qq curl ca-certificates 2>/dev/null
|
||||||
# 安装 nvm
|
# 安装 nvm
|
||||||
@@ -448,7 +309,6 @@ if ($claudeVer -notmatch "MISSING") {
|
|||||||
$installClaudeCmd = @'
|
$installClaudeCmd = @'
|
||||||
export NVM_DIR="$HOME/.nvm"
|
export NVM_DIR="$HOME/.nvm"
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||||||
. ~/.mcp-proxy.env 2>/dev/null || true
|
|
||||||
npm install -g @anthropic-ai/claude-code --quiet
|
npm install -g @anthropic-ai/claude-code --quiet
|
||||||
which claude
|
which claude
|
||||||
claude --version
|
claude --version
|
||||||
@@ -619,7 +479,6 @@ $wslMcpDir = "~/.mcp-servers/unity-mcp-server"
|
|||||||
$wslMcpCmd = @'
|
$wslMcpCmd = @'
|
||||||
export NVM_DIR="$HOME/.nvm"
|
export NVM_DIR="$HOME/.nvm"
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||||||
. ~/.mcp-proxy.env 2>/dev/null || true
|
|
||||||
mkdir -p $HOME/.mcp-servers
|
mkdir -p $HOME/.mcp-servers
|
||||||
if [ -d $HOME/.mcp-servers/unity-mcp-server/.git ]; then
|
if [ -d $HOME/.mcp-servers/unity-mcp-server/.git ]; then
|
||||||
git -C $HOME/.mcp-servers/unity-mcp-server pull --quiet 2>/dev/null || true
|
git -C $HOME/.mcp-servers/unity-mcp-server pull --quiet 2>/dev/null || true
|
||||||
@@ -707,7 +566,6 @@ Merge-McpConfig "$env:APPDATA\Code\User\mcp.json" $mcpEntry
|
|||||||
$wslMcpCfgCmd = @"
|
$wslMcpCfgCmd = @"
|
||||||
export NVM_DIR="`$HOME/.nvm"
|
export NVM_DIR="`$HOME/.nvm"
|
||||||
[ -s "`$NVM_DIR/nvm.sh" ] && . "`$NVM_DIR/nvm.sh"
|
[ -s "`$NVM_DIR/nvm.sh" ] && . "`$NVM_DIR/nvm.sh"
|
||||||
. ~/.mcp-proxy.env 2>/dev/null || true
|
|
||||||
# 先移除旧条目(幂等),再添加
|
# 先移除旧条目(幂等),再添加
|
||||||
claude mcp remove unity-mcp --scope user 2>/dev/null || true
|
claude mcp remove unity-mcp --scope user 2>/dev/null || true
|
||||||
claude mcp add --scope user unity-mcp node $wslScript -e UNITY_BRIDGE_PORT=$BridgePort
|
claude mcp add --scope user unity-mcp node $wslScript -e UNITY_BRIDGE_PORT=$BridgePort
|
||||||
@@ -772,8 +630,6 @@ if ($rustVer -notmatch "MISSING") {
|
|||||||
Write-Info "安装 Rust 工具链..."
|
Write-Info "安装 Rust 工具链..."
|
||||||
$installRustCmd = @"
|
$installRustCmd = @"
|
||||||
sudo apt-get install -y -qq build-essential pkg-config libssl-dev 2>/dev/null || true
|
sudo apt-get install -y -qq build-essential pkg-config libssl-dev 2>/dev/null || true
|
||||||
# mirrored 模式下直接用 127.0.0.1,rustup 用 env 代理
|
|
||||||
. ~/.mcp-proxy.env 2>/dev/null || true
|
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup-init.sh
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup-init.sh
|
||||||
sh /tmp/rustup-init.sh -y --default-toolchain stable --no-modify-path
|
sh /tmp/rustup-init.sh -y --default-toolchain stable --no-modify-path
|
||||||
source ~/.cargo/env
|
source ~/.cargo/env
|
||||||
@@ -792,15 +648,7 @@ if ($rtkVer -notmatch "MISSING") {
|
|||||||
Write-Info "安装 rtk (Rust Token Killer)..."
|
Write-Info "安装 rtk (Rust Token Killer)..."
|
||||||
$installRtkCmd = @"
|
$installRtkCmd = @"
|
||||||
. ~/.cargo/env 2>/dev/null || true
|
. ~/.cargo/env 2>/dev/null || true
|
||||||
# mirrored 模式:CARGO_NET_GIT_FETCH_WITH_CLI 让 cargo 用系统 git(走代理)
|
|
||||||
# 但 git clone 到 github 时用直连(git proxy 不影响 https)
|
|
||||||
_saved_http=`$(git config --global http.proxy 2>/dev/null)
|
|
||||||
_saved_https=`$(git config --global https.proxy 2>/dev/null)
|
|
||||||
git config --global --unset http.proxy 2>/dev/null || true
|
|
||||||
git config --global --unset https.proxy 2>/dev/null || true
|
|
||||||
CARGO_NET_GIT_FETCH_WITH_CLI=true cargo install --git https://github.com/rtk-ai/rtk 2>&1 | tail -5
|
CARGO_NET_GIT_FETCH_WITH_CLI=true cargo install --git https://github.com/rtk-ai/rtk 2>&1 | tail -5
|
||||||
[ -n "`$_saved_http" ] && git config --global http.proxy "`$_saved_http" || true
|
|
||||||
[ -n "`$_saved_https" ] && git config --global https.proxy "`$_saved_https" || true
|
|
||||||
"@
|
"@
|
||||||
Invoke-WSL $installRtkCmd -IgnoreError
|
Invoke-WSL $installRtkCmd -IgnoreError
|
||||||
$rtkCheck = Invoke-WSL ". ~/.cargo/env 2>/dev/null; rtk --version 2>/dev/null || echo FAILED" -IgnoreError
|
$rtkCheck = Invoke-WSL ". ~/.cargo/env 2>/dev/null; rtk --version 2>/dev/null || echo FAILED" -IgnoreError
|
||||||
@@ -871,11 +719,6 @@ foreach ($it in $items) {
|
|||||||
Write-Host (" {0,-16} {1}" -f $it[0], $(if ($it[1]) { $it[1] } else { "(未安装)" })) -ForegroundColor White
|
Write-Host (" {0,-16} {1}" -f $it[0], $(if ($it[1]) { $it[1] } else { "(未安装)" })) -ForegroundColor White
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($resolvedProxyPort -gt 0) {
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host " v2rayN 代理 127.0.0.1:$resolvedProxyPort (WSL2 通过 Windows 主机 IP 访问)" -ForegroundColor DarkGray
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " ━━━━ 后续步骤 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
|
Write-Host " ━━━━ 后续步骤 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
|
||||||
Write-Host " 1) 在 Unity 项目中安装 MCP Plugin(每个项目一次):" -ForegroundColor White
|
Write-Host " 1) 在 Unity 项目中安装 MCP Plugin(每个项目一次):" -ForegroundColor White
|
||||||
|
|||||||
Reference in New Issue
Block a user