feat: archive 阶段校验 task 完成状态,未完成时注入警告提示词

This commit is contained in:
2026-06-09 12:36:19 +08:00
parent 5705e59285
commit c45f6e1d45
4 changed files with 75 additions and 6 deletions

View File

@@ -201,7 +201,7 @@ cli.command("archive <change-name>", "归档阶段").action(
});
}
const config = await loadConfig(root);
const prompt = assembleArchivePrompt(config, changeName);
const prompt = await assembleArchivePrompt(config, root, changeName);
const today = new Date().toISOString().slice(0, 10);
const src = changeDir;
const dest = join(getArchiveDir(root), `${today}-${changeName}`);

View File

@@ -111,15 +111,39 @@ export async function assembleBuildPrompt(
return parts.join("\n");
}
export function assembleArchivePrompt(
export async function assembleArchivePrompt(
config: RuneConfig,
projectRoot: string,
changeName: string,
): string {
): Promise<string> {
const archive = config.stages.archive;
if (!archive) throw new Error("archive 阶段未配置");
const changeDir = getChangeDir(projectRoot, changeName);
const taskPath = join(changeDir, "task.md");
const parts: string[] = [];
parts.push(`# 归档阶段:${changeName}\n`);
try {
const taskContent = await readFile(taskPath, "utf-8");
const tasks = parseTasks(taskContent);
const incompleteTasks = tasks.filter((t) => !t.checked);
if (incompleteTasks.length > 0) {
parts.push("## ⚠️ 警告:存在未完成的任务\n");
parts.push(`以下 ${incompleteTasks.length} 个任务尚未完成:`);
for (const t of incompleteTasks) {
parts.push(`- [ ] ${t.text}`);
}
parts.push("");
parts.push("请询问用户是否确认在任务未全部完成的情况下归档。");
parts.push("如用户确认,则继续归档;否则中止并返回构建阶段。");
parts.push("");
}
} catch {
// task.md 不存在时不追加警告
}
parts.push(archive.prompt);
return parts.join("\n");
}