From 5e3c7b8049dcb03e19ee2fbd64c8263a3c67d103 Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 30 Sep 2026 16:48:29 +0800 Subject: [PATCH] =?UTF-8?q?plugin:=20a=20plugin's=20provider=20has=20its?= =?UTF-8?q?=20models=20on=20a=20magpie=20that=20never=20fetched=20models.d?= =?UTF-8?q?ev=20=E2=80=94=20the=20host=20took=20the=20models=20OpenCode=20?= =?UTF-8?q?would=20from=20models.dev's=20cache,=20so=20on=20a=20fresh=20in?= =?UTF-8?q?stall=20(magpie=20plugin=20add=20before=20the=20app=20or=20gate?= =?UTF-8?q?way=20ever=20ran)=20opencode-gemini-auth=20and=20opencode-copil?= =?UTF-8?q?ot-auth=20listed=200=20models,=20and=20plugin-providers.json=20?= =?UTF-8?q?kept=20that.=20Starting=20the=20host=20now=20fetches=20the=20ca?= =?UTF-8?q?talog=20first=20when=20there=20is=20none=20(30=20s=20at=20most)?= =?UTF-8?q?.=20Tried=20in=20a=20sandbox=20HOME=20with=20the=20real=20packa?= =?UTF-8?q?ges:=20google-plugin=2038=20models,=20github-copilot=2034;=20wi?= =?UTF-8?q?th=20a=20Copilot=20sign-in=20copied=20into=20the=20sandbox,=20m?= =?UTF-8?q?agpie=20provider=20test=20github-copilot=20answered=20on=20Resp?= =?UTF-8?q?onses=20(gpt-5.4)=20through=20the=20plugin's=20fetch.=20go=20bu?= =?UTF-8?q?ild=20-tags=20nogui=20(darwin,=20GOOS=3Dlinux),=20GOOS=3Dwindow?= =?UTF-8?q?s=20go=20build,=20go=20test=20./internal/plugin=20pass.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/plugin/host.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/plugin/host.go b/internal/plugin/host.go index 44fe07527..20a50be41 100644 --- a/internal/plugin/host.go +++ b/internal/plugin/host.go @@ -186,6 +186,13 @@ func start(ctx context.Context) (*host, error) { if err := os.MkdirAll(settings.Dir(), 0o700); err != nil { return nil, err } + if catalog.Source() == "" { + // a plugin's provider has the models models.dev lists for it, as in + // OpenCode; a magpie that has never fetched them does first + cctx, cancel := context.WithTimeout(ctx, 30*time.Second) + _ = catalog.Sync(cctx) + cancel() + } // the host outlives the request that started it cmd := bunCommand(context.Background(), bun, settings.Dir(), "run", js) in, err := cmd.StdinPipe()