import type { WeeklyExportBundle } from "../telemetry/weekly-export.js"; /** * What the bundle contains, not the bundle itself. * * This used to concatenate all fifteen files — every JSONL row and every JSON blob — into a single * notification, which is not a preview of anything a person can read. The point of previewing is to * decide whether to export, so it shows the shape and the head of each file. */ export function formatExportPreview(bundle: WeeklyExportBundle, headLines = 3): string { const files = Object.entries(bundle.files); const width = Math.max(0, ...files.map(([file]) => file.length)); return [ `UltraPi export preview for ${bundle.week}: ${files.length} files, nothing written yet.`, "", ...files.flatMap(([file, contents]) => { const lines = contents.split("\n").filter(Boolean); const head = lines.slice(0, headLines).map((line) => ` ${line.length > 160 ? `${line.slice(0, 157)}...` : line}`); return [ `${file.padEnd(width)} ${lines.length} line${lines.length === 1 ? "" : "s"}, ${contents.length} chars`, ...head, ...(lines.length > head.length ? [` ... ${lines.length - head.length} more`] : []), ]; }), "", "Run /ultra-config export week to write it.", ].join("\n"); }