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