diff --git a/packages/opencode/src/installation/index.ts b/packages/opencode/src/installation/index.ts index d18c9e31a..47278bd56 100644 --- a/packages/opencode/src/installation/index.ts +++ b/packages/opencode/src/installation/index.ts @@ -148,6 +148,16 @@ export namespace Installation { break case "brew": { const formula = await getBrewFormula() + if (formula.includes("/")) { + cmd = + $`brew tap anomalyco/tap && cd "$(brew --repo anomalyco/tap)" && git pull --ff-only && brew upgrade ${formula}`.env( + { + HOMEBREW_NO_AUTO_UPDATE: "1", + ...process.env, + }, + ) + break + } cmd = $`brew upgrade ${formula}`.env({ HOMEBREW_NO_AUTO_UPDATE: "1", ...process.env, @@ -188,14 +198,19 @@ export namespace Installation { if (detectedMethod === "brew") { const formula = await getBrewFormula() - if (formula === "opencode") { - return fetch("https://formulae.brew.sh/api/formula/opencode.json") - .then((res) => { - if (!res.ok) throw new Error(res.statusText) - return res.json() - }) - .then((data: any) => data.versions.stable) + if (formula.includes("/")) { + const infoJson = await $`brew info --json=v2 ${formula}`.quiet().text() + const info = JSON.parse(infoJson) + const version = info.formulae?.[0]?.versions?.stable + if (!version) throw new Error(`Could not detect version for tap formula: ${formula}`) + return version } + return fetch("https://formulae.brew.sh/api/formula/opencode.json") + .then((res) => { + if (!res.ok) throw new Error(res.statusText) + return res.json() + }) + .then((data: any) => data.versions.stable) } if (detectedMethod === "npm" || detectedMethod === "bun" || detectedMethod === "pnpm") {