update-all.sh 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. #!/usr/bin/env bash
  2. # ============================================================
  3. # Claude Code — Update all components
  4. # Pulls latest config, updates submodules, refreshes symlinks,
  5. # and runs doctor to verify.
  6. # ============================================================
  7. set -euo pipefail
  8. RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
  9. ok() { echo -e "${GREEN}✓${NC} $1"; }
  10. warn() { echo -e "${YELLOW}⚠${NC} $1"; }
  11. info() { echo -e "${BLUE}→${NC} $1"; }
  12. REPO="$(cd "$(dirname "$0")" && pwd)"
  13. VERSION=$(cat "$REPO/version.txt" 2>/dev/null || echo "unknown")
  14. # Load shared detection library
  15. # shellcheck source=lib/detect-plugins.sh
  16. source "$REPO/lib/detect-plugins.sh"
  17. echo ""
  18. echo "═══ claude-config update (v${VERSION}) ═══"
  19. echo ""
  20. # ── 0. Update Claude Code CLI ──
  21. echo "── Updating Claude Code CLI..."
  22. if command -v claude &>/dev/null; then
  23. CURRENT_VER=$(claude --version 2>/dev/null | head -1 || echo "unknown")
  24. info "Current: $CURRENT_VER"
  25. if npm install -g @anthropic-ai/claude-code@latest 2>/dev/null; then
  26. NEW_VER=$(claude --version 2>/dev/null | head -1 || echo "unknown")
  27. if [ "$CURRENT_VER" = "$NEW_VER" ]; then
  28. ok "Claude Code already up to date ($NEW_VER)"
  29. else
  30. ok "Claude Code updated: $CURRENT_VER → $NEW_VER"
  31. fi
  32. else
  33. warn "Claude Code update failed — try manually: npm install -g @anthropic-ai/claude-code@latest"
  34. fi
  35. else
  36. warn "Claude Code not found — install first with: make install"
  37. fi
  38. echo ""
  39. # ── 1. Pull latest config ──
  40. echo "── Pulling latest config..."
  41. cd "$REPO"
  42. if git pull --rebase 2>/dev/null; then
  43. ok "Config repo updated"
  44. else
  45. warn "git pull failed — check for uncommitted changes"
  46. fi
  47. # ── 2. Update GStack submodule ──
  48. echo ""
  49. echo "── Updating GStack submodule..."
  50. warn "GStack tracks branch = main (no commit hash). Review upstream commits before updating."
  51. echo ""
  52. printf " Proceed with GStack update? [y/N] "
  53. read -r _gstack_confirm
  54. if [[ "$_gstack_confirm" =~ ^[Yy]$ ]]; then
  55. if git submodule update --remote skills-external/gstack 2>/dev/null; then
  56. if [ -d "skills-external/gstack" ]; then
  57. if [ -x "skills-external/gstack/setup" ]; then
  58. if (cd skills-external/gstack && ./setup) 2>/dev/null; then
  59. ok "GStack updated"
  60. else
  61. warn "GStack ./setup failed — submodule updated but setup did not complete"
  62. fi
  63. else
  64. warn "GStack ./setup not found or not executable — skipping"
  65. ok "GStack submodule pointer updated"
  66. fi
  67. fi
  68. else
  69. warn "GStack submodule update failed — run: git submodule update --init"
  70. fi
  71. else
  72. info "GStack update skipped"
  73. fi
  74. # ── 3. Update RTK (if pinned version available) ──
  75. echo ""
  76. echo "── Updating RTK..."
  77. if command -v cargo &>/dev/null; then
  78. RTK_VERSION=""
  79. if [ -f "$REPO/plugins.lock.json" ] && command -v python3 &>/dev/null; then
  80. RTK_VERSION=$(python3 -c "
  81. import json
  82. with open('$REPO/plugins.lock.json') as f:
  83. d = json.load(f)
  84. print(d.get('rtk',{}).get('version',''))
  85. " 2>/dev/null || true)
  86. fi
  87. if [ -n "$RTK_VERSION" ] && [ "$RTK_VERSION" != "latest" ]; then
  88. info "Pinned version: $RTK_VERSION"
  89. info "Compiling from source — this may take a few minutes..."
  90. cargo install --git https://github.com/rtk-ai/rtk --tag "$RTK_VERSION" --force \
  91. && ok "RTK updated to $RTK_VERSION" \
  92. || warn "RTK update failed"
  93. else
  94. info "No pinned version — installing latest"
  95. info "Compiling from source — this may take a few minutes..."
  96. cargo install --git https://github.com/rtk-ai/rtk --force \
  97. && ok "RTK updated (latest)" \
  98. || warn "RTK update failed"
  99. fi
  100. else
  101. warn "Cargo not available — skipping RTK"
  102. fi
  103. # ── 4. Update GSD v2 ──
  104. echo ""
  105. echo "── Updating GSD v2 (gsd-pi)..."
  106. if command -v gsd &>/dev/null; then
  107. GSD_VER=""
  108. if [ -f "$REPO/plugins.lock.json" ] && command -v python3 &>/dev/null; then
  109. GSD_VER=$(python3 -c "
  110. import json
  111. with open('$REPO/plugins.lock.json') as f:
  112. d = json.load(f)
  113. print(d.get('gsd',{}).get('version',''))
  114. " 2>/dev/null || true)
  115. fi
  116. if [ -n "$GSD_VER" ] && [ "$GSD_VER" != "latest" ]; then
  117. info "Pinned version: $GSD_VER"
  118. npm install -g "gsd-pi@${GSD_VER}" 2>/dev/null \
  119. && ok "GSD v2 updated to $GSD_VER" \
  120. || warn "GSD v2 update failed"
  121. else
  122. info "No pinned version — installing latest"
  123. npm install -g gsd-pi 2>/dev/null \
  124. && ok "GSD v2 updated (latest)" \
  125. || warn "GSD v2 update failed"
  126. fi
  127. else
  128. warn "GSD v2 not installed — skipping (run: npm install -g gsd-pi)"
  129. fi
  130. # ── 5. Update Ruflo CLI (if installed) ──
  131. echo ""
  132. echo "── Updating Ruflo CLI..."
  133. if command -v ruflo &>/dev/null || (type detect_ruflo &>/dev/null && detect_ruflo); then
  134. RUFLO_VER=""
  135. if [ -f "$REPO/plugins.lock.json" ] && command -v python3 &>/dev/null; then
  136. RUFLO_VER=$(python3 -c "
  137. import json
  138. with open('$REPO/plugins.lock.json') as f:
  139. d = json.load(f)
  140. print(d.get('ruflo',{}).get('version',''))
  141. " 2>/dev/null || true)
  142. fi
  143. if [ -n "$RUFLO_VER" ] && [ "$RUFLO_VER" != "latest" ]; then
  144. info "Pinned version: $RUFLO_VER"
  145. npm install -g "ruflo@${RUFLO_VER}" 2>/dev/null \
  146. && ok "Ruflo updated to $RUFLO_VER" \
  147. || warn "Ruflo update failed"
  148. else
  149. npm install -g ruflo@latest 2>/dev/null \
  150. && ok "Ruflo updated (latest)" \
  151. || warn "Ruflo update failed"
  152. fi
  153. else
  154. info "Ruflo not installed — skipping"
  155. fi
  156. # ── 6. Update Context7 CLI ──
  157. echo ""
  158. echo "── Updating Context7 CLI..."
  159. if command -v ctx7 &>/dev/null; then
  160. CTX7_VER=""
  161. if [ -f "$REPO/plugins.lock.json" ] && command -v python3 &>/dev/null; then
  162. CTX7_VER=$(python3 -c "
  163. import json
  164. with open('$REPO/plugins.lock.json') as f:
  165. d = json.load(f)
  166. print(d.get('ctx7',{}).get('version',''))
  167. " 2>/dev/null || true)
  168. fi
  169. if [ -n "$CTX7_VER" ] && [ "$CTX7_VER" != "latest" ]; then
  170. info "Pinned version: $CTX7_VER"
  171. npm install -g "ctx7@${CTX7_VER}" 2>/dev/null \
  172. && ok "ctx7 updated to $CTX7_VER" \
  173. || warn "ctx7 update failed"
  174. else
  175. npm install -g ctx7@latest 2>/dev/null \
  176. && ok "ctx7 updated (latest)" \
  177. || warn "ctx7 update failed"
  178. fi
  179. else
  180. info "ctx7 not installed — skipping"
  181. fi
  182. # ── 7. Update Graphifyy ──
  183. echo ""
  184. echo "── Updating Graphifyy..."
  185. if command -v graphify &>/dev/null; then
  186. pipx upgrade graphifyy 2>/dev/null \
  187. && ok "graphifyy updated" \
  188. || warn "graphifyy update failed — try: pipx upgrade graphifyy"
  189. else
  190. info "graphifyy not installed — skipping"
  191. fi
  192. # ── 8. Update marketplace plugins ──
  193. echo ""
  194. echo "── Updating marketplace plugins..."
  195. if command -v claude &>/dev/null; then
  196. _plugins=$(claude plugin list 2>/dev/null \
  197. | grep -oP '(?<=❯ )\S+' || true)
  198. if [ -n "$_plugins" ]; then
  199. while IFS= read -r _p; do
  200. _name="${_p%%@*}"
  201. info "Updating $_name..."
  202. claude plugin update "$_name" 2>/dev/null \
  203. && ok "$_name updated" \
  204. || warn "$_name update failed"
  205. done <<< "$_plugins"
  206. else
  207. info "No marketplace plugins installed — skipping"
  208. fi
  209. else
  210. warn "Claude Code not found — skipping plugin update"
  211. fi
  212. # ── 9. Refresh symlinks ──
  213. echo ""
  214. echo "── Refreshing symlinks..."
  215. bash "$REPO/link.sh"
  216. # ── 10. Run doctor ──
  217. echo ""
  218. bash "$REPO/doctor.sh"