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

Function main

scripts/export-deepseek-session-traces.ts:482–570  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

480}
481
482async function main() {
483 const args = parseArgs()
484 const outputPath = resolve(args.outPath)
485 const generatedAt = new Date().toISOString()
486
487 console.log(
488 [
489 `Querying ${args.dataset}.message`,
490 args.startDate || args.endDate
491 ? `window: ${args.startDate ?? '-infinity'} to ${args.endDate ?? 'now'}`
492 : `window: ${args.lookbackDays}d ending ${args.beforeDays}d ago`,
493 args.totalSessions
494 ? `total sessions: ${args.totalSessions} (${args.sampleMode})`
495 : `sessions per agent: ${args.sessionsPerAgent}`,
496 `min representative messages: ${args.minMessages}`,
497 args.clientId ? `client_id: ${args.clientId}` : undefined,
498 ]
499 .filter(Boolean)
500 .join('\n'),
501 )
502 console.log('')
503
504 const candidates = await fetchCandidateSessions(args)
505 const representativeRows = await fetchRepresentativeRows(
506 args,
507 candidates.map((candidate) => candidate.representative_message_id),
508 )
509 const traces = candidates.map((candidate) =>
510 buildTrace(candidate, representativeRows),
511 )
512
513 if (!args.skipAggregate) {
514 await mkdir(dirname(outputPath), { recursive: true })
515 await Bun.write(
516 outputPath,
517 JSON.stringify(
518 {
519 generated_at: generatedAt,
520 dataset: OUTPUT_DATASET_NAME,
521 lookback_days: args.lookbackDays,
522 before_days: args.beforeDays,
523 start_date: args.startDate,
524 end_date: args.endDate,
525 sample_mode: args.sampleMode,
526 trace_count: traces.length,
527 traces,
528 },
529 null,
530 2,
531 ),
532 )
533 }
534 const traceFiles = await writeTraceFiles({
535 outputPath,
536 traceDir: args.traceDir,
537 dataset: OUTPUT_DATASET_NAME,
538 generatedAt,
539 traces,

Calls 8

fetchCandidateSessionsFunction · 0.85
fetchRepresentativeRowsFunction · 0.85
buildTraceFunction · 0.85
writeTraceFilesFunction · 0.85
shortPreviewFunction · 0.85
atMethod · 0.80
parseArgsFunction · 0.70
resolveFunction · 0.50

Tested by

no test coverage detected