formatting

package
v0.210.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CapInstructions added in v0.207.0

func CapInstructions(content string, maxLines, maxChars int) (string, string)

CapInstructions bounds instruction-file content at maxLines lines, then at maxChars characters. Returns the capped content and a truncation marker ("" when nothing was cut).

func ExtractTextFromContent

func ExtractTextFromContent(content sdk.MessageContent, images []agentdomain.ImageAttachment) string

ExtractTextFromContent extracts text from potentially multimodal message content

func FormatBytes added in v0.204.0

func FormatBytes(size int64) string

FormatBytes formats a byte count the way `docker system prune` reports reclaimed space: decimal (not 1024-based) units and 4 significant digits, e.g. "0B", "4.096kB", "1.653GB".

func FormatCost

func FormatCost(cost float64) string

FormatCost formats cost with adaptive precision based on magnitude Returns "-" for zero cost, and uses 2-4 decimal places based on the amount

func FormatErrorCLI

func FormatErrorCLI(message string) string

FormatErrorCLI creates an error message with red color for CLI output

func FormatResponsiveMessage

func FormatResponsiveMessage(content string, width int) string

FormatResponsiveMessage formats a message with responsive text wrapping

func FormatSuccess

func FormatSuccess(message string) string

FormatSuccess creates a properly formatted success message

func FormatToolCall

func FormatToolCall(toolName string, args map[string]any) string

FormatToolCall formats a tool call for consistent display across the application

func FormatWarning

func FormatWarning(message string) string

FormatWarning creates a properly formatted warning message

func GetResponsiveWidth

func GetResponsiveWidth(terminalWidth int) int

GetResponsiveWidth returns the content width for a terminal: the full width minus a small right margin, floored at minWidth. No upper cap — content fills the screen at any terminal size.

func PadText added in v0.205.1

func PadText(text string, width int) string

PadText fits text to exactly width display columns: truncated when wider, space-padded when narrower. Byte length is not display width once multibyte runes or ANSI escapes are involved, so never pad a TruncateText result with len() - that is how a negative strings.Repeat count gets built.

func TruncateText

func TruncateText(text string, maxLength int) string

TruncateText truncates text to fit within maxLength display columns, adding "..." if needed. It is width-aware: multibyte and wide runes (emoji, CJK) and ANSI escapes are measured by rendered width and never split mid-grapheme.

func WrapText

func WrapText(text string, width int) string

WrapText wraps text to fit within the specified width using wordwrap

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL