From 25cf34a0eb2336c315fb498fea0db95f5ca09276 Mon Sep 17 00:00:00 2001 From: bookworm-admin Date: Wed, 10 Jun 2026 17:06:39 +0800 Subject: [PATCH] feat(v3.3.0): Phase 5.6 BookwormPub MCP auto-deploy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add Phase 5.6: clone bookworm-pub → npm install → tsc build - Fail-open: deployment failure degrades gracefully, never blocks setup - Add bookworm-pub to inline MCP fallback list (方案 B, 22→23) - Add $PubUrl/$PubDir path constants - Bump version 3.2.0 → 3.3.0 - Prereq: bookworm/bookworm-pub repo must exist on Gitea Co-Authored-By: Claude Opus 4.6 (1M context) --- auto-setup.ps1 | 55 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/auto-setup.ps1 b/auto-setup.ps1 index 375cc22..a92550b 100644 --- a/auto-setup.ps1 +++ b/auto-setup.ps1 @@ -48,7 +48,7 @@ trap { } # ─── 版本号 (每次更新递增, build.ps1 自动读取) ────── -$BWVersion = "3.2.0" # feat: Phase 8 OTA 自动更新基础设施 (pubkey/DPAPI凭证/bw-ota.ps1) +$BWVersion = "3.3.0" # feat: Phase 5.6 BookwormPub MCP clone+build + inject-mcp v3 # DryRun 模式日志标记 if ($DryRun) { $global:BWDryRun = $DryRun } else { $global:BWDryRun = $null } @@ -78,6 +78,8 @@ $ClaudeDir = Join-Path $env:USERPROFILE ".claude" $BackupDir = Join-Path $env:USERPROFILE ".claude.bw-backup" $GitUrl = "https://code.letcareme.com/bookworm/bookworm-smart-assistant.git" # v3.2: 统一配置仓库 (public) $BootUrl = "https://code.letcareme.com/bookworm/bookworm-boot.git" +$PubUrl = "https://code.letcareme.com/bookworm/bookworm-pub.git" +$PubDir = Join-Path $ClaudeDir "bookworm-pub" $BootDir = Join-Path $ScriptDir "bookworm-boot" $SecretsEnc = Join-Path $BootDir "secrets.enc" $TOTAL_PHASES = 8 @@ -2127,6 +2129,8 @@ if (Test-Path $templateFile) { 'S["windows-mcp"]={command:"uvx",args:["--python","3.13","windows-mcp"],type:"stdio"};' 'S.atlassian={command:"uvx",args:["mcp-atlassian"],type:"stdio"};' 'S["computer-control-mcp"]={command:"uvx",args:["computer-control-mcp@latest"],type:"stdio"};' + 'var H2=process.env.USERPROFILE||process.env.HOME||"";' + 'S["bookworm-pub"]={command:"node",args:[require("path").join(H2,".claude","bookworm-pub","dist","mcp","entry.js")],type:"stdio"};' 'd.mcpServers=S;' 'fs.writeFileSync(f,JSON.stringify(d,null,2));' 'console.log("OK: "+Object.keys(S).length+" MCP servers (fallback)");' @@ -2282,6 +2286,55 @@ $sentinelEnd try { "[$([DateTime]::Now.ToString('s'))] PHASE_5_5_FAIL $($_.Exception.Message) @ $($_.InvocationInfo.ScriptLineNumber)" | Out-File -FilePath $global:BWCrashLog -Append -Encoding UTF8 -EA SilentlyContinue } catch {} } +# ======================================================================== +# Phase 5.6: BookwormPub MCP 部署 (v3.3.0 新增) +# ======================================================================== +# 目标: 克隆 BookwormPub 到 ~/.claude/bookworm-pub/, 编译 TypeScript, 供 MCP 调用 +# 依赖: Node.js + npm (Phase 1 已保证), git (Phase 1 已保证) +# 失败策略: 降级不阻断 (BookwormPub 是增强功能, 不影响核心 Bookworm 使用) +Log-Info "[5.6/$TOTAL_PHASES] BookwormPub MCP 部署" +Update-Progress-SubStatus "部署 BookwormPub 发布系统..." + +try { + if (Test-Path (Join-Path $PubDir ".git")) { + Log-Info "BookwormPub 已存在, git pull 更新..." + try { + $pullOut = & git -C $PubDir pull --ff-only 2>&1 + Log-OK "BookwormPub pull: $($pullOut | Select-Object -First 1)" + } catch { + Log-Warn "BookwormPub pull 失败 (保持现有版本): $_" + } + } else { + Log-Info "克隆 BookwormPub..." + $cloneOut = & git clone --depth 1 $PubUrl $PubDir 2>&1 + if ($LASTEXITCODE -ne 0) { throw "git clone 失败: $cloneOut" } + Log-OK "BookwormPub 克隆完成" + } + + if (Test-Path $PubDir) { + Log-Info "安装 BookwormPub 依赖..." + $npmCmd = if (Get-Command pnpm -ErrorAction SilentlyContinue) { "pnpm" } else { "npm" } + $installOut = & $npmCmd install --prefix $PubDir 2>&1 + if ($LASTEXITCODE -ne 0) { Log-Warn "BookwormPub 依赖安装可能不完整: exit=$LASTEXITCODE" } + else { Log-OK "BookwormPub 依赖安装完成 ($npmCmd)" } + + Log-Info "编译 BookwormPub TypeScript..." + $buildOut = & npx.cmd --yes tsc --project (Join-Path $PubDir "tsconfig.json") 2>&1 + if ($LASTEXITCODE -ne 0) { Log-Warn "BookwormPub 编译告警 (可能仍可用): exit=$LASTEXITCODE" } + else { Log-OK "BookwormPub 编译完成" } + + $entryFile = Join-Path $PubDir "dist\mcp\entry.js" + if (Test-Path $entryFile) { + Log-OK "BookwormPub MCP 入口就绪: $entryFile" + } else { + Log-Warn "BookwormPub MCP 入口未生成, MCP 服务将不可用" + } + } +} catch { + Log-Warn "Phase 5.6 BookwormPub 部署异常 (不影响主功能): $($_.Exception.Message)" + try { "[$([DateTime]::Now.ToString('s'))] PHASE_5_6_FAIL $($_.Exception.Message) @ $($_.InvocationInfo.ScriptLineNumber)" | Out-File -FilePath $global:BWCrashLog -Append -Encoding UTF8 -EA SilentlyContinue } catch {} +} + # ======================================================================== # Phase 6: MCP 验证 + 自动安装 # ========================================================================