MCPcopy Index your code
hub / github.com/codeaashu/claude-code / extractConversationText

Function extractConversationText

src/utils/sessionTitle.ts:33–54  ·  view source on GitHub ↗
(messages: Message[])

Source from the content-addressed store, hash-verified

31 * recent context wins when the conversation is long.
32 */
33export function extractConversationText(messages: Message[]): string {
34 const parts: string[] = []
35 for (const msg of messages) {
36 if (msg.type !== 'user' && msg.type !== 'assistant') continue
37 if ('isMeta' in msg && msg.isMeta) continue
38 if ('origin' in msg && msg.origin && msg.origin.kind !== 'human') continue
39 const content = msg.message.content
40 if (typeof content === 'string') {
41 parts.push(content)
42 } else if (Array.isArray(content)) {
43 for (const block of content) {
44 if ('type' in block && block.type === 'text' && 'text' in block) {
45 parts.push(block.text as string)
46 }
47 }
48 }
49 }
50 const text = parts.join('\n')
51 return text.length > MAX_CONVERSATION_TEXT
52 ? text.slice(-MAX_CONVERSATION_TEXT)
53 : text
54}
55
56const SESSION_TITLE_PROMPT = `Generate a concise, sentence-case title (3-7 words) that captures the main topic or goal of this coding session. The title should be clear enough that the user recognizes the session in a list. Use sentence case: capitalize only the first word and proper nouns.
57

Callers 2

onUserMessageFunction · 0.85
generateSessionNameFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected