11import { createHash } from 'crypto' ;
2- import * as fs from 'fs-extra' ;
2+ import fse from 'fs-extra' ;
3+ import { promises as fsp } from 'fs' ;
34import * as path from 'path' ;
45
56/**
@@ -224,18 +225,18 @@ export class DocumentIndex {
224225 lastUpdated : new Date ( ) . toISOString ( )
225226 } ;
226227
227- await fs . writeJSON ( this . indexFilePath , indexData , { spaces : 2 } ) ;
228+ await fse . writeJSON ( this . indexFilePath , indexData , { spaces : 2 } ) ;
228229 }
229230
230231 /**
231232 * Load index from disk
232233 */
233234 private async loadIndex ( ) : Promise < void > {
234- if ( ! await fs . pathExists ( this . indexFilePath ) ) {
235+ if ( ! await fse . pathExists ( this . indexFilePath ) ) {
235236 throw new Error ( 'Index file does not exist' ) ;
236237 }
237238
238- const indexData = await fs . readJSON ( this . indexFilePath ) ;
239+ const indexData = await fse . readJSON ( this . indexFilePath ) ;
239240
240241 this . documentMap = new Map ( Object . entries ( indexData . documentMap || { } ) ) ;
241242 this . chunkMap = new Map ( Object . entries ( indexData . chunkMap || { } ) ) ;
@@ -257,13 +258,13 @@ export class DocumentIndex {
257258 this . keywordIndex . clear ( ) ;
258259
259260 try {
260- const files = await fs . readdir ( dataDir ) ;
261+ const files = await fsp . readdir ( dataDir ) ;
261262 const documentFiles = files . filter ( file => file . endsWith ( '.json' ) && file !== 'document-index.json' ) ;
262263
263264 for ( const file of documentFiles ) {
264265 try {
265266 const filePath = path . join ( dataDir , file ) ;
266- const document = await fs . readJSON ( filePath ) ;
267+ const document = await fse . readJSON ( filePath ) ;
267268
268269 if ( document . id && document . content ) {
269270 this . addDocument ( document . id , filePath , document . content , document . chunks ) ;
0 commit comments