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

Function filterDuplicateMemoryAttachments

src/utils/attachments.ts:2520–2541  ·  view source on GitHub ↗
(
  attachments: Attachment[],
  readFileState: FileStateCache,
)

Source from the content-addressed store, hash-verified

2518 * from any iteration.
2519 */
2520export function filterDuplicateMemoryAttachments(
2521 attachments: Attachment[],
2522 readFileState: FileStateCache,
2523): Attachment[] {
2524 return attachments
2525 .map(attachment => {
2526 if (attachment.type !== 'relevant_memories') return attachment
2527 const filtered = attachment.memories.filter(
2528 m => !readFileState.has(m.path),
2529 )
2530 for (const m of filtered) {
2531 readFileState.set(m.path, {
2532 content: m.content,
2533 timestamp: m.mtimeMs,
2534 offset: undefined,
2535 limit: m.limit,
2536 })
2537 }
2538 return filtered.length > 0 ? { ...attachment, memories: filtered } : null
2539 })
2540 .filter((a): a is Attachment => a !== null)
2541}
2542
2543/**
2544 * Processes skill directories that were discovered during file operations.

Callers 1

queryLoopFunction · 0.85

Calls 2

hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected