remoteOfficialPluginAssets.test.ts 1.9 KB

123456789101112131415161718192021222324252627282930
  1. import { readdirSync } from "node:fs";
  2. import { fileURLToPath } from "node:url";
  3. import { describe, expect, it } from "vitest";
  4. import { OFFICIAL_DESIGN_REQUIRED_SEED_PATHS } from "../../../apps/zcode-cli/packages/bootstrap/src/app/official-plugin-definitions.js";
  5. import { REMOTE_AGENT_OFFICIAL_PLUGIN_REQUIRED_RELATIVE_PATHS } from "../src/remote/zcodeAgentOfficialPluginAssets.js";
  6. // design 的规则文件与脚本是会话里按需读取/执行的,远端缺一份只会在用到时失败;远端部署前的必需路径
  7. // 因此要覆盖本地 seed 的全部必需路径。server 运行时不依赖 bootstrap,这里机械对照两份清单。
  8. describe("remote official plugin required paths", () => {
  9. it("design 覆盖本地 seed 的全部必需路径(references 与磁盘一致、7 个运行时脚本、hook)", () => {
  10. const remote = new Set<string>(REMOTE_AGENT_OFFICIAL_PLUGIN_REQUIRED_RELATIVE_PATHS);
  11. const missing = OFFICIAL_DESIGN_REQUIRED_SEED_PATHS.map((path) => `design-plugin/${path}`).filter(
  12. (path) => !remote.has(path),
  13. );
  14. expect(missing).toEqual([]);
  15. const seeds: readonly string[] = OFFICIAL_DESIGN_REQUIRED_SEED_PATHS;
  16. // 规则文件按需读取,少登记一份只会在用到时才报错:seed 清单必须等于随包 references 目录。
  17. const referencesDir = fileURLToPath(
  18. new URL("../../../apps/zcode-cli/packages/design-plugin/skills/design/references/", import.meta.url),
  19. );
  20. expect(seeds.filter((path) => path.startsWith("skills/design/references/")).sort()).toEqual(
  21. readdirSync(referencesDir)
  22. .filter((name) => name.endsWith(".md"))
  23. .map((name) => `skills/design/references/${name}`)
  24. .sort(),
  25. );
  26. // build-catalog.mjs / frontmatter.mjs 只在开发时生成目录,不随包;其余脚本会话里会执行。
  27. expect(seeds.filter((path) => path.startsWith("skills/design/scripts/"))).toHaveLength(7);
  28. });
  29. });