sea-official-plugin-assets.test.mjs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import assert from "node:assert/strict";
  2. import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
  3. import { tmpdir } from "node:os";
  4. import { dirname, join } from "node:path";
  5. import test from "node:test";
  6. import { collectSeaOfficialPluginAssets } from "../scripts/sea-official-plugin-assets.mjs";
  7. test("includes the document judge agent in official SEA assets", async () => {
  8. const stagingDirectory = await mkdtemp(join(tmpdir(), "zcode-sea-document-agent-"));
  9. const root = join(import.meta.dirname, "../../..");
  10. try {
  11. const { manifest } = await collectSeaOfficialPluginAssets({
  12. root,
  13. stagingDirectory,
  14. });
  15. assert.equal(
  16. manifest.plugins.some((plugin) => plugin.name === "document-skills"),
  17. false,
  18. );
  19. for (const [name, skill] of [
  20. ["documents", "docx"],
  21. ["pdf", "pdf"],
  22. ["presentations", "pptx"],
  23. ["spreadsheets", "xlsx"],
  24. ]) {
  25. const plugin = manifest.plugins.find((plugin) => plugin.name === name);
  26. assert.ok(plugin, `missing ${name} SEA manifest entry`);
  27. assert.equal(plugin.version, "0.1.6");
  28. for (const path of ["agents/visual-judge.md", `skills/${skill}/SKILL.md`])
  29. assert.ok(
  30. plugin.files.some((file) => file.path === path),
  31. `${name}: ${path}`,
  32. );
  33. }
  34. const creator = manifest.plugins.find((plugin) => plugin.name === "plugin-creator");
  35. assert.ok(creator, "missing plugin-creator SEA manifest entry");
  36. for (const path of [
  37. ".zcode-plugin/plugin.json",
  38. "skills/plugin-creator/SKILL.md",
  39. "skills/plugin-creator/scripts/create-basic-plugin.mjs",
  40. "skills/plugin-creator/scripts/marketplace-files.mjs",
  41. "skills/plugin-creator/scripts/upsert-dev-marketplace.mjs",
  42. "skills/plugin-creator/scripts/scaffold-files.mjs",
  43. "skills/plugin-creator/scripts/validate-plugin.mjs",
  44. "skills/plugin-creator/references/plugin-json-spec.md",
  45. "skills/plugin-creator/references/installing-and-updating.md",
  46. ])
  47. assert.ok(
  48. creator.files.some((file) => file.path === path),
  49. `missing ${path}`,
  50. );
  51. } finally {
  52. await rm(stagingDirectory, { force: true, recursive: true });
  53. }
  54. });
  55. test("rejects an incomplete documents SEA seed", async () => {
  56. const directory = await mkdtemp(join(tmpdir(), "zcode-sea-document-agent-missing-"));
  57. const root = join(directory, "root");
  58. const stagingDirectory = join(directory, "staging");
  59. try {
  60. await writeTestFile(root, "packages/android-emulator-plugin/.zcode-plugin/plugin.json", "{}");
  61. await writeTestFile(root, "packages/documents-plugin/.zcode-plugin/plugin.json", "{}");
  62. await assert.rejects(
  63. collectSeaOfficialPluginAssets({ root, stagingDirectory }),
  64. /Missing documents required seed asset.*agents[/\\]visual-judge\.md/u,
  65. );
  66. } finally {
  67. await rm(directory, { force: true, recursive: true });
  68. }
  69. });
  70. async function writeTestFile(root, relativePath, content) {
  71. const filePath = join(root, ...relativePath.split("/"));
  72. await mkdir(dirname(filePath), { recursive: true });
  73. await writeFile(filePath, content, "utf8");
  74. }