Sfoglia il codice sorgente

force models.dev refresh on auth login

Dax Raad 6 mesi fa
parent
commit
71cd84dbbb

+ 4 - 29
opencode.json

@@ -1,38 +1,13 @@
 {
   "$schema": "https://opencode.ai/config.json",
   "provider": {
-    "openrouter": {
-      "models": {
-        "moonshotai/kimi-k2": {
-          "options": {
-            "provider": {
-              "order": ["baseten"],
-              "allow_fallbacks": false
-            }
-          }
-        }
-      }
-    },
-    "huggingface": {
-      "models": {
-        "Qwen/Qwen3-235B-A22B-Instruct-2507:fireworks-ai": {}
-      }
-    },
-    "local": {
-      "npm": "@ai-sdk/openai-compatible",
-      "name": "Local",
+    "cerebras": {
       "options": {
-        "baseURL": "http://127.0.0.1:1234/v1",
-        "includeUsage": true
+        "apiKey": "csk-m33xrvt43whkypn8r4ph9xc8fenhx2f68c3pj22ext45v5k9"
       },
+      "npm": "@ai-sdk/cerebras",
       "models": {
-        "qwen/qwen3-coder-30b": {
-          "name": "Qwen-Coder 30B",
-          "limit": {
-            "context": 262144,
-            "output": 66536
-          }
-        }
+        "qwen-3-coder-480b": {}
       }
     }
   },

+ 1 - 0
packages/opencode/src/cli/cmd/auth.ts

@@ -100,6 +100,7 @@ export const AuthLoginCommand = cmd({
       prompts.outro("Done")
       return
     }
+    await ModelsDev.refresh().catch(() => {})
     const providers = await ModelsDev.get()
     const priority: Record<string, number> = {
       anthropic: 0,

+ 1 - 1
packages/opencode/src/global/index.ts

@@ -27,7 +27,7 @@ await Promise.all([
   fs.mkdir(Global.Path.log, { recursive: true }),
 ])
 
-const CACHE_VERSION = "3"
+const CACHE_VERSION = "4"
 
 const version = await Bun.file(path.join(Global.Path.cache, "version"))
   .text()

+ 1 - 0
packages/opencode/src/lsp/index.ts

@@ -84,6 +84,7 @@ export namespace LSP {
       }
       return {
         broken: new Set<string>(),
+        servers,
         clients,
       }
     },

+ 9 - 3
packages/opencode/src/provider/models.ts

@@ -61,13 +61,19 @@ export namespace ModelsDev {
 
   export async function refresh() {
     const file = Bun.file(filepath)
-    log.info("refreshing")
+    log.info("refreshing", {
+      file,
+    })
     const result = await fetch("https://models.dev/api.json", {
       headers: {
         "User-Agent": Installation.USER_AGENT,
       },
-    }).catch(() => {})
-    if (result && result.ok) await Bun.write(file, result)
+    }).catch((e) => {
+      log.error("Failed to fetch models.dev", {
+        error: e,
+      })
+    })
+    if (result && result.ok) await Bun.write(file, await result.text())
   }
 }