(log: LogOption)
| 835 | } |
| 836 | |
| 837 | function formatTranscriptForFacets(log: LogOption): string { |
| 838 | const lines: string[] = [] |
| 839 | const meta = logToSessionMeta(log) |
| 840 | |
| 841 | lines.push(`Session: ${meta.session_id.slice(0, 8)}`) |
| 842 | lines.push(`Date: ${meta.start_time}`) |
| 843 | lines.push(`Project: ${meta.project_path}`) |
| 844 | lines.push(`Duration: ${meta.duration_minutes} min`) |
| 845 | lines.push('') |
| 846 | |
| 847 | for (const msg of log.messages) { |
| 848 | if (msg.type === 'user' && msg.message) { |
| 849 | const content = msg.message.content |
| 850 | if (typeof content === 'string') { |
| 851 | lines.push(`[User]: ${content.slice(0, 500)}`) |
| 852 | } else if (Array.isArray(content)) { |
| 853 | for (const block of content) { |
| 854 | if (block.type === 'text' && 'text' in block) { |
| 855 | lines.push(`[User]: ${(block.text as string).slice(0, 500)}`) |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | } else if (msg.type === 'assistant' && msg.message) { |
| 860 | const content = msg.message.content |
| 861 | if (Array.isArray(content)) { |
| 862 | for (const block of content) { |
| 863 | if (block.type === 'text' && 'text' in block) { |
| 864 | lines.push(`[Assistant]: ${(block.text as string).slice(0, 300)}`) |
| 865 | } else if (block.type === 'tool_use' && 'name' in block) { |
| 866 | lines.push(`[Tool: ${block.name}]`) |
| 867 | } |
| 868 | } |
| 869 | } |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | return lines.join('\n') |
| 874 | } |
| 875 | |
| 876 | const SUMMARIZE_CHUNK_PROMPT = `Summarize this portion of a Code session transcript. Focus on: |
| 877 | 1. What the user asked for |
no test coverage detected