formatTaskLedgerBlock function

String formatTaskLedgerBlock(
  1. TaskLedger ledger
)

Renders ledger back into the fenced task-ledger block the contract mandates (the parser's exact input shape) — the IT harness and tests build final answers with it.

Implementation

String formatTaskLedgerBlock(TaskLedger ledger) {
  final buffer = StringBuffer('```task-ledger\n');
  for (final item in ledger.items) {
    buffer
      ..writeln('- requirement: ${item.requirement}')
      ..writeln('  command: ${item.command}')
      ..writeln('  expected: ${item.expected}')
      ..writeln('  actual: ${item.actual}')
      ..writeln('  status: ${item.status.jsonName}');
  }
  buffer.write('```');
  return buffer.toString();
}