( log: LogOption, )
| 904 | } |
| 905 | |
| 906 | async function formatTranscriptWithSummarization( |
| 907 | log: LogOption, |
| 908 | ): Promise<string> { |
| 909 | const fullTranscript = formatTranscriptForFacets(log) |
| 910 | |
| 911 | // If under 30k chars, use as-is |
| 912 | if (fullTranscript.length <= 30000) { |
| 913 | return fullTranscript |
| 914 | } |
| 915 | |
| 916 | // For long transcripts, split into chunks and summarize in parallel |
| 917 | const CHUNK_SIZE = 25000 |
| 918 | const chunks: string[] = [] |
| 919 | |
| 920 | for (let i = 0; i < fullTranscript.length; i += CHUNK_SIZE) { |
| 921 | chunks.push(fullTranscript.slice(i, i + CHUNK_SIZE)) |
| 922 | } |
| 923 | |
| 924 | // Summarize all chunks in parallel |
| 925 | const summaries = await Promise.all(chunks.map(summarizeTranscriptChunk)) |
| 926 | |
| 927 | // Combine summaries with session header |
| 928 | const meta = logToSessionMeta(log) |
| 929 | const header = [ |
| 930 | `Session: ${meta.session_id.slice(0, 8)}`, |
| 931 | `Date: ${meta.start_time}`, |
| 932 | `Project: ${meta.project_path}`, |
| 933 | `Duration: ${meta.duration_minutes} min`, |
| 934 | `[Long session - ${chunks.length} parts summarized]`, |
| 935 | '', |
| 936 | ].join('\n') |
| 937 | |
| 938 | return header + summaries.join('\n\n---\n\n') |
| 939 | } |
| 940 | |
| 941 | async function loadCachedFacets( |
| 942 | sessionId: string, |
no test coverage detected