From 115d5b125ed9141b2f07be22dd9483b1d6f05be2 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Thu, 11 Jun 2026 16:41:14 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20archive=20=E9=98=B6=E6=AE=B5?= =?UTF-8?q?=E6=94=B9=E7=94=A8=20PromptBuilder=20=E7=BB=84=E8=A3=85?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/assembler.ts | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/core/assembler.ts b/src/core/assembler.ts index b554a00..2daa78e 100644 --- a/src/core/assembler.ts +++ b/src/core/assembler.ts @@ -190,8 +190,10 @@ export async function assembleArchivePrompt( hint: "请在 .rune/config.yaml 中配置 stages.archive", }); - const parts: string[] = []; - parts.push(`# 归档阶段:${changeName}\n`); + const builder = new PromptBuilder(); + + builder.head(`# 归档阶段:${changeName}`); + builder.prompt(archive.prompt); const changeDir = getChangeDir(projectRoot, changeName); const taskPath = join(changeDir, "task.md"); @@ -201,15 +203,10 @@ export async function assembleArchivePrompt( const tasks = parseTasks(taskContent); const incompleteTasks = tasks.filter((t) => !t.checked); if (incompleteTasks.length > 0) { - parts.push("## ⚠️ 警告:存在未完成的任务\n"); - parts.push("以下任务尚未完成:"); - for (const t of incompleteTasks) { - parts.push(`- [ ] ${t.text}`); - } - parts.push(""); - parts.push("询问用户是否确认在任务未全部完成的情况下归档。"); - parts.push("如用户确认,则继续执行归档操作;否则中止并返回构建阶段。"); - parts.push(""); + const taskLines = incompleteTasks.map((t) => `- [ ] ${t.text}`).join("\n"); + builder.warn( + `## ⚠️ 警告:存在未完成的任务\n\n以下任务尚未完成:\n${taskLines}\n\n询问用户是否确认在任务未全部完成的情况下归档。\n如用户确认,则继续执行归档操作;否则中止并返回构建阶段。`, + ); } } catch (e) { const code = (e as NodeJS.ErrnoException)?.code; @@ -219,6 +216,5 @@ export async function assembleArchivePrompt( } } - parts.push(archive.prompt); - return applyCommandPrefix(parts.join("\n"), config); + return applyCommandPrefix(builder.build(), config); }