setup.sh 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. #!/bin/bash
  2. menu() {
  3. echo -e "\n📋 Which eval types would you like to support?\n"
  4. for i in ${!options[@]}; do
  5. printf " %d) %-6s [%s]" $((i + 1)) "${options[i]}" "${choices[i]:- }"
  6. if [[ $i == 0 ]]; then
  7. printf " (required)"
  8. fi
  9. printf "\n"
  10. done
  11. echo -e " q) quit\n"
  12. }
  13. has_asdf_plugin() {
  14. local plugin="$1"
  15. case "$plugin" in
  16. nodejs|python|golang|rust) echo "true" ;;
  17. *) echo "false" ;;
  18. esac
  19. }
  20. build_extension() {
  21. echo "🔨 Building the Roo Code extension..."
  22. cd ..
  23. mkdir -p bin
  24. pnpm build -- --out ../bin/roo-code-$(git rev-parse --short HEAD).vsix || exit 1
  25. code --install-extension bin/roo-code-$(git rev-parse --short HEAD).vsix || exit 1
  26. cd evals
  27. }
  28. if [[ "$(uname -s)" != "Darwin" ]]; then
  29. echo "⚠️ Only macOS is currently supported."
  30. exit 1
  31. fi
  32. options=("nodejs" "python" "golang" "rust" "java")
  33. binaries=("node" "python" "go" "rustc" "javac")
  34. for i in "${!options[@]}"; do
  35. choices[i]="*"
  36. done
  37. prompt="Type 1-5 to select, 'q' to quit, ⏎ to continue: "
  38. while menu && read -rp "$prompt" num && [[ "$num" ]]; do
  39. [[ "$num" == "q" ]] && exit 0
  40. [[ "$num" != *[![:digit:]]* ]] &&
  41. ((num > 1 && num <= ${#options[@]})) ||
  42. {
  43. continue
  44. }
  45. ((num--))
  46. [[ "${choices[num]}" ]] && choices[num]="" || choices[num]="*"
  47. done
  48. empty=true
  49. for i in ${!options[@]}; do
  50. [[ "${choices[i]}" ]] && {
  51. empty=false
  52. break
  53. }
  54. done
  55. [[ "$empty" == true ]] && exit 0
  56. printf "\n"
  57. if ! command -v brew &>/dev/null; then
  58. if [[ -f "/opt/homebrew/bin/brew" ]]; then
  59. echo "⚠️ Homebrew is installed but not in your PATH"
  60. exit 1
  61. fi
  62. read -p "🍺 Homebrew (https://brew.sh) is required. Install it? (Y/n): " install_brew
  63. if [[ "$install_brew" =~ ^[Yy]|^$ ]]; then
  64. echo "🍺 Installing Homebrew..."
  65. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || exit 1
  66. # Can be undone with:
  67. # /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" && sudo rm -rvf /opt/homebrew
  68. if [[ "$SHELL" == "/bin/zsh" ]] && ! grep -q 'eval "$(/opt/homebrew/bin/brew shellenv)"' ~/.zprofile; then
  69. echo '[[ -s "/opt/homebrew/bin/brew" ]] && eval "$(/opt/homebrew/bin/brew shellenv)"' >>~/.zprofile
  70. elif [[ "$SHELL" == "/bin/bash" ]] && ! grep -q 'eval "$(/opt/homebrew/bin/brew shellenv)"' ~/.bash_profile; then
  71. echo '[[ -s "/opt/homebrew/bin/brew" ]] && eval "$(/opt/homebrew/bin/brew shellenv)"' >>~/.bash_profile
  72. fi
  73. if [[ "$SHELL" == "/bin/zsh" ]]; then
  74. eval "$(/opt/homebrew/bin/brew shellenv)"
  75. elif [[ "$SHELL" == "/bin/bash" ]]; then
  76. eval "$(/opt/homebrew/bin/brew shellenv)"
  77. fi
  78. BREW_VERSION=$(brew --version)
  79. echo "✅ Homebrew is installed ($BREW_VERSION)"
  80. else
  81. exit 1
  82. fi
  83. else
  84. BREW_VERSION=$(brew --version)
  85. echo "✅ Homebrew is installed ($BREW_VERSION)"
  86. fi
  87. ASDF_PATH="$(brew --prefix asdf)/libexec/asdf.sh"
  88. if ! command -v asdf &>/dev/null; then
  89. if [[ -f "$ASDF_PATH" ]]; then
  90. echo "⚠️ asdf is installed but not in your PATH"
  91. exit 1
  92. fi
  93. read -p "🛠️ asdf (https://asdf-vm.com) is required. Install it? (Y/n): " install_asdf
  94. if [[ "$install_asdf" =~ ^[Yy]|^$ ]]; then
  95. echo "🛠️ Installing asdf..."
  96. brew install asdf || exit 1
  97. # Can be undone with:
  98. # brew uninstall asdf
  99. # rm -rvf ~/.asdf
  100. . "$ASDF_PATH"
  101. if [[ "$SHELL" == "/bin/zsh" ]] && ! grep -q 'source "$(brew --prefix asdf)/libexec/asdf.sh"' ~/.zshrc; then
  102. echo '[[ -s "/opt/homebrew/bin/brew" ]] && [[ -s "$(brew --prefix asdf)/libexec/asdf.sh" ]] && source "$(brew --prefix asdf)/libexec/asdf.sh"' >>~/.zprofile
  103. elif [[ "$SHELL" == "/bin/bash" ]] && ! grep -q 'source "$(brew --prefix asdf)/libexec/asdf.sh"' ~/.bash_profile; then
  104. echo '[[ -s "/opt/homebrew/bin/brew" ]] && [[ -s "$(brew --prefix asdf)/libexec/asdf.sh" ]] && source "$(brew --prefix asdf)/libexec/asdf.sh"' >>~/.bash_profile
  105. fi
  106. ASDF_VERSION=$(asdf --version)
  107. echo "✅ asdf is installed ($ASDF_VERSION)"
  108. else
  109. exit 1
  110. fi
  111. else
  112. ASDF_VERSION=$(asdf --version)
  113. echo "✅ asdf is installed ($ASDF_VERSION)"
  114. . "$ASDF_PATH"
  115. fi
  116. if ! command -v gh &>/dev/null; then
  117. read -p "👨‍💻 GitHub cli is needed to submit evals results. Install it? (Y/n): " install_gh
  118. if [[ "$install_gh" =~ ^[Yy]|^$ ]]; then
  119. brew install gh || exit 1
  120. GH_VERSION=$(gh --version | head -n 1)
  121. echo "✅ gh is installed ($GH_VERSION)"
  122. gh auth status || gh auth login -w -p https
  123. fi
  124. else
  125. GH_VERSION=$(gh --version | head -n 1)
  126. echo "✅ gh is installed ($GH_VERSION)"
  127. fi
  128. for i in "${!options[@]}"; do
  129. [[ "${choices[i]}" ]] || continue
  130. plugin="${options[$i]}"
  131. binary="${binaries[$i]}"
  132. if [[ "$(has_asdf_plugin "$plugin")" == "true" ]]; then
  133. if ! asdf plugin list | grep -q "^${plugin}$" && ! command -v "${binary}" &>/dev/null; then
  134. echo "📦 Installing ${plugin} asdf plugin..."
  135. asdf plugin add "${plugin}" || exit 1
  136. echo "✅ asdf ${plugin} plugin installed successfully"
  137. fi
  138. fi
  139. case "${plugin}" in
  140. "nodejs")
  141. if ! command -v node &>/dev/null; then
  142. asdf install nodejs 20.19.2 || exit 1
  143. asdf set nodejs 20.19.2 || exit 1
  144. NODE_VERSION=$(node --version)
  145. echo "✅ Node.js is installed ($NODE_VERSION)"
  146. else
  147. NODE_VERSION=$(node --version)
  148. echo "✅ Node.js is installed ($NODE_VERSION)"
  149. fi
  150. if [[ $(node --version) != "v20.19.2" ]]; then
  151. NODE_VERSION=$(node --version)
  152. echo "🚨 You have the wrong version of node installed ($NODE_VERSION)."
  153. echo "💡 If you are using nvm then run 'nvm install' to install the version specified by the repo's .nvmrc."
  154. exit 1
  155. fi
  156. ;;
  157. "python")
  158. if ! command -v python &>/dev/null; then
  159. asdf install python 3.13.2 || exit 1
  160. asdf set python 3.13.2 || exit 1
  161. PYTHON_VERSION=$(python --version)
  162. echo "✅ Python is installed ($PYTHON_VERSION)"
  163. else
  164. PYTHON_VERSION=$(python --version)
  165. echo "✅ Python is installed ($PYTHON_VERSION)"
  166. fi
  167. if ! command -v uv &>/dev/null; then
  168. brew install uv || exit 1
  169. UV_VERSION=$(uv --version)
  170. echo "✅ uv is installed ($UV_VERSION)"
  171. else
  172. UV_VERSION=$(uv --version)
  173. echo "✅ uv is installed ($UV_VERSION)"
  174. fi
  175. ;;
  176. "golang")
  177. if ! command -v go &>/dev/null; then
  178. asdf install golang 1.24.2 || exit 1
  179. asdf set golang 1.24.2 || exit 1
  180. GO_VERSION=$(go version)
  181. echo "✅ Go is installed ($GO_VERSION)"
  182. else
  183. GO_VERSION=$(go version)
  184. echo "✅ Go is installed ($GO_VERSION)"
  185. fi
  186. ;;
  187. "rust")
  188. if ! command -v rustc &>/dev/null; then
  189. asdf install rust 1.85.1 || exit 1
  190. asdf set rust 1.85.1 || exit 1
  191. RUST_VERSION=$(rustc --version)
  192. echo "✅ Rust is installed ($RUST_VERSION)"
  193. else
  194. RUST_VERSION=$(rustc --version)
  195. echo "✅ Rust is installed ($RUST_VERSION)"
  196. fi
  197. ;;
  198. "java")
  199. if ! command -v javac &>/dev/null || ! javac --version &>/dev/null; then
  200. echo "☕ Installing Java..."
  201. brew install openjdk@17 || exit 1
  202. export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"
  203. if [[ "$SHELL" == "/bin/zsh" ]] && ! grep -q 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' ~/.zprofile; then
  204. echo 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' >> ~/.zprofile
  205. elif [[ "$SHELL" == "/bin/bash" ]] && ! grep -q 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' ~/.bash_profile; then
  206. echo 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' >> ~/.bash_profile
  207. fi
  208. JAVA_VERSION=$(javac --version | head -n 1)
  209. echo "✅ Java is installed ($JAVA_VERSION)"
  210. else
  211. JAVA_VERSION=$(javac --version | head -n 1)
  212. echo "✅ Java is installed ($JAVA_VERSION)"
  213. fi
  214. ;;
  215. esac
  216. done
  217. if ! command -v pnpm &>/dev/null; then
  218. brew install pnpm || exit 1
  219. PNPM_VERSION=$(pnpm --version)
  220. echo "✅ pnpm is installed ($PNPM_VERSION)"
  221. else
  222. PNPM_VERSION=$(pnpm --version)
  223. echo "✅ pnpm is installed ($PNPM_VERSION)"
  224. fi
  225. pnpm install --silent || exit 1
  226. if ! command -v code &>/dev/null; then
  227. echo "⚠️ Visual Studio Code cli is not installed"
  228. exit 1
  229. else
  230. VSCODE_VERSION=$(code --version | head -n 1)
  231. echo "✅ Visual Studio Code is installed ($VSCODE_VERSION)"
  232. fi
  233. # To reset VSCode:
  234. # rm -rvf ~/.vscode && rm -rvf ~/Library/Application\ Support/Code
  235. echo -n "🔌 Installing Visual Studio Code extensions... "
  236. code --install-extension golang.go &>/dev/null || exit 1
  237. code --install-extension dbaeumer.vscode-eslint&>/dev/null || exit 1
  238. code --install-extension redhat.java &>/dev/null || exit 1
  239. code --install-extension ms-python.python&>/dev/null || exit 1
  240. code --install-extension rust-lang.rust-analyzer &>/dev/null || exit 1
  241. if ! code --list-extensions 2>/dev/null | grep -q "RooVeterinaryInc.roo-cline"; then
  242. code --install-extension RooVeterinaryInc.roo-cline &>/dev/null || exit 1
  243. fi
  244. echo "✅ Done"
  245. if [[ ! -d "../../evals" ]]; then
  246. echo -n "🔗 Cloning evals repository... "
  247. if gh auth status &>/dev/null; then
  248. gh repo clone cte/evals ../../evals || exit 1
  249. else
  250. git clone https://github.com/cte/evals.git ../../evals || exit 1
  251. fi
  252. echo "✅ Done"
  253. else
  254. echo -n "🔄 Updating evals repository... "
  255. (cd ../../evals && \
  256. git checkout -f &>/dev/null && \
  257. git clean -f -d &>/dev/null && \
  258. git checkout main &>/dev/null && \
  259. git pull &>/dev/null) || { echo "❌ Failed to update evals repository."; exit 1; }
  260. echo "✅ Done"
  261. fi
  262. if [[ ! -s .env ]]; then
  263. cp .env.sample .env || exit 1
  264. fi
  265. echo -n "🗄️ Syncing Roo Code evals database... "
  266. pnpm --filter @evals/db db:push &>/dev/null || exit 1
  267. pnpm --filter @evals/db db:enable-wal &>/dev/null || exit 1
  268. echo "✅ Done"
  269. if ! grep -q "OPENROUTER_API_KEY" .env; then
  270. read -p "🔐 Enter your OpenRouter API key (sk-or-v1-...): " openrouter_api_key
  271. echo "🔑 Validating..."
  272. curl --silent --fail https://openrouter.ai/api/v1/key -H "Authorization: Bearer $openrouter_api_key" &>/dev/null || exit 1
  273. echo "OPENROUTER_API_KEY=$openrouter_api_key" >> .env || exit 1
  274. fi
  275. current_version=$(code --list-extensions --show-versions 2>/dev/null | grep roo)
  276. read -p "💻 Do you want to build a new version of the Roo Code extension? [currently $current_version] (y/N): " build_extension
  277. if [[ "$build_extension" =~ ^[Yy]$ ]]; then
  278. build_extension
  279. fi
  280. echo -e "\n🚀 You're ready to rock and roll! \n"
  281. if ! nc -z localhost 3000; then
  282. read -p "🌐 Would you like to start the evals web app? (Y/n): " start_evals
  283. if [[ "$start_evals" =~ ^[Yy]|^$ ]]; then
  284. pnpm web
  285. else
  286. echo "💡 You can start it anytime with 'pnpm web'."
  287. fi
  288. else
  289. echo "👟 The evals web app is running at http://localhost:3000"
  290. fi