/// Truncate `s` to at most `max` bytes on a UTF-8 char boundary, appending
/// `marker` so callers know content was capped. Plain `String::truncate` panics
/// mid-character (e.g. on CJK); this walks back to the nearest boundary.
pub
/// Keep the first `max` lines of `s`. Returns `(head, total_lines)` where
/// `total_lines` is the original line count. If `total_lines <= max`, `head`
/// equals `s` (no truncation needed). Callers should append a tool-specific
/// recovery hint when truncation occurred.
pub