MCPcopy Create free account
hub / github.com/Noumena-Network/code / isMemorySearch

Function isMemorySearch

src/utils/collapseReadSearch.ts:92–117  ·  view source on GitHub ↗

* Check if a search tool use targets memory files by examining its path, pattern, and glob.

(toolInput: unknown)

Source from the content-addressed store, hash-verified

90 * Check if a search tool use targets memory files by examining its path, pattern, and glob.
91 */
92function isMemorySearch(toolInput: unknown): boolean {
93 const input = toolInput as
94 | { path?: string | string[]; pattern?: string; glob?: string; command?: string }
95 | undefined
96 if (!input) {
97 return false
98 }
99 // Check if the search path targets a memory file or directory (Grep/Glob tools).
100 // `path` may be an array for multi-directory searches — check every entry.
101 if (input.path) {
102 const paths = Array.isArray(input.path) ? input.path : [input.path]
103 if (paths.some(p => isAutoManagedMemoryFile(p) || isMemoryDirectory(p))) {
104 return true
105 }
106 }
107 // Check glob patterns that indicate memory file access
108 if (input.glob && isAutoManagedMemoryPattern(input.glob)) {
109 return true
110 }
111 // For shell commands (bash grep/rg, PowerShell Select-String, etc.),
112 // check if the command targets memory paths
113 if (input.command && isShellCommandTargetingMemory(input.command)) {
114 return true
115 }
116 return false
117}
118
119/**
120 * Check if a Write or Edit tool use targets a memory file and should be collapsed.

Callers 1

collapseReadSearchGroupsFunction · 0.85

Calls 4

isAutoManagedMemoryFileFunction · 0.85
isMemoryDirectoryFunction · 0.85

Tested by

no test coverage detected