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

Function joinTextAtSeam

src/utils/messages.ts:2505–2515  ·  view source on GitHub ↗

* Concatenate two content block arrays, appending `\n` to a's last text block * when the seam is text-text. The API concatenates adjacent text blocks in a * user message without a separator, so two queued prompts `"2 + 2"` + * `"3 + 3"` would otherwise reach the model as `"2 + 23 + 3"`. * * Blo

(
  a: ContentBlockParam[],
  b: ContentBlockParam[],
)

Source from the content-addressed store, hash-verified

2503 * when b is an SR-wrapped attachment.
2504 */
2505function joinTextAtSeam(
2506 a: ContentBlockParam[],
2507 b: ContentBlockParam[],
2508): ContentBlockParam[] {
2509 const lastA = a.at(-1)
2510 const firstB = b[0]
2511 if (lastA?.type === 'text' && firstB?.type === 'text') {
2512 return [...a.slice(0, -1), { ...lastA, text: lastA.text + '\n' }, ...b]
2513 }
2514 return [...a, ...b]
2515}
2516
2517type ToolResultContentItem = Extract<
2518 ToolResultBlockParam['content'],

Callers 1

mergeUserMessagesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected