From 33764e38e8362710b14e624099b8f6024cffd3b6 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Fri, 21 Nov 2025 05:42:40 -0600 Subject: [PATCH 1/5] Reapply "feat(cli): better install script output" This reverts commit 8bad5131407c94dca19880551f8235fc48164b40. --- install | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 117 insertions(+), 9 deletions(-) diff --git a/install b/install index 42ae846efd47..37864b4edd0d 100755 --- a/install +++ b/install @@ -2,9 +2,8 @@ set -euo pipefail APP=opencode +MUTED='\033[0;2m' RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' ORANGE='\033[38;2;255;140;0m' NC='\033[0m' # No Color @@ -67,8 +66,8 @@ print_message() { local color="" case $level in - info) color="${GREEN}" ;; - warning) color="${YELLOW}" ;; + info) color="${NC}" ;; + warning) color="${NC}" ;; error) color="${RED}" ;; esac @@ -86,18 +85,110 @@ check_version() { installed_version=$(echo $installed_version | awk '{print $2}') if [[ "$installed_version" != "$specific_version" ]]; then - print_message info "Installed version: ${YELLOW}$installed_version." + print_message info "${MUTED}Installed version: ${NC}$installed_version." else - print_message info "Version ${YELLOW}$specific_version${GREEN} already installed" + print_message info "${MUTED}Version ${NC}$specific_version${MUTED} already installed" exit 0 fi fi } +unbuffered_sed() { + if echo | sed -u >/dev/null 2>&1; then + sed -nu "$@" + elif echo | sed -l >/dev/null 2>&1; then + sed -nl "$@" + else + local pad="$(printf "\n%512s" "")" + sed -ne "s/$/\\${pad}/" "$@" + fi +} + +print_progress() { + local bytes="$1" + local length="$2" + [ "$length" -gt 0 ] || return 0 + + local width=50 + local percent=$(( bytes * 100 / length )) + [ "$percent" -gt 100 ] && percent=100 + local on=$(( percent * width / 100 )) + local off=$(( width - on )) + + local full_filled=$(printf "%.0s■" {1..50}) + local full_empty=$(printf "%.0s・" {1..50}) + + printf "\r${ORANGE}%s%s %3d%%${NC}" "${full_filled:0:$on}" "${full_empty:0:$off}" "$percent" >&4 +} + +download_with_progress() { + local url="$1" + local output="$2" + + if [ -t 2 ]; then + exec 4>&2 + else + exec 4>/dev/null + fi + + local tmp_dir=${TMPDIR:-/tmp} + local basename="${tmp_dir}/opencode_install_$$" + local tracefile="${basename}.trace" + + rm -f "$tracefile" + mkfifo "$tracefile" + + # Hide cursor + printf "\033[?25l" >&4 + + trap "trap - RETURN; rm -f \"$tracefile\"; printf '\033[?25h' >&4; exec 4>&-" RETURN + + ( + curl --trace-ascii "$tracefile" -s -L -o "$output" "$url" + ) & + local curl_pid=$! + + unbuffered_sed \ + -e 'y/ACDEGHLNORTV/acdeghlnortv/' \ + -e '/^0000: content-length:/p' \ + -e '/^<= recv data/p' \ + "$tracefile" | \ + { + local length=0 + local bytes=0 + + while IFS=" " read -r -a line; do + local tag="${line[0]} ${line[1]}" + + if [ "$tag" = "0000: content-length:" ]; then + length="${line[2]}" + length=$(echo "$length" | tr -d '\r') + bytes=0 + elif [ "$tag" = "<= recv" ]; then + local size="${line[3]}" + bytes=$(( bytes + size )) + if [ "$length" -gt 0 ]; then + print_progress "$bytes" "$length" + fi + fi + done + } + + wait $curl_pid + local ret=$? + echo "" >&4 + return $ret +} + download_and_install() { - print_message info "Downloading ${ORANGE}opencode ${GREEN}version: ${YELLOW}$specific_version ${GREEN}..." + print_message info "\n${MUTED}Installing ${NC}opencode ${MUTED}version: ${NC}$specific_version" mkdir -p opencodetmp && cd opencodetmp - curl -# -L -o "$filename" "$url" + + if ! download_with_progress "$url" "$filename"; then + # Fallback to standard curl if custom fails for some reason + curl -# -L -o "$filename" "$url" + fi + unzip -q "$filename" mv opencode "$INSTALL_DIR" chmod 755 "${INSTALL_DIR}/opencode" @@ -117,7 +208,7 @@ add_to_path() { elif [[ -w $config_file ]]; then echo -e "\n# opencode" >> "$config_file" echo "$command" >> "$config_file" - print_message info "Successfully added ${ORANGE}opencode ${GREEN}to \$PATH in $config_file" + print_message info "${MUTED}Successfully added ${NC}opencode ${MUTED}to \$PATH in ${NC}$config_file" else print_message warning "Manually add the directory to $config_file (or similar):" print_message info " $command" @@ -191,3 +282,20 @@ if [ -n "${GITHUB_ACTIONS-}" ] && [ "${GITHUB_ACTIONS}" == "true" ]; then echo "$INSTALL_DIR" >> $GITHUB_PATH print_message info "Added $INSTALL_DIR to \$GITHUB_PATH" fi + +echo -e "" +echo -e "${MUTED}  ${NC} ▄ " +echo -e "${MUTED}█▀▀█ █▀▀█ █▀▀█ █▀▀▄ ${NC}█▀▀▀ █▀▀█ █▀▀█ █▀▀█" +echo -e "${MUTED}█░░█ █░░█ █▀▀▀ █░░█ ${NC}█░░░ █░░█ █░░█ █▀▀▀" +echo -e "${MUTED}▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀ ▀ ${NC}▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀" +echo -e "" +echo -e "" +echo -e "${MUTED}To get started, navigate to a project and run:${NC}" +echo -e "opencode ${MUTED}Use free models${NC}" +echo -e "opencode auth login ${MUTED}Add paid provider API keys${NC}" +echo -e "opencode help ${MUTED}List commands and options${NC}" +echo -e "" +echo -e "${MUTED}For more information visit ${NC}https://opencode.ai/docs" +echo -e "" +echo -e "" + From 8d489abd7551980cb29e55120496dd025f467fd5 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Fri, 21 Nov 2025 06:08:06 -0600 Subject: [PATCH 2/5] fix(install): custom progress bar fix for linux --- install | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install b/install index 37864b4edd0d..8b510f36da85 100755 --- a/install +++ b/install @@ -94,9 +94,9 @@ check_version() { } unbuffered_sed() { - if echo | sed -u >/dev/null 2>&1; then + if echo | sed -u -e "" >/dev/null 2>&1; then sed -nu "$@" - elif echo | sed -l >/dev/null 2>&1; then + elif echo | sed -l -e "" >/dev/null 2>&1; then sed -nl "$@" else local pad="$(printf "\n%512s" "")" @@ -158,6 +158,7 @@ download_with_progress() { local bytes=0 while IFS=" " read -r -a line; do + [ "${#line[@]}" -lt 2 ] && continue local tag="${line[0]} ${line[1]}" if [ "$tag" = "0000: content-length:" ]; then From 1c9e943a64f3e4c1ba0c684be838adbaa2380abe Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Fri, 21 Nov 2025 06:49:09 -0600 Subject: [PATCH 3/5] fix(install): normal curl command on windows --- install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install b/install index 8b510f36da85..7c647941f5a2 100755 --- a/install +++ b/install @@ -185,8 +185,8 @@ download_and_install() { print_message info "\n${MUTED}Installing ${NC}opencode ${MUTED}version: ${NC}$specific_version" mkdir -p opencodetmp && cd opencodetmp - if ! download_with_progress "$url" "$filename"; then - # Fallback to standard curl if custom fails for some reason + if [[ "$os" == "windows" ]] || ! download_with_progress "$url" "$filename"; then + # Fallback to standard curl on Windows or if custom progress fails curl -# -L -o "$filename" "$url" fi From dcbaeb3785fa9bb9160d83f8e097ad171c4464be Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Fri, 21 Nov 2025 06:51:54 -0600 Subject: [PATCH 4/5] fix(install): better handling of progress bar for linux --- install | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/install b/install index 7c647941f5a2..2d1fa35da959 100755 --- a/install +++ b/install @@ -115,10 +115,12 @@ print_progress() { local on=$(( percent * width / 100 )) local off=$(( width - on )) - local full_filled=$(printf "%.0s■" {1..50}) - local full_empty=$(printf "%.0s・" {1..50}) + local filled=$(printf "%*s" "$on" "") + filled=${filled// /■} + local empty=$(printf "%*s" "$off" "") + empty=${empty// /・} - printf "\r${ORANGE}%s%s %3d%%${NC}" "${full_filled:0:$on}" "${full_empty:0:$off}" "$percent" >&4 + printf "\r${ORANGE}%s%s %3d%%${NC}" "$filled" "$empty" "$percent" >&4 } download_with_progress() { From a8a2f5d89156f05741a8dea085885cc74870fffb Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Fri, 21 Nov 2025 07:04:47 -0600 Subject: [PATCH 5/5] fix(install): warn on missing unzip --- install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/install b/install index 2d1fa35da959..e7090ad4fb7b 100755 --- a/install +++ b/install @@ -44,6 +44,11 @@ case "$filename" in ;; esac +if ! command -v unzip >/dev/null 2>&1; then + echo -e "${RED}Error: 'unzip' is required but not installed.${NC}" + exit 1 +fi + INSTALL_DIR=$HOME/.opencode/bin mkdir -p "$INSTALL_DIR"