当前位置: 首页 > news >正文

SkillHub 手动安装脚本

$ErrorActionPreference = "Stop"Write-Host "=== SkillHub Installer ===" -ForegroundColor Cyan# 1. Download
Write-Host "[1/3] Downloading..." -ForegroundColor Yellow
Add-Type -AssemblyName System.Net.Http
$handler = New-Object System.Net.Http.HttpClientHandler
$client = New-Object System.Net.Http.HttpClient($handler)
$client.Timeout = New-Object TimeSpan(0, 2, 0)
$response = $client.GetAsync("https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/latest.tar.gz").Result
$tarBytes = $response.Content.ReadAsByteArrayAsync().Result
Write-Host "    Downloaded $($tarBytes.Length) bytes" -ForegroundColor Green# 2. Find Python
$pythonCmd = Get-Command python -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Source
if (-not $pythonCmd) {Write-Host "    Python NOT FOUND. Install from https://www.python.org/downloads/" -ForegroundColor Redexit 1
}
Write-Host "    Found: $pythonCmd" -ForegroundColor Gray# 3. Write Python install script to TEMP (single-quoted here-string to avoid $ expansion)
$pyCode = @'
import tarfile, io, base64, json, os, stat, systar_b64 = "{TAR_B64}"
tar_bytes = base64.b64decode(tar_b64)
tar = tarfile.open(fileobj=io.BytesIO(tar_bytes), mode="r:gz")
files = {}
for m in tar.getmembers():f = tar.extractfile(m)if f:files[m.name] = f.read()home = os.path.expanduser("~")
base = os.path.join(home, ".skillhub")
binDir = os.path.join(home, ".local", "bin")
skillDir = os.path.join(home, ".openclaw", "workspace", "skills", "find-skills")
prefDir = os.path.join(home, ".openclaw", "workspace", "skills", "skillhub-preference")os.makedirs(base, exist_ok=True)
os.makedirs(binDir, exist_ok=True)
os.makedirs(skillDir, exist_ok=True)
os.makedirs(prefDir, exist_ok=True)for fname, data in [("skills_store_cli.py", files.get("cli/skills_store_cli.py", b"")),("skills_upgrade.py", files.get("cli/skills_upgrade.py", b"")),("version.json", files.get("cli/version.json", b"")),("metadata.json", files.get("cli/metadata.json", b"")),
]:if data:with open(os.path.join(base, fname), "wb") as f:f.write(data)print("Wrote " + fname)cfg = {"self_update_url": "https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/version.json"}
with open(os.path.join(base, "config.json"), "w", encoding="utf-8") as f:json.dump(cfg, f, indent=2)
print("Wrote config.json")for wname in ["skillhub.py", "oc-skills.py"]:wpath = os.path.join(binDir, wname)with open(wpath, "w", encoding="utf-8") as f:f.write("#!/usr/bin/env python3\n")f.write("import os, sys\n")f.write("cli = os.path.join(os.path.expanduser('~'), '.skillhub', 'skills_store_cli.py')\n")f.write("os.execv(sys.executable, [sys.executable, cli] + sys.argv[1:])\n")os.chmod(wpath, os.stat(wpath).st_mode | stat.S_IXUSR)print("Wrote " + wname)for bname in ["skillhub.bat", "oc-skills.bat"]:bpath = os.path.join(binDir, bname)py_name = bname.replace(".bat", ".py")with open(bpath, "w", encoding="utf-8") as f:f.write("@echo off\r\npython \"%USERPROFILE%\\.local\\bin\\" + py_name + "\" %*\r\n")print("Wrote " + bname)for src, dst in [("cli/skill/SKILL.md", os.path.join(skillDir, "SKILL.md")),("cli/skill/SKILL.skillhub-preference.md", os.path.join(prefDir, "SKILL.md")),
]:if src in files:with open(dst, "wb") as f:f.write(files[src])print("Wrote " + os.path.basename(dst))print("ALL DONE")
'@# Replace placeholder with actual base64 data
$pyCode = $pyCode -replace "\{TAR_B64\}", [Convert]::ToBase64String($tarBytes)$tmpPy = "$env:TEMP\skillhub_install_$(Get-Random).py"
Write-Host "[2/3] Writing Python script..." -ForegroundColor Yellow
[System.IO.File]::WriteAllText($tmpPy, $pyCode, [System.Text.Encoding]::UTF8)Write-Host "[3/3] Running Python install..." -ForegroundColor Yellow
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.FileName = $pythonCmd
$psi.Arguments = $tmpPy
$psi.UseShellExecute = $false
$psi.RedirectStandardOutput = $true
$psi.RedirectStandardError = $true
$proc = [System.Diagnostics.Process]::Start($psi)
$stdout = $proc.StandardOutput.ReadToEnd()
$stderr = $proc.StandardError.ReadToEnd()
$proc.WaitForExit()
Write-Host $stdout -ForegroundColor Gray
if ($stderr) { Write-Host $stderr -ForegroundColor Red }
if ($proc.ExitCode -eq 0) {Write-Host "    Exit code: 0 - SUCCESS" -ForegroundColor Green
} else {Write-Host "    Exit code: $($proc.ExitCode) - FAILED" -ForegroundColor Red
}Remove-Item $tmpPy -Force -ErrorAction SilentlyContinueWrite-Host ""
Write-Host "=== Done ===" -ForegroundColor Cyan
$cliPath = Join-Path $env:USERPROFILE ".skillhub\skills_store_cli.py"
if (Test-Path $cliPath) {Write-Host "CLI installed: $cliPath" -ForegroundColor GreenWrite-Host "Test:" -ForegroundColor Gray& $pythonCmd $cliPath --help 2>&1 | Select-Object -First 8
} else {Write-Host "CLI NOT found - check errors above" -ForegroundColor Red
}

  

http://www.jsqmd.com/news/508027/

相关文章:

  • 前缀和与差分算法入门
  • 伏羲气象大模型Python入门教程:从零开始调用API
  • 多重背包单调队列优化的完整数学推导
  • 手把手教你用NVIDIA Jetson AGX Orin运行PointRCNN:OpenPCDet环境搭建全流程
  • Android正在变得越来越封闭,请向Android抗议,恳请不要注册抢先体验计划或Android开发人员控制台
  • 大树科技电话查询:AI时代品牌认知构建策略解析 - 十大品牌推荐
  • 从零开始:如何高效连接DeepSeek AI智能客服(附完整代码示例)
  • 后OTP时代:基于AFASA法案的无密码认证架构演进研究
  • 【2026年最新600套毕设项目分享】基于SpringBoot的校园设备维护报修系统(14199)
  • IDEA 又整新活:推出全新调试工具!
  • FFTW3实战:如何用C++实现音频降噪(附完整代码与性能对比)
  • 别35岁焦虑!网络安全行业“越老越吃香“,30岁转行正当时(附282G学习资源必收藏)
  • Qwen-Image镜像开源可部署:企业私有云中安全可控的多模态AI底座
  • AudioSeal音频保护教程:3步完成音频隐形水印添加与检测
  • 腾讯混元OCR网页版部署技巧:Nginx反向代理配置,提升安全性
  • Spring AI 2.x 全面指南:架构升级、高效的工具调用、多模型生态与实战示例
  • SPIRAN ART SUMMONER效果展示:风格迁移对比实验
  • Qwen3-32B-Chat百度开发者能力认证:部署/调优/安全/扩展四大模块考核大纲
  • GD32 Flash擦写异常排查:EXMC配置陷阱与pgerr的深层解析
  • 基于高保真UI伪造与反沙箱机制的加密货币钓鱼攻击研究
  • BLE广播包中的公司ID:如何快速查询和修改(附最新Company-Identifiers表)
  • 丹青识画入门必看:从部署到生成,完整体验AI艺术创作流程
  • 信捷XD5与威纶触摸屏编写机械手六轴程序:成熟可靠,高借鉴价值,附详细注释
  • BAAI/bge-m3性能优化:CPU环境下如何实现毫秒级向量计算
  • VSCode 1.109 Chat UX 大升级!
  • 2026年TQM系统排名:10款实用TQM系统助力质量提升
  • LobeChat实战体验:一键部署多模态聊天机器人,效果惊艳实测
  • BMP180气压传感器驱动开发与海拔计算实战
  • 抖音直播数据实时抓取终极指南:5个实战技巧打造智能监控系统
  • Java+大模型工程化落地:AIGS范式重构企业级服务新内核