MCPcopy Create free account
hub / github.com/Quorinex/Kiro-Go / appendMessageCacheBlocks

Function appendMessageCacheBlocks

proxy/cache_tracker.go:319–355  ·  view source on GitHub ↗
(blocks *[]cacheablePromptBlock, messageIndex int, msg ClaudeMessage)

Source from the content-addressed store, hash-verified

317}
318
319func appendMessageCacheBlocks(blocks *[]cacheablePromptBlock, messageIndex int, msg ClaudeMessage) {
320 role := msg.Role
321 switch content := msg.Content.(type) {
322 case string:
323 appendPromptBlock(blocks, map[string]interface{}{
324 "kind": "message",
325 "message_index": messageIndex,
326 "role": role,
327 "block_index": 0,
328 "block": map[string]interface{}{
329 "type": "text",
330 "text": content,
331 },
332 }, true)
333 case []interface{}:
334 lastIdx := len(content) - 1
335 for blockIndex, block := range content {
336 appendPromptBlock(blocks, map[string]interface{}{
337 "kind": "message",
338 "message_index": messageIndex,
339 "role": role,
340 "block_index": blockIndex,
341 "block": block,
342 }, blockIndex == lastIdx)
343 }
344 default:
345 if content != nil {
346 appendPromptBlock(blocks, map[string]interface{}{
347 "kind": "message",
348 "message_index": messageIndex,
349 "role": role,
350 "block_index": 0,
351 "block": content,
352 }, true)
353 }
354 }
355}
356
357func appendPromptBlock(blocks *[]cacheablePromptBlock, wrapper map[string]interface{}, isMessageEnd bool) {
358 blockValue := wrapper["block"]

Callers 1

flattenClaudeCacheBlocksFunction · 0.85

Calls 1

appendPromptBlockFunction · 0.85

Tested by

no test coverage detected