MCPcopy Create free account
hub / github.com/codehamr/codehamr / runeBoundaryDown

Function runeBoundaryDown

internal/ctx/ctx.go:100–108  ·  view source on GitHub ↗

runeBoundaryDown walks i left to a rune start so out[:i] never ends mid-sequence. Safe for i == len(out).

(out string, i int)

Source from the content-addressed store, hash-verified

98// the model never reads "rerun the command" and "don't rerun it" in one
99// result; rerunning narrower is only the fallback when no spill happened.
100func Truncate(out string) string {
101 total := Tokens(out)
102 if total <= ToolOutputCap {
103 return out
104 }
105 head := runeBoundaryDown(out, ToolTruncHead*4)
106 tail := runeBoundaryUp(out, len(out)-ToolTruncTail*4)
107 marker := fmt.Sprintf("\n───── truncated: %d tokens total, first %d + last %d shown, the middle is OMITTED. This is a PARTIAL view; you can't review or conclude from what you can't see here. If a line below names a full output file, grep or read that file for the omitted span; otherwise rerun narrower (grep/sed/head/tail). ─────\n",
108 total, ToolTruncHead, ToolTruncTail)
109 return out[:head] + marker + out[tail:]
110}
111

Callers 1

TruncateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected