feat: assemblePlanPrompt 改为按单文档组装,增加依赖说明
This commit is contained in:
@@ -37,16 +37,16 @@ describe("assembleDiscussPrompt", () => {
|
||||
});
|
||||
|
||||
describe("assemblePlanPrompt", () => {
|
||||
it("包含变更名称和文档指引", async () => {
|
||||
it("包含指定文档名称和提示词", async () => {
|
||||
const prompt = await assemblePlanPrompt(
|
||||
defaultConfig,
|
||||
TMP_DIR,
|
||||
"user-auth",
|
||||
"design",
|
||||
);
|
||||
expect(prompt).toContain("user-auth");
|
||||
expect(prompt).toContain("design");
|
||||
expect(prompt).toContain("task");
|
||||
expect(prompt).toContain("格式模板");
|
||||
expect(prompt).not.toContain("task");
|
||||
});
|
||||
|
||||
it("包含已有文档内容(重复 plan 场景)", async () => {
|
||||
@@ -57,6 +57,7 @@ describe("assemblePlanPrompt", () => {
|
||||
defaultConfig,
|
||||
TMP_DIR,
|
||||
"user-auth",
|
||||
"design",
|
||||
);
|
||||
expect(prompt).toContain("已有设计");
|
||||
expect(prompt).toContain("在此基础上修订");
|
||||
@@ -67,12 +68,67 @@ describe("assemblePlanPrompt", () => {
|
||||
defaultConfig,
|
||||
TMP_DIR,
|
||||
"user-auth",
|
||||
"design",
|
||||
);
|
||||
expect(prompt).toContain("user-auth 设计文档");
|
||||
expect(prompt).toContain("user-auth 任务列表");
|
||||
expect(prompt).not.toContain("{{change-name}}");
|
||||
});
|
||||
|
||||
it("包含依赖说明(有依赖时)", async () => {
|
||||
const config: RuneConfig = {
|
||||
stages: {
|
||||
plan: {
|
||||
documents: [
|
||||
{ name: "design", prompt: "生成设计" },
|
||||
{ name: "task", prompt: "生成任务", depend: ["design"] },
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
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",
|
||||
);
|
||||
expect(prompt).not.toContain("依赖说明");
|
||||
});
|
||||
|
||||
it("依赖说明标注完成状态", async () => {
|
||||
const changeDir = join(TMP_DIR, ".rune", "changes", "user-auth");
|
||||
await mkdir(changeDir, { recursive: true });
|
||||
await writeFile(join(changeDir, "design.md"), "# 设计");
|
||||
|
||||
const config: RuneConfig = {
|
||||
stages: {
|
||||
plan: {
|
||||
documents: [
|
||||
{ name: "design", prompt: "生成设计" },
|
||||
{ name: "task", prompt: "生成任务", depend: ["design"] },
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
const prompt = await assemblePlanPrompt(
|
||||
config,
|
||||
TMP_DIR,
|
||||
"user-auth",
|
||||
"task",
|
||||
);
|
||||
expect(prompt).toContain("已完成");
|
||||
});
|
||||
|
||||
it("使用自定义 plan 配置", async () => {
|
||||
const config: RuneConfig = {
|
||||
stages: {
|
||||
@@ -87,7 +143,7 @@ describe("assemblePlanPrompt", () => {
|
||||
},
|
||||
},
|
||||
};
|
||||
const prompt = await assemblePlanPrompt(config, TMP_DIR, "my-feature");
|
||||
const prompt = await assemblePlanPrompt(config, TMP_DIR, "my-feature", "spec");
|
||||
expect(prompt).toContain("spec");
|
||||
expect(prompt).toContain("my-feature 规格");
|
||||
expect(prompt).not.toContain("design");
|
||||
|
||||
Reference in New Issue
Block a user