# china-etax-wizard Skill installer (Windows PowerShell). # 只做四件事:下载、校验 SHA-256、解压、复制到 Skill 目录(旧版移到备份)。不运行包里其他任何东西。 param( [string]$File = "", [string]$Sha256 = "", [ValidateSet("all","claude","codex","custom")] [string]$Agent = "all", [string]$Dir = "" ) $ErrorActionPreference = "Stop" $Base = "https://www.paibaowork.com/skills/china-etax-wizard" $Pkg = "china-etax-wizard-skill.tar.gz" $Skill = "china-etax-wizard" $Backup = Join-Path $HOME ".config\china-etax\skill-backups" $TMP = Join-Path ([System.IO.Path]::GetTempPath()) ("cetax-" + [guid]::NewGuid().ToString("N")) New-Item -ItemType Directory -Force -Path $TMP | Out-Null try { if ($File -ne "") { Copy-Item $File (Join-Path $TMP $Pkg) } else { Write-Host "下载 $Base/latest/$Pkg ..." Invoke-WebRequest -Uri "$Base/latest/$Pkg" -OutFile (Join-Path $TMP $Pkg) } $pkgPath = Join-Path $TMP $Pkg if ($Sha256 -eq "" -and $File -eq "") { try { $shaText = (Invoke-WebRequest -Uri "$Base/latest/$Pkg.sha256").Content $Sha256 = ($shaText -split '\s+')[0] } catch {} } if ($Sha256 -ne "") { $got = (Get-FileHash $pkgPath -Algorithm SHA256).Hash.ToLower() if ($got -ne $Sha256.ToLower()) { Write-Error "SHA-256 校验失败,停止安装。`n 期望 $Sha256`n 实际 $got" exit 1 } Write-Host "SHA-256 校验通过。" } else { Write-Host "未提供 SHA-256,跳过校验(建议从官网 .sha256 核对)。" } # Windows 自带 tar(Windows 10 1803+) tar -xzf $pkgPath -C $TMP $src = Join-Path $TMP "skills\$Skill" if (-not (Test-Path $src)) { Write-Error "包结构异常:缺少 skills\$Skill"; exit 1 } function Install-One([string]$Target) { New-Item -ItemType Directory -Force -Path $Target | Out-Null $dst = Join-Path $Target $Skill if (Test-Path $dst) { New-Item -ItemType Directory -Force -Path $Backup | Out-Null $stamp = Get-Date -Format "yyyyMMddHHmmss" Move-Item $dst (Join-Path $Backup "$Skill-$stamp") Write-Host "旧版已备份到 $(Join-Path $Backup "$Skill-$stamp")" } Copy-Item $src $dst -Recurse Write-Host "已安装到 $dst" } switch ($Agent) { "claude" { Install-One (Join-Path $HOME ".claude\skills") } "codex" { Install-One (Join-Path $HOME ".agents\skills") } "custom" { Install-One $Dir } "all" { Install-One (Join-Path $HOME ".claude\skills") Install-One (Join-Path $HOME ".agents\skills") } } Write-Host "完成。请阅读 $Skill/SKILL.md:登录、刷脸、验证码、最终提交由你本人操作。" } finally { Remove-Item -Recurse -Force $TMP -ErrorAction SilentlyContinue }