MCPcopy Index your code
hub / github.com/MiniCodeMonkey/chief / processOutput

Method processOutput

internal/loop/loop.go:454–482  ·  view source on GitHub ↗

processOutput reads stdout line by line, logs it, and parses events.

(r io.Reader)

Source from the content-addressed store, hash-verified

452
453// processOutput reads stdout line by line, logs it, and parses events.
454func (l *Loop) processOutput(r io.Reader) {
455 scanner := bufio.NewScanner(r)
456 // Increase buffer size for long lines (Claude can output large JSON)
457 buf := make([]byte, 0, 64*1024)
458 scanner.Buffer(buf, 1024*1024)
459
460 for scanner.Scan() {
461 line := scanner.Text()
462
463 // Update last output time for watchdog
464 l.mu.Lock()
465 l.lastOutputTime = time.Now()
466 l.mu.Unlock()
467
468 // Log raw output
469 l.logLine(line)
470
471 // Parse the line and emit event if valid
472 if event := l.provider.ParseLine(line); event != nil {
473 l.mu.Lock()
474 event.Iteration = l.iteration
475 if event.Type == EventStoryDone {
476 l.sawStoryDone = true
477 }
478 l.mu.Unlock()
479 l.events <- *event
480 }
481 }
482}
483
484// logStream logs a stream with a prefix.
485func (l *Loop) logStream(r io.Reader, prefix string) {

Calls 2

logLineMethod · 0.95
ParseLineMethod · 0.65