utils

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger *slog.Logger

Logger is the global logger instance.

Functions

func Abs

func Abs(x int) int

Abs returns the absolute value of x.

func Clamp

func Clamp(x, min, max int) int

Clamp returns x constrained to the range [min, max].

func FormatBytes

func FormatBytes(bytes int64) string

FormatBytes converts a byte count to a human-readable string.

func FormatDuration

func FormatDuration(ms int64) string

FormatDuration converts milliseconds to a human-readable duration string.

func FormatTokens

func FormatTokens(n int) string

FormatTokens formats a token count with K/M/B suffixes.

func FormatTokens64

func FormatTokens64(n uint64) string

FormatTokens64 formats a uint64 token count with K/M/B suffixes.

func GetModelFamily

func GetModelFamily(modelName string) string

GetModelFamily extracts the model family from a model name. Returns the family identifier (e.g., "claude", "gpt", "gemini") or "other". Used by tracking and command execution for AI agent attribution.

func InitLogger

func InitLogger(logPath string, level LogLevel) error

InitLogger initializes the global logger.

func Max

func Max(a, b int) int

Max returns the larger of a and b.

func Min

func Min(a, b int) int

Min returns the smaller of a and b.

func ShortenPath

func ShortenPath(path string, maxLen int) string

ShortenPath truncates a path to fit within maxLen characters. It preserves the end of the path and adds "..." prefix if truncated.

func Warn

func Warn(msg string, args ...any)

Warn logs a warning message.

Types

type LogLevel

type LogLevel string

LogLevel represents logging severity.

const (
	LevelDebug LogLevel = "debug"
	LevelInfo  LogLevel = "info"
	LevelWarn  LogLevel = "warn"
	LevelError LogLevel = "error"
)

Jump to

Keyboard shortcuts

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