MCPcopy
hub / github.com/codeaashu/claude-code / formatTranscriptForFacets

Function formatTranscriptForFacets

src/commands/insights.ts:831–868  ·  view source on GitHub ↗
(log: LogOption)

Source from the content-addressed store, hash-verified

829}
830
831function 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
870const SUMMARIZE_CHUNK_PROMPT = `Summarize this portion of a Claude Code session transcript. Focus on:
8711. What the user asked for

Callers 1

Calls 2

logToSessionMetaFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected