feat: opencode/claude-code 统一 command 格式、智能识别引导、新增 intro/create、移除 status
This commit is contained in:
@@ -15,20 +15,27 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
describe("injectClaudeCode", () => {
|
||||
it("生成 discuss、plan、build、archive 的 command 文件", async () => {
|
||||
it("生成 discuss、create、plan、build、archive 的 command 文件", async () => {
|
||||
await injectClaudeCode(TMP_DIR);
|
||||
|
||||
const commands = await readdir(join(TMP_DIR, ".claude", "commands"));
|
||||
for (const stage of ["discuss", "plan", "build", "archive"]) {
|
||||
for (const stage of ["discuss", "create", "plan", "build", "archive"]) {
|
||||
expect(commands).toContain(`rune-${stage}.md`);
|
||||
}
|
||||
});
|
||||
|
||||
it("生成 rune-status command 文件", async () => {
|
||||
it("不生成 rune-status command", async () => {
|
||||
await injectClaudeCode(TMP_DIR);
|
||||
|
||||
const commands = await readdir(join(TMP_DIR, ".claude", "commands"));
|
||||
expect(commands).toContain("rune-status.md");
|
||||
expect(commands).not.toContain("rune-status.md");
|
||||
});
|
||||
|
||||
it("生成 rune-intro command", async () => {
|
||||
await injectClaudeCode(TMP_DIR);
|
||||
|
||||
const commands = await readdir(join(TMP_DIR, ".claude", "commands"));
|
||||
expect(commands).toContain("rune-intro.md");
|
||||
});
|
||||
|
||||
it("command 文件包含 bash 命令", async () => {
|
||||
@@ -41,26 +48,26 @@ describe("injectClaudeCode", () => {
|
||||
expect(content).toContain("```bash");
|
||||
});
|
||||
|
||||
it("plan/build/archive command 包含变更名称提示", async () => {
|
||||
it("create/plan/build/archive command 包含变更名智能识别引导", async () => {
|
||||
await injectClaudeCode(TMP_DIR);
|
||||
|
||||
for (const stage of ["plan", "build", "archive"]) {
|
||||
for (const stage of ["create", "plan", "build", "archive"]) {
|
||||
const content = await readFile(
|
||||
join(TMP_DIR, ".claude", "commands", `rune-${stage}.md`),
|
||||
"utf-8",
|
||||
);
|
||||
expect(content).toContain("变更名");
|
||||
expect(content).toContain("如果用户没有指定变更名称");
|
||||
expect(content).toContain("智能识别");
|
||||
expect(content).toContain("rune status");
|
||||
}
|
||||
});
|
||||
|
||||
it("discuss command 不包含变更名称提示", async () => {
|
||||
it("discuss command 不包含智能识别引导", async () => {
|
||||
await injectClaudeCode(TMP_DIR);
|
||||
const content = await readFile(
|
||||
join(TMP_DIR, ".claude", "commands", "rune-discuss.md"),
|
||||
"utf-8",
|
||||
);
|
||||
expect(content).not.toContain("如果用户没有指定变更名称");
|
||||
expect(content).not.toContain("智能识别");
|
||||
});
|
||||
|
||||
it("重复注入时不覆盖已存在的文件", async () => {
|
||||
@@ -113,9 +120,14 @@ describe("updateClaudeCode", () => {
|
||||
expect(content).toContain("rune discuss");
|
||||
});
|
||||
|
||||
it("更新 status 命令", async () => {
|
||||
it("更新时生成 rune-intro 命令", async () => {
|
||||
await updateClaudeCode(TMP_DIR);
|
||||
expect(existsSync(join(TMP_DIR, ".claude", "commands", "rune-status.md"))).toBe(true);
|
||||
expect(existsSync(join(TMP_DIR, ".claude", "commands", "rune-intro.md"))).toBe(true);
|
||||
});
|
||||
|
||||
it("不生成 rune-status 命令", async () => {
|
||||
await updateClaudeCode(TMP_DIR);
|
||||
expect(existsSync(join(TMP_DIR, ".claude", "commands", "rune-status.md"))).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -138,9 +150,9 @@ describe("injectClaudeCode with command prefix", () => {
|
||||
expect(content).toContain("rune discuss");
|
||||
});
|
||||
|
||||
it("status command 使用自定义前缀", async () => {
|
||||
it("rune-intro command 使用自定义前缀", async () => {
|
||||
await injectClaudeCode(TMP_DIR, "npx @lanyuanxiaoyao/rune");
|
||||
const content = await readFile(join(TMP_DIR, ".claude", "commands", "rune-status.md"), "utf-8");
|
||||
const content = await readFile(join(TMP_DIR, ".claude", "commands", "rune-intro.md"), "utf-8");
|
||||
expect(content).toContain("npx @lanyuanxiaoyao/rune status");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user