fix(cli): resolve latest CLI release when GitHub latest points to non-CLI tag (#12148)

* fix(cli): resolve latest CLI release when install script hits non-CLI tag

The GitHub releases/latest endpoint can point to non-CLI releases
(e.g., jetbrains/v7.0.4), whose tag prefix doesn't match the existing
version regex. Query the paginated releases endpoint, pick the first
tag starting with 'v', and use that version for both display and the
download URL instead of trusting releases/latest.

Closes #12125

* fix(cli): select stable installer release

---------

Co-authored-by: marius-kilocode <marius@kilocode.ai>
This commit is contained in:
Ulises Millán
2026-07-13 02:25:31 -06:00
committed by GitHub
parent bf2b33b87b
commit 77f7983995
2 changed files with 13 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---
Install the latest stable CLI release when newer non-CLI or prerelease releases exist.
+8 -4
View File
@@ -183,13 +183,17 @@ else
fi
if [ -z "$requested_version" ]; then
url="https://github.com/Kilo-Org/kilocode/releases/latest/download/$filename"
specific_version=$(curl -s https://api.github.com/repos/Kilo-Org/kilocode/releases/latest | sed -n 's/.*"tag_name": *"v\([^"]*\)".*/\1/p')
if [[ $? -ne 0 || -z "$specific_version" ]]; then
# The npm latest tag tracks stable CLI releases independently of other GitHub release types.
if ! specific_version=$(curl -fsSL "https://registry.npmjs.org/-/package/%40kilocode%2Fcli/dist-tags" |
sed -n 's/.*"latest"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p'); then
echo -e "${RED}Failed to fetch version information${NC}"
exit 1
fi
if [[ ! "$specific_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo -e "${RED}Failed to fetch version information${NC}"
exit 1
fi
url="https://github.com/Kilo-Org/kilocode/releases/download/v${specific_version}/$filename"
else
# Strip leading 'v' if present
requested_version="${requested_version#v}"