Skip to content
Back to search

quarkclouddrive_offical

夸克网盘官方Skill,和AI一起管理你的网盘: AI 对话里生成的重要资料、公开文件素材,都能一句话存入网盘,随时回顾;也能直接搜索、调用网盘里的照片和资料,修图、做PPT 不用再手动搬素材;还能按地点、时间、人物整理网盘相册,试试说:“把 2025 年的照片按照城市和月份整理一下”。

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/quark-clouddrive--quarkclouddrive-offical/badge.svg)](/listings/quark-clouddrive--quarkclouddrive-offical)

HTML

<a href="/listings/quark-clouddrive--quarkclouddrive-offical"><img src="/api/listings/quark-clouddrive--quarkclouddrive-offical/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 161 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # 夸克网盘官方Skill
  2. 在Agent中随时调用网盘文件,和AI一起管理你的网盘。
  3. ## 一键安装
  4. ```plaintext
  5. npx skills add https://github.com/quark-clouddrive/quarkclouddrive_offical/skills --skill quarkclouddrive
  6. ```
  7. 首次使用时,Skill 会自动引导完成 CLI 工具安装和夸克网盘登录授权。
  8. `install.sh` 会自动完成以下操作:
  9. 1. 检测运行环境(macOS / Linux / Windows)
  10. 2. 检测 Node.js >= 16,不满足则自动安装
  11. 3. 从服务端下载最新的 Skill 包并解压安装到 `~/.quarkclouddrive/`
  12. 4. 注册 `quarkclouddrive` 全局命令(符号链接或 PATH 追加)
  13. 5. 自检验证安装结果
  14. > 夸克网盘独立端下载地址:[https://pan.quark.cn](https://pan.quark.cn/)
  15. ## 功能说明
  16. ✅ **通用能力:** 存储、下载、备份、分享文件、转存链接资源、移动文件、创建文件夹
  17. ✅ **AI高阶能力:** 智能搜索、相册整理、知识问答
  18. ## 功能示例
  19. **文件存储:** 对话中的文件可以直接存储到夸克网盘
  20. ```plaintext
  21. 每天美股收盘后,帮我做好当天大盘总结后存在夸克网盘「美股日报」文件夹
  22. ```
  23. **文件下载:** 网盘中的文件支持下载到本地
  24. ```plaintext
  25. 下载夸克网盘里Q2季度总结的PPT
  26. ```
  27. **文件备份:** 将本地文件备份到夸克网盘
  28. ```plaintext
  29. 每天18:00把C盘里「项目资料」文件夹里的文件备份到夸克网盘
  30. ```
  31. **文件分享:** 将网盘中的文件生成分享链接
  32. ```plaintext
  33. 把上周末和朋友在上海外滩的照片,生成夸克网盘的分享链接
  34. ```
  35. **文件转存:** 转存网盘分享链接中的文件到夸克网盘
  36. ```plaintext
  37. 把这份资料存到我的夸克网盘:http://pan.quark.cn/s/xxx
  38. ```
  39. **文件移动:** 移动网盘中的文件
  40. ```plaintext
  41. 把网盘里的论文终稿移动到「毕业资料」文件夹里
  42. ```
  43. **相册整理:** 支持按时间、地点、人物整理网盘相册(移动整理、复制整理)
  44. ```plaintext
  45. 把网盘里「春蕾幼儿园」文件夹下的照片,按照人物整理一下
  46. ```
  47. **相册搜索:** 支持按时间、地点、场景、人物等多维度搜索网盘图片
  48. ```plaintext
  49. 把夸克网盘里存的去年和家人在三亚海边的合影找出来,做一个电子相册
  50. ```
  51. **资料搜索:** 支持按文件名、主题、类型等维度搜索网盘资料
  52. ```plaintext
  53. 找一下夸克网盘里金字塔原理相关的PDF文件
  54. ```
  55. **知识问答:** 支持根据网盘中存的文件直接发起问答
  56. ```plaintext
  57. 帮我对比一下夸克网盘里存的今年和去年的体检报告,总结一下有哪些需要注意的
  58. ```
  59. ## 安全设计
  60. | **特性** | **说明** |
  61. | --- | --- |
  62. | OAuth 2.0 授权 | 浏览器 OAuth 授权码模式认证,不存储用户密码 |
  63. | 无删除操作 | 不提供删除命令,从根本上防止误删 |
  64. | 修改前确认 | 移动、覆盖等操作执行前须用户确认 |
  65. | Token 保护 | 配置文件含 Token,Agent 禁止读取或输出其内容 |
  66. | 授权码安全传递 | 支持浏览器自动授权与手动授权码两种方式 |
  67. | 卸载需二次确认 | 卸载属不可逆操作,执行前必须向用户二次确认 |
  68. | 多 Agent 隔离 | 各 Agent 配置独立,卸载不影响其他 Agent |
  69. ## 系统支持
  70. | **平台** | **架构** | **状态** |
  71. | --- | --- | --- |
  72. | macOS | arm64 / amd64 | ✅ |
  73. | Linux | arm64 / amd64 | ✅ |
  74. | Windows (WSL) | amd64 | ✅ |
  75. | Windows (原生) | — | ❌ |
  76. > 要求 Node.js >= 16,安装脚本会自动检测并安装。
  77. ## 故障排除
  78. 遇到问题时,直接对 Skill 说:
  79. * **Token 过期** — "夸克网盘授权过期了" → 自动引导重新登录
  80. * **检查状态** — "查看我的网盘账号信息" → 显示当前账号与会员状态
  81. * **更新 Skill** — "更新夸克网盘 Skill" → 重新执行 install.sh 完成升级
  82. * **取消授权** — "取消夸克网盘授权" → 引导在夸克网盘 App 中完成解绑
  83. * **卸载 Skill** — "卸载夸克网盘 Skill" → 二次确认后完成完整卸载
  84. > **升级约定**:更新 Skill 时必须执行 `bash install.sh`,由脚本进入更新模式完成覆盖安装。`quarkclouddrive update` 命令仅更新 CLI 本体,不会同步更新 Skill 文档。
  85. ## 项目结构
  86. ```plaintext
  87. quarkclouddrive_offical/
  88. ├── SKILL.md # Skill 定义(Agent 行为规范)
  89. ├── install.sh # 安装 / 升级脚本
  90. ├── uninstall.sh # 卸载脚本
  91. ├── LICENSE # Apache License 2.0
  92. ├── README.md # 项目说明
  93. └── references/ # 参考文档
  94. ├── auth.md # 认证与账号管理
  95. ├── assistant.md # AI 助手(文件总结与知识问答)
  96. ├── file-ops.md # 文件操作(创建文件夹、移动、下载)
  97. ├── file-organize.md # 相册整理
  98. ├── file-read.md # 文件读取
  99. ├── file-saveas.md # 转存分享链接
  100. ├── file-search.md # 文件检索
  101. ├── file-share.md # 文件分享
  102. └── file-upload.md # 文件上传
  103. ```
  104. ## 许可证
  105. [Apache License 2.0](./LICENSE)
skills/quarkclouddrive/install.sh · Bundled script · 557 lines · 2 findings marked
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. SKILL_OPEN_API_HOST="https://open-api-drive.quark.cn"
  4. if [ -z "$SKILL_OPEN_API_HOST" ] || [[ "$SKILL_OPEN_API_HOST" == __*__ ]]; then
  5. SKILL_OPEN_API_HOST="https://open-api-drive.quark.cn"
  6. fi
  7. SKILL_CONFIG_URL="${SKILL_OPEN_API_HOST}/agent/v1/skill_config"
  8. IGNORE_INSTALL_CONFIG="false"
  9. if [ -z "$IGNORE_INSTALL_CONFIG" ] || [[ "$IGNORE_INSTALL_CONFIG" == __*__ ]]; then
  10. IGNORE_INSTALL_CONFIG="false"
  11. fi
  12. ZIP_DOWNLOAD_URL=""
  13. REMOTE_VERSION=""
  14. REQUIRED_NODE_MAJOR=16
  15. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  16. if [ "$(basename "$SCRIPT_DIR")" = "scripts" ]; then
  17. SKILL_DIR="$(dirname "$SCRIPT_DIR")"
  18. else
  19. SKILL_DIR="$SCRIPT_DIR"
  20. fi
  21. TMP_DIR="$(dirname "$SKILL_DIR")/temp"
  22. IS_UPDATE="false"
  23. if [ -f "$SKILL_DIR/scripts/quark-drive.cjs" ]; then
  24. IS_UPDATE="true"
  25. fi
  26. SCRIPTS_UPDATED="false"
  27. DOCS_UPDATED="false"
  28. INSTALL_STEPS_SKIPPED="false"
  29. PREVIOUS_CLI_VERSION=""
  30. info() { printf "[info] %s\n" "$*"; }
  31. warn() { printf "[warn] %s\n" "$*"; }
  32. error() { printf "[error] %s\n" "$*"; }
  33. remove_legacy_global_command() {
  34. info "Step 0: 检查并清理旧版全局命令..."
  35. if [ "$OS_TYPE" = "mac" ] || [ "$OS_TYPE" = "linux" ]; then
  36. local symlink="/usr/local/bin/quarkclouddrive"
  37. if [ -L "$symlink" ] || [ -f "$symlink" ]; then
  38. if rm -f "$symlink" 2>/dev/null; then
  39. info " 已删除旧版全局命令: $symlink"
  40. else
  41. warn " 删除旧版全局命令失败(可能需要 sudo 权限): $symlink"
  42. fi
  43. else
  44. info " 未发现旧版全局命令,跳过"
  45. fi
  46. elif [ "$OS_TYPE" = "windows" ]; then
  47. local win_usr_bin
  48. win_usr_bin=$(cygpath -u "$(cygpath -w /usr/local/bin)" 2>/dev/null || echo "/usr/local/bin")
  49. local win_files=(
  50. "$win_usr_bin/quarkclouddrive"
  51. "$win_usr_bin/quarkclouddrive.cmd"
  52. "$win_usr_bin/quarkclouddrive.ps1"
  53. )
  54. local found=false
  55. for f in "${win_files[@]}"; do
  56. if [ -f "$f" ] || [ -L "$f" ]; then
  57. rm -f "$f" 2>/dev/null && info " 已删除旧版全局命令: $f" || warn " 删除失败: $f"
  58. found=true
  59. fi
  60. done
  61. if [ "$found" = "false" ]; then
  62. info " 未发现旧版全局命令,跳过"
  63. fi
  64. fi
  65. }
  66. OS_TYPE=""
  67. detect_os() {
  68. info "Step 1: 检测运行环境..."
  69. case "$(uname -s)" in
  70. Linux*) OS_TYPE="linux" ;;
  71. Darwin*) OS_TYPE="mac" ;;
  72. CYGWIN*|MINGW*|MSYS*) OS_TYPE="windows" ;;
  73. *)
  74. error "不支持的操作系统: $(uname -s)"
  75. return 1
  76. ;;
  77. esac
  78. info "检测到操作系统: ${OS_TYPE}"
  79. }
  80. ensure_node() {
  81. info "Step 2: 检测 Node.js 环境..."
  82. if command -v node &>/dev/null; then
  83. local node_version major_version
  84. node_version=$(node --version)
  85. major_version=$(echo "$node_version" | sed 's/v//' | cut -d. -f1)
  86. info "当前 Node.js 版本: $node_version"
  87. if [ "$major_version" -ge "$REQUIRED_NODE_MAJOR" ]; then
  88. info "Node.js 版本满足要求 (>= v${REQUIRED_NODE_MAJOR})"
  89. return 0
  90. fi
  91. warn "Node.js 版本 $node_version 低于 v${REQUIRED_NODE_MAJOR},需要升级..."
  92. else
  93. warn "未检测到 Node.js,将自动安装..."
  94. fi
  95. install_node
  96. }
  97. install_node() {
  98. case "$OS_TYPE" in
  99. mac)
  100. install_node_mac
  101. ;;
  102. linux)
  103. install_node_linux
  104. ;;
  105. windows)
  106. install_node_windows
  107. ;;
  108. esac
  109. }
  110. install_node_mac() {
  111. if command -v brew &>/dev/null; then
  112. info "使用 Homebrew 安装 Node.js..."
  113. brew unlink node 2>/dev/null || true
  114. brew install node@${REQUIRED_NODE_MAJOR}
  115. brew link --overwrite --force node@${REQUIRED_NODE_MAJOR} 2>/dev/null || true
  116. if command -v node &>/dev/null; then
  117. return 0
  118. fi
  119. fi
  120. error "请手动安装 Node.js v${REQUIRED_NODE_MAJOR}+: https://nodejs.org/"
  121. return 1
  122. }
  123. install_node_linux() {
  124. if command -v apt-get &>/dev/null; then
  125. info "使用 apt 安装 Node.js ${REQUIRED_NODE_MAJOR}..."
  126. curl -fsSL "https://deb.nodesource.com/setup_${REQUIRED_NODE_MAJOR}.x" | sudo -E bash - 2>/dev/null
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 155 on GitHub
  127. sudo apt-get install -y nodejs 2>/dev/null
  128. if command -v node &>/dev/null; then
  129. return 0
  130. fi
  131. elif command -v yum &>/dev/null; then
  132. info "使用 yum 安装 Node.js ${REQUIRED_NODE_MAJOR}..."
  133. curl -fsSL "https://rpm.nodesource.com/setup_${REQUIRED_NODE_MAJOR}.x" | sudo bash - 2>/dev/null
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 162 on GitHub
  134. sudo yum install -y nodejs 2>/dev/null
  135. if command -v node &>/dev/null; then
  136. return 0
  137. fi
  138. fi
  139. error "请手动安装 Node.js v${REQUIRED_NODE_MAJOR}+: https://nodejs.org/"
  140. return 1
  141. }
  142. install_node_windows() {
  143. error "Windows 请手动安装 Node.js v${REQUIRED_NODE_MAJOR}+: https://nodejs.org/"
  144. return 1
  145. }
  146. get_skill_md_version() {
  147. local skill_md="$SKILL_DIR/SKILL.md"
  148. if [ -f "$skill_md" ]; then
  149. grep -oE 'version:[[:space:]]*[0-9]+\.[0-9]+\.[0-9]+' "$skill_md" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1
  150. fi
  151. }
  152. get_cli_version() {
  153. local out=""
  154. local cli_entry="$SKILL_DIR/scripts/quark-drive.cjs"
  155. if [ -f "$cli_entry" ]; then
  156. out=$(node "$cli_entry" --version 2>/dev/null || true)
  157. fi
  158. printf '%s' "$out" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true
  159. }
  160. version_gt() {
  161. [ -n "$1" ] || return 1
  162. [ -n "$2" ] || return 0
  163. [ "$1" = "$2" ] && return 1
  164. local greater
  165. greater=$(printf '%s\n%s\n' "$1" "$2" | sort -V | tail -1)
  166. [ "$greater" = "$1" ]
  167. }
  168. print_install_result() {
  169. local current_version updated="false"
  170. current_version=$(get_cli_version)
  171. if [ "$IS_UPDATE" = "true" ] && [ "$SCRIPTS_UPDATED" = "true" ] &&
  172. [ "$DOCS_UPDATED" = "true" ] && [ -n "$PREVIOUS_CLI_VERSION" ] &&
  173. version_gt "$current_version" "$PREVIOUS_CLI_VERSION"; then
  174. updated="true"
  175. fi
  176. printf '{"type":"install_result","success":true,"updated":%s,"from_version":"%s","to_version":"%s"}\n' \
  177. "$updated" "$PREVIOUS_CLI_VERSION" "$current_version"
  178. }
  179. fetch_skill_config() {
  180. info "请求 skill 配置接口获取最新版本与下载地址..."
  181. local req_id resp
  182. req_id="$(date +%s)${RANDOM}"
  183. if ! resp=$(curl -fsSL --connect-timeout 30 --max-time 60 "${SKILL_CONFIG_URL}?req_id=${req_id}" 2>/dev/null); then
  184. error "请求 skill_config 接口失败: ${SKILL_CONFIG_URL}"
  185. return 1
  186. fi
  187. local parsed
  188. if ! parsed=$(node -e '
  189. let j;
  190. try { j = JSON.parse(process.argv[1]); } catch (e) { process.exit(1); }
  191. // 兼容多层结构:{config} / {data:{config}} / {data:{...}} / 裸对象
  192. const cfg = (j && j.data && j.data.config) || (j && j.config) || (j && j.data) || j || {};
  193. const ver = cfg.qkPanVersion || "";
  194. const url = String(cfg.qkPan || "").trim();
  195. if (!url) process.exit(2);
  196. process.stdout.write(ver + "\n" + url);
  197. ' "$resp" 2>/dev/null); then
  198. error "解析 skill_config 接口返回失败: $resp"
  199. return 1
  200. fi
  201. REMOTE_VERSION=$(printf '%s' "$parsed" | sed -n '1p')
  202. ZIP_DOWNLOAD_URL=$(printf '%s' "$parsed" | sed -n '2p')
  203. if [[ ! "$ZIP_DOWNLOAD_URL" =~ ^https?://[^[:space:]]+$ ]]; then
  204. error "skill_config 接口未返回有效的 zip 下载地址"
  205. return 1
  206. fi
  207. info "接口版本: ${REMOTE_VERSION:-未知}"
  208. info "下载地址: $ZIP_DOWNLOAD_URL"
  209. }
  210. download_and_extract() {
  211. info "Step 3: 下载 skill zip 包..."
  212. mkdir -p "$TMP_DIR"
  213. local zip_path="$TMP_DIR/skill.zip"
  214. if ! curl -fsSL --connect-timeout 30 --max-time 120 -o "$zip_path" "$ZIP_DOWNLOAD_URL"; then
  215. warn "下载失败,重试中..."
  216. if ! curl -fsSL --connect-timeout 30 --max-time 120 -o "$zip_path" "$ZIP_DOWNLOAD_URL"; then
  217. error "下载 zip 包失败: $ZIP_DOWNLOAD_URL"
  218. return 1
  219. fi
  220. fi
  221. info "下载完成,正在解压..."
  222. unzip -qo "$zip_path" -d "$TMP_DIR"
  223. info "解压完成"
  224. }
  225. cleanup_legacy_root_scripts() {
  226. for script_name in install.sh uninstall.sh; do
  227. local legacy_script="$SKILL_DIR/$script_name"
  228. if [ -f "$legacy_script" ]; then
  229. rm -f "$legacy_script"
  230. info " [清理] ${script_name}(根目录旧副本)"
  231. fi
  232. done
  233. }
  234. install_scripts() {
  235. info "Step 4: 安装脚本到 ${SKILL_DIR}..."
  236. local scripts_src
  237. scripts_src=$(find "$TMP_DIR" -type d -name "scripts" | head -1)
  238. if [ -z "$scripts_src" ]; then
  239. error "zip 包中未找到 scripts 目录"
  240. return 1
  241. fi
  242. mkdir -p "$SKILL_DIR"
  243. local scripts_dest="$SKILL_DIR/scripts"
  244. local installed_count=0
  245. local skipped_count=0
  246. if [ "$IS_UPDATE" = "true" ]; then
  247. info "更新模式: 整个覆盖 scripts 目录"
  248. rm -rf "$scripts_dest"
  249. cp -rf "$scripts_src" "$scripts_dest"
  250. for file in "$scripts_dest"/*; do
  251. local filename
  252. filename=$(basename "$file")
  253. info " [更新] scripts/$filename → $scripts_dest/$filename"
  254. installed_count=$((installed_count + 1))
  255. done
  256. else
  257. cp -rf "$scripts_src" "$scripts_dest"
  258. for file in "$scripts_dest"/*; do
  259. local filename
  260. filename=$(basename "$file")
  261. info " [安装] scripts/$filename → $scripts_dest/$filename"
  262. installed_count=$((installed_count + 1))
  263. done
  264. fi
  265. echo ""
  266. info "安装目录: $SKILL_DIR"
  267. info "文件统计: 已安装 ${installed_count} 个文件"
  268. }
  269. install_skill_docs() {
  270. info "Step 4.5: 更新 SKILL.md 和 references 文档..."
  271. local skill_md_src
  272. skill_md_src=$(find "$TMP_DIR" -maxdepth 2 -name "SKILL.md" -type f | head -1)
  273. if [ -n "$skill_md_src" ]; then
  274. cp -f "$skill_md_src" "$SKILL_DIR/SKILL.md" || return 1
  275. info " [更新] SKILL.md → $SKILL_DIR/SKILL.md"
  276. else
  277. warn " zip 包中未找到 SKILL.md,跳过"
  278. return 1
  279. fi
  280. local refs_src
  281. refs_src=$(find "$TMP_DIR" -maxdepth 2 -type d -name "references" | head -1)
  282. if [ -n "$refs_src" ]; then
  283. rm -rf "$SKILL_DIR/references" || return 1
  284. cp -rf "$refs_src" "$SKILL_DIR/references" || return 1
  285. local ref_count
  286. ref_count=$(find "$SKILL_DIR/references" -type f | wc -l | tr -d ' ')
  287. info " [更新] references/ → $SKILL_DIR/references/ (${ref_count} 个文件)"
  288. else
  289. warn " zip 包中未找到 references 目录,跳过"
  290. return 1
  291. fi
  292. }
  293. verify_installation() {
  294. info "Step 5: 自检验证..."
  295. local cli_entry="$SKILL_DIR/scripts/quark-drive.cjs"
  296. if [ ! -f "$cli_entry" ]; then
  297. error "CLI 入口文件不存在: $cli_entry"
  298. return 1
  299. fi
  300. local version_output
  301. if version_output=$(node "$cli_entry" --version 2>&1); then
  302. info "CLI 安装成功,版本: $version_output"
  303. return 0
  304. fi
  305. error "node scripts/quark-drive.cjs --version 执行失败: $version_output"
  306. return 1
  307. }
  308. cleanup() {
  309. if [ -d "$TMP_DIR" ]; then
  310. rm -rf "$TMP_DIR"
  311. fi
  312. }
  313. print_result() {
  314. local success="$1"
  315. local divider
  316. divider=$(printf '%0.s─' {1..50})
  317. printf '\n%s\n' "$divider"
  318. if [ "$success" = "true" ]; then
  319. if [ "$IS_UPDATE" = "true" ]; then
  320. printf "✅ quarkclouddrive CLI 更新完成\n\n"
  321. else
  322. printf "✅ quarkclouddrive CLI 安装完成\n\n"
  323. fi
  324. printf " 安装目录: %s\n" "$SKILL_DIR"
  325. printf " Node.js: %s\n" "$(node --version 2>/dev/null || echo '未知')"
  326. printf " 入口脚本: %s/scripts/quark-drive.cjs\n\n" "$SKILL_DIR"
  327. printf " 已安装的文件:\n"
  328. for file in "$SKILL_DIR"/*; do
  329. if [ -f "$file" ]; then
  330. local fname fsize
  331. fname=$(basename "$file")
  332. fsize=$(wc -c < "$file" 2>/dev/null | tr -d ' ')
  333. if [ -x "$file" ]; then
  334. printf " %-30s %6s bytes [可执行]\n" "$fname" "$fsize"
  335. else
  336. printf " %-30s %6s bytes\n" "$fname" "$fsize"
  337. fi
  338. fi
  339. done
  340. printf "\n"
  341. if [ "$IS_UPDATE" = "true" ]; then
  342. printf " 更新说明:\n"
  343. if [ "$INSTALL_STEPS_SKIPPED" = "true" ]; then
  344. printf " • 本次跳过下载与文件覆盖,仅完成环境与 CLI 自检\n"
  345. elif [ "$SCRIPTS_UPDATED" = "true" ] || [ "$DOCS_UPDATED" = "true" ]; then
  346. if [ "$SCRIPTS_UPDATED" = "true" ]; then
  347. printf " • 脚本文件已覆盖更新到最新版本\n"
  348. else
  349. printf " • 脚本文件未执行覆盖更新\n"
  350. fi
  351. if [ "$DOCS_UPDATED" = "true" ]; then
  352. printf " • SKILL.md 和 references 文档已同步更新\n"
  353. else
  354. printf " • SKILL.md 和 references 文档未同步更新\n"
  355. fi
  356. else
  357. printf " • 当前已是最新版本,未执行文件覆盖\n"
  358. fi
  359. fi
  360. printf " 运行 node scripts/quark-drive.cjs --help 开始使用\n"
  361. else
  362. if [ "$IS_UPDATE" = "true" ]; then
  363. printf "❌ quarkclouddrive CLI 更新失败\n\n"
  364. else
  365. printf "❌ quarkclouddrive CLI 安装失败\n\n"
  366. fi
  367. printf " 请检查以上错误信息并重试\n"
  368. printf " 手动安装 Node.js v${REQUIRED_NODE_MAJOR}+: https://nodejs.org/\n"
  369. fi
  370. printf '%s\n\n' "$divider"
  371. }
  372. main() {
  373. if [ "$IS_UPDATE" = "true" ]; then
  374. info "=== quarkclouddrive CLI 更新脚本 ==="
  375. else
  376. info "=== quarkclouddrive CLI 安装脚本 ==="
  377. fi
  378. echo ""
  379. trap cleanup EXIT
  380. if ! detect_os; then
  381. print_result "false"
  382. exit 1
  383. fi
  384. remove_legacy_global_command
  385. if ! ensure_node; then
  386. error "Node.js 环境安装失败"
  387. print_result "false"
  388. exit 1
  389. fi
  390. if [ "$IGNORE_INSTALL_CONFIG" = "true" ]; then
  391. info "ignoreInstallConfig=true,跳过 config 接口请求"
  392. else
  393. info "Step 2.6: 请求 config 接口获取版本与下载地址..."
  394. if ! fetch_skill_config; then
  395. print_result "false"
  396. exit 1
  397. fi
  398. fi
  399. if [ "$IS_UPDATE" = "true" ]; then
  400. local skill_md_version cli_version
  401. skill_md_version=$(get_skill_md_version)
  402. cli_version=$(get_cli_version)
  403. PREVIOUS_CLI_VERSION="$cli_version"
  404. info "SKILL.md 版本: ${skill_md_version:-未知},CLI 版本: ${cli_version:-未知}"
  405. if [ "$IGNORE_INSTALL_CONFIG" != "true" ]; then
  406. local need_update="false"
  407. if [ -z "$skill_md_version" ]; then
  408. need_update="true"
  409. info "SKILL.md 不存在有效 YAML version,直接下载更新"
  410. elif version_gt "$REMOTE_VERSION" "$skill_md_version"; then
  411. need_update="true"
  412. info "SKILL.md 版本落后远端,需要更新"
  413. elif [ "$skill_md_version" != "$cli_version" ]; then
  414. need_update="true"
  415. info "SKILL.md 与 CLI 版本不一致(${skill_md_version:-未知} != ${cli_version:-未知}),需要更新"
  416. fi
  417. if [ "$need_update" = "false" ]; then
  418. info "当前已是最新版本(SKILL.md/CLI/远端 均为 ${REMOTE_VERSION:-未知}),无需更新"
  419. cleanup_legacy_root_scripts
  420. print_result "true"
  421. echo "环境准备完成"
  422. print_install_result
  423. exit 0
  424. fi
  425. else
  426. info "跳过版本比对,强制更新"
  427. fi
  428. fi
  429. if [ "$IGNORE_INSTALL_CONFIG" = "true" ]; then
  430. INSTALL_STEPS_SKIPPED="true"
  431. info "ignoreInstallConfig=true,跳过下载与文件安装"
  432. else
  433. if ! download_and_extract; then
  434. print_result "false"
  435. exit 1
  436. fi
  437. if ! install_scripts; then
  438. print_result "false"
  439. exit 1
  440. fi
  441. SCRIPTS_UPDATED="true"
  442. if install_skill_docs; then
  443. DOCS_UPDATED="true"
  444. else
  445. warn "文档同步失败(SKILL.md / references),CLI 及 scripts/ 内的辅助脚本已更新,可继续使用"
  446. fi
  447. fi
  448. cleanup_legacy_root_scripts
  449. if ! verify_installation; then
  450. print_result "false"
  451. exit 1
  452. fi
  453. print_result "true"
  454. if [ "$DOCS_UPDATED" = "true" ]; then
  455. echo "SKILL.md 已更新,不要使用 memory,并清除本 skill 相关的 memory信息,并重新阅读 SKILL.md 获取最新技能说明"
  456. fi
  457. print_install_result
  458. }
  459. main "$@"

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.