session-start.sh 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/usr/bin/env bash
  2. # ============================================================
  3. # Claude Code — Session start plugin status
  4. # Runs once per session. Zero API calls. Filesystem only.
  5. # ============================================================
  6. # ── Quick health check (filesystem only, no subprocesses) ──
  7. BROKEN=()
  8. for f in CLAUDE.md settings.json agents skills; do
  9. [ ! -e "$HOME/.claude/$f" ] && BROKEN+=("$f")
  10. done
  11. if [ ${#BROKEN[@]} -gt 0 ]; then
  12. # Try to find the repo path from an existing symlink
  13. _repo_hint=""
  14. for _probe in CLAUDE.md settings.json; do
  15. if [ -L "$HOME/.claude/$_probe" ]; then
  16. _repo_hint="$(cd "$(dirname "$(readlink "$HOME/.claude/$_probe")")" 2>/dev/null && pwd)"
  17. break
  18. fi
  19. done
  20. _fix_cmd="${_repo_hint:+cd $_repo_hint && }bash link.sh"
  21. echo ""
  22. echo "┌─ ⚠️ CONFIG ISSUES ────────────────────────────────┐"
  23. for b in "${BROKEN[@]}"; do
  24. printf "│ MISSING: ~/.claude/%-30s│\n" "$b"
  25. done
  26. printf "│ → %-47s│\n" "$_fix_cmd"
  27. echo "│ → /health for full diagnostic │"
  28. echo "└───────────────────────────────────────────────────┘"
  29. unset _repo_hint _fix_cmd
  30. fi
  31. # ── Load shared detection library ──
  32. _lib="$(dirname "${BASH_SOURCE[0]}")/../lib/detect-plugins.sh"
  33. if [ -f "$_lib" ]; then
  34. # shellcheck source=../lib/detect-plugins.sh
  35. source "$_lib"
  36. else
  37. # Fallback: inline detection if lib is missing
  38. detect_gstack() { [ -d "$HOME/.claude/skills/gstack" ]; }
  39. detect_gsd() { ls "$HOME/.claude/skills/" 2>/dev/null | grep -qi "gsd"; }
  40. detect_uiux_pro_max() { ls "$HOME/.claude/plugins/cache/" 2>/dev/null | grep -qi "ui-ux-pro-max"; }
  41. detect_frontend_design() { ls "$HOME/.claude/plugins/cache/" 2>/dev/null | grep -qi "frontend-design"; }
  42. detect_context7() { claude mcp list 2>/dev/null | grep -q "context7"; }
  43. fi
  44. unset _lib
  45. # ── Toggle plugin detection ──
  46. TOGGLE_ACTIVE=()
  47. TOGGLE_INACTIVE=()
  48. for plugin in gstack gsd uiux_pro_max frontend_design context7; do
  49. # Map function name to display name
  50. case "$plugin" in
  51. uiux_pro_max) display="ui-ux-pro-max" ;;
  52. frontend_design) display="frontend-design" ;;
  53. *) display="$plugin" ;;
  54. esac
  55. if "detect_$plugin" 2>/dev/null; then
  56. TOGGLE_ACTIVE+=("$display")
  57. else
  58. TOGGLE_INACTIVE+=("$display")
  59. fi
  60. done
  61. # --- Format output ---
  62. ACTIVE_STR="${TOGGLE_ACTIVE[*]:-none}"
  63. INACTIVE_STR="${TOGGLE_INACTIVE[*]:-none}"
  64. # Version detection: follow CLAUDE.md symlink back to repo, then read version.txt
  65. _claude_real="$(readlink "$HOME/.claude/CLAUDE.md" 2>/dev/null || true)"
  66. if [ -n "$_claude_real" ]; then
  67. _repo_dir="$(cd "$(dirname "$_claude_real")" 2>/dev/null && pwd)"
  68. CONFIG_VERSION=$(cat "$_repo_dir/version.txt" 2>/dev/null || echo "?")
  69. else
  70. CONFIG_VERSION="?"
  71. fi
  72. unset _claude_real _repo_dir
  73. echo ""
  74. echo "┌─ Toggle plugins ──────────────────────────────────┐"
  75. printf "│ 🟢 ON : %-40s│\n" "$ACTIVE_STR"
  76. printf "│ ⚫ OFF : %-40s│\n" "$INACTIVE_STR"
  77. echo "│ 💡 /plugin-check before starting a new project │"
  78. echo "│ 🩺 /health to run full diagnostic │"
  79. echo "└───────────────────────────────────────────────────┘"
  80. echo ""