formatting

package
v0.181.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractTextFromContent

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

ExtractTextFromContent extracts text from potentially multimodal message content

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 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

type ConversationLineFormatter

type ConversationLineFormatter struct {
	// contains filtered or unexported fields
}

ConversationLineFormatter converts conversation entries to text lines

func NewConversationLineFormatter

func NewConversationLineFormatter(width int, toolFormatter agentdomain.ToolFormatter) *ConversationLineFormatter

NewConversationLineFormatter creates a new conversation line formatter

func (*ConversationLineFormatter) FormatConversationToLines

func (f *ConversationLineFormatter) FormatConversationToLines(conversation []convdomain.ConversationEntry) []string

FormatConversationToLines converts conversation entries to plain text lines

func (*ConversationLineFormatter) SetWidth

func (f *ConversationLineFormatter) SetWidth(width int)

SetWidth updates the formatter width

Jump to

Keyboard shortcuts

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