setup.sh 11 KB

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