kingchen95272025 (#1200): scripts/tagged.mjs only read magpie.agent when a package had no main or exports, so an agent plugin that keeps a host module (cursor-bridge-enhanced 0.2.17, magpie-agent-deva, magpie-kiki) had no kind in dist/tagged.json and Discover showed it under Providers, while magpie's own readTagged (internal/plugin/ github.go, since plugins#737) calls it an agent. tagged.mjs also had no hooks branch. - scripts/tagged-kind.mjs holds kindOf and entryOf, mirroring readTagged: middleware, page and hooks only without a module of their own; magpie.agent always. The file checked is the package's module when it has one, else the file its kind declares, as readTagged does. - tagged.json carries read: 2. A file read the old way is read again whole on the next run, so entries not pushed to since are corrected too, not only new pushes. version stays 1, which the site's worker checks. Run (mote): - bun test scripts/: 30 pass, 0 fail. - node scripts/tagged.mjs on a copy of dist's tagged.json, against GitHub (no token): 442 plugins, 0 unread, read 2. The three repos #1200 names, and 30 more, went from no kind to agent; 8 hooks repositories got hooks. No entry changed kind any other way. Which repositories the topic search returns differed from dist's file (16 gone, 10 new); that comes from the search, not this change. Broken by hand: kindOf with the old nesting: 2 of 3 tests fail. Not tried: the tagged workflow itself; it runs on its half-hourly schedule after this lands.
34 lines
1.8 KiB
JavaScript
34 lines
1.8 KiB
JavaScript
import { expect, test } from "bun:test"
|
|
import { entryOf, kindOf } from "./tagged-kind.mjs"
|
|
|
|
// The manifests #1200 lists from dist/tagged.json, cut to what decides.
|
|
test("an agent plugin that keeps a module of its own is an agent (#1200)", () => {
|
|
const enhanced = { main: "./control/host.js", magpie: { agent: "./agent.js" } } // cursor-bridge-enhanced 0.2.17
|
|
const deva = { main: "./index.mjs", magpie: { agent: "deva.agent.js" } }
|
|
const kiki = { main: "./kiki.host.js", magpie: { agent: "./kiki.agent.js" } }
|
|
const plain = { magpie: { agent: "./agent.js" } } // cursor-bridge 0.2.7
|
|
for (const pj of [enhanced, deva, kiki, plain]) expect(kindOf(pj)).toBe("agent")
|
|
// the file it loads is its module, as magpie's readTagged checks it
|
|
expect(entryOf(kiki, "agent", true)).toBe("./kiki.host.js")
|
|
expect(entryOf(plain, "agent", true)).toBe("./agent.js")
|
|
})
|
|
|
|
test("hooks alone are a hooks plugin, and their file is the one to find", () => {
|
|
const pj = { magpie: { hooks: "./model-watch.hooks.js" } }
|
|
expect(kindOf(pj)).toBe("hooks")
|
|
expect(entryOf(pj, "hooks", true)).toBe("./model-watch.hooks.js")
|
|
})
|
|
|
|
test("a module of its own keeps middleware, a page and hooks a provider, as before", () => {
|
|
for (const mg of [{ middleware: "m.js" }, { page: { file: "p.html" } }, { hooks: "h.js" }]) {
|
|
expect(kindOf({ main: "index.mjs", magpie: mg })).toBe("")
|
|
expect(kindOf({ exports: { ".": "./i.mjs" }, magpie: mg })).toBe("")
|
|
}
|
|
expect(kindOf({ main: "index.mjs" })).toBe("")
|
|
expect(kindOf({ magpie: { middleware: "m.js" } })).toBe("middleware")
|
|
expect(kindOf({ magpie: { page: { file: "p.html" } } })).toBe("page")
|
|
// installed from npm, a provider loads npm's index file
|
|
expect(entryOf({ main: "index.mjs" }, "", false)).toBe("index.js")
|
|
expect(entryOf({ exports: { ".": { bun: "./b.mjs" } } }, "", true)).toBe("./b.mjs")
|
|
})
|