feat: 新增 assembleCreatePrompt,plan/build/archive 不再内嵌文件内容
This commit is contained in:
@@ -16,6 +16,15 @@ export function assembleDiscussPrompt(config: RuneConfig): string {
|
||||
return applyCommandPrefix(discuss.prompt, config);
|
||||
}
|
||||
|
||||
export function assembleCreatePrompt(config: RuneConfig): string {
|
||||
const create = config.stages.create;
|
||||
if (!create)
|
||||
throw new CommandError("创建阶段未配置", {
|
||||
hint: "请在 .rune/config.yaml 中配置 stages.create",
|
||||
});
|
||||
return applyCommandPrefix(create.prompt, config);
|
||||
}
|
||||
|
||||
export async function assemblePlanPrompt(
|
||||
config: RuneConfig,
|
||||
projectRoot: string,
|
||||
@@ -45,8 +54,7 @@ export async function assemblePlanPrompt(
|
||||
|
||||
const docPath = join(changeDir, `${doc.name}.md`);
|
||||
if (existsSync(docPath)) {
|
||||
const existing = await readFile(docPath, "utf-8");
|
||||
parts.push(`\n### 已有内容(请在此基础上修订):\n${existing}`);
|
||||
parts.push(`\n文档已存在,请先读取 ${docPath} 查看已有内容,在此基础上修订。`);
|
||||
}
|
||||
|
||||
if (doc.template) {
|
||||
@@ -114,13 +122,9 @@ export async function assembleBuildPrompt(
|
||||
const parts: string[] = [];
|
||||
parts.push(`# 构建阶段:${changeName}\n`);
|
||||
parts.push(build.prompt);
|
||||
parts.push(`\n## 任务列表\n`);
|
||||
parts.push(taskContent);
|
||||
parts.push(`\n## 待执行任务(共 ${pendingTasks.length} 项)`);
|
||||
for (const task of pendingTasks) {
|
||||
parts.push(`- [ ] ${task.text}`);
|
||||
}
|
||||
parts.push(`\n请从第一个待执行任务开始。完成后更新 ${taskPath} 中的 checkbox。`);
|
||||
parts.push(`\n请先读取 ${taskPath} 查看任务列表。`);
|
||||
parts.push(`当前有 ${pendingTasks.length} 个待执行任务,从第一个未完成的任务开始。`);
|
||||
parts.push(`完成后更新 ${taskPath} 中的 checkbox。`);
|
||||
|
||||
return applyCommandPrefix(parts.join("\n"), config);
|
||||
}
|
||||
@@ -142,23 +146,21 @@ export async function assembleArchivePrompt(
|
||||
if (config.metadata?.tracked) {
|
||||
const changeDir = getChangeDir(projectRoot, changeName);
|
||||
const taskPath = join(changeDir, "task.md");
|
||||
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}`);
|
||||
if (existsSync(taskPath)) {
|
||||
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(`请先读取 ${taskPath} 检查是否有未完成的任务。`);
|
||||
parts.push("如有未完成任务,询问用户是否确认在任务未全部完成的情况下归档。");
|
||||
parts.push("如用户确认,则继续归档;否则中止并返回构建阶段。");
|
||||
parts.push("");
|
||||
}
|
||||
parts.push("");
|
||||
parts.push("请询问用户是否确认在任务未全部完成的情况下归档。");
|
||||
parts.push("如用户确认,则继续归档;否则中止并返回构建阶段。");
|
||||
parts.push("");
|
||||
} catch {
|
||||
// task.md 读取失败时不追加警告
|
||||
}
|
||||
} catch {
|
||||
// task.md 不存在时不追加警告
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user