Skip to main content

Module formatting

Module formatting 

Source
Expand description

Unified formatting utilities for UI and logging

Constants§

RAN_COMMAND_CONTINUATION_WIDTH
Continuation-line budget for RAN_COMMAND_FIRST_WIDTH headers.
RAN_COMMAND_FIRST_WIDTH
Shared • Ran header wrap widths so every tool-call command surface stays in sync: 62 chars for the first line (• Ran prefix), 58 for continuations ( │ prefix). All surfaces wrap the full command with wrap_shell_command_with_continuations (explicit \, no …); TUI reflow owns any residual viewport overflow.

Functions§

clean_reasoning_text
Clean reasoning text by trimming trailing whitespace on each line and removing blank lines.
collapse_whitespace
Collapse consecutive whitespace into single spaces, trimming leading/trailing.
compact_reasoning_text
Compact reasoning text for on-screen display.
contains_ignore_ascii_case
Case-insensitive ASCII substring search that does not allocate a lowercased copy of either input.
format_float_display
Format an f64 float for display, collapsing decimal artifacts.
format_size
Format file size in human-readable form (KB, MB, GB, etc.)
head_tail_truncate
Truncate value to max_chars chars by keeping a head and a tail joined by marker, preserving context from both ends of the text.
humanize_duration_compact
Format a duration in seconds as a compact human-readable unit.
indent_block
Indent a block of text with the given prefix
is_markdown_fence_delimiter
Whether line opens or closes a fenced markdown code block.
lowercase_leading_word
Lowercase a leading capitalized plain word so text reads as a clause continuing a sentence (for example after a colon). Acronyms and identifiers (a second uppercase letter, a digit, or punctuation after the first letter) and the pronoun “I” keep their case.
strip_optional_word_prefix
Strip an optional leading word (case-insensitive) that is separated from the rest by whitespace, returning the trimmed remainder, or input unchanged when the prefix is absent or not word-boundary separated.
trim_wrapping_quotes_and_punctuation
Trim surrounding whitespace, matched wrapping quotes ("/'), and trailing sentence punctuation (. , ; ! ?), repeating until the value is stable.
truncate_byte_budget
Truncate a string so that the retained prefix is at most max_bytes bytes, rounded down to the nearest UTF-8 char boundary. Returns the truncated prefix with suffix appended, or the original string when it already fits.
truncate_middle
Truncate text to at most max_len chars, keeping a head and a tail joined by a single … so context from both ends is preserved.
truncate_path_middle
Truncate a file path in the middle, preferring to break at path separators.
truncate_text
Truncate text to a maximum length (in chars) with an optional ellipsis.
truncate_utf8_prefix
Borrow the longest prefix of text that is at most max_bytes bytes, rounded down to the nearest UTF-8 char boundary.
truncate_within
Truncate text to max_len chars, reserving room for ellipsis so the returned string never exceeds max_len chars.
wrap_shell_command
Word-wrap a shell command into lines, allowing first_width chars on the first line and continuation_width chars on subsequent lines.
wrap_shell_command_lines
Operator-aware word-wrap of a shell command without continuation markers.
wrap_shell_command_with_continuations
Word-wrap a shell command into display lines with explicit \ continuations, so multi-line tool-call headers read as valid shell.
wrap_text_words
Word-wrap text into lines, allowing first_width chars on the first line and continuation_width chars on subsequent lines. Wrapping prefers whitespace boundaries and is UTF-8 safe (widths count chars, not bytes).