subagentSelectionAuthority.test.ts 1.1 KB

1234567891011121314151617181920212223242526272829
  1. import { describe, expect, it } from "vitest";
  2. import { parseSubagentMarkdownSelection } from "@zcode/shared";
  3. import { parseSubagentMarkdown } from "../src/subagents/subagentMarkdown.js";
  4. describe("Subagent 正式 Markdown 字段", () => {
  5. it.each(["null", "{}", "false"])("忽略中间字段 %s,model 是正式字段而不是 fallback", (value) => {
  6. const result = parseSubagentMarkdown({
  7. content: `---\nname: audit\ndescription: audit\nmodelSelection: ${value}\nmodel: personal:p/m\nthoughtLevel: high\n---\nAudit`,
  8. path: "/fixture/audit.md",
  9. scope: "user",
  10. });
  11. expect(result.agent).toBeDefined();
  12. expect(result.agent?.modelSelection).toEqual({
  13. providerId: "personal:p",
  14. modelId: "m",
  15. options: { reasoningLevel: "high" },
  16. });
  17. });
  18. it("正式编码无损读取 model 和 thoughtLevel", () => {
  19. expect(
  20. parseSubagentMarkdownSelection({ model: "custom:personal%3Ap:m", thoughtLevel: "high" }),
  21. ).toEqual({
  22. providerId: "personal:p",
  23. modelId: "m",
  24. options: { reasoningLevel: "high" },
  25. });
  26. });
  27. });