Files
xgt/scripts/install_opencode_supermemory.ps1
huacracker 2640aeb97c feat: 更新项目配置及业务模块
- 添加热部署依赖(spring-boot-devtools)
- 更新数据库配置(192.168.1.203/oademo)
- 添加新业务模块(TpClientFund, TpDeptCost, TpDeptReport)
- 更新MySQL驱动版本到8.4.0
- 完善工作流模块及其他业务代码
2026-03-07 14:29:03 +08:00

89 lines
3.0 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<#
OpenCode 插件安装脚本install_opencode_supermemory.ps1
功能:在 Windows 环境下,使用本地 bun.exe 安装 opencode-supermemory 插件,支持指定版本或 latest并可注入 SUPERMEMORY_API_KEY。
用法示例:
- 指定版本安装powershell -ExecutionPolicy Bypass -File scripts\install_opencode_supermemory.ps1 -Version 3.3.8 -ApiKey "sm_你的密钥"
- 安装最新版本powershell -ExecutionPolicy Bypass -File scripts\install_opencode_supermemory.ps1 -Version latest
#>
param(
[ValidateSet("latest","3.3.8")]
[string]$Version = "3.3.8",
[string]$BunExePath = "C:\\Soft\\bun-windows-x64\\bun.exe",
[string]$ApiKey
)
$ErrorActionPreference = "Stop"
Write-Host "---------- OpenCode: Install opencode-supermemory ----------"
if (-Not (Test-Path $BunExePath)) {
Write-Error "Bun 可执行文件未找到:$BunExePath"
Write-Host "请确保 bun.exe 位于该路径,或调整参数 -BunExePath。"
exit 1
}
# 1) 将 Bun 目录加入用户 PATH确保会话后续可用
$bunDir = [System.IO.Path]::GetDirectoryName($BunExePath)
try {
$currentPath = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::User)
$paths = @($currentPath -split ";" | Where-Object { $_ -and $_ -ne $null })
if (-Not ($paths -contains $bunDir)) {
$newPath = $currentPath + ";" + $bunDir
[Environment]::SetEnvironmentVariable("PATH", $newPath, [EnvironmentVariableTarget]::User)
Write-Host "PATH 已更新,已包含 Bun 目录:$bunDir (用户作用域)"
} else {
Write-Host "PATH 已包含 Bun 目录:$bunDir"
}
} catch {
Write-Warning "无法更新 PATH$($_.Exception.Message)"
}
# 2) 验证 bun 与 bunx 是否可用
try {
$bunVer = & "${BunExePath}" --version
Write-Host "Bun 版本:$bunVer"
$bunxPath = Join-Path $bunDir "bunx.exe"
if (Test-Path $bunxPath) {
$bunxVer = & "$bunxPath" --version
Write-Host "Bunx 版本:$bunxVer"
} else {
Write-Host "未找到 bunx.exe将使用 bun.exe 进行安装。"
}
} catch {
Write-Error "无法验证 Bun$($_.Exception.Message)"
exit 1
}
# 3) 安装插件
if ($Version -eq "latest") {
$installTarget = "opencode-supermemory@latest install"
} else {
$installTarget = "opencode-supermemory@${Version} install"
}
try {
if (Test-Path (Join-Path $bunDir "bunx.exe")) {
& (Join-Path $bunDir "bunx.exe") $installTarget
} else {
& (Join-Path $bunDir "bun.exe") $installTarget
}
} catch {
Write-Error "安装插件失败: $($_.Exception.Message)"
exit 1
}
# 4) 设置 SUPERMEMORY_API_KEY若提供
if (-not [string]::IsNullOrEmpty($ApiKey)) {
[Environment]::SetEnvironmentVariable("SUPERMEMORY_API_KEY", $ApiKey, [EnvironmentVariableTarget]::User)
Write-Host "SUPERMEMORY_API_KEY 已设置(用户级变量)"
} elseif ($Env:SUPERMEMORY_API_KEY) {
Write-Host "检测到已有 SUPERMEMORY_API_KEY 环境变量。"
} else {
Write-Host "未提供 SUPERMEMORY_API_KEY。若要使用云记忆请提供密钥。"
}
Write-Host "安装流程完成。请重新打开终端以刷新 PATH 与环境变量。"
Exit 0