@@ -312,17 +312,23 @@ impl Repl {
312312 ) ;
313313 }
314314
315- println ! ( "{}" , output. dimmed( ) ) ;
316- println ! ( ) ;
315+ // Create display message based on tool type
316+ let display_output = self . create_tool_display_message ( tool_name, tool_input, & output) ;
317+
318+ // Only print if there's a display message
319+ if !display_output. is_empty ( ) {
320+ println ! ( "{}" , display_output. dimmed( ) ) ;
321+ println ! ( ) ;
322+ }
317323
318- // Track tool execution in display_messages
324+ // Track tool execution in display_messages with summary for quiet tools
319325 self . display_messages . push ( crate :: history:: DisplayMessage :: ToolExecution {
320326 tool_name : tool_name. clone ( ) ,
321327 tool_input : tool_input. clone ( ) ,
322- tool_output : output . clone ( ) ,
328+ tool_output : display_output . clone ( ) ,
323329 } ) ;
324330
325- // Collect tool result instead of adding immediately
331+ // Collect tool result (full output for Claude)
326332 tool_results. push ( crate :: api:: MessageContentBlock :: ToolResult {
327333 tool_use_id : tool_id. clone ( ) ,
328334 content : output. clone ( ) ,
@@ -685,4 +691,63 @@ impl Repl {
685691 println ! ( "{}" , "═" . repeat( 80 ) . bright_cyan( ) ) ;
686692 println ! ( ) ;
687693 }
694+
695+ fn create_tool_display_message (
696+ & self ,
697+ tool_name : & str ,
698+ tool_input : & serde_json:: Value ,
699+ output : & str ,
700+ ) -> String {
701+ match tool_name {
702+ "read_file" => {
703+ let file_path = tool_input. get ( "path" )
704+ . and_then ( |v| v. as_str ( ) )
705+ . unwrap_or ( "" ) ;
706+
707+ let offset = tool_input. get ( "offset" )
708+ . and_then ( |v| v. as_u64 ( ) )
709+ . unwrap_or ( 1 ) ;
710+
711+ // Count actual lines in output
712+ let line_count = output. lines ( ) . count ( ) as u64 ;
713+
714+ if line_count == 0 {
715+ if file_path. is_empty ( ) {
716+ format ! ( "Read file (empty or not found)" )
717+ } else {
718+ format ! ( "Read file from {} - empty or not found" , file_path. bright_cyan( ) )
719+ }
720+ } else {
721+ let end_line = offset + line_count - 1 ;
722+ if file_path. is_empty ( ) {
723+ format ! ( "Read lines {}-{}" , offset, end_line)
724+ } else {
725+ format ! ( "Read lines {}-{} from {}" , offset, end_line, file_path. bright_cyan( ) )
726+ }
727+ }
728+ }
729+ "list_directory" => {
730+ let path = tool_input. get ( "path" )
731+ . and_then ( |v| v. as_str ( ) )
732+ . unwrap_or ( "." ) ;
733+
734+ // Count number of items listed
735+ let item_count = output. lines ( )
736+ . filter ( |line| !line. trim ( ) . is_empty ( ) && !line. starts_with ( "Contents of" ) )
737+ . count ( ) ;
738+
739+ if item_count == 0 {
740+ format ! ( "Found 0 items in {}" , path. bright_cyan( ) )
741+ } else if item_count == 1 {
742+ format ! ( "Found 1 item in {}" , path. bright_cyan( ) )
743+ } else {
744+ format ! ( "Found {} items in {}" , item_count, path. bright_cyan( ) )
745+ }
746+ }
747+ _ => {
748+ // For all other tools, return the full output
749+ output. to_string ( )
750+ }
751+ }
752+ }
688753}
0 commit comments