* Check if a search tool use targets memory files by examining its path, pattern, and glob.
(toolInput: unknown)
| 79 | * Check if a search tool use targets memory files by examining its path, pattern, and glob. |
| 80 | */ |
| 81 | function isMemorySearch(toolInput: unknown): boolean { |
| 82 | const input = toolInput as |
| 83 | | { path?: string; pattern?: string; glob?: string; command?: string } |
| 84 | | undefined |
| 85 | if (!input) { |
| 86 | return false |
| 87 | } |
| 88 | // Check if the search path targets a memory file or directory (Grep/Glob tools) |
| 89 | if (input.path) { |
| 90 | if (isAutoManagedMemoryFile(input.path) || isMemoryDirectory(input.path)) { |
| 91 | return true |
| 92 | } |
| 93 | } |
| 94 | // Check glob patterns that indicate memory file access |
| 95 | if (input.glob && isAutoManagedMemoryPattern(input.glob)) { |
| 96 | return true |
| 97 | } |
| 98 | // For shell commands (bash grep/rg, PowerShell Select-String, etc.), |
| 99 | // check if the command targets memory paths |
| 100 | if (input.command && isShellCommandTargetingMemory(input.command)) { |
| 101 | return true |
| 102 | } |
| 103 | return false |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Check if a Write or Edit tool use targets a memory file and should be collapsed. |
no test coverage detected