From 1aa2c3e6ef7612c4e3a98b747c474af499575f33 Mon Sep 17 00:00:00 2001 From: bookworm Date: Sat, 18 Apr 2026 23:04:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20v3.0.0-beta=20-=20=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=88=B0=20portable-config=20=E8=84=B1=E6=95=8F=E4=BB=93?= =?UTF-8?q?=E5=BA=93=20+=20Phase=204.5=20License=20=E6=BF=80=E6=B4=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto-setup.ps1 | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/auto-setup.ps1 b/auto-setup.ps1 index 333efc7..f13147d 100644 --- a/auto-setup.ps1 +++ b/auto-setup.ps1 @@ -16,7 +16,7 @@ param( $ErrorActionPreference = "Stop" # ─── 版本号 (每次更新递增, build.ps1 自动读取) ────── -$BWVersion = "2.3.1" +$BWVersion = "3.0.0-beta" # ─── B4: 单实例保护 (防止双击两次导致竞态) ───────── $mutexCreated = $false @@ -40,7 +40,7 @@ $ScriptDir = if ($PSScriptRoot) { } $ClaudeDir = Join-Path $env:USERPROFILE ".claude" $BackupDir = Join-Path $env:USERPROFILE ".claude.bw-backup" -$GitUrl = "https://code.letcareme.com/bookworm/bookworm-config.git" +$GitUrl = "https://code.letcareme.com/bookworm/bookworm-portable-config.git" # v3.0: 脱敏分发仓库 $BootUrl = "https://code.letcareme.com/bookworm/bookworm-boot.git" $BootDir = Join-Path $ScriptDir "bookworm-boot" $SecretsEnc = Join-Path $BootDir "secrets.enc" @@ -1261,6 +1261,41 @@ else { } } # end if (-not $secretsDecrypted) +# ======================================================================== +# Phase 4.5: License 激活 (v3.0 新增, 可选) +# ======================================================================== +# 检查 ~/.claude/.bw-token 是否存在且未过期; 不存在则引导激活 +$bwTokenFile = Join-Path $ClaudeDir ".bw-token" +$bwActivateJs = Join-Path $ClaudeDir "lib\activate.js" +$needLicenseActivate = $true +if (Test-Path $bwTokenFile) { + try { + $tok = Get-Content $bwTokenFile -Raw | ConvertFrom-Json + if ($tok.expires_at -gt ((New-TimeSpan -Start (Get-Date "1970-01-01") -End (Get-Date).ToUniversalTime()).TotalMilliseconds + 86400000)) { + Log-OK "License token 有效 (UUID: $($tok.license_uuid))" + $needLicenseActivate = $false + } + } catch {} +} +if ($needLicenseActivate -and (Test-Path $bwActivateJs) -and (Test-Cmd "node")) { + $activateChoice = Show-MsgBox "是否激活 Bookworm License (用于加载 Skill 专家)?`n`n如果有 License Key (BW-XXXX-XXXX-...), 点是`n如果没有, 点否 (可后续用 change-key.bat 激活)" "License 激活" "YesNo" "Information" + if ($activateChoice -eq "Yes") { + $licKey = Show-ApiKeyDialog 1 1 "" # 复用现有对话框 + if ($licKey) { + try { + $licKey | & node $bwActivateJs 2>&1 | Out-Null + if ($LASTEXITCODE -eq 0) { + Log-OK "License 激活成功" + } else { + Log-Warn "License 激活失败 (可用 change-key.bat 重试)" + } + } catch { Log-Warn "License 激活异常: $_" } + } + } else { + Log-Info "已跳过 License 激活" + } +} + # ======================================================================== # Phase 5: 配置渲染 # ========================================================================