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

Function ClampToAbsoluteMax

tools/budget.go:52–72  ·  view source on GitHub ↗
(content string, absoluteMax int)

Source from the content-addressed store, hash-verified

50 return fmt.Sprintf(
51 "<persisted-output>\nOutput too large (%s). Full output saved to: %s\n\nPreview (first %d characters):\n%s\n</persisted-output>",
52 sizeLabel,
53 filePath,
54 previewCount,
55 preview,
56 ), nil
57}
58
59func ClampToAbsoluteMax(content string, absoluteMax int) string {
60 if charLen(content) <= absoluteMax {
61 return content
62 }
63
64 half := absoluteMax / 2
65 head := firstChars(content, half)
66 tail := lastChars(content, half)
67 if absoluteMax == 0 {
68 tail = content
69 }
70 removed := charLen(content) - absoluteMax
71 return fmt.Sprintf(
72 "%s\n\n[OUTPUT TRUNCATED: %s, %d characters removed — exceeds absolute limit of %s]\n\n%s",
73 head,
74 formatSize(len([]byte(content))),
75 removed,

Callers 1

FormatLargeResultMethod · 0.85

Calls 4

charLenFunction · 0.85
firstCharsFunction · 0.85
lastCharsFunction · 0.85
formatSizeFunction · 0.85

Tested by

no test coverage detected