registry: a package that declares magpie.agent is listed as an agent, with a main or without (#737)

An agent that needs a runtime (miaocell's magpie-agent-deva) keeps its moejs agent file and adds a Bun module as main, as agent-kimi-desktop and agent-reasonix-desktop do. The README's agent convention now says so, and that such a package is kind "agent" in registry.json. check.mjs fails a registry entry whose package declares magpie.agent but whose kind is not "agent" (agentKindProblems in scripts/registry.mjs). magpie's side is v0.1.2995 (ed7aeb052): the GitHub list and the Installed row read the declaration, not the main.

Run: bun test scripts/check.test.mjs, 17 pass (the new test also checks the repo's real kimi-desktop, reasonix-desktop and aider packages); bun scripts/check.mjs exit 0. Broken by hand: agent-kimi-desktop's kind removed from registry.json made check.mjs fail with '@magpie-community/agent-kimi-desktop declares magpie.agent, but its entry's kind is null, not "agent"'; restored. No package version changes, so nothing publishes.
This commit is contained in:
yetone
2026-11-05 03:55:16 +08:00
parent 6a0d9e5b7a
commit 1ad712d963
4 changed files with 48 additions and 5 deletions
+16 -1
View File
@@ -2,7 +2,7 @@ import { expect, test } from "bun:test"
import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"
import { tmpdir } from "node:os"
import { join } from "node:path"
import { registryProblems } from "./registry.mjs"
import { agentKindProblems, registryProblems } from "./registry.mjs"
// Exercise the checker in a tiny independent repository, without loading any
// real plugin, credential file or network client.
@@ -134,6 +134,21 @@ test("check passes this repository's own registry.json", () => {
expect(registryProblems(readFileSync(new URL("../registry.json", import.meta.url), "utf8"))).toEqual([])
})
// a package that adds an agent is listed as one, with a Bun module
// (main) beside it or not (#737): kimi-desktop and reasonix-desktop have one
test("an agent package's entry is kind agent, main or not (#737)", () => {
const reg = (kind) => JSON.stringify({ version: 1, plugins: [{ package: "@magpie-community/agent-deva", name: "Deva", kind, summary: { en: "D", zh: "D" } }] })
const pkg = { name: "@magpie-community/agent-deva", main: "./index.mjs", magpie: { agent: "./deva.agent.js" } }
expect(agentKindProblems(reg("agent"), [pkg])).toEqual([])
expect(agentKindProblems(reg(undefined), [pkg])[0]).toContain('declares magpie.agent, but its entry\'s kind is null')
expect(agentKindProblems(reg("tools"), [pkg])).toHaveLength(1)
expect(agentKindProblems(reg(undefined), [{ ...pkg, magpie: {} }])).toEqual([])
const own = new URL("../packages/", import.meta.url)
const pkgs = ["kimi-desktop", "reasonix-desktop", "aider"].map((n) => JSON.parse(readFileSync(new URL(n + "/package.json", own), "utf8")))
expect(pkgs.filter((p) => p.main).length).toBe(2)
expect(agentKindProblems(readFileSync(new URL("../registry.json", import.meta.url), "utf8"), pkgs)).toEqual([])
})
test("check fails a registry.json that is not JSON (#612)", () => {
const result = check(fine, okRegistry.slice(0, -2))
expect(result.code).toBe(1)