( toolName: string, toolInput: unknown, tools: Tools, )
| 161 | * Returns detailed information about whether it's a search or read operation. |
| 162 | */ |
| 163 | export 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) ?? |
no test coverage detected