MCPcopy
hub / github.com/claude-code-best/claude-code / extractTranscript

Function extractTranscript

src/utils/agenticSessionSearch.ts:86–108  ·  view source on GitHub ↗

* Extracts a truncated transcript from session messages.

(messages: SerializedMessage[])

Source from the content-addressed store, hash-verified

84 * Extracts a truncated transcript from session messages.
85 */
86function extractTranscript(messages: SerializedMessage[]): string {
87 if (messages.length === 0) return ''
88
89 // Take messages from start and end to get context
90 const messagesToScan =
91 messages.length <= MAX_MESSAGES_TO_SCAN
92 ? messages
93 : [
94 ...messages.slice(0, MAX_MESSAGES_TO_SCAN / 2),
95 ...messages.slice(-MAX_MESSAGES_TO_SCAN / 2),
96 ]
97
98 const text = messagesToScan
99 .map(extractMessageText)
100 .filter(Boolean)
101 .join(' ')
102 .replace(/\s+/g, ' ')
103 .trim()
104
105 return text.length > MAX_TRANSCRIPT_CHARS
106 ? text.slice(0, MAX_TRANSCRIPT_CHARS) + '…'
107 : text
108}
109
110/**
111 * Checks if a log contains the query term in any searchable field.

Callers 2

logContainsQueryFunction · 0.85
agenticSessionSearchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected