diff --git a/vibn-frontend/app/api/mcp/route.ts b/vibn-frontend/app/api/mcp/route.ts index b21a24d7..e6aff6bb 100644 --- a/vibn-frontend/app/api/mcp/route.ts +++ b/vibn-frontend/app/api/mcp/route.ts @@ -5763,12 +5763,34 @@ async function readPrdContent( } } +async function readTaskTemplate( + principal: Principal, + projectId: string, + filename: string, +): Promise { + 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) { 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) { decisions: [], ideas: [], templates: { - plan: PLAN_TEMPLATE, - tasks: TASKS_TEMPLATE, + plan: planTemplate || PLAN_TEMPLATE, + tasks: tasksTemplate || TASKS_TEMPLATE, }, }, });