MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / tally

Function tally

scripts/agent-eval/parse-session.mjs:31–43  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

29const sessionId = sessions[0].f.replace('.jsonl', '');
30
31function tally(file) {
32 const counts = {};
33 for (const line of readFileSync(file, 'utf8').split('\n')) {
34 if (!line) continue;
35 let ev; try { ev = JSON.parse(line); } catch { continue; }
36 const content = ev.message?.content;
37 if (!Array.isArray(content)) continue;
38 for (const b of content) {
39 if (b.type === 'tool_use') counts[b.name] = (counts[b.name] || 0) + 1;
40 }
41 }
42 return counts;
43}
44
45// Sum token usage from a transcript. The TUI's "Done (…Xk tokens…)" line only
46// covers a subagent's throughput; this works for main-thread runs too and is

Callers 1

parse-session.mjsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected