Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
plugin: a GitHub listing takes package.json's licence when GitHub names none (plugins#468)
yetone5957d45ac12a
diff --git a/internal/plugin/github.go b/internal/plugin/github.goindex cbe447289..1a18ae149 100644--- a/internal/plugin/github.go+++ b/internal/plugin/github.go@@ -26,15 +26,21 @@ const Topic = "magpie-plugin"// Tagged is a repository tagged with Topic.type Tagged struct {- Spec string `json:"spec"` // what Install adds: its npm name when npm has it from this repository, else github:owner/repo- Repo string `json:"repo"` // owner/repo- URL string `json:"url"` // its page on GitHub- Owner string `json:"owner"` // its owner's login- OwnerAvatar string `json:"ownerAvatar,omitempty"`- Description string `json:"description,omitempty"`- Stars int `json:"stars"`- License string `json:"license,omitempty"` // SPDX id- Pushed time.Time `json:"pushed"`+ Spec string `json:"spec"` // what Install adds: its npm name when npm has it from this repository, else github:owner/repo+ Repo string `json:"repo"` // owner/repo+ URL string `json:"url"` // its page on GitHub+ Owner string `json:"owner"` // its owner's login+ OwnerAvatar string `json:"ownerAvatar,omitempty"`+ Description string `json:"description,omitempty"`+ Stars int `json:"stars"`+ // License is its SPDX id as GitHub reads its LICENSE file, else as+ // its package.json says (PkgLicense): a LICENSE GitHub can't match to+ // one (NOASSERTION: MIT's text with a line of credit added) or none at+ // all left the card with no licence, while npm shows package.json's+ // (plugins#468)+ License string `json:"license,omitempty"`+ PkgLicense string `json:"pkgLicense,omitempty"`+ Pushed time.Time `json:"pushed"`// from its package.json on the default branch: what bun will install// it as, its version, and whether it is gateway middleware or an agentPackage string `json:"package,omitempty"`@@ -261,6 +267,9 @@ func askTagged(ctx context.Context, last []Tagged) (l []Tagged, whole bool, miss// what the search says now, over what is kept of a repositoryfresh := func(r, t Tagged) Tagged {r.URL, r.Owner, r.OwnerAvatar, r.Description, r.Stars, r.License, r.Pushed = t.URL, t.Owner, t.OwnerAvatar, t.Description, t.Stars, t.License, t.Pushed+ if r.License == "" {+ r.License = r.PkgLicense+ }return r}var mu sync.Mutex // out, keep, done, why; late once the page stops waiting@@ -394,6 +403,7 @@ func readTagged(pc context.Context, t Tagged, branch string) (Tagged, bool, boolVersion string `json:"version"`Main string `json:"main"`Exports json.RawMessage `json:"exports"`+ License any `json:"license"`Magpie struct {Middleware string `json:"middleware"`Agent string `json:"agent"`@@ -407,6 +417,14 @@ func readTagged(pc context.Context, t Tagged, branch string) (Tagged, bool, boolreturn t, false, true, nil}t.Package, t.Version = pj.Name, pj.Version+ // the licence it names, a string as npm takes it, for when GitHub+ // couldn't tell one from its LICENSE file+ if l, ok := pj.License.(string); ok {+ t.PkgLicense = strings.TrimSpace(l)+ if t.License == "" {+ t.License = t.PkgLicense+ }+ }// a picture, as host.js's iconOf takes one: magpie checks and// keeps it before the page shows it (the GUI's /api/plugins/github)t.Icon = ownIcon(pj.Magpie.Icon)diff --git a/internal/plugin/github_test.go b/internal/plugin/github_test.goindex c857ec639..d650f4644 100644--- a/internal/plugin/github_test.go+++ b/internal/plugin/github_test.go@@ -206,8 +206,14 @@ func TestTaggedRepos(t *testing.T) {c.Owner != "griffinmartin" || c.License != "MIT" || c.Stars != 1301 || c.Kind != "" || c.Pushed.IsZero() || c.URL != "https://github.com/griffinmartin/opencode-claude-auth" {t.Fatalf("claude auth: %+v", c)}- if x := byRepo["someone/flaky-entry"]; x.License != "" {- t.Fatalf("NOASSERTION is no license: %+v", x)+ // GitHub's NOASSERTION (a LICENSE file it can't name) is no license,+ // and package.json's stands in for it; one with neither shows none+ // (plugins#468)+ if x := byRepo["someone/flaky-entry"]; x.License != "MIT" {+ t.Fatalf("NOASSERTION, package.json MIT: %+v", x)+ }+ if x := byRepo["someone/page-glance"]; x.License != "" {+ t.Fatalf("NOASSERTION and no package.json license: %+v", x)}// its own picture, package.json's magpie.icon, as an installed// plugin's provider has it; none when it gives none@@ -225,7 +231,7 @@ func TestTaggedRepos(t *testing.T) {if x := byRepo["someone/page-glance"]; x.Kind != "page" || x.Spec != "github:someone/page-glance" || x.Package != "magpie-usage-glance" {t.Fatalf("a page alone: %+v", x)}- if x := byRepo["someone/word-guard"]; x.Kind != "middleware" || x.Package != "@magpie-community/middleware-word-guard" || x.License != "" {+ if x := byRepo["someone/word-guard"]; x.Kind != "middleware" || x.Package != "@magpie-community/middleware-word-guard" || x.License != "MIT" {t.Fatalf("a middleware alone: %+v", x)}// npm's copy when npm has it from this very repository (its build isdiff --git a/internal/plugin/testdata/github/raw/someone/flaky-entry/main/package.json b/internal/plugin/testdata/github/raw/someone/flaky-entry/main/package.jsonindex 9204fead4..baef42d44 100644--- a/internal/plugin/testdata/github/raw/someone/flaky-entry/main/package.json+++ b/internal/plugin/testdata/github/raw/someone/flaky-entry/main/package.json@@ -1,6 +1,7 @@{"name": "flaky-entry","version": "0.1.0",+ "license": "MIT","type": "module","main": "./index.js","magpie": { "icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiI+PGNpcmNsZSBjeD0iOCIgY3k9IjgiIHI9IjYiLz48L3N2Zz4=" }