From 932ee45f9417d752c5538600ffd32c2437cb6039 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Wed, 10 Jun 2026 15:26:37 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=20adapter=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=80=82=E9=85=8D=20create=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/adapters/claude-code.test.ts | 38 ++++++++++++++++-- tests/adapters/opencode.test.ts | 63 ++++++++++++++++++++---------- 2 files changed, 77 insertions(+), 24 deletions(-) diff --git a/tests/adapters/claude-code.test.ts b/tests/adapters/claude-code.test.ts index 035c981..d135a2e 100644 --- a/tests/adapters/claude-code.test.ts +++ b/tests/adapters/claude-code.test.ts @@ -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( diff --git a/tests/adapters/opencode.test.ts b/tests/adapters/opencode.test.ts index 8baa1b9..43cc57b 100644 --- a/tests/adapters/opencode.test.ts +++ b/tests/adapters/opencode.test.ts @@ -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 });