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

Function extractFirstMessageText

src/utils/fingerprint.ts:16–38  ·  view source on GitHub ↗
(
  messages: (UserMessage | AssistantMessage)[],
)

Source from the content-addressed store, hash-verified

14 * @returns First text content, or empty string if not found
15 */
16export function extractFirstMessageText(
17 messages: (UserMessage | AssistantMessage)[],
18): string {
19 const firstUserMessage = messages.find(msg => msg.type === 'user')
20 if (!firstUserMessage) {
21 return ''
22 }
23
24 const content = firstUserMessage.message.content
25
26 if (typeof content === 'string') {
27 return content
28 }
29
30 if (Array.isArray(content)) {
31 const textBlock = content.find(block => block.type === 'text')
32 if (textBlock && textBlock.type === 'text') {
33 return textBlock.text
34 }
35 }
36
37 return ''
38}
39
40/**
41 * Computes 3-character fingerprint for Claude Code attribution.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected