MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getToolSearchOrReadInfo

Function getToolSearchOrReadInfo

src/utils/collapseReadSearch.ts:143–238  ·  view source on GitHub ↗
(
  toolName: string,
  toolInput: unknown,
  tools: Tools,
)

Source from the content-addressed store, hash-verified

141 * Returns detailed information about whether it's a search or read operation.
142 */
143export function getToolSearchOrReadInfo(
144 toolName: string,
145 toolInput: unknown,
146 tools: Tools,
147): SearchOrReadResult {
148 // REPL is absorbed silently — its inner tool calls are emitted as virtual
149 // messages (isVirtual: true) via newMessages and flow through this function
150 // as regular Read/Grep/Bash messages. The REPL wrapper itself contributes
151 // no counts and doesn't break the group, so consecutive REPL calls merge.
152 if (toolName === REPL_TOOL_NAME) {
153 return {
154 isCollapsible: true,
155 isSearch: false,
156 isRead: false,
157 isList: false,
158 isREPL: true,
159 isMemoryWrite: false,
160 isAbsorbedSilently: true,
161 }
162 }
163
164 // Memory file writes/edits are collapsible
165 if (isMemoryWriteOrEdit(toolName, toolInput)) {
166 return {
167 isCollapsible: true,
168 isSearch: false,
169 isRead: false,
170 isList: false,
171 isREPL: false,
172 isMemoryWrite: true,
173 isAbsorbedSilently: false,
174 }
175 }
176
177 // Meta-operations absorbed silently: Snip (context cleanup) and ToolSearch
178 // (lazy tool schema loading). Neither should break a collapse group or
179 // contribute to its count, but both stay visible in verbose mode.
180 if (
181 (feature('HISTORY_SNIP') && toolName === SNIP_TOOL_NAME) ||
182 (isFullscreenEnvEnabled() && toolName === TOOL_SEARCH_TOOL_NAME)
183 ) {
184 return {
185 isCollapsible: true,
186 isSearch: false,
187 isRead: false,
188 isList: false,
189 isREPL: false,
190 isMemoryWrite: false,
191 isAbsorbedSilently: true,
192 }
193 }
194
195 // Fallback to REPL primitives: in REPL mode, Bash/Read/Grep/etc. are
196 // stripped from the execution tools list, but REPL emits them as virtual
197 // messages. Without the fallback they'd return isCollapsible: false and
198 // vanish from the summary line.
199 const tool =
200 findToolByName(tools, toolName) ??

Callers 4

hasContentAfterIndexFunction · 0.85
isToolSearchOrReadFunction · 0.85

Calls 5

isMemoryWriteOrEditFunction · 0.85
featureFunction · 0.85
isFullscreenEnvEnabledFunction · 0.85
findToolByNameFunction · 0.85
getReplPrimitiveToolsFunction · 0.85

Tested by

no test coverage detected