MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / hardTruncate

Function hardTruncate

tools/budget.go:133–145  ·  view source on GitHub ↗
(content string, maxChars int)

Source from the content-addressed store, hash-verified

131 if sizeBytes < 1024*1024 {
132 return fmt.Sprintf("%.1f KB", float64(sizeBytes)/1024)
133 }
134 if sizeBytes < 1024*1024*1024 {
135 return fmt.Sprintf("%.1f MB", float64(sizeBytes)/(1024*1024))
136 }
137 return fmt.Sprintf("%.2f GB", float64(sizeBytes)/(1024*1024*1024))
138}
139
140func hardTruncate(content string, maxChars int) string {
141 if charLen(content) <= maxChars {
142 return content
143 }
144 half := maxChars / 2
145 head := firstChars(content, half)
146 tail := lastChars(content, half)
147 if maxChars == 0 {
148 tail = content

Callers 1

Calls 3

charLenFunction · 0.85
firstCharsFunction · 0.85
lastCharsFunction · 0.85

Tested by

no test coverage detected