@@ -18,6 +18,7 @@ import ora from 'ora';
1818import { getDefaultConfig , loadConfig } from '../utils/config.js' ;
1919import { formatBytes , getDirectorySize } from '../utils/file.js' ;
2020import { createIndexLogger , logger } from '../utils/logger.js' ;
21+ import { formatIndexSummary , output } from '../utils/output.js' ;
2122
2223/**
2324 * Check if a command is available
@@ -165,20 +166,10 @@ export const indexCommand = new Command('index')
165166
166167 await indexer . close ( ) ;
167168
168- const codeDuration = ( ( Date . now ( ) - startTime ) / 1000 ) . toFixed ( 2 ) ;
169+ const codeDuration = ( Date . now ( ) - startTime ) / 1000 ;
169170
170171 spinner . succeed ( chalk . green ( 'Code indexed successfully!' ) ) ;
171172
172- // Show code stats
173- logger . log ( '' ) ;
174- logger . log ( chalk . bold ( 'Code Indexing:' ) ) ;
175- logger . log ( ` ${ chalk . cyan ( 'Files scanned:' ) } ${ stats . filesScanned } ` ) ;
176- logger . log ( ` ${ chalk . cyan ( 'Documents extracted:' ) } ${ stats . documentsExtracted } ` ) ;
177- logger . log ( ` ${ chalk . cyan ( 'Documents indexed:' ) } ${ stats . documentsIndexed } ` ) ;
178- logger . log ( ` ${ chalk . cyan ( 'Vectors stored:' ) } ${ stats . vectorsStored } ` ) ;
179- logger . log ( ` ${ chalk . cyan ( 'Storage size:' ) } ${ formatBytes ( storageSize ) } ` ) ;
180- logger . log ( ` ${ chalk . cyan ( 'Duration:' ) } ${ codeDuration } s` ) ;
181-
182173 // Index git history if available
183174 let gitStats = { commitsIndexed : 0 , durationMs : 0 } ;
184175 if ( canIndexGit ) {
@@ -206,12 +197,6 @@ export const indexCommand = new Command('index')
206197 await gitVectorStore . close ( ) ;
207198
208199 spinner . succeed ( chalk . green ( 'Git history indexed!' ) ) ;
209- logger . log ( '' ) ;
210- logger . log ( chalk . bold ( 'Git History:' ) ) ;
211- logger . log ( ` ${ chalk . cyan ( 'Commits indexed:' ) } ${ gitStats . commitsIndexed } ` ) ;
212- logger . log (
213- ` ${ chalk . cyan ( 'Duration:' ) } ${ ( gitStats . durationMs / 1000 ) . toFixed ( 2 ) } s`
214- ) ;
215200 }
216201
217202 // Index GitHub issues/PRs if available
@@ -238,33 +223,50 @@ export const indexCommand = new Command('index')
238223 } ,
239224 } ) ;
240225 spinner . succeed ( chalk . green ( 'GitHub indexed!' ) ) ;
241- logger . log ( '' ) ;
242- logger . log ( chalk . bold ( 'GitHub:' ) ) ;
243- logger . log ( ` ${ chalk . cyan ( 'Issues/PRs indexed:' ) } ${ ghStats . totalDocuments } ` ) ;
244- logger . log (
245- ` ${ chalk . cyan ( 'Duration:' ) } ${ ( ghStats . indexDuration / 1000 ) . toFixed ( 2 ) } s`
246- ) ;
247226 }
248227
249- const totalDuration = ( ( Date . now ( ) - startTime ) / 1000 ) . toFixed ( 2 ) ;
250-
251- logger . log ( '' ) ;
252- logger . log ( chalk . bold ( 'Summary:' ) ) ;
253- logger . log ( ` ${ chalk . cyan ( 'Total duration:' ) } ${ totalDuration } s` ) ;
254- logger . log ( ` ${ chalk . cyan ( 'Storage:' ) } ${ storagePath } ` ) ;
228+ const totalDuration = ( Date . now ( ) - startTime ) / 1000 ;
229+
230+ // Compact summary output
231+ output . log ( '' ) ;
232+ output . log (
233+ formatIndexSummary ( {
234+ code : {
235+ files : stats . filesScanned ,
236+ documents : stats . documentsIndexed ,
237+ vectors : stats . vectorsStored ,
238+ duration : codeDuration ,
239+ size : formatBytes ( storageSize ) ,
240+ } ,
241+ git : canIndexGit
242+ ? { commits : gitStats . commitsIndexed , duration : gitStats . durationMs / 1000 }
243+ : undefined ,
244+ github : canIndexGitHub
245+ ? { documents : ghStats . totalDocuments , duration : ghStats . indexDuration / 1000 }
246+ : undefined ,
247+ total : {
248+ duration : totalDuration ,
249+ storage : storagePath ,
250+ } ,
251+ } )
252+ ) ;
255253
254+ // Show errors if any
256255 if ( stats . errors . length > 0 ) {
257- logger . log ( '' ) ;
258- logger . warn ( `${ stats . errors . length } error(s) occurred during indexing` ) ;
256+ output . log ( '' ) ;
257+ output . warn ( `${ stats . errors . length } error(s) occurred during indexing` ) ;
259258 if ( options . verbose ) {
260259 for ( const error of stats . errors ) {
261- logger . error ( ` ${ error . file } : ${ error . message } ` ) ;
260+ output . log ( ` ${ chalk . gray ( error . file ) } : ${ error . message } ` ) ;
262261 }
262+ } else {
263+ output . log (
264+ ` ${ chalk . gray ( 'Run with' ) } ${ chalk . cyan ( '--verbose' ) } ${ chalk . gray ( 'to see details' ) } `
265+ ) ;
263266 }
264267 }
265268
266- logger . log ( '' ) ;
267- logger . log ( `Now you can search with: ${ chalk . yellow ( 'dev search "<query>"' ) } ` ) ;
269+ output . log ( '' ) ;
268270 } catch ( error ) {
269271 spinner . fail ( 'Failed to index repository' ) ;
270272 logger . error ( error instanceof Error ? error . message : String ( error ) ) ;
0 commit comments