chore: 添加 .oxfmtrc.json 并格式化全部代码

This commit is contained in:
2026-06-09 14:22:33 +08:00
parent ebd5bb4051
commit b82f1caf0b
23 changed files with 209 additions and 373 deletions

View File

@@ -38,12 +38,7 @@ describe("assembleDiscussPrompt", () => {
describe("assemblePlanPrompt", () => {
it("包含指定文档名称和提示词", async () => {
const prompt = await assemblePlanPrompt(
defaultConfig,
TMP_DIR,
"user-auth",
"design",
);
const prompt = await assemblePlanPrompt(defaultConfig, TMP_DIR, "user-auth", "design");
expect(prompt).toContain("user-auth");
expect(prompt).toContain("design");
expect(prompt).not.toContain("task");
@@ -53,23 +48,13 @@ describe("assemblePlanPrompt", () => {
const changeDir = join(TMP_DIR, ".rune", "changes", "user-auth");
await mkdir(changeDir, { recursive: true });
await writeFile(join(changeDir, "design.md"), "# 已有设计");
const prompt = await assemblePlanPrompt(
defaultConfig,
TMP_DIR,
"user-auth",
"design",
);
const prompt = await assemblePlanPrompt(defaultConfig, TMP_DIR, "user-auth", "design");
expect(prompt).toContain("已有设计");
expect(prompt).toContain("在此基础上修订");
});
it("替换模板中的 {{change-name}}", async () => {
const prompt = await assemblePlanPrompt(
defaultConfig,
TMP_DIR,
"user-auth",
"design",
);
const prompt = await assemblePlanPrompt(defaultConfig, TMP_DIR, "user-auth", "design");
expect(prompt).toContain("user-auth 设计文档");
expect(prompt).not.toContain("{{change-name}}");
});
@@ -85,23 +70,13 @@ describe("assemblePlanPrompt", () => {
},
},
};
const prompt = await assemblePlanPrompt(
config,
TMP_DIR,
"user-auth",
"task",
);
const prompt = await assemblePlanPrompt(config, TMP_DIR, "user-auth", "task");
expect(prompt).toContain("依赖说明");
expect(prompt).toContain("design.md");
});
it("无依赖时不包含依赖说明", async () => {
const prompt = await assemblePlanPrompt(
defaultConfig,
TMP_DIR,
"user-auth",
"design",
);
const prompt = await assemblePlanPrompt(defaultConfig, TMP_DIR, "user-auth", "design");
expect(prompt).not.toContain("依赖说明");
});
@@ -120,12 +95,7 @@ describe("assemblePlanPrompt", () => {
},
},
};
const prompt = await assemblePlanPrompt(
config,
TMP_DIR,
"user-auth",
"task",
);
const prompt = await assemblePlanPrompt(config, TMP_DIR, "user-auth", "task");
expect(prompt).toContain("已完成");
});
@@ -154,15 +124,8 @@ describe("assembleBuildPrompt", () => {
it("包含待执行任务列表", async () => {
const changeDir = join(TMP_DIR, ".rune", "changes", "user-auth");
await mkdir(changeDir, { recursive: true });
await writeFile(
join(changeDir, "task.md"),
`- [x] 任务一\n- [ ] 任务二\n- [ ] 任务三`,
);
const prompt = await assembleBuildPrompt(
defaultConfig,
TMP_DIR,
"user-auth",
);
await writeFile(join(changeDir, "task.md"), `- [x] 任务一\n- [ ] 任务二\n- [ ] 任务三`);
const prompt = await assembleBuildPrompt(defaultConfig, TMP_DIR, "user-auth");
expect(prompt).toContain("任务二");
expect(prompt).toContain("待执行任务");
expect(prompt).toContain("共 2 项");
@@ -171,15 +134,8 @@ describe("assembleBuildPrompt", () => {
it("所有任务完成时提示可归档", async () => {
const changeDir = join(TMP_DIR, ".rune", "changes", "user-auth");
await mkdir(changeDir, { recursive: true });
await writeFile(
join(changeDir, "task.md"),
`- [x] 任务一\n- [x] 任务二`,
);
const prompt = await assembleBuildPrompt(
defaultConfig,
TMP_DIR,
"user-auth",
);
await writeFile(join(changeDir, "task.md"), `- [x] 任务一\n- [x] 任务二`);
const prompt = await assembleBuildPrompt(defaultConfig, TMP_DIR, "user-auth");
expect(prompt).toContain("已完成");
expect(prompt).toContain("归档");
});

View File

@@ -91,10 +91,7 @@ describe("loadConfig", () => {
it("YAML 解析错误时返回默认配置", async () => {
const runeDir = join(TMP_DIR, ".rune");
await mkdir(runeDir, { recursive: true });
await writeFile(
join(runeDir, "config.yaml"),
`stages: [invalid yaml {{{`,
);
await writeFile(join(runeDir, "config.yaml"), `stages: [invalid yaml {{{`);
const config = await loadConfig(TMP_DIR);
expect(config.stages.discuss).toBeDefined();
});
@@ -125,9 +122,7 @@ describe("validateConfig", () => {
const config: RuneConfig = {
stages: {
plan: {
documents: [
{ name: "task", prompt: "生成任务", depend: ["nonexistent"] },
],
documents: [{ name: "task", prompt: "生成任务", depend: ["nonexistent"] }],
},
},
};
@@ -138,9 +133,7 @@ describe("validateConfig", () => {
const config: RuneConfig = {
stages: {
plan: {
documents: [
{ name: "design", prompt: "生成设计", depend: ["design"] },
],
documents: [{ name: "design", prompt: "生成设计", depend: ["design"] }],
},
},
};
@@ -170,9 +163,7 @@ describe("validateConfig", () => {
const config: RuneConfig = {
stages: {
plan: {
documents: [
{ name: "design", prompt: "生成设计", depend: [] },
],
documents: [{ name: "design", prompt: "生成设计", depend: [] }],
},
},
};

View File

@@ -25,10 +25,7 @@ describe("scanChanges", () => {
const changesDir = join(TMP_DIR, ".rune", "changes");
await mkdir(join(changesDir, "user-auth"), { recursive: true });
await writeFile(join(changesDir, "user-auth", "design.md"), "# 设计");
await writeFile(
join(changesDir, "user-auth", "task.md"),
`- [x] 任务一\n- [ ] 任务二`,
);
await writeFile(join(changesDir, "user-auth", "task.md"), `- [x] 任务一\n- [ ] 任务二`);
const changes = await scanChanges(TMP_DIR);
expect(changes).toHaveLength(1);