feat: 适配器支持动态命令前缀
This commit is contained in:
@@ -148,3 +148,50 @@ describe("updateOpenCode", () => {
|
||||
expect(existsSync(join(TMP_DIR, ".opencode", "skills", "rune-status", "SKILL.md"))).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("injectOpenCode with command prefix", () => {
|
||||
it("使用自定义前缀生成 skill 文件", async () => {
|
||||
const tmpDir = join(import.meta.dir, "__tmp_opencode_prefix_test__");
|
||||
await mkdir(tmpDir, { recursive: true });
|
||||
try {
|
||||
await injectOpenCode(tmpDir, "bunx @lanyuanxiaoyao/rune");
|
||||
const content = await readFile(
|
||||
join(tmpDir, ".opencode", "skills", "rune-discuss", "SKILL.md"),
|
||||
"utf-8",
|
||||
);
|
||||
expect(content).toContain("bunx @lanyuanxiaoyao/rune discuss");
|
||||
} finally {
|
||||
await rm(tmpDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("不传前缀时使用默认 rune 前缀", async () => {
|
||||
const tmpDir = join(import.meta.dir, "__tmp_opencode_default_test__");
|
||||
await mkdir(tmpDir, { recursive: true });
|
||||
try {
|
||||
await injectOpenCode(tmpDir);
|
||||
const content = await readFile(
|
||||
join(tmpDir, ".opencode", "skills", "rune-discuss", "SKILL.md"),
|
||||
"utf-8",
|
||||
);
|
||||
expect(content).toContain("rune discuss");
|
||||
} finally {
|
||||
await rm(tmpDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("status skill 使用自定义前缀", async () => {
|
||||
const tmpDir = join(import.meta.dir, "__tmp_opencode_status_test__");
|
||||
await mkdir(tmpDir, { recursive: true });
|
||||
try {
|
||||
await injectOpenCode(tmpDir, "pnpx @lanyuanxiaoyao/rune");
|
||||
const content = await readFile(
|
||||
join(tmpDir, ".opencode", "skills", "rune-status", "SKILL.md"),
|
||||
"utf-8",
|
||||
);
|
||||
expect(content).toContain("pnpx @lanyuanxiaoyao/rune status");
|
||||
} finally {
|
||||
await rm(tmpDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user