Unverified Commit 1487f98d authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

opencode: 1.0.45 -> 1.0.78 (#462588)

parents 0f1670e9 2d475775
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
{
  "node_modules": {
    "aarch64-linux": "3yXOsptDRUoyL/FBQu8esD4ipudOA9jyLenNt1WChMU=",
    "x86_64-linux": "sha256-ocgmxMx+V6uBMLZTrHfYAqO4l38WQVCrQ2AbUWagaoM=",
    "aarch64-darwin": "sha256-xNU+ucIy84iqmyoWKwwLBIV34TTmH/OGmIbIiNOPM/w=",
    "x86_64-darwin": "sha256-9kplc7tpWgYnB+4471EBkE2xYF3RkpgKqpg26M6bUPs="
    "aarch64-linux": "sha256-uqOotHS6p5mLBmh3f7lka9boXBz7trTKuGahGfOSTD4=",
    "x86_64-linux": "sha256-qlVlP5ayYTuf/uZIW7lk8wKYxArB0jOHmw94yK9v9Bg=",
    "aarch64-darwin": "sha256-dDKVLmE33P9epJFmsUluDjtyVL5jT87atpv8qbEFy7o=",
    "x86_64-darwin": "sha256-eBsU9hSf1tRfp8ErZtmM731YVtVRZ8ovQ5nYmokaPD0="
  }
}
+0 −20
Original line number Diff line number Diff line
diff --git i/packages/opencode/src/provider/models-macro.ts w/packages/opencode/src/provider/models-macro.ts
index 91a0348..4f60069 100644
--- i/packages/opencode/src/provider/models-macro.ts
+++ w/packages/opencode/src/provider/models-macro.ts
@@ -1,4 +1,15 @@
 export async function data() {
+  const localApiJsonPath = process.env.MODELS_DEV_API_JSON
+  
+  // Try to read from local file if path is provided
+  if (localApiJsonPath) {
+    const localFile = Bun.file(localApiJsonPath)
+    if (await localFile.exists()) {
+      return await localFile.text()
+    }
+  }
+  
+  // Fallback to fetching from remote URL
   const json = await fetch("https://models.dev/api.json").then((x) => x.text())
   return json
 }
+6 −5
Original line number Diff line number Diff line
@@ -14,12 +14,12 @@

stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "opencode";
  version = "1.0.45";
  version = "1.0.78";
  src = fetchFromGitHub {
    owner = "sst";
    repo = "opencode";
    tag = "v${finalAttrs.version}";
    hash = "sha256-59nsauILNEvQ4Q8ATHKtgTViIWMaFnUyBf7CN6qrtdk=";
    hash = "sha256-o+rNkij9niggHkA+TtexTbrXLK0I9Ol1Cp9NC/wEuAk=";
  };

  node_modules = stdenvNoCC.mkDerivation {
@@ -80,9 +80,6 @@ stdenvNoCC.mkDerivation (finalAttrs: {
  ];

  patches = [
    # NOTE: Patch `packages/opencode/src/provider/models-macro.ts` to get contents of
    # `_api.json` from the file bundled with `bun build`.
    ./local-models-dev.patch
    # NOTE: Skip npm pack commands in build.ts since packages are already in node_modules
    ./skip-npm-pack.patch
  ];
@@ -168,5 +165,9 @@ stdenvNoCC.mkDerivation (finalAttrs: {
    license = lib.licenses.mit;
    platforms = lib.platforms.unix;
    mainProgram = "opencode";
    badPlatforms = [
      # Problems with bun >= 1.3.2, see https://github.com/oven-sh/bun/issues/24645
      lib.systems.inspect.patterns.isDarwin
    ];
  };
})
+21 −16
Original line number Diff line number Diff line
diff --git i/packages/opencode/script/build.ts w/packages/opencode/script/build.ts
index 29706c09..584b00d4 100755
index 502baed..f854e99 100755
--- i/packages/opencode/script/build.ts
+++ w/packages/opencode/script/build.ts
@@ -39,15 +39,9 @@ for (const [os, arch] of targets) {
   const name = `${pkg.name}-${os}-${arch}`
   await $`mkdir -p dist/${name}/bin`
@@ -77,14 +77,19 @@ const allTargets: {
 ]
 
-  const opentui = `@opentui/core-${os === "windows" ? "win32" : os}-${arch.replace("-baseline", "")}`
-  await $`mkdir -p ../../node_modules/${opentui}`
-  await $`npm pack ${opentui}@${pkg.dependencies["@opentui/core"]}`.cwd(path.join(dir, "../../node_modules"))
-  await $`tar -xf ../../node_modules/${opentui.replace("@opentui/", "opentui-")}-*.tgz -C ../../node_modules/${opentui} --strip-components=1`
+  // Skip npm pack - packages already installed in node_modules by Nix
 const targets = singleFlag
-  ? allTargets.filter((item) => item.os === process.platform && item.arch === process.arch)
+  ? allTargets.filter((item) =>
+      item.os === process.platform &&
+      item.arch === process.arch &&
+      item.avx2 !== false &&
+      item.abi === undefined
+    ).slice(0, 1)
   : allTargets
 
-  const watcher = `@parcel/watcher-${os === "windows" ? "win32" : os}-${arch.replace("-baseline", "")}${os === "linux" ? "-glibc" : ""}`
-  await $`mkdir -p ../../node_modules/${watcher}`
-  await $`npm pack ${watcher}`.cwd(path.join(dir, "../../node_modules")).quiet()
-  await $`tar -xf ../../node_modules/${watcher.replace("@parcel/", "parcel-")}-*.tgz -C ../../node_modules/${watcher} --strip-components=1`
+  // Skip npm pack - packages already installed in node_modules by Nix
 await $`rm -rf dist`
 
   const parserWorker = fs.realpathSync(path.resolve(dir, "./node_modules/@opentui/core/parser.worker.js"))
   const workerPath = "./src/cli/cmd/tui/worker.ts"
 const binaries: Record<string, string> = {}
-await $`bun install --os="*" --cpu="*" @opentui/core@${pkg.dependencies["@opentui/core"]}`
-await $`bun install --os="*" --cpu="*" @parcel/watcher@${pkg.dependencies["@parcel/watcher"]}`
+// Skip bun install - packages already installed in node_modules by Nix
+// Skip bun install - packages already installed in node_modules by Nix
 for (const item of targets) {
   const name = [
     pkg.name,