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