feat: dynamically load planning templates from Gitea inside .vibncode/tasks/

This commit is contained in:
2026-06-03 11:09:26 -07:00
parent cdf48456a5
commit 1ccd4b7066

View File

@@ -5763,12 +5763,34 @@ async function readPrdContent(
}
}
async function readTaskTemplate(
principal: Principal,
projectId: string,
filename: string,
): Promise<string> {
try {
const res = await toolFsRead(principal, {
projectId,
path: `.vibncode/tasks/${filename}`,
});
const data = await res.json();
return data.result?.content || "";
} catch {
return "";
}
}
async function toolPlanGet(principal: Principal, params: Record<string, any>) {
const projectId = String(params.projectId ?? "").trim();
if (!projectId)
return NextResponse.json({ error: "projectId required" }, { status: 400 });
const content = await readPrdContent(principal, projectId);
const [content, planTemplate, tasksTemplate] = await Promise.all([
readPrdContent(principal, projectId),
readTaskTemplate(principal, projectId, "plan-template.md"),
readTaskTemplate(principal, projectId, "tasks-template.md"),
]);
const lines = content.split("\n");
const tasks: any[] = [];
const checklistRegex = /^\s*-\s*\[([ xX])\]\s+(.+)$/;
@@ -5791,8 +5813,8 @@ async function toolPlanGet(principal: Principal, params: Record<string, any>) {
decisions: [],
ideas: [],
templates: {
plan: PLAN_TEMPLATE,
tasks: TASKS_TEMPLATE,
plan: planTemplate || PLAN_TEMPLATE,
tasks: tasksTemplate || TASKS_TEMPLATE,
},
},
});