Files
nixpkgs/pkgs/by-name/op/opencode/local-models-dev.patch
Thierry Delafontaine a317d6f6ce opencode: use models-dev package instead of fetching from online api
- Added `models-dev` to `nativeBuildInputs`.
- Removed the old patch that fetched data from a remote URL and
  introduced a new patch to read from a local file if a path is provided
  via the `MODELS_DEV_API_JSON` environment variable.
2025-07-14 13:43:06 +02:00

21 lines
721 B
Diff

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
}