{"version":3,"sources":["../../src/legacy/format.ts"],"sourcesContent":["import type { Score } from \"./shared\";\n\n/**\n * Temporary legacy formatter helpers.\n *\n * Keep these local to the scorer-first compatibility layer so legacy can be\n * deleted without touching the harness-first entrypoint.\n */\n\n/** Wraps scorer output into fixed-width lines for legacy failure messages. */\nexport function wrapText(text: string, width = 80): string {\n  if (!text || text.length <= width) {\n    return text;\n  }\n\n  const words = text.split(/\\s+/);\n  const lines: string[] = [];\n  let currentLine = \"\";\n\n  for (const word of words) {\n    if (currentLine.length + word.length + 1 > width) {\n      lines.push(currentLine.trim());\n      currentLine = word;\n    } else {\n      currentLine += (currentLine ? \" \" : \"\") + word;\n    }\n  }\n\n  if (currentLine) {\n    lines.push(currentLine);\n  }\n\n  return lines.join(\"\\n\");\n}\n\n/** Formats legacy scorer results for matcher and assertion output. */\nexport function formatScores(scores: (Score & { name: string })[]) {\n  return scores\n    .map((score) => {\n      const scoreLine = `${score.name || \"Unknown\"} [${(score.score ?? 0).toFixed(1)}]`;\n      if (\n        ((score.score ?? 0) < 1.0 && score.metadata?.rationale) ||\n        score.metadata?.output\n      ) {\n        let formattedOutput = \"\";\n        if (score.metadata?.output !== undefined) {\n          const output = score.metadata.output;\n          formattedOutput =\n            typeof output === \"string\"\n              ? `\\noutput  ${wrapText(output)}`\n              : `\\noutput  ${wrapText(JSON.stringify(output, null, 2))}`;\n        }\n\n        return `${scoreLine}${\n          score.metadata?.rationale\n            ? `\\nreason  ${wrapText(score.metadata.rationale)}`\n            : \"\"\n        }${formattedOutput}`;\n      }\n      return scoreLine;\n    })\n    .join(\"\\n\\n\");\n}\n"],"mappings":";AAUO,SAAS,SAAS,MAAc,QAAQ,IAAY;AACzD,MAAI,CAAC,QAAQ,KAAK,UAAU,OAAO;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,KAAK,MAAM,KAAK;AAC9B,QAAM,QAAkB,CAAC;AACzB,MAAI,cAAc;AAElB,aAAW,QAAQ,OAAO;AACxB,QAAI,YAAY,SAAS,KAAK,SAAS,IAAI,OAAO;AAChD,YAAM,KAAK,YAAY,KAAK,CAAC;AAC7B,oBAAc;AAAA,IAChB,OAAO;AACL,sBAAgB,cAAc,MAAM,MAAM;AAAA,IAC5C;AAAA,EACF;AAEA,MAAI,aAAa;AACf,UAAM,KAAK,WAAW;AAAA,EACxB;AAEA,SAAO,MAAM,KAAK,IAAI;AACxB;AAGO,SAAS,aAAa,QAAsC;AACjE,SAAO,OACJ,IAAI,CAAC,UAAU;AACd,UAAM,YAAY,GAAG,MAAM,QAAQ,SAAS,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC;AAC9E,SACI,MAAM,SAAS,KAAK,KAAO,MAAM,UAAU,aAC7C,MAAM,UAAU,QAChB;AACA,UAAI,kBAAkB;AACtB,UAAI,MAAM,UAAU,WAAW,QAAW;AACxC,cAAM,SAAS,MAAM,SAAS;AAC9B,0BACE,OAAO,WAAW,WACd;AAAA,UAAa,SAAS,MAAM,CAAC,KAC7B;AAAA,UAAa,SAAS,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC,CAAC;AAAA,MAC9D;AAEA,aAAO,GAAG,SAAS,GACjB,MAAM,UAAU,YACZ;AAAA,UAAa,SAAS,MAAM,SAAS,SAAS,CAAC,KAC/C,EACN,GAAG,eAAe;AAAA,IACpB;AACA,WAAO;AAAA,EACT,CAAC,EACA,KAAK,MAAM;AAChB;","names":[]}