Skip to main content

Module text

Module text 

Source
Expand description

Small text utilities shared by the TypeScript and Rust scanners.

Both scanners read source as plain text โ€” the drift check must work when ag-ui does not compile and when no TypeScript toolchain is present. Everything here is therefore delimiter counting with string-literal awareness, nothing more.

Functionsยง

apply_rename_all
Applies a serde rename_all rule to an already-snake_case name.
blank_lifetimes
Replaces the apostrophe that opens a Rust lifetime with a space.
closing ๐Ÿ”’
The closing delimiter for an opening one.
find_top_level
Byte index of the first needle in s that sits outside every delimiter pair and string literal.
match_delim
Byte index of the delimiter matching the one at open, or None when the source is unbalanced.
pascal_to_screaming_snake
TextMessageStart -> TEXT_MESSAGE_START.
push_trimmed ๐Ÿ”’
read_ident
Reads the identifier starting at byte index at, or an empty string.
screaming_snake_to_pascal
TEXT_MESSAGE_START -> TextMessageStart.
skip_string ๐Ÿ”’
Consumes an iterator up to and including the closing quote.
snake_to_camel
message_id -> messageId.
snake_to_pascal
message_id -> MessageId.
split_top_level
Splits s on sep occurrences that sit outside every delimiter pair and string literal. Empty (whitespace-only) pieces are dropped, so a trailing comma costs nothing.
strip_comments
Replaces // and /* */ comments with spaces, keeping every newline so byte offsets stay usable for line numbers.