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