Help us shape the future of Go! Take the 2026 Go Developer Survey

renderfmt

package
v0.0.51 Latest Latest
Warning

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

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

Documentation

Overview

Package renderfmt provides stateless formatting shared by mecatui renderers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgumentOrder added in v0.0.47

func ArgumentOrder(name string) []string

ArgumentOrder returns a caller-owned ordered copy of the known argument names. Unknown tools have no preferred order.

func CacheHitRate

func CacheHitRate(u client.Usage) float64

CacheHitRate returns the cache-read fraction of input tokens.

func FormatDuration

func FormatDuration(ms int64) string

FormatDuration renders an elapsed millisecond count compactly.

func HumanizeBytes

func HumanizeBytes(n int64) string

HumanizeBytes renders a byte count compactly: bytes verbatim under 1 KB, then "N.N KB"/"N.N MB"/"N.N GB"/"N.N TB" with one decimal (trailing ".0" trimmed). The math is SI/decimal (1 KB = 1000 B, 1 MB = 1e6 B, …).

func HumanizeDuration

func HumanizeDuration(ms int64) string

HumanizeDuration renders a millisecond wall-clock duration compactly: sub-second as "Nms", under a minute as "N.Ns", else "Nm Ns". A non-positive duration (no clock) renders as "0ms".

func HumanizeTokens

func HumanizeTokens(n int64) string

HumanizeTokens renders a token count compactly.

func PctString

func PctString(frac float64) string

PctString formats a fraction as a clamped integer percentage.

func RenderContextMeter

func RenderContextMeter(th theme.Theme, used, window int64) string

RenderContextMeter formats context for a team roster subhead.

func RenderContextMeterPlain

func RenderContextMeterPlain(used, window int64) string

RenderContextMeterPlain is the ANSI-free representation required before generic roster wrapping; RenderContextMeter's styled bar must not be sanitized as raw text.

func StopReasonLabel

func StopReasonLabel(stop string) (text, slot string)

StopReasonLabel maps a terminal stop reason to status text and theme style slot.

func ToolIntent added in v0.0.47

func ToolIntent(name, arguments string) string

ToolIntent derives a terminal-safe single-line description from a tool call's JSON arguments. Malformed arguments fall back to the tool name.

func TrivialTurn

func TrivialTurn(msg client.TurnEndMsg) bool

TrivialTurn reports whether a turn's statistics are too negligible for scrollback.

func TurnStatLine

func TurnStatLine(msg client.TurnEndMsg) string

TurnStatLine formats the inline per-turn model-exchange statistics.

Types

type ToolLine added in v0.0.47

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

ToolLine is a terminal-safe single-line tool-call presentation.

func PresentToolLine added in v0.0.47

func PresentToolLine(displayName, intent string, state ToolState) ToolLine

PresentToolLine derives the complete single-line status vocabulary from the observed lifecycle state. Surface renderers own theme lookup and layout.

func (ToolLine) Content added in v0.0.47

func (line ToolLine) Content() string

Content returns the text after the optional glyph, for surfaces that style the glyph separately.

func (ToolLine) Glyph added in v0.0.47

func (line ToolLine) Glyph() string

Glyph returns the status symbol.

func (ToolLine) Intent added in v0.0.47

func (line ToolLine) Intent() string

Intent returns the bounded call-side intent.

func (ToolLine) Name added in v0.0.47

func (line ToolLine) Name() string

Name returns the bounded display name.

func (ToolLine) Status added in v0.0.47

func (line ToolLine) Status() string

Status returns a textual lifecycle cue, empty for a successful settled call.

func (ToolLine) StatusStyle added in v0.0.47

func (line ToolLine) StatusStyle() string

StatusStyle returns the semantic theme slot for the status glyph and label.

func (ToolLine) Text added in v0.0.47

func (line ToolLine) Text() string

Text returns the plain tool-call summary with its optional glyph.

type ToolState added in v0.0.47

type ToolState uint8

ToolState is the observed lifecycle phase of a tool call.

const (
	ToolRunning ToolState = iota
	ToolAwaitingResult
	ToolFinalizing
	ToolFinalizingFailed
	ToolDelegatedPending
	ToolSucceeded
	ToolFailed
)

ToolState values distinguish top-level lifecycle phases from a delegated call whose result has not yet been observed. Only an observed result is final.

Jump to

Keyboard shortcuts

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