@@ -12,54 +12,61 @@ import type { ToolRenderConfig } from './types'
1212 */
1313export const CodeSearchComponent = defineToolComponent ( {
1414 toolName : 'code_search' ,
15-
15+
1616 render ( toolBlock , theme , options ) : ToolRenderConfig | null {
1717 const input = toolBlock . input as any
1818 const pattern = input ?. pattern ?? ''
1919 const flags = input ?. flags ?? ''
20-
20+ const cwd = input ?. cwd ?? ''
21+
2122 // Count results from output
2223 let totalResults = 0
2324 let fileCount = 0
24-
25+
2526 if ( toolBlock . output && typeof toolBlock . output === 'string' ) {
2627 const lines = toolBlock . output . split ( '\n' )
2728 const files = new Set < string > ( )
28-
29+
2930 for ( const line of lines ) {
3031 const trimmed = line . trim ( )
31-
32+
3233 // File paths end with a colon and typically start with ./ or /
33- if ( trimmed . endsWith ( ':' ) && ( trimmed . startsWith ( './' ) || trimmed . startsWith ( '/' ) ) ) {
34+ if (
35+ trimmed . endsWith ( ':' ) &&
36+ ( trimmed . startsWith ( './' ) || trimmed . startsWith ( '/' ) )
37+ ) {
3438 files . add ( trimmed . slice ( 0 , - 1 ) ) // Remove trailing colon
3539 }
3640 // Result lines start with a number followed by a colon
3741 else if ( / ^ \d + : / . test ( trimmed ) ) {
3842 totalResults ++
3943 }
4044 }
41-
45+
4246 fileCount = files . size
4347 }
44-
48+
4549 // Build single-line summary
46- let summary = `"${ pattern } "`
47-
48- if ( flags ) {
49- summary += ` ${ flags } `
50- }
51-
52- summary += ` → ${ totalResults } result${ totalResults === 1 ? '' : 's' } `
53-
54- if ( fileCount > 0 ) {
55- summary += ` across ${ fileCount } file${ fileCount === 1 ? '' : 's' } `
50+ let summary = ''
51+
52+ summary += `${ pattern } `
53+
54+ if ( cwd ) {
55+ summary += ` in ${ cwd } `
5656 }
57-
57+
58+ // Disable showing flags since they are noisy.
59+ // if (flags) {
60+ // summary += ` ${flags}`
61+ // }
62+
63+ summary += ` (${ totalResults } result${ totalResults === 1 ? '' : 's' } )`
64+
5865 // Return as content using SimpleToolCallItem
5966 return {
6067 content : (
6168 < SimpleToolCallItem
62- name = "Code Search"
69+ name = "Search"
6370 description = { summary }
6471 branchChar = { options . branchChar }
6572 />
0 commit comments