MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / main

Function main

scripts/fetch-recent-chat-completion-traces.ts:342–378  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

340}
341
342async function main() {
343 const args = parseArgs()
344 const rows = await fetchRows(args)
345 const sessions = reconstructTraceSessions(rows)
346 const outDir = resolve(args.outDir)
347 const indexEntries = sessions.map(buildIndexEntry)
348
349 await mkdir(outDir, { recursive: true })
350 await Promise.all(
351 sessions.map((session, index) =>
352 writeFile(
353 join(outDir, indexEntries[index]!.file),
354 JSON.stringify(buildTraceFile(session), null, 2),
355 ),
356 ),
357 )
358 await writeFile(
359 join(outDir, 'index.json'),
360 JSON.stringify(
361 {
362 generated_at: new Date().toISOString(),
363 dataset: args.dataset,
364 lookback_hours: args.lookbackHours,
365 trace_session_id: args.traceSessionId,
366 sessions: indexEntries,
367 },
368 null,
369 2,
370 ),
371 )
372
373 printSummary(args, sessions)
374 console.log('')
375 console.log(
376 `Wrote ${sessions.length} trace file(s) and index.json to ${outDir}`,
377 )
378}
379
380main().catch((error) => {
381 console.error(error)

Calls 6

fetchRowsFunction · 0.85
reconstructTraceSessionsFunction · 0.85
buildTraceFileFunction · 0.85
printSummaryFunction · 0.85
parseArgsFunction · 0.70
resolveFunction · 0.50

Tested by

no test coverage detected