Decouple agent host skill bridging into dedicated module src/core/agent-hosts/: - antigravity.ts: manage ~/.gemini/config/skills.json - symlink-hosts.ts: detect and bridge ~/.workbuddy, ~/.claude, and ~/.qoder - types.ts: explicit types for host results and statuses - agent-hosts.test.ts: isolated unit tests for host discovery and symlinks Respect existing parent symlinks, replace legacy real directories safely, prevent dotfile pollution by only acting when host roots exist, and expose unified hosts array in seal-use skill install & status.
67 lines
2.8 KiB
TypeScript
67 lines
2.8 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import packageJson from "../../package.json" with { type: "json" };
|
|
import {
|
|
EMBEDDED_SKILL_ALL_PATHS,
|
|
EMBEDDED_SKILL_ASSETS,
|
|
EMBEDDED_SKILL_FILES,
|
|
EMBEDDED_SKILL_VERSION,
|
|
getSkillContent,
|
|
installSkillFiles,
|
|
parseSkillVersion,
|
|
readInstalledSkillVersion
|
|
} from "./embedded-skill.js";
|
|
|
|
describe("embedded-skill", () => {
|
|
test("embeds skill text and asset files", () => {
|
|
expect(EMBEDDED_SKILL_FILES["SKILL.md"]).toBeDefined();
|
|
expect(EMBEDDED_SKILL_FILES["SKILL.md"]).toContain("name: seal-use");
|
|
expect(EMBEDDED_SKILL_FILES["references/cli.md"]).toBeDefined();
|
|
expect(EMBEDDED_SKILL_FILES["references/enterprise-onboarding.md"]).toContain("# Enterprise Onboarding");
|
|
expect(EMBEDDED_SKILL_FILES["references/first-time-user.md"]).toContain("复制 → 以 cURL 格式复制");
|
|
expect(EMBEDDED_SKILL_ASSETS["assets/hose-curl-copy-as-curl.png"]).toBeDefined();
|
|
expect(EMBEDDED_SKILL_ALL_PATHS).toContain("assets/hose-curl-copy-as-curl.png");
|
|
expect(getSkillContent()).toContain("name: seal-use");
|
|
});
|
|
|
|
test("installSkillFiles writes all embedded files to target directory", () => {
|
|
const tmp = mkdtempSync(join(tmpdir(), "skill-test-"));
|
|
try {
|
|
const res = installSkillFiles(tmp);
|
|
expect(res.targetDir).toBe(tmp);
|
|
expect(res.files.length).toBeGreaterThan(5);
|
|
expect(existsSync(join(tmp, "SKILL.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "cli.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "enterprise-onboarding.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "first-time-user.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "assets", "hose-curl-copy-as-curl.png"))).toBe(true);
|
|
} finally {
|
|
rmSync(tmp, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|
|
|
|
describe("embedded-skill version contract", () => {
|
|
test("the skill's version matches the package version", () => {
|
|
expect(EMBEDDED_SKILL_VERSION).toBe(packageJson.version);
|
|
});
|
|
|
|
test("parses the version out of SKILL.md front matter", () => {
|
|
expect(parseSkillVersion("---\nname: seal-use\nversion: 1.2.3\n---\n")).toBe("1.2.3");
|
|
expect(parseSkillVersion("# no front matter here")).toBeUndefined();
|
|
});
|
|
|
|
test("reads back the version of an installed skill", () => {
|
|
const tmp = mkdtempSync(join(tmpdir(), "skill-version-"));
|
|
try {
|
|
const res = installSkillFiles(tmp);
|
|
expect(readInstalledSkillVersion(join(res.targetDir, "SKILL.md"))).toBe(EMBEDDED_SKILL_VERSION);
|
|
expect(readInstalledSkillVersion(join(tmp, "missing.md"))).toBeUndefined();
|
|
} finally {
|
|
rmSync(tmp, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|