MCPcopy Create free account
hub / github.com/alibaba/open-code-review / capFileReadLine

Function capFileReadLine

internal/tool/file_read.go:136–145  ·  view source on GitHub ↗

capFileReadLine caps one rendered line at fileReadMaxLineBytes. The cut backs off to a UTF-8 rune boundary so a multibyte character is never split mid-sequence, and the marker reports the omitted byte count so the model knows the line was not shown in full.

(s string)

Source from the content-addressed store, hash-verified

134// mid-sequence, and the marker reports the omitted byte count so the model
135// knows the line was not shown in full.
136func capFileReadLine(s string) (string, bool) {
137 if len(s) <= fileReadMaxLineBytes {
138 return s, false
139 }
140 cut := fileReadMaxLineBytes
141 for cut > 0 && !utf8.RuneStart(s[cut]) {
142 cut--
143 }
144 return fmt.Sprintf("%s …[line truncated, %d more bytes omitted]", s[:cut], len(s)-cut), true
145}

Callers 1

executeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected