MCPcopy
hub / github.com/claude-code-best/claude-code / #writeBuffered

Method #writeBuffered

src/utils/task/TaskOutput.ts:176–200  ·  view source on GitHub ↗
(data: string, isStderr: boolean)

Source from the content-addressed store, hash-verified

174 }
175
176 #writeBuffered(data: string, isStderr: boolean): void {
177 this.#totalBytes += data.length
178
179 this.#updateProgress(data)
180
181 // Write to disk if already overflowed
182 if (this.#disk) {
183 this.#disk.append(isStderr ? `[stderr] ${data}` : data)
184 return
185 }
186
187 // Check if this chunk would exceed the in-memory limit
188 const totalMem =
189 this.#stdoutBuffer.length + this.#stderrBuffer.length + data.length
190 if (totalMem > this.#maxMemory) {
191 this.#spillToDisk(isStderr ? data : null, isStderr ? null : data)
192 return
193 }
194
195 if (isStderr) {
196 this.#stderrBuffer += data
197 } else {
198 this.#stdoutBuffer += data
199 }
200 }
201
202 /**
203 * Single backward pass: count all newlines (for totalLines) and extract

Callers 2

writeStdoutMethod · 0.95
writeStderrMethod · 0.95

Calls 3

#updateProgressMethod · 0.95
#spillToDiskMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected