summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoropencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>2025-12-01 16:58:39 -0600
committerGitHub <[email protected]>2025-12-01 16:58:39 -0600
commit8e248ae045d7d682ff9766d7d7be5c29f0174112 (patch)
treea3b28bcc7126f7e12e3a2881dd693afff5245ebe
parent0acefd5c08d724d440071de2ff7bcee4b599ecad (diff)
downloadopencode-8e248ae045d7d682ff9766d7d7be5c29f0174112.tar.gz
opencode-8e248ae045d7d682ff9766d7d7be5c29f0174112.zip
fix: respect npm registry (#4958)
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <[email protected]> Co-authored-by: Aiden Cline <[email protected]>
-rw-r--r--packages/opencode/src/installation/index.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/opencode/src/installation/index.ts b/packages/opencode/src/installation/index.ts
index 7ac2980c4..755236551 100644
--- a/packages/opencode/src/installation/index.ts
+++ b/packages/opencode/src/installation/index.ts
@@ -4,6 +4,7 @@ import z from "zod"
import { NamedError } from "@opencode-ai/util/error"
import { Bus } from "../bus"
import { Log } from "../util/log"
+import { iife } from "@/util/iife"
declare global {
const OPENCODE_VERSION: string
@@ -163,9 +164,14 @@ export namespace Installation {
export const USER_AGENT = `opencode/${CHANNEL}/${VERSION}`
export async function latest() {
+ const registry = await iife(async () => {
+ const r = (await $`npm config get registry`.throws(false).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
- return fetch(`https://registry.npmjs.org/opencode-ai/${channel}`)
+ return fetch(`${registry}/opencode-ai/${channel}`)
.then((res) => {
if (!res.ok) throw new Error(res.statusText)
return res.json()