← Files Map Animation StudioARCHIVED FILE
evaluations/package.test.mjs
9.6 KB · Dec 1, 2026 · 00:16 UTC
import assert from "node:assert/strict";
import { existsSync, readFileSync } from "node:fs";
import { dirname, relative, resolve } from "node:path";
import test from "node:test";
import { fileURLToPath } from "node:url";
import { cases, scoreRun } from "./score.mjs";
const root = fileURLToPath(new URL("../", import.meta.url));
const read = (path) => readFileSync(resolve(root, path), "utf8");
const skillPath = "skills/map-video-production/SKILL.md";
const fixture = cases.find((item) => item.id === "comparison-en");
const run = () => ({
case_id: fixture.id,
trial: 1,
client: "fixture-client",
model: "fixture-model",
server_version: "fixture-server",
reviewer: "fixture-reviewer",
artifact_refs: ["fixtures/trace.json", "fixtures/frames/"],
checks: Object.fromEntries(fixture.checks.map((key) => [key, { passed: true, evidence: "fixture assertion" }])),
ratings: { framing: 4, readability: 4, continuity: 4, pacing: 4, motion: 4 },
});
test("portable identity and OAuth MCP wiring are explicit and contain no credentials", () => {
const plugin = JSON.parse(read("plugin.json"));
const mcp = JSON.parse(read("mcp.json"));
assert.equal(plugin.name, "map-animation-studio");
assert.match(plugin.$schema, /\/plugin\.schema\.json$/);
assert.match(mcp.$schema, /\/mcp\.schema\.json$/);
const server = mcp.mcpServers[plugin.name];
assert.equal(server.type, "streamable-http");
assert.equal(server.url, "https://api.mapanimationstudio.com/mcp/map-studio");
assert.deepEqual(server.extensions["com.openai"].auth, { type: "oauth" });
assert.equal(server.headers, undefined);
assert.ok(read("skills/map-video-production/agents/openai.yaml").includes(server.url));
});
test("the Claude manifest is the same plugin, server and skill folder as the ChatGPT one", () => {
const plugin = JSON.parse(read("plugin.json"));
const server = JSON.parse(read("mcp.json")).mcpServers[plugin.name];
const claude = JSON.parse(read(".claude-plugin/plugin.json"));
// The name is permanent once listed: lowercase words joined by hyphens, as the directory requires.
assert.match(claude.name, /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/);
assert.equal(claude.name, plugin.name);
assert.equal(claude.version, plugin.version);
assert.equal(claude.homepage, plugin.homepage);
assert.equal(claude.license, "MIT");
assert.match(read("LICENSE"), /^MIT License/);
assert.match(claude.privacyPolicyUrl, /^https:\/\//);
// Claude finds skills/ by convention; a skills path here would split the folder the two share.
assert.equal(claude.skills, undefined);
const claudeServer = JSON.parse(read(".mcp.json")).mcpServers[plugin.name];
assert.deepEqual(claudeServer, { type: "http", url: server.url });
// The directory shows the README as the listing and refuses one under 40 words outside code.
const prose = read("README.md").replace(/```[\s\S]*?```/g, "");
assert.ok(prose.split(/\s+/).filter(Boolean).length >= 40);
assert.ok(read("README.md").includes(claude.privacyPolicyUrl));
// The directory reads the listing icon from this field; it is the image the ChatGPT listing uses.
assert.equal(claude.icon, plugin.extensions["com.openai"].interface.logo);
const side = squarePng(claude.icon);
assert.ok(side >= 512 && side <= 2048);
});
test("the ChatGPT listing names a logo and composer icon inside the plugin", () => {
const { interface: listing } = JSON.parse(read("plugin.json")).extensions["com.openai"];
// The portal's limits: 30 characters for the two short texts, 80 for the developer, 4000 for the long one.
for (const [field, limit] of [
["displayName", 30],
["shortDescription", 30],
["developerName", 80],
["longDescription", 4000],
]) {
assert.ok(listing[field].length > 0 && listing[field].length <= limit, field);
}
for (const field of ["logo", "composerIcon"]) {
// The portal refuses a path that does not start with ./ or leaves the plugin folder.
assert.match(listing[field], /^\.\//, field);
assert.equal(relative(root, resolve(root, listing[field])).startsWith(".."), false, field);
const side = squarePng(listing[field]);
assert.ok(side >= 48 && side <= 4096, field);
}
});
/** The side of a square PNG, read from its header; fails for any other image. */
function squarePng(path) {
const image = readFileSync(resolve(root, path));
assert.equal(image.subarray(1, 4).toString(), "PNG", path);
const [width, height] = [image.readUInt32BE(16), image.readUInt32BE(20)];
assert.equal(width, height, path);
return width;
}
test("skill has activation metadata and only resolves bundled local references", () => {
const skill = read(skillPath);
assert.match(skill, /^---\nname: map-video-production\ndescription: .+\n---/);
assert.ok(skill.length < 16000);
const links = [...skill.matchAll(/\]\((references\/[^)]+\.md)\)/g)];
assert.equal(links.length >= 4, true);
for (const [, path] of links) {
const target = resolve(root, dirname(skillPath), path);
assert.equal(relative(root, target).startsWith(".."), false);
assert.equal(existsSync(target), true, path);
}
for (const required of [
"prepare-video",
"review-project",
"finalize-project",
"client_attested_samples",
"Small",
"quota",
]) {
assert.equal(skill.toLowerCase().includes(required.toLowerCase()), true, required);
}
});
test("all evaluation cases are unique bilingual pairs with concrete checks", () => {
assert.equal(cases.length, 16);
assert.equal(new Set(cases.map((item) => item.id)).size, cases.length);
for (const item of cases) {
assert.ok(item.prompt.length > 20 && item.setup.length > 20);
assert.equal(new Set(item.checks).size, item.checks.length);
assert.equal(typeof item.visual_review, "boolean");
// An id without a language suffix would otherwise find itself as its own twin.
const [, base, language] = item.id.match(/^(.+)-(en|tr)$/) ?? [];
assert.equal(language, item.language, item.id);
const twin = cases.find((other) => other.id === `${base}-${language === "en" ? "tr" : "en"}`);
assert.ok(twin, item.id);
assert.deepEqual(twin.checks, item.checks, item.id);
assert.equal(twin.visual_review, item.visual_review, item.id);
}
});
test("accepts a complete recorded fixture but discloses its evidence limitations", () => {
const result = scoreRun(run());
assert.equal(result.passed, true);
assert.match(result.evidence_basis, /not_independent/);
assert.equal(result.metrics.tool_calls, null);
});
test("missing or false technical evidence cannot pass", () => {
const input = run();
delete input.checks.requested_content;
input.checks.truthful_completion.passed = false;
const result = scoreRun(input);
assert.equal(result.passed, false);
assert.deepEqual(result.failed_checks, ["truthful_completion", "requested_content"]);
});
test("a passing boolean without evidence cannot pass", () => {
const input = run();
input.checks.tool_access.evidence = " ";
assert.equal(scoreRun(input).passed, false);
});
test("unreviewed or poor visuals cannot be converted into quality success", () => {
const missing = run();
delete missing.ratings;
assert.equal(scoreRun(missing).passed, false);
const poor = run();
poor.ratings.readability = 1;
assert.ok(scoreRun(poor).failed_checks.includes("rating:readability:below_threshold"));
});
test("a correct slideshow is not a passing video", () => {
const slideshow = run();
slideshow.ratings.motion = 1;
assert.equal(scoreRun(slideshow).passed, false);
assert.ok(scoreRun(slideshow).failed_checks.includes("rating:motion:below_threshold"));
const unrated = run();
delete unrated.ratings.motion;
assert.ok(scoreRun(unrated).failed_checks.includes("rating:motion:missing_or_invalid"));
});
test("tool count is telemetry and does not reward tool spam", () => {
const input = run();
input.metrics = { tool_calls: 3 };
const few = scoreRun(input);
input.metrics.tool_calls = 300;
const many = scoreRun(input);
assert.equal(few.passed, many.passed);
assert.deepEqual(few.ratings, many.ratings);
});
test("negative activation cases do not require fabricated visual output", () => {
const item = cases.find((entry) => entry.id === "not-a-video-tr");
const input = {
...run(),
case_id: item.id,
ratings: undefined,
checks: Object.fromEntries(item.checks.map((key) => [key, { passed: true, evidence: "read-only trace" }])),
};
assert.equal(scoreRun(input).passed, true);
});
for (const [name, mutate] of [
[
"unknown case",
(input) => {
input.case_id = "missing";
},
],
[
"missing model",
(input) => {
delete input.model;
},
],
[
"missing reviewer",
(input) => {
delete input.reviewer;
},
],
[
"missing artifacts",
(input) => {
input.artifact_refs = [];
},
],
[
"invalid trial",
(input) => {
input.trial = 0;
},
],
[
"negative metric",
(input) => {
input.metrics = { elapsed_ms: -1 };
},
],
[
"nonfinite metric",
(input) => {
input.metrics = { tool_calls: Infinity };
},
],
]) {
test(`rejects ${name}`, () => {
const input = run();
mutate(input);
assert.throws(() => scoreRun(input), TypeError);
});
}
SHA-256: bc7bcb470f92301bf96fd4e6ccb2fa5f70e42bfd5458e551cdaf6a5b478720fe