refactor: task 和 build 阶段改用 PromptBuilder 组装提示词
This commit is contained in:
@@ -106,23 +106,22 @@ export async function assembleTaskPrompt(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const parts: string[] = [];
|
const builder = new PromptBuilder();
|
||||||
parts.push(`# 任务拆解阶段:${changeName}\n`);
|
|
||||||
parts.push(task.prompt);
|
builder.head(`# 任务拆解阶段:${changeName}`);
|
||||||
|
builder.prompt(task.prompt);
|
||||||
|
|
||||||
const planDocPaths = plan.documents.map((d) => join(changeDir, `${d.name}.md`));
|
const planDocPaths = plan.documents.map((d) => join(changeDir, `${d.name}.md`));
|
||||||
parts.push(`\n请先读取以下规划文档:`);
|
builder.context(`请先读取以下规划文档:\n${planDocPaths.map((p) => `- ${p}`).join("\n")}`);
|
||||||
for (const p of planDocPaths) {
|
|
||||||
parts.push(`- ${p}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const taskPath = join(changeDir, "task.md");
|
const taskPath = join(changeDir, "task.md");
|
||||||
if (existsSync(taskPath)) {
|
if (existsSync(taskPath)) {
|
||||||
parts.push(`\ntask.md 已存在,请先读取 ${taskPath} 查看已有内容,在此基础上修订。`);
|
builder.context(`task.md 已存在,请先读取 ${taskPath} 查看已有内容,在此基础上修订。`);
|
||||||
}
|
}
|
||||||
|
|
||||||
parts.push(`\n请将任务列表写入 ${taskPath}`);
|
builder.guide(`请将任务列表写入 ${taskPath}`);
|
||||||
return applyCommandPrefix(parts.join("\n"), config);
|
|
||||||
|
return applyCommandPrefix(builder.build(), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function assembleBuildPrompt(
|
export async function assembleBuildPrompt(
|
||||||
@@ -168,14 +167,16 @@ export async function assembleBuildPrompt(
|
|||||||
return `所有任务已完成。变更 "${changeName}" 可以归档。`;
|
return `所有任务已完成。变更 "${changeName}" 可以归档。`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const parts: string[] = [];
|
const builder = new PromptBuilder();
|
||||||
parts.push(`# 构建阶段:${changeName}\n`);
|
|
||||||
parts.push(build.prompt);
|
|
||||||
parts.push(`\n请先读取 ${taskPath} 查看任务列表。`);
|
|
||||||
parts.push(`当前有 ${pendingTasks.length} 个待执行任务,从第一个未完成的任务开始。`);
|
|
||||||
parts.push(`完成后更新 ${taskPath} 中的 checkbox。`);
|
|
||||||
|
|
||||||
return applyCommandPrefix(parts.join("\n"), config);
|
builder.head(`# 构建阶段:${changeName}`);
|
||||||
|
builder.prompt(build.prompt);
|
||||||
|
builder.context(
|
||||||
|
`请先读取 ${taskPath} 查看任务列表。\n当前有 ${pendingTasks.length} 个待执行任务,从第一个未完成的任务开始。`,
|
||||||
|
);
|
||||||
|
builder.guide(`完成后更新 ${taskPath} 中的 checkbox。`);
|
||||||
|
|
||||||
|
return applyCommandPrefix(builder.build(), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function assembleArchivePrompt(
|
export async function assembleArchivePrompt(
|
||||||
|
|||||||
Reference in New Issue
Block a user