agent: 'agent'
description: Download, install or upgrade cloudwise-sdd tool based on operating system
使命: 根据操作系统自动下载、安装或升级 cloudwise-sdd 工具
成功标准:
根据当前操作系统类型,执行相应的 cloudwise-sdd 安装或升级脚本。此命令可以反复执行,如果已安装 cloudwise-sdd,将自动升级到最新版本。每日检查机制:如果今天已经执行过安装/升级,将自动跳过,避免重复调用。
检查今天是否已执行: 首先检查今天是否已经执行过安装/升级。根据操作系统使用相应的工具:
macOS / Linux: 使用 Bash 工具执行检查:
TODAY=$(date '+%Y-%m-%d')
LAST_INSTALL_FILE=".github/prompts/.last_install_date"
if [ -f "$LAST_INSTALL_FILE" ] && [ "$(cat "$LAST_INSTALL_FILE" 2>/dev/null | tr -d '\r\n')" = "$TODAY" ]; then
echo "Already installed today ($TODAY), skipping installation/upgrade"
exit 0
fi
Windows: 使用 PowerShell 工具执行检查:
$today = Get-Date -Format "yyyy-MM-dd"
$lastInstallFile = ".github/prompts/.last_install_date"
if (Test-Path $lastInstallFile) {
$lastDate = (Get-Content $lastInstallFile -Raw).Trim()
if ($lastDate -eq $today) {
Write-Host "Already installed today ($today), skipping installation/upgrade"
exit 0
}
}
如果文件存在且日期是今天,则跳过安装/升级步骤,直接退出
如果文件不存在或日期不是今天,则继续执行安装/升级步骤
注意:标记文件位于项目根目录下的 .github/prompts/.last_install_date(Windows 路径使用反斜杠)
检测操作系统: 使用 Bash 工具检测当前操作系统类型:
# 检测操作系统类型
OS_TYPE="unknown"
if [[ "$OSTYPE" == "darwin"* ]]; then
OS_TYPE="macOS"
elif [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "linux"* ]]; then
OS_TYPE="Linux"
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]] || [[ -n "$WINDIR" ]]; then
OS_TYPE="Windows"
else
# 尝试使用 uname 命令
UNAME_OS=$(uname -s 2>/dev/null || echo "")
if [[ "$UNAME_OS" == "Darwin" ]]; then
OS_TYPE="macOS"
elif [[ "$UNAME_OS" == "Linux" ]]; then
OS_TYPE="Linux"
fi
fi
echo "检测到操作系统: $OS_TYPE"
执行安装/升级脚本:
macOS / Linux: 如果检测到 macOS 或 Linux,使用 Bash 工具执行(如果已安装会自动升级):
/bin/bash -c "$(curl -fsSL https://docp.cloud.cloudwise.com/ARCH/cloudwise-sdd/install.sh)" -- --copilot --yes
Windows: 如果检测到 Windows,使用 PowerShell 工具执行(如果已安装会自动升级):
powershell -ExecutionPolicy Bypass -Command '& { $script = (Invoke-WebRequest -Uri "https://docp.cloud.cloudwise.com/ARCH/cloudwise-sdd/install.ps1" -UseBasicParsing).Content; Invoke-Expression $script }' -Agent copilot -Yes
未知系统: 如果无法检测操作系统类型,提示用户手动选择:
/bin/bash -c "$(curl -fsSL https://docp.cloud.cloudwise.com/ARCH/cloudwise-sdd/install.sh)" -- --copilot --yespowershell -ExecutionPolicy Bypass -Command '& { $script = (Invoke-WebRequest -Uri "https://docp.cloud.cloudwise.com/ARCH/cloudwise-sdd/install.ps1" -UseBasicParsing).Content; Invoke-Expression $script }' -Agent copilot -Yes注意: 此命令可以安全地反复执行,如果 cloudwise-sdd 已安装,脚本会自动检测并升级到最新版本
每日检查:
.github/prompts/.last_install_date 文件.github/prompts/.last_install_date 文件操作系统检测:
$OSTYPE 环境变量或 uname -s 命令判断操作系统执行安装/升级脚本:
安装/升级后处理:
如果安装/升级成功,根据操作系统使用相应的工具将今天的日期写入标记文件:
macOS / Linux: 使用 Bash 工具执行:
echo "$(date '+%Y-%m-%d')" > .github/prompts/.last_install_date
Windows: 使用 PowerShell 工具执行:
New-Item -ItemType Directory -Force -Path ".github/prompts" | Out-Null
(Get-Date -Format "yyyy-MM-dd") | Out-File -FilePath ".github/prompts/.last_install_date" -Encoding utf8 -NoNewline
提供使用说明和下一步操作建议
说明可以随时再次执行此命令以升级到最新版本
$OSTYPE == "darwin"* 或 uname -s == "Darwin"$OSTYPE == "linux-gnu"* 或 uname -s == "Linux"$OSTYPE == "msys" 或 $OSTYPE == "cygwin" 或存在 $WINDIR 环境变量安装或升级完成后,cloudwise-sdd 工具将可用于:
/sdd-steering/sdd-steering-custom <name>/sdd-spec-init "description"升级说明: 此命令可以反复执行,如果 cloudwise-sdd 已安装,再次执行将自动升级到最新版本。建议定期执行此命令以保持工具为最新版本。 注意: 此命令失败不影响后续执行。