test: 更新 adapter 测试适配 create 移除

This commit is contained in:
2026-06-10 15:26:37 +08:00
parent a4c3a245c3
commit 932ee45f94
2 changed files with 77 additions and 24 deletions

View File

@@ -15,11 +15,11 @@ afterEach(async () => {
});
describe("injectClaudeCode", () => {
it("生成 discuss、create、plan、build、archive 的 command 文件", async () => {
it("生成 discuss、plan、build、archive 的 command 文件", async () => {
await injectClaudeCode(TMP_DIR);
const commands = await readdir(join(TMP_DIR, ".claude", "commands"));
for (const stage of ["discuss", "create", "plan", "build", "archive"]) {
for (const stage of ["discuss", "plan", "build", "archive"]) {
expect(commands).toContain(`rune-${stage}.md`);
}
});
@@ -48,10 +48,10 @@ describe("injectClaudeCode", () => {
expect(content).toContain("```bash");
});
it("create/plan/build/archive command 包含变更名智能识别引导", async () => {
it("plan/build/archive command 包含变更名智能识别引导", async () => {
await injectClaudeCode(TMP_DIR);
for (const stage of ["create", "plan", "build", "archive"]) {
for (const stage of ["plan", "build", "archive"]) {
const content = await readFile(
join(TMP_DIR, ".claude", "commands", `rune-${stage}.md`),
"utf-8",
@@ -70,6 +70,36 @@ describe("injectClaudeCode", () => {
expect(content).not.toContain("智能识别");
});
it("不生成 rune-create command", async () => {
await injectClaudeCode(TMP_DIR);
const commands = await readdir(join(TMP_DIR, ".claude", "commands"));
expect(commands).not.toContain("rune-create.md");
});
it("plan command 包含 create 引导", async () => {
await injectClaudeCode(TMP_DIR);
const content = await readFile(join(TMP_DIR, ".claude", "commands", "rune-plan.md"), "utf-8");
expect(content).toContain("如果变更目录尚不存在");
expect(content).toContain("rune create <变更名>");
});
it("discuss command 包含 create 引导", async () => {
await injectClaudeCode(TMP_DIR);
const content = await readFile(
join(TMP_DIR, ".claude", "commands", "rune-discuss.md"),
"utf-8",
);
expect(content).toContain("讨论结束后");
expect(content).toContain("rune create <变更名>");
});
it("intro command 不包含 rune-create 作为独立命令", async () => {
await injectClaudeCode(TMP_DIR);
const content = await readFile(join(TMP_DIR, ".claude", "commands", "rune-intro.md"), "utf-8");
expect(content).not.toContain("/rune-create");
expect(content).toContain("rune create <变更名>");
});
it("重复注入时不覆盖已存在的文件", async () => {
await injectClaudeCode(TMP_DIR);
const originalContent = await readFile(

View File

@@ -15,13 +15,13 @@ afterEach(async () => {
});
describe("injectOpenCode", () => {
it("生成 discuss、create、plan、build、archive 的 command 和 skill 文件", async () => {
it("生成 discuss、plan、build、archive 的 command 和 skill 文件", async () => {
await injectOpenCode(TMP_DIR);
const commands = await readdir(join(TMP_DIR, ".opencode", "commands"));
const skills = await readdir(join(TMP_DIR, ".opencode", "skills"));
for (const stage of ["discuss", "create", "plan", "build", "archive"]) {
for (const stage of ["discuss", "plan", "build", "archive"]) {
expect(commands).toContain(`rune-${stage}.md`);
expect(skills).toContain(`rune-${stage}`);
expect(existsSync(join(TMP_DIR, ".opencode", "skills", `rune-${stage}`, "SKILL.md"))).toBe(
@@ -54,7 +54,7 @@ describe("injectOpenCode", () => {
it("command 文件统一格式:只包含 skill 调用指令", async () => {
await injectOpenCode(TMP_DIR);
for (const stage of ["discuss", "create", "plan", "build", "archive"]) {
for (const stage of ["discuss", "plan", "build", "archive"]) {
const content = await readFile(
join(TMP_DIR, ".opencode", "commands", `rune-${stage}.md`),
"utf-8",
@@ -64,10 +64,10 @@ describe("injectOpenCode", () => {
}
});
it("create/plan/build/archive skill 包含变更名智能识别引导", async () => {
it("plan/build/archive skill 包含变更名智能识别引导", async () => {
await injectOpenCode(TMP_DIR);
for (const stage of ["create", "plan", "build", "archive"]) {
for (const stage of ["plan", "build", "archive"]) {
const content = await readFile(
join(TMP_DIR, ".opencode", "skills", `rune-${stage}`, "SKILL.md"),
"utf-8",
@@ -104,6 +104,44 @@ describe("injectOpenCode", () => {
expect(content).not.toContain("规划阶段应先运行");
});
it("不生成 rune-create command 和 skill", async () => {
await injectOpenCode(TMP_DIR);
const commands = await readdir(join(TMP_DIR, ".opencode", "commands"));
const skills = await readdir(join(TMP_DIR, ".opencode", "skills"));
expect(commands).not.toContain("rune-create.md");
expect(skills).not.toContain("rune-create");
});
it("plan skill 包含 create 引导", async () => {
await injectOpenCode(TMP_DIR);
const content = await readFile(
join(TMP_DIR, ".opencode", "skills", "rune-plan", "SKILL.md"),
"utf-8",
);
expect(content).toContain("如果变更目录尚不存在");
expect(content).toContain("rune create <变更名>");
});
it("discuss skill 包含 create 引导", async () => {
await injectOpenCode(TMP_DIR);
const content = await readFile(
join(TMP_DIR, ".opencode", "skills", "rune-discuss", "SKILL.md"),
"utf-8",
);
expect(content).toContain("讨论结束后");
expect(content).toContain("rune create <变更名>");
});
it("intro skill 不包含 rune-create 作为独立命令", async () => {
await injectOpenCode(TMP_DIR);
const content = await readFile(
join(TMP_DIR, ".opencode", "skills", "rune-intro", "SKILL.md"),
"utf-8",
);
expect(content).not.toContain("/rune-create");
expect(content).toContain("rune create <变更名>");
});
it("重复注入时不覆盖已存在的文件", async () => {
await injectOpenCode(TMP_DIR);
const originalContent = await readFile(
@@ -198,21 +236,6 @@ describe("injectOpenCode with command prefix", () => {
}
});
it("create skill 使用自定义前缀", async () => {
const tmpDir = join(import.meta.dir, "__tmp_opencode_create_test__");
await mkdir(tmpDir, { recursive: true });
try {
await injectOpenCode(tmpDir, "pnpx @lanyuanxiaoyao/rune");
const content = await readFile(
join(tmpDir, ".opencode", "skills", "rune-create", "SKILL.md"),
"utf-8",
);
expect(content).toContain("pnpx @lanyuanxiaoyao/rune create");
} finally {
await rm(tmpDir, { recursive: true, force: true });
}
});
it("rune-intro skill 使用自定义前缀", async () => {
const tmpDir = join(import.meta.dir, "__tmp_opencode_intro_test__");
await mkdir(tmpDir, { recursive: true });