resource-formatting.test.ts 997 B

123456789101112131415161718192021222324
  1. import { describe, expect, it } from "vitest";
  2. import { formatPromptTemplateInvocation } from "../../src/harness/prompt-templates.ts";
  3. import { formatSkillInvocation } from "../../src/harness/skills.ts";
  4. describe("resource formatting helpers", () => {
  5. it("formats skill invocations with additional instructions", () => {
  6. const skill = {
  7. name: "inspect",
  8. description: "Inspect things",
  9. content: "Use inspection tools.",
  10. filePath: "/project/.pi/skills/inspect/SKILL.md",
  11. };
  12. expect(formatSkillInvocation(skill, "Check errors.")).toBe(
  13. '<skill name="inspect" location="/project/.pi/skills/inspect/SKILL.md">\nReferences are relative to /project/.pi/skills/inspect.\n\nUse inspection tools.\n</skill>\n\nCheck errors.',
  14. );
  15. });
  16. it("formats prompt template invocations with positional arguments", () => {
  17. expect(
  18. formatPromptTemplateInvocation({ name: "review", content: "Review $1 with $ARGUMENTS" }, ["a.ts", "care"]),
  19. ).toBe("Review a.ts with a.ts care");
  20. });
  21. });