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

Function writeTraceFiles

scripts/export-deepseek-session-traces.ts:443–480  ·  view source on GitHub ↗
(params: {
  outputPath: string
  traceDir: string | null
  dataset: string
  generatedAt: string
  traces: SessionTrace[]
})

Source from the content-addressed store, hash-verified

441type SessionTrace = ReturnType<typeof buildTrace>
442
443async function writeTraceFiles(params: {
444 outputPath: string
445 traceDir: string | null
446 dataset: string
447 generatedAt: string
448 traces: SessionTrace[]
449}) {
450 const { outputPath, dataset, generatedAt, traces } = params
451 const traceDir =
452 params.traceDir ?? join(dirname(outputPath), 'deepseek-session-traces')
453
454 await mkdir(traceDir, { recursive: true })
455
456 const files: string[] = []
457 for (const trace of traces) {
458 const fileName = [
459 safeFilePart(trace.model),
460 safeFilePart(trace.client_id),
461 ].join('__')
462 const filePath = join(traceDir, `${fileName}.json`)
463
464 await Bun.write(
465 filePath,
466 JSON.stringify(
467 {
468 generated_at: generatedAt,
469 dataset,
470 ...trace,
471 },
472 null,
473 2,
474 ),
475 )
476 files.push(filePath)
477 }
478
479 return files
480}
481
482async function main() {
483 const args = parseArgs()

Callers 1

mainFunction · 0.85

Calls 1

safeFilePartFunction · 0.70

Tested by

no test coverage detected