MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / formatTranscriptForFacets

Function formatTranscriptForFacets

source code/commands/insights.ts:833–870  ·  view source on GitHub ↗
(log: LogOption)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 1

logToSessionMetaFunction · 0.85

Tested by

no test coverage detected