@@ -166,6 +166,8 @@ export namespace Installation { |
166 | 166 |
|
167 | 167 | export async function latest(installMethod?: Method) { |
168 | 168 | const detectedMethod = installMethod || (await method()) |
| 169 | + |
| 170 | + // Use brew formula API for homebrew core formula |
169 | 171 | if (detectedMethod === "brew") { |
170 | 172 | const formula = await getBrewFormula() |
171 | 173 | if (formula === "opencode") { |
@@ -178,19 +180,28 @@ export namespace Installation { |
178 | 180 | } |
179 | 181 | } |
180 | 182 |
|
181 | | - const registry = await iife(async () => { |
182 | | - const r = (await $`npm config get registry`.quiet().nothrow().text()).trim() |
183 | | - const reg = r || "https://registry.npmjs.org" |
184 | | - return reg.endsWith("/") ? reg.slice(0, -1) : reg |
185 | | - }) |
186 | | - const [major] = VERSION.split(".").map((x) => Number(x)) |
187 | | - // const channel = CHANNEL === "latest" ? `latest-${major}` : CHANNEL |
188 | | - const channel = CHANNEL |
189 | | - return fetch(`${registry}/opencode-ai/${channel}`) |
| 183 | + // Use npm registry for npm/bun/pnpm |
| 184 | + if (detectedMethod === "npm" || detectedMethod === "bun" || detectedMethod === "pnpm") { |
| 185 | + const registry = await iife(async () => { |
| 186 | + const r = (await $`npm config get registry`.quiet().nothrow().text()).trim() |
| 187 | + const reg = r || "https://registry.npmjs.org" |
| 188 | + return reg.endsWith("/") ? reg.slice(0, -1) : reg |
| 189 | + }) |
| 190 | + const channel = CHANNEL |
| 191 | + return fetch(`${registry}/opencode-ai/${channel}`) |
| 192 | + .then((res) => { |
| 193 | + if (!res.ok) throw new Error(res.statusText) |
| 194 | + return res.json() |
| 195 | + }) |
| 196 | + .then((data: any) => data.version) |
| 197 | + } |
| 198 | + |
| 199 | + // Use GitHub releases for everything else (curl, yarn, brew tap, unknown) |
| 200 | + return fetch("https://api.github.com/repos/sst/opencode/releases/latest") |
190 | 201 | .then((res) => { |
191 | 202 | if (!res.ok) throw new Error(res.statusText) |
192 | 203 | return res.json() |
193 | 204 | }) |
194 | | - .then((data: any) => data.version) |
| 205 | + .then((data: any) => data.tag_name.replace(/^v/, "")) |
195 | 206 | } |
196 | 207 | } |