Skip to content

Commit a6bee0c

Browse files
committed
feature-233-implement-openrouter: Refactor file and Supabase repository handling for chunked files
- Updated ChunkedFile class to accept pre-calculated SHA256 checksum. - Introduced ChunkedFileChunk class for better representation of chunked file data. - Enhanced FileRepository methods to include shuffling of chunked files and improved chunk processing. - Refined SupabaseRepository methods for chunked file retrieval and insertion, including error handling. - Improved logging in VectorActionUseCase for clearer progress tracking and error reporting. - Updated SQL migration to reflect changes in chunked file structure.
1 parent f428bce commit a6bee0c

31 files changed

+1075
-419
lines changed

bin/index.js

Lines changed: 231 additions & 93 deletions
Large diffs are not rendered by default.

bin/src/data/model/chunked_file.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ export declare class ChunkedFile {
66
chunks: string[];
77
shasum: string;
88
vector: number[][];
9-
constructor(path: string, index: number, type: 'line' | 'block', content: string, chunks: string[]);
10-
private calculateShasum;
9+
constructor(path: string, index: number, type: 'line' | 'block', content: string, shasum: string, chunks: string[]);
1110
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export declare class ChunkedFileChunk {
2+
owner: string;
3+
repository: string;
4+
branch: string;
5+
path: string;
6+
type: 'line' | 'block';
7+
index: number;
8+
chunkIndex: number;
9+
chunk: string;
10+
shasum: string;
11+
vector: number[];
12+
constructor(owner: string, repository: string, branch: string, path: string, type: 'line' | 'block', index: number, chunkIndex: number, chunk: string, shasum: string, vector: number[]);
13+
}

bin/src/data/repository/file_repository.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ export declare class FileRepository {
99
private shouldIgnoreFile;
1010
private extractCodeBlocks;
1111
private shouldIgnoreLine;
12+
private shuffleArray;
13+
private calculateShasum;
1214
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ChunkedFile } from '../model/chunked_file';
2+
import { ChunkedFileChunk } from '../model/chunked_file_chunk';
23
import { SupabaseConfig } from '../model/supabase_config';
34
export declare class SupabaseRepository {
45
private readonly CHUNKS_TABLE;
@@ -7,7 +8,9 @@ export declare class SupabaseRepository {
78
private supabase;
89
constructor(config: SupabaseConfig);
910
setChunkedFile: (owner: string, repository: string, branch: string, chunkedFile: ChunkedFile) => Promise<void>;
10-
getChunkedFile: (owner: string, repository: string, branch: string, shasum: string) => Promise<ChunkedFile | undefined>;
11-
getChunksByFile: (owner: string, repository: string, branch: string, path: string) => Promise<ChunkedFile[]>;
11+
getChunkedFileByShasum: (owner: string, repository: string, branch: string, type: string, shasum: string) => Promise<ChunkedFileChunk[]>;
12+
getChunks: (owner: string, repository: string, branch: string, path: string, type: string, index: number) => Promise<ChunkedFileChunk[]>;
13+
getChunksByShasum: (owner: string, repository: string, branch: string, shasum: string) => Promise<ChunkedFileChunk[]>;
1214
updateVector: (owner: string, repository: string, branch: string, path: string, index: number, chunkIndex: number, vector: number[]) => Promise<void>;
15+
matchChunks: (owner: string, repository: string, branch: string, type: string, queryEmbedding: number[], matchCount?: number) => Promise<ChunkedFileChunk[]>;
1316
}

bin/src/usecase/vector_action_use_case.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export declare class VectorActionUseCase implements ParamUseCase<Execution, Resu
55
taskId: string;
66
private dockerRepository;
77
private fileRepository;
8-
private readonly CODE_INSTRUCTION;
8+
private readonly CODE_INSTRUCTION_BLOCK;
9+
private readonly CODE_INSTRUCTION_LINE;
910
invoke(param: Execution): Promise<Result[]>;
1011
}

bin/src/utils/logger.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export declare function setGlobalLoggerDebug(debug: boolean): void;
2-
export declare function logInfo(message: string): void;
2+
export declare function logInfo(message: string, previousWasSingleLine?: boolean): void;
33
export declare function logWarning(message: string): void;
44
export declare function logError(message: any): void;
5-
export declare function logDebugInfo(message: string): void;
5+
export declare function logDebugInfo(message: string, previousWasSingleLine?: boolean): void;
66
export declare function logDebugWarning(message: string): void;
77
export declare function logDebugError(message: any): void;
88
export declare function logSingleLine(message: string): void;

0 commit comments

Comments
 (0)