MCPcopy Create free account
hub / github.com/codeaashu/claude-code / deriveFirstPrompt

Function deriveFirstPrompt

src/commands/branch/branch.ts:38–54  ·  view source on GitHub ↗
(
  firstUserMessage: Extract<SerializedMessage, { type: 'user' }> | undefined,
)

Source from the content-addressed store, hash-verified

36 * otherwise flow into the saved title and break the resume hint.
37 */
38export function deriveFirstPrompt(
39 firstUserMessage: Extract<SerializedMessage, { type: 'user' }> | undefined,
40): string {
41 const content = firstUserMessage?.message?.content
42 if (!content) return 'Branched conversation'
43 const raw =
44 typeof content === 'string'
45 ? content
46 : content.find(
47 (block): block is { type: 'text'; text: string } =>
48 block.type === 'text',
49 )?.text
50 if (!raw) return 'Branched conversation'
51 return (
52 raw.replace(/\s+/g, ' ').trim().slice(0, 100) || 'Branched conversation'
53 )
54}
55
56/**
57 * Creates a fork of the current conversation by copying from the transcript file.

Callers 1

callFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected