update-all.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. echo ""
  15. echo "═══ claude-config update (v${VERSION}) ═══"
  16. echo ""
  17. # ── 1. Pull latest config ──
  18. echo "── Pulling latest config..."
  19. cd "$REPO"
  20. if git pull --rebase 2>/dev/null; then
  21. ok "Config repo updated"
  22. else
  23. warn "git pull failed — check for uncommitted changes"
  24. fi
  25. # ── 2. Update GStack submodule ──
  26. echo ""
  27. echo "── Updating GStack submodule..."
  28. warn "GStack tracks branch = main (no commit hash). Review upstream commits before updating."
  29. echo ""
  30. printf " Proceed with GStack update? [y/N] "
  31. read -r _gstack_confirm
  32. if [[ "$_gstack_confirm" =~ ^[Yy]$ ]]; then
  33. if git submodule update --remote skills-external/gstack 2>/dev/null; then
  34. if [ -d "skills-external/gstack" ]; then
  35. if [ -x "skills-external/gstack/setup" ]; then
  36. if (cd skills-external/gstack && ./setup) 2>/dev/null; then
  37. ok "GStack updated"
  38. else
  39. warn "GStack ./setup failed — submodule updated but setup did not complete"
  40. fi
  41. else
  42. warn "GStack ./setup not found or not executable — skipping"
  43. ok "GStack submodule pointer updated"
  44. fi
  45. fi
  46. else
  47. warn "GStack submodule update failed — run: git submodule update --init"
  48. fi
  49. else
  50. info "GStack update skipped"
  51. fi
  52. # ── 3. Update RTK (if pinned version available) ──
  53. echo ""
  54. echo "── Updating RTK..."
  55. if command -v cargo &>/dev/null; then
  56. RTK_VERSION=""
  57. if [ -f "$REPO/plugins.lock.json" ] && command -v python3 &>/dev/null; then
  58. RTK_VERSION=$(python3 -c "
  59. import json
  60. with open('$REPO/plugins.lock.json') as f:
  61. d = json.load(f)
  62. print(d.get('rtk',{}).get('version',''))
  63. " 2>/dev/null || true)
  64. fi
  65. if [ -n "$RTK_VERSION" ] && [ "$RTK_VERSION" != "latest" ]; then
  66. info "Pinned version: $RTK_VERSION"
  67. cargo install --git https://github.com/rtk-ai/rtk --tag "$RTK_VERSION" --force 2>/dev/null \
  68. && ok "RTK updated to $RTK_VERSION" \
  69. || warn "RTK update failed"
  70. else
  71. info "No pinned version — installing latest"
  72. cargo install --git https://github.com/rtk-ai/rtk --force 2>/dev/null \
  73. && ok "RTK updated (latest)" \
  74. || warn "RTK update failed"
  75. fi
  76. else
  77. warn "Cargo not available — skipping RTK"
  78. fi
  79. # ── 4. Update GSD v2 ──
  80. echo ""
  81. echo "── Updating GSD v2 (gsd-pi)..."
  82. if command -v gsd &>/dev/null; then
  83. GSD_VER=""
  84. if [ -f "$REPO/plugins.lock.json" ] && command -v python3 &>/dev/null; then
  85. GSD_VER=$(python3 -c "
  86. import json
  87. with open('$REPO/plugins.lock.json') as f:
  88. d = json.load(f)
  89. print(d.get('gsd',{}).get('version',''))
  90. " 2>/dev/null || true)
  91. fi
  92. if [ -n "$GSD_VER" ] && [ "$GSD_VER" != "latest" ]; then
  93. info "Pinned version: $GSD_VER"
  94. npm install -g "gsd-pi@${GSD_VER}" 2>/dev/null \
  95. && ok "GSD v2 updated to $GSD_VER" \
  96. || warn "GSD v2 update failed"
  97. else
  98. info "No pinned version — installing latest"
  99. npm install -g gsd-pi 2>/dev/null \
  100. && ok "GSD v2 updated (latest)" \
  101. || warn "GSD v2 update failed"
  102. fi
  103. else
  104. warn "GSD v2 not installed — skipping (run: npm install -g gsd-pi)"
  105. fi
  106. # ── 5. Update Ruflo CLI (if installed) ──
  107. echo ""
  108. echo "── Updating Ruflo CLI..."
  109. if command -v ruflo &>/dev/null || detect_ruflo; then
  110. RUFLO_VER=""
  111. if [ -f "$REPO/plugins.lock.json" ] && command -v python3 &>/dev/null; then
  112. RUFLO_VER=$(python3 -c "
  113. import json
  114. with open('$REPO/plugins.lock.json') as f:
  115. d = json.load(f)
  116. print(d.get('ruflo',{}).get('version',''))
  117. " 2>/dev/null || true)
  118. fi
  119. if [ -n "$RUFLO_VER" ] && [ "$RUFLO_VER" != "latest" ]; then
  120. info "Pinned version: $RUFLO_VER"
  121. npm install -g "ruflo@${RUFLO_VER}" 2>/dev/null \
  122. && ok "Ruflo updated to $RUFLO_VER" \
  123. || warn "Ruflo update failed"
  124. else
  125. npm install -g ruflo@latest 2>/dev/null \
  126. && ok "Ruflo updated (latest)" \
  127. || warn "Ruflo update failed"
  128. fi
  129. else
  130. info "Ruflo not installed — skipping"
  131. fi
  132. # ── 6. Refresh symlinks ──
  133. echo ""
  134. echo "── Refreshing symlinks..."
  135. bash "$REPO/link.sh"
  136. # ── 7. Run doctor ──
  137. echo ""
  138. bash "$REPO/doctor.sh"