67 lines
3.5 KiB
TypeScript
67 lines
3.5 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { mkdtempSync, rmSync, existsSync } from "node:fs";
|
|
import { homedir, tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { EMBEDDED_SKILL_FILES, getDefaultGlobalSkillDir, getSkillContent, installSkillFiles } from "./embedded-skill.js";
|
|
|
|
describe("embedded-skill - 多文件内嵌 Skill 体系", () => {
|
|
test("全局 Skill 目录固定为 ~/.agents/skills/hose-use", () => {
|
|
expect(getDefaultGlobalSkillDir()).toBe(join(homedir(), ".agents", "skills", "hose-use"));
|
|
});
|
|
|
|
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");
|
|
expect(EMBEDDED_SKILL_FILES["references/feetype.md"]).toBeDefined();
|
|
expect(EMBEDDED_SKILL_FILES["references/feetype.md"]).toContain("feetype");
|
|
expect(EMBEDDED_SKILL_FILES["references/store.md"]).toBeDefined();
|
|
expect(EMBEDDED_SKILL_FILES["references/store.md"]).toContain("hose-use keys");
|
|
expect(EMBEDDED_SKILL_FILES["SKILL.md"]).toContain("--reveal -o <path>");
|
|
expect(EMBEDDED_SKILL_FILES["SKILL.md"]).toContain("references/store.md");
|
|
});
|
|
|
|
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(14);
|
|
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", "feetype.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);
|
|
expect(existsSync(join(tmp, "references", "store.md"))).toBe(true);
|
|
} finally {
|
|
rmSync(tmp, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|