MCPcopy Create free account
hub / github.com/diillson/chatcli / WriteJSONL

Function WriteJSONL

cli/agent/trajectory/trajectory.go:101–117  ·  view source on GitHub ↗

WriteJSONL writes one JSON object per line to w and returns the count.

(w io.Writer, msgs []models.Message)

Source from the content-addressed store, hash-verified

99
100// WriteJSONL writes one JSON object per line to w and returns the count.
101func WriteJSONL(w io.Writer, msgs []models.Message) (int, error) {
102 bw := bufio.NewWriter(w)
103 turns := ToTurns(msgs)
104 for _, t := range turns {
105 line, err := json.Marshal(t)
106 if err != nil {
107 return 0, err
108 }
109 if _, err := bw.Write(line); err != nil {
110 return 0, err
111 }
112 if err := bw.WriteByte('\n'); err != nil {
113 return 0, err
114 }
115 }
116 return len(turns), bw.Flush()
117}

Callers 2

handleExportCommandMethod · 0.92
TestWriteJSONLFunction · 0.85

Calls 3

ToTurnsFunction · 0.85
FlushMethod · 0.80
WriteMethod · 0.65

Tested by 1

TestWriteJSONLFunction · 0.68