import { readFile } from "fs/promises"; import path from "path"; import { auth } from "@/lib/auth"; const PIPELINE_ROOT = process.env.PIPELINE_ROOT || path.join(process.cwd(), "pipeline"); function markdownToHtml(md: string): string { let html = md // Headers .replace(/^#{6}\s+(.+)$/gm, "
$1
") .replace(/^#{5}\s+(.+)$/gm, "
$1
") .replace(/^#{4}\s+(.+)$/gm, "

$1

") .replace(/^###\s+(.+)$/gm, "

$1

") .replace(/^##\s+(.+)$/gm, "

$1

") .replace(/^#\s+(.+)$/gm, "

$1

") // Bold and italic .replace(/\*\*\*(.+?)\*\*\*/g, "$1") .replace(/\*\*(.+?)\*\*/g, "$1") .replace(/\*(.+?)\*/g, "$1") // Code blocks .replace(/```(\w*)\n([\s\S]*?)```/g, "
$2
") // Inline code .replace(/`([^`]+)`/g, "$1") // Unordered lists .replace(/^[-*]\s+(.+)$/gm, "
  • $1
  • ") // Ordered lists .replace(/^\d+\.\s+(.+)$/gm, "
  • $1
  • ") // Horizontal rules .replace(/^---+$/gm, "
    ") // Line breaks to paragraphs .replace(/\n\n+/g, "

    ") // Single newlines in context .replace(/\n/g, "
    "); // Wrap consecutive

  • in