update-all.sh 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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 Context7 CLI ──
  131. echo ""
  132. echo "── Updating Context7 CLI..."
  133. if command -v ctx7 &>/dev/null; then
  134. CTX7_VER=""
  135. if [ -f "$REPO/plugins.lock.json" ] && command -v python3 &>/dev/null; then
  136. CTX7_VER=$(python3 -c "
  137. import json
  138. with open('$REPO/plugins.lock.json') as f:
  139. d = json.load(f)
  140. print(d.get('ctx7',{}).get('version',''))
  141. " 2>/dev/null || true)
  142. fi
  143. if [ -n "$CTX7_VER" ] && [ "$CTX7_VER" != "latest" ]; then
  144. info "Pinned version: $CTX7_VER"
  145. npm install -g "ctx7@${CTX7_VER}" 2>/dev/null \
  146. && ok "ctx7 updated to $CTX7_VER" \
  147. || warn "ctx7 update failed"
  148. else
  149. npm install -g ctx7@latest 2>/dev/null \
  150. && ok "ctx7 updated (latest)" \
  151. || warn "ctx7 update failed"
  152. fi
  153. else
  154. info "ctx7 not installed — skipping"
  155. fi
  156. # ── 6. Update Graphifyy ──
  157. echo ""
  158. echo "── Updating Graphifyy..."
  159. if command -v graphify &>/dev/null; then
  160. pipx upgrade graphifyy 2>/dev/null \
  161. && ok "graphifyy updated" \
  162. || warn "graphifyy update failed — try: pipx upgrade graphifyy"
  163. else
  164. info "graphifyy not installed — skipping"
  165. fi
  166. # ── 7. Update Emil Design Engineering skill ──
  167. echo ""
  168. echo "── Updating Emil Design Engineering..."
  169. EMIL_DIR="$REPO/skills-external/emil-design-eng"
  170. EMIL_URL="https://raw.githubusercontent.com/emilkowalski/skill/main/skills/emil-design-eng/SKILL.md"
  171. if [ -d "$EMIL_DIR" ]; then
  172. info "Fetching latest SKILL.md from emilkowalski/skill..."
  173. curl -fsSL "$EMIL_URL" -o "$EMIL_DIR/SKILL.md.tmp" \
  174. && mv "$EMIL_DIR/SKILL.md.tmp" "$EMIL_DIR/SKILL.md" \
  175. && ok "emil-design-eng updated" \
  176. || warn "emil-design-eng update failed"
  177. else
  178. info "emil-design-eng not installed — skipping (run: make plugin)"
  179. fi
  180. # ── 8. Update marketplace plugins ──
  181. echo ""
  182. echo "── Updating marketplace plugins..."
  183. if command -v claude &>/dev/null; then
  184. _plugins=$(claude plugin list 2>/dev/null \
  185. | grep -oP '(?<=❯ )\S+' || true)
  186. if [ -n "$_plugins" ]; then
  187. while IFS= read -r _p; do
  188. _name="${_p%%@*}"
  189. info "Updating $_name..."
  190. claude plugin update "$_name" 2>/dev/null \
  191. && ok "$_name updated" \
  192. || warn "$_name update failed"
  193. done <<< "$_plugins"
  194. else
  195. info "No marketplace plugins installed — skipping"
  196. fi
  197. else
  198. warn "Claude Code not found — skipping plugin update"
  199. fi
  200. # ── 9. Refresh symlinks ──
  201. echo ""
  202. echo "── Refreshing symlinks..."
  203. bash "$REPO/link.sh"
  204. # ── 10. Run doctor ──
  205. echo ""
  206. bash "$REPO/doctor.sh"