@@ -83,12 +83,67 @@ export const updateCommand = new Command('update')
8383
8484 await indexer . initialize ( ) ;
8585
86- // Create logger for updating (verbose mode shows debug logs)
87- const indexLogger = createIndexLogger ( options . verbose ) ;
86+ // Get update plan to show user what will be updated
87+ const updatePlan = await indexer . getUpdatePlan ( ) ;
8888
89- // Stop spinner and switch to section-based progress
89+ // Stop spinner
9090 spinner . stop ( ) ;
9191
92+ if ( ! updatePlan || updatePlan . total === 0 ) {
93+ output . success ( 'No changes detected' ) ;
94+ await indexer . close ( ) ;
95+ metricsStore . close ( ) ;
96+ return ;
97+ }
98+
99+ // Show update plan
100+ console . log ( '' ) ;
101+ console . log ( chalk . bold ( 'Update plan:' ) ) ;
102+ console . log ( '' ) ;
103+
104+ if ( updatePlan . added . length > 0 ) {
105+ console . log ( chalk . green ( ` ✓ ${ updatePlan . added . length } new file(s)` ) ) ;
106+ if ( options . verbose ) {
107+ for ( const file of updatePlan . added . slice ( 0 , 5 ) ) {
108+ console . log ( chalk . dim ( ` + ${ file } ` ) ) ;
109+ }
110+ if ( updatePlan . added . length > 5 ) {
111+ console . log ( chalk . dim ( ` ... and ${ updatePlan . added . length - 5 } more` ) ) ;
112+ }
113+ }
114+ }
115+
116+ if ( updatePlan . changed . length > 0 ) {
117+ console . log ( chalk . yellow ( ` ↻ ${ updatePlan . changed . length } modified file(s)` ) ) ;
118+ if ( options . verbose ) {
119+ for ( const file of updatePlan . changed . slice ( 0 , 5 ) ) {
120+ console . log ( chalk . dim ( ` ~ ${ file } ` ) ) ;
121+ }
122+ if ( updatePlan . changed . length > 5 ) {
123+ console . log ( chalk . dim ( ` ... and ${ updatePlan . changed . length - 5 } more` ) ) ;
124+ }
125+ }
126+ }
127+
128+ if ( updatePlan . deleted . length > 0 ) {
129+ console . log ( chalk . red ( ` ✗ ${ updatePlan . deleted . length } deleted file(s)` ) ) ;
130+ if ( options . verbose ) {
131+ for ( const file of updatePlan . deleted . slice ( 0 , 5 ) ) {
132+ console . log ( chalk . dim ( ` - ${ file } ` ) ) ;
133+ }
134+ if ( updatePlan . deleted . length > 5 ) {
135+ console . log ( chalk . dim ( ` ... and ${ updatePlan . deleted . length - 5 } more` ) ) ;
136+ }
137+ }
138+ }
139+
140+ console . log ( '' ) ;
141+ console . log ( chalk . dim ( `Total: ${ updatePlan . total } file(s) to process` ) ) ;
142+ console . log ( '' ) ;
143+
144+ // Create logger for updating (verbose mode shows debug logs)
145+ const indexLogger = createIndexLogger ( options . verbose ) ;
146+
92147 // Initialize progress renderer
93148 const progressRenderer = new ProgressRenderer ( { verbose : options . verbose } ) ;
94149 progressRenderer . setSections ( [ 'Scanning Changed Files' , 'Embedding Vectors' ] ) ;
@@ -114,17 +169,20 @@ export const updateCommand = new Command('update')
114169 }
115170
116171 // Update embedding progress
117- const pct = Math . round ( ( progress . documentsIndexed / progress . totalDocuments ) * 100 ) ;
118- const embeddingElapsed = ( Date . now ( ) - embeddingStartTime ) / 1000 ;
119- const docsPerSec =
120- embeddingElapsed > 0 ? progress . documentsIndexed / embeddingElapsed : 0 ;
121- progressRenderer . updateSection (
122- `${ progress . documentsIndexed . toLocaleString ( ) } /${ progress . totalDocuments . toLocaleString ( ) } documents (${ pct } %, ${ docsPerSec . toFixed ( 0 ) } docs/sec)`
172+ progressRenderer . updateSectionWithRate (
173+ progress . documentsIndexed ,
174+ progress . totalDocuments ,
175+ 'documents' ,
176+ embeddingStartTime
123177 ) ;
124178 } else {
125179 // Scanning phase
126- const percent = progress . percentComplete || 0 ;
127- progressRenderer . updateSection ( `${ percent . toFixed ( 0 ) } % complete` ) ;
180+ progressRenderer . updateSectionWithRate (
181+ progress . filesProcessed ,
182+ progress . totalFiles ,
183+ 'files' ,
184+ scanStartTime
185+ ) ;
128186 }
129187 } ,
130188 } ) ;
@@ -155,13 +213,9 @@ export const updateCommand = new Command('update')
155213
156214 // Show completion message
157215 output . log ( '' ) ;
158- if ( stats . filesScanned === 0 ) {
159- output . success ( 'No changes detected' ) ;
160- } else {
161- output . success (
162- `Updated ${ stats . filesScanned . toLocaleString ( ) } files in ${ duration . toFixed ( 1 ) } s`
163- ) ;
164- }
216+ output . success (
217+ `Updated ${ stats . filesScanned . toLocaleString ( ) } files in ${ duration . toFixed ( 1 ) } s`
218+ ) ;
165219 output . log ( '' ) ;
166220
167221 // Show errors if any
0 commit comments