* Count memory file accesses in transcript entries. * Uses the same detection conditions as the PostToolUse session file access hooks.
( entries: ReadonlyArray<Entry>, )
| 223 | * Uses the same detection conditions as the PostToolUse session file access hooks. |
| 224 | */ |
| 225 | function countMemoryFileAccessFromEntries( |
| 226 | entries: ReadonlyArray<Entry>, |
| 227 | ): number { |
| 228 | let count = 0 |
| 229 | for (const entry of entries) { |
| 230 | if (entry.type !== 'assistant') continue |
| 231 | const content = entry.message?.content |
| 232 | if (!Array.isArray(content)) continue |
| 233 | for (const block of content) { |
| 234 | if ( |
| 235 | block.type !== 'tool_use' || |
| 236 | !MEMORY_ACCESS_TOOL_NAMES.has(block.name) |
| 237 | ) |
| 238 | continue |
| 239 | if (isMemoryFileAccess(block.name, block.input)) count++ |
| 240 | } |
| 241 | } |
| 242 | return count |
| 243 | } |
| 244 | |
| 245 | /** |
| 246 | * Read session transcript entries and compute prompt count and memory access |
no test coverage detected