55 lines
2.7 KiB
TypeScript
55 lines
2.7 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { mkdtempSync, rmSync, existsSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { EMBEDDED_SKILL_FILES, getSkillContent, installSkillFiles } from "./embedded-skill.js";
|
|
|
|
describe("embedded-skill - 多文件内嵌 Skill 体系", () => {
|
|
test("正确内嵌 SKILL.md、agents/openai.yaml 及各领域参考专卷", () => {
|
|
expect(EMBEDDED_SKILL_FILES["SKILL.md"]).toBeDefined();
|
|
expect(EMBEDDED_SKILL_FILES["SKILL.md"]).toContain("name: hose-use");
|
|
expect(getSkillContent()).toContain("name: hose-use");
|
|
|
|
expect(EMBEDDED_SKILL_FILES["agents/openai.yaml"]).toBeDefined();
|
|
expect(EMBEDDED_SKILL_FILES["agents/openai.yaml"]).toContain("hose_cli");
|
|
|
|
expect(EMBEDDED_SKILL_FILES["references/auth.md"]).toBeDefined();
|
|
expect(EMBEDDED_SKILL_FILES["references/auth.md"]).toContain("RSA");
|
|
|
|
expect(EMBEDDED_SKILL_FILES["references/bill.md"]).toBeDefined();
|
|
expect(EMBEDDED_SKILL_FILES["references/bill.md"]).toContain("bill get");
|
|
|
|
expect(EMBEDDED_SKILL_FILES["references/workflow.md"]).toBeDefined();
|
|
expect(EMBEDDED_SKILL_FILES["references/workflow.md"]).toContain("workflow find");
|
|
|
|
expect(EMBEDDED_SKILL_FILES["references/service.md"]).toBeDefined();
|
|
expect(EMBEDDED_SKILL_FILES["references/service.md"]).toContain("POST /api/cli");
|
|
|
|
expect(EMBEDDED_SKILL_FILES["references/contact.md"]).toBeDefined();
|
|
expect(EMBEDDED_SKILL_FILES["references/contact.md"]).toContain("contact search");
|
|
|
|
expect(EMBEDDED_SKILL_FILES["references/approval.md"]).toBeDefined();
|
|
expect(EMBEDDED_SKILL_FILES["references/approval.md"]).toContain("hose-aipro");
|
|
});
|
|
|
|
test("installSkillFiles 递归保留层级结构并落盘到目标目录", () => {
|
|
const tmp = mkdtempSync(join(tmpdir(), "hose-skill-test-"));
|
|
try {
|
|
const res = installSkillFiles(tmp);
|
|
expect(res.targetDir).toBe(tmp);
|
|
expect(res.files.length).toBe(12);
|
|
expect(existsSync(join(tmp, "SKILL.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "agents", "openai.yaml"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "auth.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "approval.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "bill.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "contact.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "role.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "workflow.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "service.md"))).toBe(true);
|
|
} finally {
|
|
rmSync(tmp, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|