skillsMentionProvider.test.ts 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { describe, expect, it } from "vitest";
  2. import { mapSkillsToMentionItemsForTest } from "../src/mentions/providers/skillsMentionProvider.js";
  3. describe("skills mention provider", () => {
  4. it("dedupes same-name skills for $ panel and prefers workspace source", () => {
  5. const items = mapSkillsToMentionItemsForTest([
  6. {
  7. id: "claude:user:review:a",
  8. name: "review",
  9. description: "user review",
  10. path: "/home/user/.claude/skills/review/SKILL.md",
  11. scope: "user",
  12. },
  13. {
  14. id: "claude:plugin:review:b",
  15. name: "review",
  16. description: "plugin review",
  17. path: "/home/user/.claude/plugins/review/skills/review/SKILL.md",
  18. scope: "plugin",
  19. },
  20. {
  21. id: "claude:workspace:review:c",
  22. name: "review",
  23. description: "workspace review",
  24. path: "/repo/.claude/skills/review/SKILL.md",
  25. scope: "workspace",
  26. },
  27. ]);
  28. expect(items).toHaveLength(1);
  29. expect(items[0]).toMatchObject({
  30. label: "review",
  31. value: "review",
  32. description: "Workspace · workspace review",
  33. data: {
  34. scope: "workspace",
  35. path: "/repo/.claude/skills/review/SKILL.md",
  36. },
  37. });
  38. });
  39. it("$ panel displays the original frontmatter skill name without formatting", () => {
  40. const items = mapSkillsToMentionItemsForTest([
  41. {
  42. id: "claude:user:agent-browser:a",
  43. name: "agent-browser",
  44. description: "browser",
  45. path: "/home/user/.claude/skills/agent-browser/SKILL.md",
  46. scope: "user",
  47. },
  48. ]);
  49. expect(items[0]).toMatchObject({
  50. label: "agent-browser",
  51. value: "agent-browser",
  52. keywords: ["agent-browser", "browser", "user"],
  53. });
  54. });
  55. it("localizes bundled plugin skill descriptions for the $ panel", () => {
  56. const skill = {
  57. id: "builtin-pdf",
  58. name: "pdf",
  59. description: "专业 PDF 工具集",
  60. path: "/cache/zcode-plugins-official/document-skills/0.1.0/skills/pdf/SKILL.md",
  61. scope: "plugin" as const,
  62. pluginName: "document-skills",
  63. };
  64. expect(mapSkillsToMentionItemsForTest([skill], "en-US")[0]?.description).toContain(
  65. "Plugin · Professional PDF toolkit",
  66. );
  67. expect(mapSkillsToMentionItemsForTest([skill], "zh-CN")[0]?.description).toContain(
  68. "插件 · 专业 PDF 工具集",
  69. );
  70. });
  71. it("localizes the official Browser Use tester skill by plugin name", () => {
  72. const skill = {
  73. id: "builtin-web-gui-tester",
  74. name: "web-gui-tester",
  75. description: "frontmatter fallback",
  76. path: "/plugins/browser-use/skills/web-gui-tester/SKILL.md",
  77. scope: "plugin" as const,
  78. pluginName: "browser-use",
  79. };
  80. expect(mapSkillsToMentionItemsForTest([skill], "en-US")[0]?.description).toContain(
  81. "Plugin · Run pure GUI black-box tests",
  82. );
  83. expect(mapSkillsToMentionItemsForTest([skill], "zh-CN")[0]?.description).toContain(
  84. "插件 · 使用 ZCode Browser Use 对网页和本地 Web 前端执行纯 GUI 黑盒测试",
  85. );
  86. });
  87. });