feat: dynamically load planning templates from Gitea inside .vibncode/tasks/
This commit is contained in:
@@ -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>) {
|
async function toolPlanGet(principal: Principal, params: Record<string, any>) {
|
||||||
const projectId = String(params.projectId ?? "").trim();
|
const projectId = String(params.projectId ?? "").trim();
|
||||||
if (!projectId)
|
if (!projectId)
|
||||||
return NextResponse.json({ error: "projectId required" }, { status: 400 });
|
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 lines = content.split("\n");
|
||||||
const tasks: any[] = [];
|
const tasks: any[] = [];
|
||||||
const checklistRegex = /^\s*-\s*\[([ xX])\]\s+(.+)$/;
|
const checklistRegex = /^\s*-\s*\[([ xX])\]\s+(.+)$/;
|
||||||
@@ -5791,8 +5813,8 @@ async function toolPlanGet(principal: Principal, params: Record<string, any>) {
|
|||||||
decisions: [],
|
decisions: [],
|
||||||
ideas: [],
|
ideas: [],
|
||||||
templates: {
|
templates: {
|
||||||
plan: PLAN_TEMPLATE,
|
plan: planTemplate || PLAN_TEMPLATE,
|
||||||
tasks: TASKS_TEMPLATE,
|
tasks: tasksTemplate || TASKS_TEMPLATE,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user