import { appendFileSync, mkdirSync } from "node:fs";
import { dirname } from "node:path";

export const appendUltragoalLedger = (path, entry) => {
  mkdirSync(dirname(path), { recursive: true });
  const record = {
    timestamp: new Date().toISOString(),
    ...entry,
  };
  appendFileSync(path, `${JSON.stringify(record)}\n`);
  return record;
};
