import { summarizeInboxMessage } from "./records.js"; import { getProjectSnapshot, groupTasksByStatus } from "./snapshot.js"; export async function createMarkdownContext(cwd?: string): Promise { const snapshot = await getProjectSnapshot(cwd); const lines: string[] = [`# ${snapshot.projectName}`, ""]; if (snapshot.instructions.body) { lines.push("## Project instructions", "", snapshot.instructions.body, ""); } lines.push("## Inbox", ""); if (snapshot.inbox.length === 0) { lines.push("No inbox messages.", ""); } else { for (const message of snapshot.inbox) { lines.push( `- ${message.data.id} [${message.data.status}] ${summarizeInboxMessage(message.body, message.data.attachments)} (${message.data.author_name})`, ); } lines.push(""); } lines.push("## Tasks", ""); for (const group of groupTasksByStatus( snapshot.tasks, snapshot.taskStatuses, snapshot.taskPriorityModel, )) { lines.push(`### ${group.status}`, ""); if (group.tasks.length === 0) { lines.push("No tasks.", ""); continue; } for (const task of group.tasks) { lines.push(`- ${task.data.id}: ${task.data.title}`); } lines.push(""); } lines.push("## Docs", ""); if (snapshot.docs.length === 0) { lines.push("No docs.", ""); } else { for (const doc of snapshot.docs) { lines.push( `- ${doc.data.id} [${doc.data.type}/${doc.data.status}] ${doc.data.title}`, ); } lines.push(""); } return `${lines.join("\n").trimEnd()}\n`; }