MCPcopy Create free account
hub / github.com/anomalyco/opencode / append

Function append

packages/core/src/tool/read-filesystem.ts:242–261  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

240 let bytes = 0
241 let next: number | undefined
242 const append = (input: string) => {
243 if (line < offset) {
244 line++
245 return true
246 }
247 if (lines.length >= limit || bytes >= MAX_READ_BYTES) {
248 next = line
249 return false
250 }
251 const text = input.length > MAX_LINE_LENGTH ? input.slice(0, MAX_LINE_LENGTH) + MAX_LINE_SUFFIX : input
252 const size = Buffer.byteLength(text, "utf-8") + (lines.length > 0 ? 1 : 0)
253 if (bytes + size > MAX_READ_BYTES) {
254 next = line
255 return false
256 }
257 lines.push(text)
258 bytes += size
259 line++
260 return true
261 }
262 const consume = (input: string) => {
263 let text = input
264 while (true) {

Callers 2

consumeFunction · 0.70
read-filesystem.tsFile · 0.70

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected