update brew handling

This commit is contained in:
Aiden Cline
2025-11-04 00:52:15 -06:00
parent d49b1b25d1
commit d341d26e37
4 changed files with 46 additions and 30 deletions

View File

@@ -79,17 +79,19 @@ export default function Home() {
<strong>LSP enabled</strong> Automatically loads the right LSPs for the LLM <strong>LSP enabled</strong> Automatically loads the right LSPs for the LLM
</li> </li>
<li> <li>
<strong>opencode zen</strong> A <a href="/docs/zen">curated list of models</a> provided by opencode{" "} <strong>opencode zen</strong> A <a href="/docs/zen">curated list of models</a>{" "}
<label>New</label> provided by opencode <label>New</label>
</li> </li>
<li> <li>
<strong>Multi-session</strong> Start multiple agents in parallel on the same project <strong>Multi-session</strong> Start multiple agents in parallel on the same project
</li> </li>
<li> <li>
<strong>Shareable links</strong> Share a link to any sessions for reference or to debug <strong>Shareable links</strong> Share a link to any sessions for reference or to
debug
</li> </li>
<li> <li>
<strong>Claude Pro</strong> Log in with Anthropic to use your Claude Pro or Max account <strong>Claude Pro</strong> Log in with Anthropic to use your Claude Pro or Max
account
</li> </li>
<li> <li>
<strong>Use any model</strong> Supports 75+ LLM providers through{" "} <strong>Use any model</strong> Supports 75+ LLM providers through{" "}
@@ -121,7 +123,7 @@ export default function Home() {
<h3 data-component="title">homebrew</h3> <h3 data-component="title">homebrew</h3>
<button data-copy data-slot="button"> <button data-copy data-slot="button">
<span> <span>
brew install <strong>sst/tap/opencode</strong> brew install <strong>opencode</strong>
</span> </span>
<CopyStatus /> <CopyStatus />
</button> </button>

View File

@@ -73,7 +73,7 @@ export namespace Installation {
}, },
{ {
name: "brew" as const, name: "brew" as const,
command: () => $`brew list --formula opencode-ai`.throws(false).text(), command: () => $`brew list --formula opencode`.throws(false).text(),
}, },
] ]
@@ -87,7 +87,7 @@ export namespace Installation {
for (const check of checks) { for (const check of checks) {
const output = await check.command() const output = await check.command()
if (output.includes("opencode-ai")) { if (output.includes(check.name === "brew" ? "opencode" : "opencode-ai")) {
return check.name return check.name
} }
} }
@@ -102,28 +102,42 @@ export namespace Installation {
}), }),
) )
async function getBrewFormula() {
const tapFormula = await $`brew list --formula sst/tap/opencode`.throws(false).text()
if (tapFormula.includes("opencode")) return "sst/tap/opencode"
const coreFormula = await $`brew list --formula opencode`.throws(false).text()
if (coreFormula.includes("opencode")) return "opencode"
return "opencode"
}
export async function upgrade(method: Method, target: string) { export async function upgrade(method: Method, target: string) {
const cmd = (() => { let cmd
switch (method) { switch (method) {
case "curl": case "curl":
return $`curl -fsSL https://opencode.ai/install | bash`.env({ cmd = $`curl -fsSL https://opencode.ai/install | bash`.env({
...process.env, ...process.env,
VERSION: target, VERSION: target,
}) })
break
case "npm": case "npm":
return $`npm install -g opencode-ai@${target}` cmd = $`npm install -g opencode-ai@${target}`
break
case "pnpm": case "pnpm":
return $`pnpm install -g opencode-ai@${target}` cmd = $`pnpm install -g opencode-ai@${target}`
break
case "bun": case "bun":
return $`bun install -g opencode-ai@${target}` cmd = $`bun install -g opencode-ai@${target}`
case "brew": break
return $`brew install sst/tap/opencode`.env({ case "brew": {
const formula = await getBrewFormula()
cmd = $`brew install ${formula}`.env({
HOMEBREW_NO_AUTO_UPDATE: "1", HOMEBREW_NO_AUTO_UPDATE: "1",
}) })
break
}
default: default:
throw new Error(`Unknown method: ${method}`) throw new Error(`Unknown method: ${method}`)
} }
})()
const result = await cmd.quiet().throws(false) const result = await cmd.quiet().throws(false)
log.info("upgraded", { log.info("upgraded", {
method, method,

View File

@@ -109,9 +109,9 @@ if (image) {
</div> </div>
<div class="col3"> <div class="col3">
<h3>Homebrew</h3> <h3>Homebrew</h3>
<button class="command" data-command="brew install sst/tap/opencode"> <button class="command" data-command="brew install opencode">
<code> <code>
<span>brew install</span> <span class="highlight">sst/tap/opencode</span> <span>brew install</span> <span class="highlight">opencode</span>
</code> </code>
<span class="copy"> <span class="copy">
<CopyIcon /> <CopyIcon />

View File

@@ -67,7 +67,7 @@ You can also install it with the following commands:
- **Using Homebrew on macOS and Linux** - **Using Homebrew on macOS and Linux**
```bash ```bash
brew install sst/tap/opencode brew install opencode
``` ```
- **Using Paru on Arch Linux** - **Using Paru on Arch Linux**