#Requires -Version 5.1 <# .SYNOPSIS GenPrompt 一键安装向导(Windows)。 .DESCRIPTION 一条命令启动: irm https://zyinfo.pro/genprompt/install.ps1 | iex 选择 DeepSeek Harness 插件或 Claude Code 命令;自动注册体验账号或使用已有 Key;把 Key 写入 %USERPROFILE%\.genprompt\ 下的启动脚本与环境变量。 高级用法(环境变量,便于无人值守): GENPROMPT_INSTALL_CLIENT=dsh|claude GENPROMPT_INSTALL_TOKEN=gp_live_... GENPROMPT_INSTALL_TARGET=D:\code\myapp GENPROMPT_INSTALL_YES=1 GENPROMPT_INSTALL_CONSENT=1 # 无人值守时显式表示已同意隐私政策与数据使用许可;0 或未设置则退出 #> [CmdletBinding()] param( [string]$Client = '', [string]$Token = '', [string]$Target = '', [string]$Profile = 'web', [switch]$Yes, [switch]$DryRun, [switch]$NoShortcut ) $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } catch {} $Base = 'https://zyinfo.pro/genprompt' $Api = 'https://gen.zyinfo.pro' $HomeDir = Join-Path $env:USERPROFILE '.genprompt' $Downloads = Join-Path $HomeDir 'downloads' $AccountFile = Join-Path $HomeDir 'account.txt' $EnvFile = Join-Path $HomeDir 'env.cmd' $DshStart = Join-Path $HomeDir 'start-dsh.cmd' $ClaudeStart = Join-Path $HomeDir 'start-claude.cmd' if (-not $Client -and $env:GENPROMPT_INSTALL_CLIENT) { $Client = $env:GENPROMPT_INSTALL_CLIENT } if (-not $Token -and $env:GENPROMPT_INSTALL_TOKEN) { $Token = $env:GENPROMPT_INSTALL_TOKEN } if (-not $Target -and $env:GENPROMPT_INSTALL_TARGET) { $Target = $env:GENPROMPT_INSTALL_TARGET } if ($env:GENPROMPT_INSTALL_YES -eq '1') { $Yes = $true } if ($env:GENPROMPT_INSTALL_DRYRUN -eq '1') { $DryRun = $true } if ($env:GENPROMPT_INSTALL_NOSHORTCUT -eq '1') { $NoShortcut = $true } function Write-Step([string]$text) { Write-Host "`n== $text" -ForegroundColor Cyan } function Write-Info([string]$text) { Write-Host " $text" } function Write-Warn([string]$text) { Write-Host " ! $text" -ForegroundColor Yellow } function Write-OK([string]$text) { Write-Host " ✓ $text" -ForegroundColor Green } function Ensure-Dir([string]$path) { if (-not (Test-Path $path)) { New-Item -ItemType Directory -Force -Path $path | Out-Null } } # PS 5.1 会把原生命令写到 stderr 的内容当作 NativeCommandError,配合全局 # $ErrorActionPreference='Stop' 会直接中断脚本(npm 的 warn 也算)。原生命令统一走这里: # 合并 stderr 到输出、临时降级 ErrorActionPreference,成败只看退出码。 function Run-Native([string]$Exe, [string[]]$ExeArgs, [switch]$Quiet) { $prev = $ErrorActionPreference $ErrorActionPreference = 'Continue' $lines = New-Object System.Collections.Generic.List[string] try { & $Exe @ExeArgs 2>&1 | ForEach-Object { $line = if ($_ -is [System.Management.Automation.ErrorRecord]) { $_.Exception.Message } else { "$_" } $lines.Add($line) if (-not $Quiet) { Write-Host $line } } return [pscustomobject]@{ ExitCode = $LASTEXITCODE; Output = ($lines -join "`n") } } finally { $ErrorActionPreference = $prev } } function Invoke-Dsh([string[]]$DshArgs, [switch]$Quiet) { return Run-Native 'npx' (@('-y', '@deepseek-ai/dsh') + $DshArgs) -Quiet:$Quiet } # dsh plugin add 只把包装进 profile,不会写 dsh.profile.bundles;不在 bundles 里, # 包自带的 cordis.patch.yml 就不会被应用(插件静默不加载)。这里补上。 function Ensure-ProfileBundle([string]$name) { $pkgPath = Join-Path $env:USERPROFILE ('.dsh\profiles\' + $Profile + '\package.json') if (-not (Test-Path $pkgPath)) { return } try { $obj = Get-Content -LiteralPath $pkgPath -Raw | ConvertFrom-Json $bundles = @() if ($obj.dsh -and $obj.dsh.profile -and $obj.dsh.profile.bundles) { $bundles = @($obj.dsh.profile.bundles) } if ($bundles -contains $name) { return } $bundles += $name if (-not $obj.dsh) { $obj | Add-Member -NotePropertyName dsh -NotePropertyValue ([pscustomobject]@{}) } if (-not $obj.dsh.profile) { $obj.dsh | Add-Member -NotePropertyName profile -NotePropertyValue ([pscustomobject]@{}) } $obj.dsh.profile | Add-Member -NotePropertyName bundles -NotePropertyValue $bundles -Force [System.IO.File]::WriteAllText($pkgPath, ($obj | ConvertTo-Json -Depth 20), (New-Object System.Text.UTF8Encoding($false))) Write-Info "已把 $name 加入 profile bundles" } catch { Write-Warn "写入 profile bundles 失败:$($_.Exception.Message)(可手动在 $pkgPath 的 dsh.profile.bundles 里加 $name)" } } # 安装前必须确认隐私政策与数据使用许可。无人值守(-Yes)时必须显式设置 # GENPROMPT_INSTALL_CONSENT=1;设为 0 或交互时未回答 y 都直接退出。 function Confirm-Consent { if ($env:GENPROMPT_INSTALL_CONSENT -eq '1') { Write-OK '已确认隐私政策与数据使用许可(GENPROMPT_INSTALL_CONSENT=1)' return $true } if ($env:GENPROMPT_INSTALL_CONSENT -eq '0') { Write-Warn '按 GENPROMPT_INSTALL_CONSENT=0 退出安装' return $false } Write-Host '' Write-Host ' 隐私政策与数据使用' -ForegroundColor White Write-Host ' 使用 GenPrompt 服务,即表示您同意《隐私政策》:' Write-Host ' https://zyinfo.pro/genprompt/privacypolicy.html' Write-Host ' 在使用我们的功能或服务时,默认许可:上传与任务相关的文本或数据,用于帮助我们改进产品和服务。' Write-Host '' if ($Yes) { Write-Warn '无人值守安装需设置 GENPROMPT_INSTALL_CONSENT=1 表示同意。' return $false } $answer = Read-Host ' 是否同意?输入 y 继续,其他任意键退出 [y/N]' if ($answer -match '^[Yy]') { Write-OK '已确认同意' return $true } return $false } # 国内网络默认走 npm 镜像(npmmirror)。用户已显式配置 registry 时不覆盖。 function Set-DefaultRegistry { if (-not $env:npm_config_loglevel) { $env:npm_config_loglevel = 'error' } if ($env:npm_config_registry) { return } $configured = '' $npmrc = Join-Path $env:USERPROFILE '.npmrc' if (Test-Path $npmrc) { $line = Get-Content $npmrc -ErrorAction SilentlyContinue | Where-Object { $_ -match '^\s*registry\s*=' } | Select-Object -Last 1 if ($line) { $configured = ($line -split '=', 2)[1].Trim() } } if (-not $configured -or $configured -match 'registry\.npmjs\.org') { $env:npm_config_registry = 'https://registry.npmmirror.com' Write-Info 'npm 源:registry.npmmirror.com(国内镜像)' } } # 用 .NET 直接算 sha256:个别机器上 PS 5.1 的 PSModulePath 混入 PS7 目录时 Get-FileHash 会找不到。 function Get-Sha256([string]$path) { $sha = [System.Security.Cryptography.SHA256]::Create() $stream = [System.IO.File]::OpenRead($path) try { return (($sha.ComputeHash($stream) | ForEach-Object { $_.ToString('x2') }) -join '') } finally { $stream.Dispose(); $sha.Dispose() } } function Get-Manifest { try { return Invoke-RestMethod -Uri "$Base/downloads/manifest.json" -TimeoutSec 20 } catch { return $null } } function Download-Asset([string]$name, $manifest) { Ensure-Dir $Downloads $dest = Join-Path $Downloads $name Write-Info "下载 $name ..." Invoke-WebRequest -Uri "$Base/downloads/$name" -OutFile $dest -UseBasicParsing -TimeoutSec 180 if ($manifest -ne $null) { $entry = $null try { $entry = $manifest.files.PSObject.Properties[$name].Value } catch {} if ($entry -ne $null -and $entry.sha256) { $got = Get-Sha256 $dest if ($got -ne $entry.sha256.ToLower()) { throw "文件校验失败:$name(请重试或联系 youkpan)" } } } return $dest } function Test-GenPromptKey([string]$key) { $headers = @{ Authorization = "Bearer $key" } return Invoke-RestMethod -Uri "$Api/v1/me" -Headers $headers -TimeoutSec 25 } function Register-TrialAccount { try { $r = Invoke-RestMethod -Uri "$Api/v1/register" -Method Post -TimeoutSec 30 ` -ContentType 'application/json' -Body '{"source":"installer"}' return $r } catch { $msg = $_.Exception.Message try { $err = $_.ErrorDetails.Message | ConvertFrom-Json if ($err.error.message) { $msg = $err.error.message } } catch {} Write-Warn "自动注册失败:$msg" if ($msg -match 'SSL|TLS|安全通道|secure channel') { Write-Warn '本机 PowerShell 无法与服务端建立 TLS 连接(Windows 10 常见于服务端未开 TLS 1.2)。' Write-Warn '可先用浏览器打开 https://gen.zyinfo.pro/healthz 确认,或加微信 youkpan 获取 Key。' } return $null } } function Read-SavedKey { if (-not (Test-Path $AccountFile)) { return '' } foreach ($line in Get-Content $AccountFile) { if ($line -match '^api_key:\s*(\S+)') { return $Matches[1] } } return '' } function Resolve-Key { if ($Token) { return $Token.Trim() } $saved = Read-SavedKey if ($saved) { Write-Info ("检测到已保存的 Key:{0}…" -f $saved.Substring(0, [Math]::Min(16, $saved.Length))) if ($Yes) { return $saved } $reuse = Read-Host ' 继续使用这个 Key?[Y/n]' if ($reuse -eq '' -or $reuse -match '^[Yy]') { return $saved } } if ($env:GENPROMPT_TOKEN -and $Yes) { return $env:GENPROMPT_TOKEN.Trim() } if ($Yes) { $r = Register-TrialAccount if ($r -ne $null) { Write-OK ("已自动注册体验账号:{0}(初始 {1} 点)" -f $r.username, $r.balance) return $r.apiKey } return '' } Write-Host '' Write-Host ' API Key(用于调用 GenPrompt 服务)' -ForegroundColor White Write-Host ' 1) 已有 Key,手动输入' Write-Host ' 2) 自动注册体验账号(推荐,立即拿到 Key)' Write-Host ' 3) 稍后配置(先安装,加微信 youkpan 获取 Key)' $choice = Read-Host ' 请选择 [1/2/3]' switch ($choice) { '1' { do { $key = (Read-Host ' 粘贴 API Key(gp_live_ 开头)').Trim() } while (-not $key) return $key } '2' { $r = Register-TrialAccount if ($r -ne $null) { Write-OK ("已注册体验账号:{0}" -f $r.username) Write-Info ("初始体验额度 {0} 点(价值 2 元,约 3~6 次生成,按实际用量扣)" -f $r.balance) Write-Info ("体验期 {0} 天:余额低于 400 点时每天补发 {1} 点(约 5 次生成,不逐日累积)" -f $r.trialDaysLeft, $r.dailyFreeCredits) return $r.apiKey } Write-Warn '可以先完成安装,之后把 Key 填进启动脚本。' return '' } default { Write-Info '已选择稍后配置。安装完成后,把 Key 填入:' Write-Info " $EnvFile" Write-Info '或执行:setx GENPROMPT_TOKEN "gp_live_xxx"' return '' } } } function Ensure-Node { $node = Get-Command node -ErrorAction SilentlyContinue if ($node -eq $null) { throw '未检测到 Node.js。DeepSeek Harness 需要 Node.js 24.9 或更高,请先安装 https://nodejs.org/zh-cn/download ,然后重新运行本命令。' } $v = (& node --version) -replace '^v', '' $major = 0 $minor = 0 [void][int]::TryParse(($v -split '\.')[0], [ref]$major) [void][int]::TryParse(($v -split '\.')[1], [ref]$minor) if ($major -lt 24 -or ($major -eq 24 -and $minor -lt 9)) { throw "Node.js 版本过低:$v(需要 24.9 或更高)" } Write-OK "Node.js v$v" } function Install-Dsh { Write-Step '安装 DeepSeek Harness 插件' Ensure-Node if (-not (Get-Command pnpm -ErrorAction SilentlyContinue)) { throw '未检测到 pnpm(dsh 安装插件依赖它)。请先执行 npm i -g pnpm ,然后重跑本安装命令。' } Write-Info '检查 dsh(首次会下载,约 1~3 分钟)...' $dshCheck = Invoke-Dsh @('--version') if ($dshCheck.ExitCode -ne 0) { throw 'dsh 启动失败。请检查网络、Node.js 版本,或先手动运行:npx -y @deepseek-ai/dsh --version' } if ($DryRun) { Write-Info "[DryRun] 将执行:npx -y @deepseek-ai/dsh plugin --profile $Profile add genprompt@latest" return } # 早期版本把插件解压到本地再用 link: 装,和 npm 包会重复注册同一个插件 id,先清掉。 $null = Invoke-Dsh @('plugin', '--profile', $Profile, 'remove', 'dsh-plugin-genprompt') -Quiet Write-Info '从 npm 安装 genprompt(首次约 10~60 秒)...' $add = Invoke-Dsh @('plugin', '--profile', $Profile, 'add', 'genprompt@latest') # pnpm 主版本变化后,profile 的 node_modules 仍指向旧 store,pnpm add 会拒绝执行 # (ERR_PNPM_UNEXPECTED_STORE)。用当前 pnpm 重新链接依赖后重试一次。 if ($add.ExitCode -ne 0 -and $add.Output -match 'PNPM_UNEXPECTED_STORE|Unexpected store location') { Write-Warn 'profile 的依赖与当前 pnpm 主版本不一致,正在重新链接(pnpm install)...' $profileDir = Join-Path $env:USERPROFILE ('.dsh\profiles\' + $Profile) $prevCi = $env:CI $env:CI = 'true' try { $fix = Run-Native 'pnpm' @('install', '--dir', $profileDir) } finally { if ($null -eq $prevCi) { Remove-Item Env:CI -ErrorAction SilentlyContinue } else { $env:CI = $prevCi } } if ($fix.ExitCode -eq 0) { $add = Invoke-Dsh @('plugin', '--profile', $Profile, 'add', 'genprompt@latest') } } if ($add.ExitCode -ne 0) { throw '插件安装失败(pnpm add genprompt 返回非 0)。可先手动运行:npx -y @deepseek-ai/dsh plugin --profile ' + $Profile + ' add genprompt@latest' } Ensure-ProfileBundle 'genprompt' Write-OK "已从 npm 安装 genprompt 到 profile:$Profile" # 0.1.3 及更早的包把 bundle patch 的 name 写成了源码包名,装得上但启动时 # 报 "entry did not activate",插件实际不加载。装完先看版本。 $installed = Join-Path $env:USERPROFILE (".dsh\profiles\{0}\node_modules\genprompt\package.json" -f $Profile) if (Test-Path $installed) { try { $installedVersion = (Get-Content $installed -Raw | ConvertFrom-Json).version if ([version]($installedVersion -replace '-.*$', '') -lt [version]'0.1.4') { Write-Warn "当前安装的是 genprompt $installedVersion;0.1.4 之前的包在 dsh 启动时不会加载(日志:entry did not activate)。" Write-Warn "请确认 npm registry 已是 0.1.4 后重跑安装,或手动执行:npx -y @deepseek-ai/dsh plugin --profile $Profile add genprompt@latest" } else { Write-OK "genprompt v$installedVersion(bundle patch 与包名匹配)" } } catch { Write-Warn "无法读取已安装版本:$installed" } } } function Install-Claude { Write-Step '安装 Claude Code 命令' $claudeCmd = Get-Command claude -ErrorAction SilentlyContinue if ($claudeCmd -eq $null) { Write-Warn '未检测到 Claude Code(claude 命令)。请先安装:https://docs.anthropic.com/zh-CN/docs/claude-code' if (-not $Yes) { $go = Read-Host ' 仍要继续安装命令模板吗?[y/N]' if ($go -notmatch '^[Yy]') { throw '已取消' } } } $proj = $Target if (-not $proj) { $proj = Read-Host ' 目标项目目录(例如 D:\code\myapp)' } if (-not (Test-Path $proj)) { throw "目录不存在:$proj" } $proj = (Resolve-Path $proj).Path $cmdDest = Join-Path $proj '.claude\commands' $binDest = Join-Path $proj '.genprompt\bin' if ($DryRun) { Write-Info "[DryRun] 将下载 claude-code.zip 并解压到 $(Join-Path $HomeDir 'claude-code')" Write-Info "[DryRun] 将把 commands/*.md 安装到 $cmdDest" Write-Info "[DryRun] 将把 genprompt-cli.exe / genprompt.py 安装到 $binDest" return } $manifest = Get-Manifest $zip = Download-Asset 'claude-code.zip' $manifest $dest = Join-Path $HomeDir 'claude-code' if (Test-Path $dest) { Remove-Item -LiteralPath $dest -Recurse -Force } Ensure-Dir $dest Expand-Archive -LiteralPath $zip -DestinationPath $dest -Force Ensure-Dir $cmdDest Copy-Item (Join-Path $dest 'commands\*.md') $cmdDest -Force Ensure-Dir $binDest Copy-Item (Join-Path $dest 'bin\genprompt-cli.exe') $binDest -Force Copy-Item (Join-Path $dest 'genprompt.py') $binDest -Force Write-OK "命令已安装到 $cmdDest" Write-OK "CLI 已安装到 $binDest" } function Write-Launchers([string]$key) { Ensure-Dir $HomeDir $envContent = "@echo off`r`nset `"GENPROMPT_BASE_URL=$Api`"`r`nset `"GENPROMPT_TOKEN=$key`"`r`n" [System.IO.File]::WriteAllText($EnvFile, $envContent, (New-Object System.Text.UTF8Encoding($false))) $dshContent = @" @echo off call "%USERPROFILE%\.genprompt\env.cmd" echo Starting DeepSeek Harness with GenPrompt... call npx -y @deepseek-ai/dsh --profile $Profile pause "@ [System.IO.File]::WriteAllText($DshStart, $dshContent + "`r`n", (New-Object System.Text.UTF8Encoding($false))) $claudeContent = @" @echo off call "%USERPROFILE%\.genprompt\env.cmd" set "GP_PROJECT=%~1" if not "%GP_PROJECT%"=="" cd /d "%GP_PROJECT%" call claude pause "@ [System.IO.File]::WriteAllText($ClaudeStart, $claudeContent + "`r`n", (New-Object System.Text.UTF8Encoding($false))) } function Write-Shortcuts { if ($NoShortcut) { Write-Info '已跳过桌面快捷方式(-NoShortcut)'; return } try { $desktop = [Environment]::GetFolderPath('Desktop') if ([string]::IsNullOrWhiteSpace($desktop) -or -not (Test-Path $desktop)) { Write-Warn '未找到桌面目录,跳过快捷方式' return } $wsh = New-Object -ComObject WScript.Shell $items = @( @{ Name = 'GenPrompt DSH'; Target = $DshStart; Icon = 'shell32.dll,14' }, @{ Name = 'GenPrompt Claude'; Target = $ClaudeStart; Icon = 'shell32.dll,15' } ) foreach ($item in $items) { $lnkPath = Join-Path $desktop ($item.Name + '.lnk') $lnk = $wsh.CreateShortcut($lnkPath) $lnk.TargetPath = $item.Target $lnk.WorkingDirectory = $env:USERPROFILE $lnk.Description = 'GenPrompt 启动器' $lnk.IconLocation = $item.Icon $lnk.Save() Write-OK "桌面快捷方式:$lnkPath" } } catch { Write-Warn "创建桌面快捷方式失败:$($_.Exception.Message)(可手动把 $DshStart 发送到桌面)" } } function Format-Key([string]$key) { if ([string]::IsNullOrEmpty($key)) { return '(未配置)' } if ($key.Length -le 12) { return $key.Substring(0, [Math]::Min(4, $key.Length)) + '****' } return $key.Substring(0, 10) + '…' + $key.Substring($key.Length - 4) } function Save-Account([string]$key, $me) { Ensure-Dir $HomeDir $lines = @( '# GenPrompt 账号信息(明文,注意保管;可手动编辑)', ("generated: {0}" -f (Get-Date -Format 'yyyy-MM-dd HH:mm:ss')), ("base_url: {0}" -f $Api), ("username: {0}" -f $(if ($me -ne $null) { $me.username } else { '' })), ("api_key: {0}" -f $key), ("balance: {0}" -f $(if ($me -ne $null) { $me.balance } else { '-' })), ("expires_at: {0}" -f $(if ($me -ne $null) { $me.expiresAt } else { '-' })), ("trial_days_left: {0}" -f $(if ($me -ne $null) { $me.trialDaysLeft } else { '-' })), '', '# 启动脚本', ("# {0}" -f $DshStart), ("# {0}" -f $ClaudeStart), '', '# 充值:微信 youkpan' ) [System.IO.File]::WriteAllLines($AccountFile, $lines, (New-Object System.Text.UTF8Encoding($false))) } function Set-UserEnv([string]$name, [string]$value) { try { & setx $name $value | Out-Null } catch { Write-Warn "写入用户环境变量失败:$name(可手动设置)" } Set-Item -Path ("Env:" + $name) -Value $value -ErrorAction SilentlyContinue } function Show-Summary([string]$client, [string]$key, $me) { Write-Host '' Write-Host '================ 安装完成 ================' -ForegroundColor Green if ($client -eq 'dsh') { Write-Host ' 客户端:DeepSeek Harness 插件' Write-Host " 启动:$DshStart" Write-Host (" 或手动:npx -y @deepseek-ai/dsh --profile {0}" -f $Profile) Write-Host ' 会话里输入 /gp-ping 自检,再用 /genprompt <任务>' Write-Host ' 若启动日志出现 entry did not activate,说明插件版本过旧,重跑安装命令。' } else { Write-Host ' 客户端:Claude Code 命令' Write-Host " 启动:$ClaudeStart 或先运行 $EnvFile" Write-Host ' 在目标项目里使用 /genprompt /next /gcs /ffl' } if (-not $DryRun -and -not $NoShortcut) { Write-Host ' 桌面快捷方式:GenPrompt DSH / GenPrompt Claude(双击即可启动)' } if ($key) { Write-Host '' $expire = '-' if ($me -ne $null) { if ($null -ne $me.daysLeft) { $expire = ("{0} 天" -f $me.daysLeft) } elseif ($me.expiresAt) { $expire = ("至 {0}" -f $me.expiresAt) } } Write-Host (" 账号:{0} 余额:{1} 点 有效期:{2}" -f $(if ($me -ne $null) { $me.username } else { '-' }), $(if ($me -ne $null) { $me.balance } else { '-' }), $expire) if ($me -ne $null -and $me.trialDaysLeft -gt 0) { Write-Host (" 体验期:{0} 天,余额低于 400 点时每天补发 {1} 点" -f $me.trialDaysLeft, $me.dailyFreeCredits) } Write-Host (" API Key:{0}(完整值见账号信息文件)" -f (Format-Key $key)) Write-Host " 账号信息:$AccountFile(含明文 Key,可手动编辑)" Write-Host " 环境文件:$EnvFile" } else { Write-Host '' Write-Host ' 尚未配置 API Key。' -ForegroundColor Yellow Write-Host " 获取 Key 后,编辑 $EnvFile 里的 GENPROMPT_TOKEN,或执行:" Write-Host ' setx GENPROMPT_TOKEN "gp_live_xxx"' } Write-Host '' Write-Host ' 隐私:默认只把项目关键文件(AGENTS.md/README.md 等)摘要与最近对话发往' -ForegroundColor Gray Write-Host ' 服务端;敏感项目可在插件配置里把 privacy 设为 strict(仅发路径)。' -ForegroundColor Gray Write-Host ' 在使用我们的功能或服务时,这些任务相关文本会按隐私政策用于改进产品和服务:' -ForegroundColor Gray Write-Host ' https://zyinfo.pro/genprompt/privacypolicy.html' -ForegroundColor Gray Write-Host '' Write-Host ' 充值 / 咨询:微信 youkpan' -ForegroundColor White Write-Host ' 文档:https://zyinfo.pro/genprompt/' Write-Host '==========================================' -ForegroundColor Green } Write-Host '' Write-Host ' GenPrompt 安装向导' -ForegroundColor White Write-Host " 服务:$Api" -ForegroundColor Gray Set-DefaultRegistry $Client = $Client.Trim().ToLower() if ($Client -ne 'dsh' -and $Client -ne 'claude') { Write-Host '' Write-Host ' 请选择要安装的客户端:' Write-Host ' 1) DeepSeek Harness 插件(Web 界面,推荐)' Write-Host ' 2) Claude Code 命令' Write-Host ' 0) 退出' $choice = Read-Host ' 输入 1 / 2 / 0' switch ($choice) { '1' { $Client = 'dsh' } '2' { $Client = 'claude' } default { Write-Host ' 已退出。'; return } } } if (-not $DryRun -and -not (Confirm-Consent)) { Write-Host '' Write-Host ' 未同意隐私政策与数据使用许可,已退出安装。' -ForegroundColor Yellow return } $key = Resolve-Key $me = $null if ($key) { Write-Info '校验 API Key ...' try { $me = Test-GenPromptKey $key Write-OK ("Key 有效:{0},余额 {1} 点" -f $me.username, $me.balance) } catch { Write-Warn "Key 校验失败:$($_.Exception.Message)" Write-Warn '安装会继续,但需要稍后修正 Key。' } } if ($Client -eq 'dsh') { Install-Dsh } else { Install-Claude } if (-not $DryRun) { Write-Step '写入启动脚本与账号信息' Write-Launchers $key if ($key) { Save-Account $key $me Set-UserEnv 'GENPROMPT_TOKEN' $key Set-UserEnv 'GENPROMPT_BASE_URL' $Api Write-OK "启动脚本:$DshStart / $ClaudeStart" Write-OK "账号信息:$AccountFile" } else { Write-Info "已创建空模板:$EnvFile(填入 Key 后即可使用)" } Write-Step '创建桌面快捷方式' Write-Shortcuts } Show-Summary $Client $key $me