The open source coding agent.
TypeScript
fix: adjust upgrade command to use gh releases page if not npm/bun/pnpm install method
Aiden Cline4abaa052dbd3
diff --git a/packages/opencode/src/installation/index.ts b/packages/opencode/src/installation/index.tsindex 2c99e21a8f5..effe19721b4 100644--- a/packages/opencode/src/installation/index.ts+++ b/packages/opencode/src/installation/index.ts@@ -166,6 +166,8 @@ export namespace Installation {export async function latest(installMethod?: Method) {const detectedMethod = installMethod || (await method())++ // Use brew formula API for homebrew core formulaif (detectedMethod === "brew") {const formula = await getBrewFormula()if (formula === "opencode") {@@ -178,19 +180,28 @@ export namespace Installation {}}- const registry = await iife(async () => {- const r = (await $`npm config get registry`.quiet().nothrow().text()).trim()- const reg = r || "https://registry.npmjs.org"- return reg.endsWith("/") ? reg.slice(0, -1) : reg- })- const [major] = VERSION.split(".").map((x) => Number(x))- // const channel = CHANNEL === "latest" ? `latest-${major}` : CHANNEL- const channel = CHANNEL- return fetch(`${registry}/opencode-ai/${channel}`)+ // Use npm registry for npm/bun/pnpm+ if (detectedMethod === "npm" || detectedMethod === "bun" || detectedMethod === "pnpm") {+ const registry = await iife(async () => {+ const r = (await $`npm config get registry`.quiet().nothrow().text()).trim()+ const reg = r || "https://registry.npmjs.org"+ return reg.endsWith("/") ? reg.slice(0, -1) : reg+ })+ const channel = CHANNEL+ return fetch(`${registry}/opencode-ai/${channel}`)+ .then((res) => {+ if (!res.ok) throw new Error(res.statusText)+ return res.json()+ })+ .then((data: any) => data.version)+ }++ // Use GitHub releases for everything else (curl, yarn, brew tap, unknown)+ return fetch("https://api.github.com/repos/sst/opencode/releases/latest").then((res) => {if (!res.ok) throw new Error(res.statusText)return res.json()})- .then((data: any) => data.version)+ .then((data: any) => data.tag_name.replace(/^v/, ""))}}