feat: 迁移 code-drive schema 为内置默认流程
This commit is contained in:
@@ -42,26 +42,26 @@ 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", "requirements");
|
||||
expect(prompt).toContain("user-auth");
|
||||
expect(prompt).toContain("design");
|
||||
expect(prompt).toContain("requirements");
|
||||
expect(prompt).not.toContain("task");
|
||||
});
|
||||
|
||||
it("已有文档时引导 AI 读取而非内嵌内容", async () => {
|
||||
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");
|
||||
await writeFile(join(changeDir, "requirements.md"), "# 已有需求");
|
||||
const prompt = await assemblePlanPrompt(defaultConfig, TMP_DIR, "user-auth", "requirements");
|
||||
expect(prompt).toContain("已有内容");
|
||||
expect(prompt).toContain("design.md");
|
||||
expect(prompt).not.toContain("# 已有设计");
|
||||
expect(prompt).toContain("requirements.md");
|
||||
expect(prompt).not.toContain("# 已有需求");
|
||||
});
|
||||
|
||||
it("包含格式模板(纯静态文本)", async () => {
|
||||
const prompt = await assemblePlanPrompt(defaultConfig, TMP_DIR, "user-auth", "design");
|
||||
const prompt = await assemblePlanPrompt(defaultConfig, TMP_DIR, "user-auth", "requirements");
|
||||
expect(prompt).toContain("格式模板");
|
||||
expect(prompt).toContain("# 设计文档");
|
||||
expect(prompt).toContain("背景与目标");
|
||||
expect(prompt).not.toContain("{{change-name}}");
|
||||
});
|
||||
|
||||
@@ -82,7 +82,7 @@ describe("assemblePlanPrompt", () => {
|
||||
});
|
||||
|
||||
it("无依赖时不包含依赖说明", async () => {
|
||||
const prompt = await assemblePlanPrompt(defaultConfig, TMP_DIR, "user-auth", "design");
|
||||
const prompt = await assemblePlanPrompt(defaultConfig, TMP_DIR, "user-auth", "requirements");
|
||||
expect(prompt).not.toContain("依赖说明");
|
||||
});
|
||||
|
||||
|
||||
@@ -43,17 +43,23 @@ describe("defaultConfig", () => {
|
||||
expect(prompt).toContain("task.md");
|
||||
});
|
||||
|
||||
it("plan 阶段包含 design 文档配置", () => {
|
||||
it("plan 阶段包含三个文档配置(requirements/design/plan)", () => {
|
||||
const docs = defaultConfig.stages.plan!.documents;
|
||||
expect(docs).toHaveLength(1);
|
||||
expect(docs[0].name).toBe("design");
|
||||
expect(docs[0].prompt).toBeTruthy();
|
||||
expect(docs).toHaveLength(3);
|
||||
expect(docs[0].name).toBe("requirements");
|
||||
expect(docs[0].depend).toEqual([]);
|
||||
expect(docs[1].name).toBe("design");
|
||||
expect(docs[1].depend).toEqual(["requirements"]);
|
||||
expect(docs[2].name).toBe("plan");
|
||||
expect(docs[2].depend).toEqual(["requirements", "design"]);
|
||||
});
|
||||
|
||||
it("design 文档有 template", () => {
|
||||
const designDoc = defaultConfig.stages.plan!.documents.find((d) => d.name === "design");
|
||||
expect(designDoc!.template).toBeTruthy();
|
||||
expect(designDoc!.template).toContain("设计文档");
|
||||
it("每个 plan 文档都有 prompt 和 template", () => {
|
||||
const docs = defaultConfig.stages.plan!.documents;
|
||||
for (const doc of docs) {
|
||||
expect(doc.prompt).toBeTruthy();
|
||||
expect(doc.template).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
it("task 阶段有 prompt", () => {
|
||||
|
||||
@@ -39,7 +39,9 @@ describe("完整 SDD 流程", () => {
|
||||
expect(planPrompt).toContain("user-auth");
|
||||
|
||||
const changeDir = getChangeDir(TMP_DIR, changeName);
|
||||
await writeFile(join(changeDir, "requirements.md"), "# 需求\n\n## 背景\n需要用户登录功能");
|
||||
await writeFile(join(changeDir, "design.md"), "# 用户认证设计\n\n## 背景\n需要用户登录功能");
|
||||
await writeFile(join(changeDir, "plan.md"), "# 实现计划\n\n## 阶段 1: 实现登录");
|
||||
|
||||
const taskPrompt = await assembleTaskPrompt(config, TMP_DIR, changeName);
|
||||
expect(taskPrompt).toContain("user-auth");
|
||||
@@ -138,14 +140,23 @@ describe("完整 SDD 流程", () => {
|
||||
|
||||
const changeDir = getChangeDir(TMP_DIR, "dep-test");
|
||||
await mkdir(changeDir, { recursive: true });
|
||||
await writeFile(join(changeDir, "requirements.md"), "# 需求");
|
||||
await writeFile(join(changeDir, "design.md"), "# 设计文档");
|
||||
|
||||
const changes = await scanChanges(TMP_DIR, config);
|
||||
expect(changes).toHaveLength(1);
|
||||
|
||||
const requirementsDoc = changes[0].documents.find((d) => d.name === "requirements");
|
||||
expect(requirementsDoc).toBeDefined();
|
||||
expect(requirementsDoc!.completed).toBe(true);
|
||||
|
||||
const designDoc = changes[0].documents.find((d) => d.name === "design");
|
||||
expect(designDoc).toBeDefined();
|
||||
expect(designDoc!.completed).toBe(true);
|
||||
|
||||
const planDoc = changes[0].documents.find((d) => d.name === "plan");
|
||||
expect(planDoc).toBeDefined();
|
||||
expect(planDoc!.completed).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user