@memory-bank/mcp
Version:
Memory-enabled Co-Pilot (MCP) server for managing project documentation and context
121 lines • 4.67 kB
TypeScript
import { BranchInfo } from '../../domain/entities/BranchInfo.js';
import { DocumentId } from '../../domain/entities/DocumentId.js';
import { DocumentPath } from '../../domain/entities/DocumentPath.js';
import { JsonDocument, DocumentType } from '../../domain/entities/JsonDocument.js';
import { Tag } from '../../domain/entities/Tag.js';
import { IFileSystemService } from '../storage/interfaces/IFileSystemService.js';
import { IIndexService } from './interfaces/IIndexService.js';
import { DocumentReference } from '@memory-bank/schemas';
/**
* Implementation of the document index service
* Provides efficient lookup capabilities for documents using in-memory indices
* with file system persistence
*/
export declare class IndexService implements IIndexService {
private readonly fileSystemService;
private readonly rootPath;
private indices;
/**
* Create a new IndexService
* @param fileSystemService File system service for file operations
* @param rootPath Root path for storing index files
*/
constructor(fileSystemService: IFileSystemService, rootPath: string);
/**
* Initialize the index for a branch
* @param branchInfo Branch information
*/
initializeIndex(branchInfo: BranchInfo): Promise<void>;
/**
* Build the index from a collection of documents
* @param branchInfo Branch information
* @param documents Documents to index
*/
buildIndex(branchInfo: BranchInfo, documents: JsonDocument[]): Promise<void>;
/**
* Add a document to the index
* @param branchInfo Branch information
* @param document Document to add
*/
addToIndex(branchInfo: BranchInfo, document: JsonDocument): Promise<void>;
/**
* Remove a document from the index
* @param branchInfo Branch information
* @param document Document or document ID or path to remove
*/
removeFromIndex(branchInfo: BranchInfo, document: JsonDocument | DocumentId | DocumentPath): Promise<void>;
/**
* Find document reference by ID
* @param branchInfo Branch information
* @param id Document ID
* @returns Document reference if found, null otherwise
*/
findById(branchInfo: BranchInfo, id: DocumentId): Promise<DocumentReference | null>;
/**
* Convert internal document reference to the schema DocumentReference type
* @param internal Internal document reference
* @returns Schema-compatible document reference
*/
private convertToDocumentReference;
/**
* Find document reference by path
* @param branchInfo Branch information
* @param path Document path
* @returns Document reference if found, null otherwise
*/
findByPath(branchInfo: BranchInfo, path: DocumentPath): Promise<DocumentReference | null>;
/**
* Find document references by tags
* @param branchInfo Branch information
* @param tags Tags to search for
* @param matchAll If true, documents must have all tags; if false, any tag is sufficient
* @returns Array of matching document references
*/
findByTags(params: {
branchInfo: BranchInfo;
tags: Tag[];
matchAll?: boolean;
}): Promise<DocumentReference[]>;
/**
* Find document references by document type
* @param branchInfo Branch information
* @param documentType Document type to search for
* @returns Array of matching document references
*/
findByType(branchInfo: BranchInfo, documentType: DocumentType): Promise<DocumentReference[]>;
/**
* List all document references
* @param branchInfo Branch information
* @returns Array of all document references
*/
listAll(branchInfo: BranchInfo): Promise<DocumentReference[]>;
/**
* Save the index to persistent storage
* @param branchInfo Branch information
*/
saveIndex(branchInfo: BranchInfo): Promise<void>;
/**
* Load the index from persistent storage
* @param branchInfo Branch information
*/
loadIndex(branchInfo: BranchInfo): Promise<void>;
/**
* Get the index file path for a branch
* @param branchInfo Branch information
* @returns Absolute file path to the index file
*/
private getIndexFilePath;
/**
* Get an existing index or create a new one if it doesn't exist
* @param branchInfo Branch information
* @returns Document index
*/
private getOrCreateIndex;
/**
* Add a document to an index
* @param index Document index to update
* @param document Document to add
*/
private addDocumentToIndex;
}
//# sourceMappingURL=IndexService.d.ts.map