MCPcopy Create free account
hub / github.com/microsoft/Webwright / detectFormat

Function detectFormat

assets/compare_trajectory/app.js:919–948  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

917}
918
919function detectFormat(text) {
920 const source = String(text || '').trim();
921 if (!source) {
922 return null;
923 }
924 if (/^#\s+🤖\s+Copilot CLI Session/m.test(source) || /^###\s+💬\s+Copilot/m.test(source)) {
925 return 'copilot_session_md';
926 }
927 if (source[0] === '{' || source[0] === '[') {
928 const parsed = safeJsonParse(source);
929 if (parsed && typeof parsed === 'object' && Array.isArray(parsed.messages) && parsed.info) {
930 return 'trajectory_json';
931 }
932 }
933 const lines = source.split(/\r?\n/).filter(Boolean);
934 if (!lines.length) {
935 return null;
936 }
937 const first = safeJsonParse(lines[0]);
938 if (!first || typeof first !== 'object') {
939 return null;
940 }
941 if (first.timestamp && first.type) {
942 return 'codex_jsonl';
943 }
944 if (first.event === 'raw_text' && typeof first.raw_text === 'string') {
945 return 'raw_response_jsonl';
946 }
947 return null;
948}
949
950function finalizeTrace(base) {
951 const commandFamilies = toBarRows(countBy(base.commandRuns, (run) => run.primaryCommand));

Callers 1

normalizeTraceFunction · 0.85

Calls 1

safeJsonParseFunction · 0.85

Tested by

no test coverage detected