MCPcopy Create free account
hub / github.com/WJX20/claude-code / getToolSearchOrReadInfo

Function getToolSearchOrReadInfo

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

Source from the content-addressed store, hash-verified

161 * Returns detailed information about whether it's a search or read operation.
162 */
163export function getToolSearchOrReadInfo(
164 toolName: string,
165 toolInput: unknown,
166 tools: Tools,
167): SearchOrReadResult {
168 // REPL is absorbed silently — its inner tool calls are emitted as virtual
169 // messages (isVirtual: true) via newMessages and flow through this function
170 // as regular Read/Grep/Bash messages. The REPL wrapper itself contributes
171 // no counts and doesn't break the group, so consecutive REPL calls merge.
172 if (toolName === REPL_TOOL_NAME) {
173 return {
174 isCollapsible: true,
175 isSearch: false,
176 isRead: false,
177 isList: false,
178 isREPL: true,
179 isMemoryWrite: false,
180 isAbsorbedSilently: true,
181 }
182 }
183
184 // Memory file writes/edits are collapsible
185 if (isMemoryWriteOrEdit(toolName, toolInput)) {
186 return {
187 isCollapsible: true,
188 isSearch: false,
189 isRead: false,
190 isList: false,
191 isREPL: false,
192 isMemoryWrite: true,
193 isAbsorbedSilently: false,
194 }
195 }
196
197 // Meta-operations absorbed silently: Snip (context cleanup) and ToolSearch
198 // (lazy tool schema loading). Neither should break a collapse group or
199 // contribute to its count, but both stay visible in verbose mode.
200 if (
201 (feature('HISTORY_SNIP') && toolName === SNIP_TOOL_NAME) ||
202 (isFullscreenEnvEnabled() && toolName === TOOL_SEARCH_TOOL_NAME)
203 ) {
204 return {
205 isCollapsible: true,
206 isSearch: false,
207 isRead: false,
208 isList: false,
209 isREPL: false,
210 isMemoryWrite: false,
211 isAbsorbedSilently: true,
212 }
213 }
214
215 // Fallback to REPL primitives: in REPL mode, Bash/Read/Grep/etc. are
216 // stripped from the execution tools list, but REPL emits them as virtual
217 // messages. Without the fallback they'd return isCollapsible: false and
218 // vanish from the summary line.
219 const tool =
220 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