[aide] finish: 任务完成

新增环境安装 Commands:
- /aide:install-win - Windows 环境安装命令
- /aide:install-linux - Linux 环境安装命令

新增离线安装程序:
- aide-program/offline-installer/windows/
- aide-program/offline-installer/linux/

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-17 05:22:38 +08:00
parent bd723629c5
commit ba70fafa15
23 changed files with 3610 additions and 376 deletions

View File

@@ -0,0 +1,167 @@
# Aide 离线安装程序 (Windows)
本目录包含 Aide 工具的 Windows 离线安装程序,用于在无网络或受限网络环境下安装所需的环境依赖。
## 概述
此离线安装程序可以安装以下组件:
- **uv** - 高性能 Python 包管理器
- **Java JRE 17** - PlantUML 运行依赖
- **Python 3.11** - Aide 运行时(通过 uv 安装,需要网络)
## 使用步骤
### 第 1 步:下载资源文件
参考 `resources.json` 中的下载链接,下载以下文件到本目录:
| 文件名 | 说明 | 下载链接 |
|--------|------|----------|
| `uv-x86_64-pc-windows-msvc.zip` | uv 安装包 | [GitHub Releases](https://github.com/astral-sh/uv/releases/latest) |
| `OpenJDK17U-jre_x64_windows_hotspot_17.0.9_9.zip` | Java JRE 17 | [Adoptium](https://adoptium.net/temurin/releases/?os=windows&arch=x64&package=jre&version=17) |
> **注意**Java JRE 的版本号可能会更新,请下载最新的 JRE 17 版本,并相应修改 `resources.json` 中的文件名。
### 第 2 步:运行安装脚本
1. 以管理员身份打开 PowerShell
2. 导航到本目录
3. 运行安装脚本:
```powershell
# 设置执行策略(如需要)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# 运行安装脚本
.\install.ps1
```
### 第 3 步:配置 aide PATH可选
如果要将 aide 添加到系统 PATH运行时指定 aide-program 路径:
```powershell
.\install.ps1 -AideProgramPath "C:\path\to\aide-program"
```
### 第 4 步:安装 Python
由于 Python 需要通过 uv 下载,离线安装无法自动完成。请在有网络的环境下运行:
```powershell
uv python install 3.11
```
> **提示**:如果需要完全离线安装,可以在有网络的机器上提前运行此命令,然后复制 `~/.local/share/uv/python/` 目录到目标机器。
### 第 5 步:验证安装
重启终端后运行:
```powershell
# 检查各组件版本
uv --version
java -version
# 验证 aide 环境
aide env ensure --runtime
```
## 命令行选项
```powershell
.\install.ps1 [-AideProgramPath <path>] [-Silent] [-SkipJava] [-SkipUv]
```
| 选项 | 说明 |
|------|------|
| `-AideProgramPath` | 指定 aide-program 目录路径,自动添加到 PATH |
| `-Silent` | 静默安装模式,不显示交互提示 |
| `-SkipJava` | 跳过 Java JRE 安装 |
| `-SkipUv` | 跳过 uv 安装 |
## 示例
### 交互式安装
```powershell
.\install.ps1
```
### 静默安装
```powershell
.\install.ps1 -Silent
```
### 完整安装(包含 aide PATH 配置)
```powershell
.\install.ps1 -AideProgramPath "C:\projects\ccoptimize\aide-program"
```
### 仅安装 uv
```powershell
.\install.ps1 -SkipJava
```
## 安装位置
| 组件 | 安装位置 |
|------|----------|
| uv | `%USERPROFILE%\.local\bin\` |
| Java JRE | `%LOCALAPPDATA%\Programs\Java\jre-17\` |
| Python | `%USERPROFILE%\.local\share\uv\python\` (通过 uv 管理) |
## 环境变量
安装程序会自动配置以下环境变量:
| 变量 | 值 |
|------|-----|
| `PATH` | 添加 uv 和 Java bin 目录 |
| `JAVA_HOME` | Java JRE 安装路径 |
## 故障排除
### Q: 运行脚本时提示"无法加载文件,因为在此系统上禁止运行脚本"
A: 运行以下命令修改执行策略:
```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```
### Q: 安装后命令找不到?
A: 重启 PowerShell 或手动刷新环境变量:
```powershell
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","User") + ";" + [System.Environment]::GetEnvironmentVariable("Path","Machine")
```
### Q: Java 安装后 java 命令仍然找不到?
A: 检查 JAVA_HOME 和 PATH 是否正确设置:
```powershell
$env:JAVA_HOME
$env:Path -split ";" | Where-Object { $_ -like "*java*" }
```
### Q: 如何完全卸载?
A: 删除以下目录和环境变量:
1. 删除 `%USERPROFILE%\.local\bin\uv.exe`
2. 删除 `%LOCALAPPDATA%\Programs\Java\jre-17\`
3. 从用户 PATH 中移除相关路径
4. 删除 JAVA_HOME 环境变量
## 文件清单
```
windows/
├── README.md # 本说明文件
├── resources.json # 资源清单(含下载链接)
├── install.ps1 # 主安装脚本
├── uv-x86_64-pc-windows-msvc.zip # [需下载]
└── OpenJDK17U-jre_x64_windows_*.zip # [需下载]
```

View File

@@ -0,0 +1,405 @@
#Requires -Version 5.1
<#
.SYNOPSIS
Aide 离线环境安装脚本 (Windows)
.DESCRIPTION
此脚本从本地资源文件安装 aide 工具所需的环境依赖:
- uv (Python 包管理器)
- Java JRE (用于 PlantUML)
运行前请确保已下载所有必需的资源文件到脚本所在目录。
参见 resources.json 获取资源下载链接。
.PARAMETER AideProgramPath
aide-program 目录的路径(可选,用于配置 PATH
.PARAMETER Silent
静默安装模式,不显示交互提示
.PARAMETER SkipJava
跳过 Java 安装
.PARAMETER SkipUv
跳过 uv 安装
.EXAMPLE
.\install.ps1
交互式安装
.EXAMPLE
.\install.ps1 -Silent -AideProgramPath "C:\aide\aide-program"
静默安装并配置 aide PATH
.NOTES
作者: Aide Team
版本: 1.0.0
要求: Windows 10/11, PowerShell 5.1+
#>
param(
[string]$AideProgramPath,
[switch]$Silent,
[switch]$SkipJava,
[switch]$SkipUv
)
# ============================================================
# 配置
# ============================================================
$ErrorActionPreference = "Stop"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
# 资源文件名
$UvZipFile = "uv-x86_64-pc-windows-msvc.zip"
$JavaZipFile = "OpenJDK17U-jre_x64_windows_hotspot_17.0.9_9.zip"
# 安装路径
$UvInstallPath = "$env:USERPROFILE\.local\bin"
$JavaInstallPath = "$env:LOCALAPPDATA\Programs\Java\jre-17"
# ============================================================
# 辅助函数
# ============================================================
function Write-Success {
param([string]$Message)
Write-Host "$Message" -ForegroundColor Green
}
function Write-Warning {
param([string]$Message)
Write-Host "$Message" -ForegroundColor Yellow
}
function Write-Error {
param([string]$Message)
Write-Host "$Message" -ForegroundColor Red
}
function Write-Info {
param([string]$Message)
Write-Host "$Message" -ForegroundColor Cyan
}
function Write-Header {
param([string]$Message)
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " $Message" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
}
function Test-Command {
param([string]$Command)
$null -ne (Get-Command $Command -ErrorAction SilentlyContinue)
}
function Update-PathEnvironment {
# 刷新当前会话的 PATH
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "User") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "Machine")
}
function Add-ToUserPath {
param([string]$PathToAdd)
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($currentPath -notlike "*$PathToAdd*") {
[Environment]::SetEnvironmentVariable("Path", "$currentPath;$PathToAdd", "User")
Update-PathEnvironment
return $true
}
return $false
}
function Test-FileChecksum {
param(
[string]$FilePath,
[string]$ExpectedHash,
[string]$Algorithm = "SHA256"
)
if ([string]::IsNullOrWhiteSpace($ExpectedHash) -or $ExpectedHash -eq "请从发布页面获取") {
Write-Warning "跳过校验和验证(未提供预期值)"
return $true
}
$actualHash = (Get-FileHash -Path $FilePath -Algorithm $Algorithm).Hash
return $actualHash -eq $ExpectedHash
}
function Expand-ArchiveToPath {
param(
[string]$ZipPath,
[string]$DestinationPath,
[switch]$CreateIfNotExists
)
if ($CreateIfNotExists -and -not (Test-Path $DestinationPath)) {
New-Item -ItemType Directory -Path $DestinationPath -Force | Out-Null
}
Expand-Archive -Path $ZipPath -DestinationPath $DestinationPath -Force
}
# ============================================================
# 主逻辑
# ============================================================
Write-Header "Aide 离线安装程序 (Windows)"
# 检查资源文件
Write-Info "检查资源文件..."
$missingResources = @()
if (-not $SkipUv) {
$uvZipPath = Join-Path $ScriptDir $UvZipFile
if (-not (Test-Path $uvZipPath)) {
$missingResources += $UvZipFile
}
}
if (-not $SkipJava) {
$javaZipPath = Join-Path $ScriptDir $JavaZipFile
if (-not (Test-Path $javaZipPath)) {
$missingResources += $JavaZipFile
}
}
if ($missingResources.Count -gt 0) {
Write-Error "缺少以下资源文件:"
foreach ($resource in $missingResources) {
Write-Host " - $resource" -ForegroundColor Red
}
Write-Host ""
Write-Info "请参考 resources.json 下载所需文件后重新运行此脚本"
exit 1
}
Write-Success "所有资源文件已就绪"
# 确认安装
if (-not $Silent) {
Write-Host ""
Write-Info "将要安装以下组件:"
if (-not $SkipUv) {
Write-Host " - uv (Python 包管理器) -> $UvInstallPath"
}
if (-not $SkipJava) {
Write-Host " - Java JRE 17 -> $JavaInstallPath"
}
Write-Host ""
$confirm = Read-Host "是否继续? (Y/n)"
if ($confirm -eq "n" -or $confirm -eq "N") {
Write-Info "安装已取消"
exit 0
}
}
# ============================================================
# 安装 uv
# ============================================================
if (-not $SkipUv) {
Write-Host ""
Write-Info "安装 uv..."
# 检查是否已安装
if (Test-Command "uv") {
$uvVersion = uv --version 2>&1
Write-Success "uv 已安装: $uvVersion"
} else {
$uvZipPath = Join-Path $ScriptDir $UvZipFile
# 创建安装目录
if (-not (Test-Path $UvInstallPath)) {
New-Item -ItemType Directory -Path $UvInstallPath -Force | Out-Null
Write-Info "创建目录: $UvInstallPath"
}
# 解压
Write-Info "解压 uv..."
$tempDir = Join-Path $env:TEMP "uv-extract-$(Get-Random)"
Expand-ArchiveToPath -ZipPath $uvZipPath -DestinationPath $tempDir -CreateIfNotExists
# 复制 uv.exe
$uvExe = Get-ChildItem -Path $tempDir -Filter "uv.exe" -Recurse | Select-Object -First 1
if ($uvExe) {
Copy-Item -Path $uvExe.FullName -Destination $UvInstallPath -Force
# 同时复制 uvx.exe (如果存在)
$uvxExe = Get-ChildItem -Path $tempDir -Filter "uvx.exe" -Recurse | Select-Object -First 1
if ($uvxExe) {
Copy-Item -Path $uvxExe.FullName -Destination $UvInstallPath -Force
}
Write-Success "uv 已解压到 $UvInstallPath"
} else {
Write-Error "在压缩包中找不到 uv.exe"
exit 1
}
# 清理临时目录
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
# 添加到 PATH
if (Add-ToUserPath $UvInstallPath) {
Write-Success "已添加 $UvInstallPath 到 PATH"
} else {
Write-Info "uv 路径已在 PATH 中"
}
# 验证
Update-PathEnvironment
if (Test-Command "uv") {
Write-Success "uv 安装成功"
} else {
Write-Warning "uv 安装完成,但需要重启终端后才能使用"
}
}
}
# ============================================================
# 安装 Java JRE
# ============================================================
if (-not $SkipJava) {
Write-Host ""
Write-Info "安装 Java JRE..."
# 检查是否已安装
if (Test-Command "java") {
$javaVersion = java -version 2>&1 | Select-Object -First 1
Write-Success "Java 已安装: $javaVersion"
} else {
$javaZipPath = Join-Path $ScriptDir $JavaZipFile
# 创建安装目录的父目录
$javaParentDir = Split-Path $JavaInstallPath -Parent
if (-not (Test-Path $javaParentDir)) {
New-Item -ItemType Directory -Path $javaParentDir -Force | Out-Null
}
# 解压
Write-Info "解压 Java JRE..."
$tempDir = Join-Path $env:TEMP "java-extract-$(Get-Random)"
Expand-ArchiveToPath -ZipPath $javaZipPath -DestinationPath $tempDir -CreateIfNotExists
# 找到解压后的 JRE 目录
$jreDir = Get-ChildItem -Path $tempDir -Directory | Where-Object { $_.Name -like "jdk-*-jre" -or $_.Name -like "jre*" } | Select-Object -First 1
if (-not $jreDir) {
$jreDir = Get-ChildItem -Path $tempDir -Directory | Select-Object -First 1
}
if ($jreDir) {
# 移动到目标位置
if (Test-Path $JavaInstallPath) {
Remove-Item -Path $JavaInstallPath -Recurse -Force
}
Move-Item -Path $jreDir.FullName -Destination $JavaInstallPath -Force
Write-Success "Java JRE 已安装到 $JavaInstallPath"
} else {
Write-Error "在压缩包中找不到 JRE 目录"
exit 1
}
# 清理临时目录
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
# 配置 JAVA_HOME
[Environment]::SetEnvironmentVariable("JAVA_HOME", $JavaInstallPath, "User")
$env:JAVA_HOME = $JavaInstallPath
Write-Info "已设置 JAVA_HOME = $JavaInstallPath"
# 添加到 PATH
$javaBinPath = Join-Path $JavaInstallPath "bin"
if (Add-ToUserPath $javaBinPath) {
Write-Success "已添加 Java bin 到 PATH"
} else {
Write-Info "Java bin 路径已在 PATH 中"
}
# 验证
Update-PathEnvironment
if (Test-Command "java") {
$javaVersion = java -version 2>&1 | Select-Object -First 1
Write-Success "Java 安装成功: $javaVersion"
} else {
Write-Warning "Java 安装完成,但需要重启终端后才能使用"
}
}
}
# ============================================================
# 安装 Python (通过 uv)
# ============================================================
Write-Host ""
Write-Info "配置 Python..."
if (Test-Command "uv") {
$pythonList = uv python list 2>&1
if ($pythonList -match "3\.\d+") {
Write-Success "Python 已通过 uv 安装"
} else {
Write-Info "通过 uv 安装 Python 3.11..."
try {
uv python install 3.11
Write-Success "Python 3.11 安装成功"
} catch {
Write-Warning "Python 安装需要网络连接,请稍后手动运行: uv python install 3.11"
}
}
} else {
Write-Warning "uv 不可用,无法安装 Python。请重启终端后运行: uv python install 3.11"
}
# ============================================================
# 配置 aide PATH
# ============================================================
if ($AideProgramPath) {
Write-Host ""
Write-Info "配置 aide PATH..."
$aideBinPath = Join-Path $AideProgramPath "bin"
if (Test-Path $aideBinPath) {
if (Add-ToUserPath $aideBinPath) {
Write-Success "已添加 aide 到 PATH: $aideBinPath"
} else {
Write-Info "aide 已在 PATH 中"
}
} else {
Write-Warning "aide-program/bin 目录不存在: $aideBinPath"
}
}
# ============================================================
# 完成
# ============================================================
Write-Header "安装完成"
Write-Info "已安装组件:"
if (Test-Command "uv") {
Write-Host " ✓ uv: $(uv --version 2>&1)" -ForegroundColor Green
} else {
Write-Host " ⚠ uv: 需要重启终端" -ForegroundColor Yellow
}
if (Test-Command "java") {
Write-Host " ✓ Java: $(java -version 2>&1 | Select-Object -First 1)" -ForegroundColor Green
} else {
Write-Host " ⚠ Java: 需要重启终端" -ForegroundColor Yellow
}
Write-Host ""
Write-Info "下一步:"
Write-Host " 1. 重启终端使环境变量生效"
Write-Host " 2. 运行 'uv python install 3.11' 安装 Python如尚未安装"
Write-Host " 3. 运行 'aide env ensure --runtime' 验证安装"
Write-Host ""

View File

@@ -0,0 +1,62 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Aide 离线安装资源清单 (Windows)",
"description": "包含所有需要下载的资源文件信息",
"version": "1.0.0",
"platform": "windows",
"arch": "x64",
"resources": [
{
"id": "uv",
"name": "uv (Python 包管理器)",
"version": "latest",
"required": true,
"filename": "uv-x86_64-pc-windows-msvc.zip",
"url": "https://github.com/astral-sh/uv/releases/latest/download/uv-x86_64-pc-windows-msvc.zip",
"checksum": {
"algorithm": "sha256",
"value": "请从发布页面获取"
},
"install_path": "%USERPROFILE%\\.local\\bin",
"notes": "解压后将 uv.exe 放入安装路径"
},
{
"id": "java_jre",
"name": "Eclipse Temurin JRE 17",
"version": "17",
"required": true,
"filename": "OpenJDK17U-jre_x64_windows_hotspot_17.0.9_9.zip",
"url": "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9/OpenJDK17U-jre_x64_windows_hotspot_17.0.9_9.zip",
"checksum": {
"algorithm": "sha256",
"value": "请从发布页面获取"
},
"install_path": "%LOCALAPPDATA%\\Programs\\Java\\jre-17",
"notes": "解压后配置 JAVA_HOME 和 PATH"
}
],
"download_instructions": {
"zh": [
"1. 访问上述每个资源的 url 下载文件",
"2. 将下载的文件保存到此目录(与本文件同目录)",
"3. 确保文件名与 filename 字段一致",
"4. 以管理员身份运行 install.ps1"
],
"en": [
"1. Visit the url for each resource and download the file",
"2. Save the downloaded files to this directory",
"3. Ensure filenames match the filename field",
"4. Run install.ps1 as Administrator"
]
},
"post_install": {
"python": {
"note": "Python 将通过 uv python install 命令安装",
"offline_option": "如需完全离线安装 Python请提前运行 'uv python install 3.11' 下载 Python 到本地缓存"
},
"aide": {
"note": "安装完成后需要将 aide-program/bin 添加到 PATH",
"path_variable": "%PATH%"
}
}
}