MCPcopy Index your code
hub / github.com/github/copilot-sdk / writeCapturesToDisk

Function writeCapturesToDisk

test/harness/replayingCapiProxy.ts:486–520  ·  view source on GitHub ↗
(
  exchanges: readonly CapturedExchange[],
  state: ReplayingCapiProxyState,
)

Source from the content-addressed store, hash-verified

484}
485
486async function writeCapturesToDisk(
487 exchanges: readonly CapturedExchange[],
488 state: ReplayingCapiProxyState,
489) {
490 const data = await transformHttpExchanges(
491 exchanges,
492 state.workDir,
493 state.toolResultNormalizers,
494 );
495 const preservedErrors = state.storedData?.errors;
496 if (preservedErrors && preservedErrors.length > 0) {
497 data.errors = preservedErrors;
498 data.models = [
499 ...new Set([
500 ...(state.storedData?.models ?? []),
501 ...data.models,
502 ...preservedErrors
503 .map((error) => error.model)
504 .filter((model): model is string => model !== undefined),
505 ]),
506 ];
507 }
508 if (data.conversations.length > 0) {
509 let yamlText = yaml.stringify(data, { lineWidth: 120 });
510
511 // We have to normalize line endings explicitly, because yaml.stringify uses Unix-style even on Windows,
512 // and Git will restore the files with CRLF on Windows so they will appear to be changed
513 if (process.platform === "win32") {
514 yamlText = yamlText.replace(/\r?\n/g, "\r\n");
515 }
516
517 await mkdir(path.dirname(state.filePath), { recursive: true });
518 await writeFileIfDifferent(state.filePath, yamlText);
519 }
520}
521
522/**
523 * Produces a human-readable explanation of why no stored conversation matched

Callers 2

updateConfigMethod · 0.85
stopMethod · 0.85

Calls 3

transformHttpExchangesFunction · 0.85
writeFileIfDifferentFunction · 0.85
mkdirFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…