@@ -16,6 +16,7 @@ import * as Diff from 'diff';
1616// import { Buffer } from 'buffer'; // Buffer is global in Node.js
1717import { configService , logger } from "./config-service" ;
1818// import { generateEmbedding } from "./ollama"; // We will use llmProvider.generateEmbedding() instead.
19+ import { v5 as uuidv5 } from 'uuid' ; // Import uuidv5
1920import nodeFs from 'fs' ; // Standard fs for isomorphic-git functions requiring it
2021import { batchUpsertVectors } from './qdrant' ;
2122
@@ -36,6 +37,9 @@ export interface CommitDetail {
3637 changedFiles : CommitChange [ ] ;
3738}
3839
40+ // Define a namespace for UUID generation (this can be any valid UUID)
41+ const CODECOMPASS_NAMESPACE = 'f1a2b3c4-d5e6-7890-1234-567890abcdef' ;
42+
3943export async function validateGitRepository ( repoPath : string ) : Promise < boolean > {
4044 try {
4145 const gitdir = path . join ( repoPath , ".git" ) ;
@@ -182,7 +186,9 @@ export async function indexRepository(qdrantClient: QdrantClient, repoPath: stri
182186
183187 // Embed the preprocessed chunk
184188 const embedding = await llmProvider . generateEmbedding ( chunkContent ) ; // Use llmProvider
185- const pointId = `file:${ preprocessText ( filepath ) } :chunk:${ i } ` ; // Deterministic ID
189+ // Generate UUID for pointId
190+ const idContentFileChunk = `file:${ repoPath } :${ filepath } :chunk:${ i } ` ;
191+ const pointId = uuidv5 ( idContentFileChunk , CODECOMPASS_NAMESPACE ) ;
186192
187193 const payload : FileChunkPayload = {
188194 dataType : 'file_chunk' ,
@@ -574,7 +580,8 @@ async function indexCommitsAndDiffs(
574580 repositoryPath : repoPath , // Optional
575581 } ;
576582 pointsToUpsert . push ( {
577- id : `commit:${ commit . oid } ` , // Deterministic ID
583+ // Generate UUID for commit pointId
584+ id : uuidv5 ( `commit:${ repoPath } :${ commit . oid } ` , CODECOMPASS_NAMESPACE ) ,
578585 vector : commitVector ,
579586 payload : commitPayload ,
580587 } ) ;
@@ -614,7 +621,8 @@ async function indexCommitsAndDiffs(
614621 repositoryPath : repoPath , // Optional
615622 } ;
616623 pointsToUpsert . push ( {
617- id : `diff:${ commit . oid } :${ preprocessText ( changedFile . path ) } :chunk:${ i } ` , // Deterministic ID
624+ // Generate UUID for diff chunk pointId
625+ id : uuidv5 ( `diff:${ repoPath } :${ commit . oid } :${ changedFile . path } :chunk:${ i } ` , CODECOMPASS_NAMESPACE ) ,
618626 vector : diffVector ,
619627 payload : diffPayload ,
620628 } ) ;
0 commit comments