* Count memory file accesses in transcript entries. * Uses the same detection conditions as the PostToolUse session file access hooks.
( entries: ReadonlyArray<Entry>, )
| 209 | * Uses the same detection conditions as the PostToolUse session file access hooks. |
| 210 | */ |
| 211 | function countMemoryFileAccessFromEntries( |
| 212 | entries: ReadonlyArray<Entry>, |
| 213 | ): number { |
| 214 | let count = 0 |
| 215 | for (const entry of entries) { |
| 216 | if (entry.type !== 'assistant') continue |
| 217 | const content = entry.message?.content |
| 218 | if (!Array.isArray(content)) continue |
| 219 | for (const block of content) { |
| 220 | if ( |
| 221 | block.type !== 'tool_use' || |
| 222 | !MEMORY_ACCESS_TOOL_NAMES.has(block.name) |
| 223 | ) |
| 224 | continue |
| 225 | if (isMemoryFileAccess(block.name, block.input)) count++ |
| 226 | } |
| 227 | } |
| 228 | return count |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * Read session transcript entries and compute prompt count and memory access |
no test coverage detected