(text)
| 917 | } |
| 918 | |
| 919 | function 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 | |
| 950 | function finalizeTrace(base) { |
| 951 | const commandFamilies = toBarRows(countBy(base.commandRuns, (run) => run.primaryCommand)); |
no test coverage detected