@gitsense/gscb-git-tools 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/package.json +1 -1
  2. package/dist/cjs/common/logger.js +0 -97
  3. package/dist/cjs/common/logger.js.map +0 -1
  4. package/dist/cjs/common/metadata-manager.js +0 -196
  5. package/dist/cjs/common/metadata-manager.js.map +0 -1
  6. package/dist/cjs/importer/chat-manager/chat-creator.js +0 -90
  7. package/dist/cjs/importer/chat-manager/chat-creator.js.map +0 -1
  8. package/dist/cjs/importer/chat-manager/chat-manager.js +0 -179
  9. package/dist/cjs/importer/chat-manager/chat-manager.js.map +0 -1
  10. package/dist/cjs/importer/chat-manager/constants.js +0 -66
  11. package/dist/cjs/importer/chat-manager/constants.js.map +0 -1
  12. package/dist/cjs/importer/chat-manager/group-manager.js +0 -56
  13. package/dist/cjs/importer/chat-manager/group-manager.js.map +0 -1
  14. package/dist/cjs/importer/chat-manager/hierarchy-manager.js +0 -115
  15. package/dist/cjs/importer/chat-manager/hierarchy-manager.js.map +0 -1
  16. package/dist/cjs/importer/chat-manager/message-manager.js +0 -189
  17. package/dist/cjs/importer/chat-manager/message-manager.js.map +0 -1
  18. package/dist/cjs/importer/constants.js +0 -30
  19. package/dist/cjs/importer/constants.js.map +0 -1
  20. package/dist/cjs/importer/core/directory-processor.js +0 -343
  21. package/dist/cjs/importer/core/directory-processor.js.map +0 -1
  22. package/dist/cjs/importer/core/error-handler.js +0 -64
  23. package/dist/cjs/importer/core/error-handler.js.map +0 -1
  24. package/dist/cjs/importer/core/import-processor.js +0 -167
  25. package/dist/cjs/importer/core/import-processor.js.map +0 -1
  26. package/dist/cjs/importer/core/importer.js +0 -135
  27. package/dist/cjs/importer/core/importer.js.map +0 -1
  28. package/dist/cjs/importer/core/utils.js +0 -66
  29. package/dist/cjs/importer/core/utils.js.map +0 -1
  30. package/dist/cjs/importer/file-processor.js +0 -199
  31. package/dist/cjs/importer/file-processor.js.map +0 -1
  32. package/dist/cjs/importer/language-utils.js +0 -286
  33. package/dist/cjs/importer/language-utils.js.map +0 -1
  34. package/dist/cjs/importer/tree-processor.js +0 -119
  35. package/dist/cjs/importer/tree-processor.js.map +0 -1
  36. package/dist/cjs/index.js +0 -12
  37. package/dist/cjs/index.js.map +0 -1
  38. package/dist/cjs/package.json +0 -3
  39. package/dist/esm/common/logger.js +0 -95
  40. package/dist/esm/common/logger.js.map +0 -1
  41. package/dist/esm/common/metadata-manager.js +0 -194
  42. package/dist/esm/common/metadata-manager.js.map +0 -1
  43. package/dist/esm/importer/chat-manager/chat-creator.js +0 -88
  44. package/dist/esm/importer/chat-manager/chat-creator.js.map +0 -1
  45. package/dist/esm/importer/chat-manager/chat-manager.js +0 -177
  46. package/dist/esm/importer/chat-manager/chat-manager.js.map +0 -1
  47. package/dist/esm/importer/chat-manager/constants.js +0 -48
  48. package/dist/esm/importer/chat-manager/constants.js.map +0 -1
  49. package/dist/esm/importer/chat-manager/group-manager.js +0 -54
  50. package/dist/esm/importer/chat-manager/group-manager.js.map +0 -1
  51. package/dist/esm/importer/chat-manager/hierarchy-manager.js +0 -113
  52. package/dist/esm/importer/chat-manager/hierarchy-manager.js.map +0 -1
  53. package/dist/esm/importer/chat-manager/message-manager.js +0 -187
  54. package/dist/esm/importer/chat-manager/message-manager.js.map +0 -1
  55. package/dist/esm/importer/constants.js +0 -28
  56. package/dist/esm/importer/constants.js.map +0 -1
  57. package/dist/esm/importer/core/directory-processor.js +0 -337
  58. package/dist/esm/importer/core/directory-processor.js.map +0 -1
  59. package/dist/esm/importer/core/error-handler.js +0 -62
  60. package/dist/esm/importer/core/error-handler.js.map +0 -1
  61. package/dist/esm/importer/core/import-processor.js +0 -165
  62. package/dist/esm/importer/core/import-processor.js.map +0 -1
  63. package/dist/esm/importer/core/importer.js +0 -133
  64. package/dist/esm/importer/core/importer.js.map +0 -1
  65. package/dist/esm/importer/core/utils.js +0 -64
  66. package/dist/esm/importer/core/utils.js.map +0 -1
  67. package/dist/esm/importer/file-processor.js +0 -193
  68. package/dist/esm/importer/file-processor.js.map +0 -1
  69. package/dist/esm/importer/language-utils.js +0 -279
  70. package/dist/esm/importer/language-utils.js.map +0 -1
  71. package/dist/esm/importer/tree-processor.js +0 -113
  72. package/dist/esm/importer/tree-processor.js.map +0 -1
  73. package/dist/esm/index.js +0 -4
  74. package/dist/esm/index.js.map +0 -1
  75. package/dist/index.d.ts +0 -215
@@ -1,337 +0,0 @@
1
- import path from 'path';
2
- import { Utils } from './utils.js';
3
-
4
- /**
5
- * Component: Directory Processor
6
- * Block-UUID: 237b8cc5-5d1b-4285-82c4-0e1f49459f2c
7
- * Parent-UUID: 31839e44-58af-43ea-baab-96674d745ad0
8
- * Version: 8.0.0
9
- * Purpose: Add hash comparison and token estimation for directories
10
- * Language: TypeScript
11
- * Created-at: 2025-03-15T05:58:33.811Z
12
- * Updated-at: 2025-03-24T00:50:00.000Z
13
- * Authors: Claude 3.5 Sonnet (v5.0.1), Bard, Claude 3.5 Sonnet (v6.0.0), Claude 3.7 Sonnet (v6.3.0),
14
- * OpenRouter - Gemini Flash 2.0 (v6.4.0), OpenRouter - Gemini Flash 2.0 (v6.5.0),
15
- * together.ai - DeepSeek v3 (v6.6.0), Claude 3.7 Sonnet (v6.7.0), together.ai - DeepSeek v3 (v6.8.0),
16
- * together.ai - DeepSeek v3 (v7.0.0), together.ai - DeepSeek v3 (v8.0.0)
17
- */
18
- class DirectoryProcessor {
19
- dbClient;
20
- gitRepo;
21
- fileProcessor;
22
- treeProcessor;
23
- metadataManager;
24
- chatManager;
25
- logger;
26
- constructor(dbClient, gitRepo, fileProcessor, treeProcessor, metadataManager, chatManager, logger) {
27
- this.dbClient = dbClient;
28
- this.gitRepo = gitRepo;
29
- this.fileProcessor = fileProcessor;
30
- this.treeProcessor = treeProcessor;
31
- this.metadataManager = metadataManager;
32
- this.chatManager = chatManager;
33
- this.logger = logger;
34
- }
35
- /**
36
- * Estimates tokens using 1.33 tokens per word.
37
- */
38
- estimateTokens(text) {
39
- const wordCount = text.split(/\s+/).filter(Boolean).length;
40
- return Math.ceil(wordCount * 1.33);
41
- }
42
- /**
43
- * Processes all files and directories in the repository, ensuring a proper parent-child relationship.
44
- */
45
- async processFiles(rootChatId) {
46
- try {
47
- // Start processing from the root directory. Empty string is root.
48
- return await this.processDirectory('', rootChatId);
49
- }
50
- catch (error) {
51
- throw new Error(`Failed to process files: ${error instanceof Error ? error.message : String(error)}`);
52
- }
53
- }
54
- /**
55
- * Processes entries (files and directories) that have changed between commits.
56
- */
57
- async processChangedEntries(changedEntries, refChatId, repoGroupId) {
58
- // Group entries by change type
59
- const addedOrModifiedFiles = [];
60
- const deletedFiles = [];
61
- const deletedDirs = [];
62
- for (const entry of changedEntries) {
63
- // Normalize the path
64
- const normalizedPath = this.normalizePath(entry.path);
65
- // Skip files that match skip patterns if they're being added or modified
66
- if (entry.entryType === 'file' && entry.changeType !== 'delete' &&
67
- await this.fileProcessor.shouldSkipFile(normalizedPath)) {
68
- this.logger.log(`Skipping file: ${normalizedPath}`);
69
- continue;
70
- }
71
- // Categorize the entry
72
- if (entry.entryType === 'file') {
73
- if (entry.changeType === 'delete') {
74
- deletedFiles.push(normalizedPath);
75
- }
76
- else {
77
- addedOrModifiedFiles.push(normalizedPath);
78
- }
79
- }
80
- else {
81
- if (entry.changeType === 'delete') {
82
- deletedDirs.push(normalizedPath);
83
- }
84
- }
85
- }
86
- // Process deleted files first
87
- if (deletedFiles.length > 0) {
88
- this.logger.log(`Processing ${deletedFiles.length} deleted files`);
89
- await this.processDeletedFiles(deletedFiles, refChatId);
90
- }
91
- // Process deleted directories
92
- if (deletedDirs.length > 0) {
93
- this.logger.log(`Processing ${deletedDirs.length} deleted directories`);
94
- await this.processDeletedDirectories(deletedDirs, refChatId);
95
- }
96
- // Group added/modified files by directory
97
- const filesByDirectory = {};
98
- for (const filePath of addedOrModifiedFiles) {
99
- const dirPath = this.normalizePath(path.dirname(filePath));
100
- if (!filesByDirectory[dirPath]) {
101
- filesByDirectory[dirPath] = [];
102
- }
103
- filesByDirectory[dirPath].push(filePath);
104
- }
105
- // Process each directory's added/modified files
106
- for (const [dirPath, files] of Object.entries(filesByDirectory)) {
107
- this.logger.log(`Processing ${files.length} files in directory: ${dirPath}`);
108
- // Find or create the directory chat
109
- const dirChatId = await this.findOrCreateDirectoryChat(dirPath, refChatId, repoGroupId);
110
- // Process each file in the directory
111
- let orderWeight = 10;
112
- for (const filePath of files) {
113
- this.logger.log(`Processing file: ${filePath}`);
114
- // FileProcessor will handle both new files and updates
115
- await this.fileProcessor.processFile(filePath, dirChatId, orderWeight);
116
- orderWeight += 10;
117
- }
118
- await this.metadataManager.updateDirectoryMetadata(dirChatId, dirPath, null);
119
- }
120
- }
121
- /**
122
- * Recursively processes a directory and its contents.
123
- */
124
- async processDirectory(dirPath, parentChatId, treeSha = '') {
125
- try {
126
- // Used to define chat order
127
- let orderWeight = 0;
128
- // Create a chat for the current directory
129
- const dirChatId = dirPath === ''
130
- ? parentChatId
131
- : await this.treeProcessor.createDirectoryChat(dirPath, parentChatId, treeSha, orderWeight);
132
- // List the contents of the directory
133
- const entries = await this.gitRepo.listDirectory(dirPath);
134
- // Separate directories and files, then sort alphabetically
135
- const directories = entries
136
- .filter(entry => entry.type === 'tree')
137
- .sort((a, b) => b.path.localeCompare(a.path));
138
- const files = entries
139
- .filter(entry => entry.type === 'blob')
140
- .sort((a, b) => a.path.localeCompare(b.path));
141
- // Process directories and files
142
- const childCommits = [];
143
- for (const dir of directories) {
144
- orderWeight += 10;
145
- const childCommit = await this.processDirectory(dirPath + (dirPath === '' ? '' : '/') + dir.path, dirChatId, dir.oid);
146
- if (childCommit)
147
- childCommits.push(childCommit);
148
- }
149
- for (const file of files) {
150
- const { path } = file;
151
- if (await this.fileProcessor.shouldSkipFile(path))
152
- continue;
153
- orderWeight += 10;
154
- const fileCommit = await this.fileProcessor.processFile(dirPath + (dirPath === '' ? '' : '/') + path, dirChatId, orderWeight);
155
- if (fileCommit)
156
- childCommits.push(fileCommit);
157
- }
158
- // Determine the latest commit for the directory
159
- const latestCommit = Utils.getLatestCommit(childCommits);
160
- // Skip update if the commit hash hasn't changed
161
- const existingMeta = (await this.chatManager.getChatById(dirChatId))?.meta || {};
162
- if (existingMeta.commit?.hash === latestCommit?.hash) {
163
- this.logger.log(`Skipping update for directory '${dirPath}' (commit hash unchanged)`);
164
- return latestCommit;
165
- }
166
- // Estimate tokens for directory metadata
167
- const now = new Date().toISOString();
168
- const metaTokens = this.estimateTokens(JSON.stringify({
169
- type: 'git-tree',
170
- tree: treeSha,
171
- path: dirPath,
172
- name: path.basename(dirPath),
173
- commit: latestCommit,
174
- status: 'imported'
175
- }));
176
- // Update the directory metadata
177
- const update = {
178
- status: 'imported',
179
- importFinishedAt: now,
180
- tokens: {
181
- metadata: { estimate: metaTokens, estimatedAt: now }
182
- }
183
- };
184
- if (dirPath !== '' && dirPath !== '.') {
185
- update.commit = latestCommit;
186
- }
187
- await this.metadataManager.updateChatMetadata(dirChatId, { ...existingMeta, ...update });
188
- return latestCommit;
189
- }
190
- catch (error) {
191
- console.trace();
192
- throw new Error(`Failed to process directory '${dirPath}': ${error instanceof Error ? error.message : String(error)}`);
193
- }
194
- }
195
- /**
196
- * Processes deleted files.
197
- */
198
- async processDeletedFiles(deletedFiles, refChatId) {
199
- for (const filePath of deletedFiles) {
200
- this.logger.log(`Processing deleted file: ${filePath}`);
201
- // Find the directory chat for this file
202
- const dirPath = this.normalizePath(path.dirname(filePath));
203
- const dirChatId = await this.findDirectoryChat(dirPath, refChatId);
204
- if (!dirChatId) {
205
- this.logger.log(`Could not find directory chat for ${dirPath}, skipping deletion of ${filePath}`);
206
- continue;
207
- }
208
- // Find the file chat
209
- const fileName = path.basename(filePath);
210
- const childChats = await this.dbClient.getChatsByParentId(dirChatId);
211
- const fileChat = childChats.find(chat => chat.type === 'git-blob' &&
212
- chat.name === fileName && chat.meta?.path === filePath);
213
- if (!fileChat) {
214
- this.logger.log(`Could not find chat for file ${filePath}, it may have been deleted already`);
215
- continue;
216
- }
217
- // Mark the file as deleted
218
- await this.metadataManager.markFileAsDeleted(fileChat.id, filePath);
219
- await this.metadataManager.updateDirectoryMetadata(dirChatId, dirPath, null);
220
- }
221
- }
222
- /**
223
- * Processes deleted directories.
224
- */
225
- async processDeletedDirectories(deletedDirs, refChatId) {
226
- // Sort directories by depth (deepest first) to handle nested directories correctly
227
- const sortedDirs = [...deletedDirs].sort((a, b) => b.split('/').length - a.split('/').length);
228
- for (const dirPath of sortedDirs) {
229
- this.logger.log(`Processing deleted directory: ${dirPath}`);
230
- // Find the parent directory chat
231
- const parentDirPath = this.normalizePath(path.dirname(dirPath));
232
- const parentDirChatId = await this.findDirectoryChat(parentDirPath, refChatId);
233
- if (!parentDirChatId) {
234
- this.logger.log(`Could not find parent directory chat for ${parentDirPath}, skipping deletion of ${dirPath}`);
235
- continue;
236
- }
237
- // Find the directory chat
238
- const dirName = path.basename(dirPath);
239
- const childChats = await this.dbClient.getChatsByParentId(parentDirChatId);
240
- const dirChat = childChats.find(chat => chat.type === 'git-tree' &&
241
- chat.name === dirName &&
242
- chat.meta?.path === dirPath);
243
- if (!dirChat) {
244
- this.logger.log(`Could not find chat for directory ${dirPath}, it may have been deleted already`);
245
- continue;
246
- }
247
- // Delete the directory
248
- await this.dbClient.deleteChat(dirChat.id);
249
- // Mark the directory and all its contents as deleted
250
- await this.metadataManager.markDirectoryAsDeleted(dirChat.id, dirPath);
251
- }
252
- }
253
- /**
254
- * Finds or creates a directory chat.
255
- */
256
- async findOrCreateDirectoryChat(dirPath, refChatId, repoGroupId) {
257
- // Normalize the input path
258
- const normalizedDirPath = this.normalizePath(dirPath);
259
- if (normalizedDirPath === '.' || normalizedDirPath === '') {
260
- return refChatId;
261
- }
262
- // Split the path into components
263
- const pathComponents = normalizedDirPath.split('/');
264
- // Start from the root chat
265
- let currentChatId = refChatId;
266
- let currentPath = '';
267
- // Traverse the path, creating directory chats as needed
268
- for (const component of pathComponents) {
269
- currentPath = currentPath ? `${currentPath}/${component}` : component;
270
- const normalizedCurrentPath = this.normalizePath(currentPath);
271
- // Try to find an existing chat for this directory
272
- const childChats = await this.dbClient.getChatsByParentId(currentChatId);
273
- const dirChat = childChats.find(chat => {
274
- // Normalize the path from meta for comparison
275
- const chatPath = this.normalizePath(chat.meta?.path || '');
276
- return chat.type === 'git-tree' && chatPath === normalizedCurrentPath;
277
- });
278
- if (dirChat) {
279
- currentChatId = dirChat.id;
280
- this.logger.log(`Found existing directory chat for ${normalizedCurrentPath}: ${currentChatId}`);
281
- }
282
- else {
283
- // Create a new directory chat
284
- this.logger.log(`Creating new directory chat for ${normalizedCurrentPath}`);
285
- const treeSha = await this.gitRepo.getTreeSha(normalizedCurrentPath);
286
- currentChatId = await this.treeProcessor.createDirectoryChat(normalizedCurrentPath, currentChatId, treeSha, 10) || 0;
287
- }
288
- }
289
- return currentChatId;
290
- }
291
- /**
292
- * Finds a directory chat by path.
293
- */
294
- async findDirectoryChat(dirPath, rootChatId) {
295
- // Normalize the input path
296
- const normalizedDirPath = this.normalizePath(dirPath);
297
- if (normalizedDirPath === '.' || normalizedDirPath === '') {
298
- return rootChatId;
299
- }
300
- // Split the path into components
301
- const pathComponents = normalizedDirPath.split('/');
302
- // Start from the root chat
303
- let currentChatId = rootChatId;
304
- let currentPath = '';
305
- // Traverse the path, looking for existing directory chats
306
- for (const component of pathComponents) {
307
- currentPath = currentPath ? `${currentPath}/${component}` : component;
308
- const normalizedCurrentPath = this.normalizePath(currentPath);
309
- // Try to find an existing chat for this directory
310
- const childChats = await this.dbClient.getChatsByParentId(currentChatId);
311
- const dirChat = childChats.find(chat => {
312
- // Normalize the path from meta for comparison
313
- const chatPath = this.normalizePath(chat.meta?.path || '');
314
- return chat.type === 'git-tree' && chatPath === normalizedCurrentPath;
315
- });
316
- if (dirChat) {
317
- currentChatId = dirChat.id;
318
- this.logger.log(`Found existing directory chat for ${normalizedCurrentPath}: ${currentChatId}`);
319
- }
320
- else {
321
- // If we can't find a directory at any level, return undefined
322
- this.logger.log(`Could not find directory chat for ${normalizedCurrentPath}`);
323
- return undefined;
324
- }
325
- }
326
- return currentChatId;
327
- }
328
- /**
329
- * Normalizes a file path.
330
- */
331
- normalizePath(path) {
332
- return path.replace(/\\/g, '/').replace(/\/+/g, '/').replace(/\/$/, '');
333
- }
334
- }
335
-
336
- export { DirectoryProcessor };
337
- //# sourceMappingURL=directory-processor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"directory-processor.js","sources":["../../../../src/importer/core/directory-processor.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;AAaG;MAYU,kBAAkB,CAAA;AAEN,IAAA,QAAA;AACA,IAAA,OAAA;AACA,IAAA,aAAA;AACA,IAAA,aAAA;AACA,IAAA,eAAA;AACA,IAAA,WAAA;AACA,IAAA,MAAA;AAPrB,IAAA,WAAA,CACqB,QAAwB,EACxB,OAAmB,EACnB,aAA4B,EAC5B,aAA4B,EAC5B,eAAgC,EAChC,WAAwB,EACxB,MAAc,EAAA;QANd,IAAQ,CAAA,QAAA,GAAR,QAAQ;QACR,IAAO,CAAA,OAAA,GAAP,OAAO;QACP,IAAa,CAAA,aAAA,GAAb,aAAa;QACb,IAAa,CAAA,aAAA,GAAb,aAAa;QACb,IAAe,CAAA,eAAA,GAAf,eAAe;QACf,IAAW,CAAA,WAAA,GAAX,WAAW;QACX,IAAM,CAAA,MAAA,GAAN,MAAM;;AAG3B;;AAEG;AACK,IAAA,cAAc,CAAC,IAAY,EAAA;AAC/B,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM;QAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;;AAGtC;;AAEG;IACH,MAAM,YAAY,CAAC,UAAkB,EAAA;AACjC,QAAA,IAAI;;YAEA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AO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;;AAE9E;;;;"}
@@ -1,62 +0,0 @@
1
- import { DatabaseError, ValidationError, NotFoundError } from 'gscb-db';
2
-
3
- /**
4
- * Component: Error Handler
5
- * Block-UUID: 237b8cc5-5d1b-4285-82c4-0e1f49459f2c
6
- * Parent-UUID: 31839e44-58af-43ea-baab-96674d745ad0
7
- * Version: 6.6.0
8
- * Purpose: Centralized error handling for GitImporter
9
- * Language: TypeScript
10
- * Created-at: 2025-03-15T05:59:20.178Z
11
- * Authors: Claude 3.5 Sonnet (v5.0.1), Bard, Claude 3.5 Sonnet (v6.0.0), Claude 3.7 Sonnet (v6.3.0), OpenRouter - Gemini Flash 2.0 (v6.4.0), OpenRouter - Gemini Flash 2.0 (v6.5.0), together.ai - DeepSeek v3 (v6.6.0)
12
- */
13
- class ErrorHandler {
14
- logger;
15
- constructor(logger) {
16
- this.logger = logger;
17
- }
18
- /**
19
- * Handles errors during the import process.
20
- * @param error The error to handle.
21
- * @throws {Error} Always throws an error after handling.
22
- */
23
- async handleError(error) {
24
- let message;
25
- let isExpected = false;
26
- if (error instanceof DatabaseError) {
27
- message = `Database error: ${error.message}`;
28
- isExpected = true;
29
- }
30
- else if (error instanceof ValidationError) {
31
- message = `Validation error: ${error.message}`;
32
- isExpected = true;
33
- }
34
- else if (error instanceof NotFoundError) {
35
- message = `Not found: ${error.message}`;
36
- isExpected = true;
37
- }
38
- else if (this.isGitError(error)) {
39
- message = `Git error: ${error.message}`;
40
- isExpected = true;
41
- }
42
- else if (error instanceof Error) {
43
- message = `Unexpected error: ${error.message}`;
44
- }
45
- else {
46
- message = `Unknown error: ${String(error)}`;
47
- }
48
- this.logger.log(message, error, !isExpected);
49
- throw error;
50
- }
51
- /**
52
- * Checks if an error is a Git error.
53
- */
54
- isGitError(error) {
55
- return (error instanceof Error &&
56
- 'code' in error &&
57
- typeof error.code === 'string');
58
- }
59
- }
60
-
61
- export { ErrorHandler };
62
- //# sourceMappingURL=error-handler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-handler.js","sources":["../../../../src/importer/core/error-handler.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;AASG;MAMU,YAAY,CAAA;AACQ,IAAA,MAAA;AAA7B,IAAA,WAAA,CAA6B,MAAc,EAAA;QAAd,IAAM,CAAA,MAAA,GAAN,MAAM;;AAEnC;;;;AAIG;IACH,MAAM,WAAW,CAAC,KAAc,EAAA;AAC5B,QAAA,IAAI,OAAe;QACnB,IAAI,UAAU,GAAG,KAAK;AAEtB,QAAA,IAAI,KAAK,YAAY,aAAa,EAAE;AAChC,YAAA,OAAO,GAAG,CAAmB,gBAAA,EAAA,KAAK,CAAC,OAAO,EAAE;YAC5C,UAAU,GAAG,IAAI;;AACd,aAAA,IAAI,KAAK,YAAY,eAAe,EAAE;AACzC,YAAA,OAAO,GAAG,CAAqB,kBAAA,EAAA,KAAK,CAAC,OAAO,EAAE;YAC9C,UAAU,GAAG,IAAI;;AACd,aAAA,IAAI,KAAK,YAAY,aAAa,EAAE;AACvC,YAAA,OAAO,GAAG,CAAc,WAAA,EAAA,KAAK,CAAC,OAAO,EAAE;YACvC,UAAU,GAAG,IAAI;;AACd,aAAA,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;AAC/B,YAAA,OAAO,GAAG,CAAe,WAAA,EAAA,KAA6B,CAAC,OAAO,EAAE;YAChE,UAAU,GAAG,IAAI;;AACd,aAAA,IAAI,KAAK,YAAY,KAAK,EAAE;AAC/B,YAAA,OAAO,GAAG,CAAqB,kBAAA,EAAA,KAAK,CAAC,OAAO,EAAE;;aAC3C;AACH,YAAA,OAAO,GAAG,CAAkB,eAAA,EAAA,MAAM,CAAC,KAAK,CAAC,EAAE;;AAG/C,QAAA,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,UAAU,CAAC;AAC5C,QAAA,MAAM,KAAK;;AAGf;;AAEG;AACK,IAAA,UAAU,CAAC,KAAc,EAAA;QAC7B,QACI,KAAK,YAAY,KAAK;AACtB,YAAA,MAAM,IAAI,KAAK;AACf,YAAA,OAAQ,KAAkB,CAAC,IAAI,KAAK,QAAQ;;AAGvD;;;;"}
@@ -1,165 +0,0 @@
1
- import { ChatManager } from '../chat-manager/chat-manager.js';
2
- import { MessageManager } from '../chat-manager/message-manager.js';
3
- import { FileProcessor } from '../file-processor.js';
4
- import { TreeProcessor } from '../tree-processor.js';
5
- import { DirectoryProcessor } from './directory-processor.js';
6
- import { MetadataManager } from '../../common/metadata-manager.js';
7
-
8
- /**
9
- * Component: Import Processor
10
- * Block-UUID: 5cc5dcf8-63d7-415a-aa21-ffa85e3b8dd9
11
- * Parent-UUID: 237b8cc5-5d1b-4285-82c4-0e1f49459f2c
12
- * Version: 6.8.0
13
- * Purpose: Handles the import process logic for GitImporter with optimized metadata updates
14
- * Language: TypeScript
15
- * Created-at: 2025-03-17T04:14:43.902Z
16
- * Authors: Claude 3.5 Sonnet (v5.0.1), Bard, Claude 3.5 Sonnet (v6.0.0), Claude 3.7 Sonnet (v6.3.0),
17
- * OpenRouter - Gemini Flash 2.0 (v6.4.0), OpenRouter - Gemini Flash 2.0 (v6.5.0),
18
- * together.ai - DeepSeek v3 (v6.6.0), Claude 3.7 Sonnet (v6.7.0), together.ai - DeepSeek v3 (v6.8.0)
19
- */
20
- class ImportProcessor {
21
- dbClient;
22
- gitRepo;
23
- repoOwner;
24
- repoName;
25
- ref;
26
- refType;
27
- options;
28
- logger;
29
- chatManager;
30
- messageManager;
31
- _metadataManager = null;
32
- _fileProcessor = null;
33
- _treeProcessor = null;
34
- constructor(dbClient, gitRepo, repoOwner, repoName, ref, refType, options, logger) {
35
- this.dbClient = dbClient;
36
- this.gitRepo = gitRepo;
37
- this.repoOwner = repoOwner;
38
- this.repoName = repoName;
39
- this.ref = ref;
40
- this.refType = refType;
41
- this.options = options;
42
- this.logger = logger;
43
- this.chatManager = new ChatManager(dbClient, gitRepo, repoOwner, repoName, ref, refType, options, logger);
44
- this.messageManager = new MessageManager(dbClient, logger);
45
- }
46
- /**
47
- * Sets up the import process with optimized metadata updates
48
- */
49
- async setupImport() {
50
- try {
51
- // Setup chat hierarchy
52
- const { refChatId, repoGroupId } = await this.chatManager.setupChatHierarchy();
53
- // Process import
54
- const currentCommit = await this.gitRepo.resolveRef(this.ref);
55
- const refChat = await this.chatManager.getChatById(refChatId);
56
- const meta = refChat?.meta || {};
57
- if (meta && meta.status === 'imported' && meta.commit) {
58
- await this.processExistingImport(meta, currentCommit, refChatId, repoGroupId);
59
- }
60
- else {
61
- await this.processNewImport(refChatId, repoGroupId);
62
- }
63
- return { refChatId, repoGroupId };
64
- }
65
- catch (error) {
66
- throw error;
67
- }
68
- }
69
- /**
70
- * Processes an existing import by checking for changes and performing an incremental import if necessary.
71
- */
72
- async processExistingImport(meta, currentCommit, refChatId, repoGroupId) {
73
- if (!meta.commit)
74
- throw new Error("No ref commit meta or hash found");
75
- const metadataManager = this.getMetadataManager();
76
- if (meta.commit.hash === currentCommit) {
77
- this.logger.log('Repository already imported with the same commit hash, skipping import');
78
- return;
79
- }
80
- try {
81
- this.logger.log(`Found previous import with commit hash: ${meta.commit.hash}`);
82
- // Mark the start of the import
83
- await metadataManager.markImportStarted(refChatId, this.ref);
84
- // Get the list of changed entries with their change types
85
- const changedEntries = await this.gitRepo.getChangedEntriesBetweenCommits(meta.commit?.hash || '', currentCommit, { includeFiles: true, includeDirectories: true });
86
- if (changedEntries.length > 0) {
87
- this.logger.log(`Found ${changedEntries.length} changed entries to process`);
88
- // Process the changed entries
89
- const directoryProcessor = new DirectoryProcessor(this.dbClient, this.gitRepo, this.getFileProcessor(repoGroupId), this.getTreeProcessor(repoGroupId), this.getMetadataManager(), this.chatManager, this.logger);
90
- await directoryProcessor.processChangedEntries(changedEntries, refChatId, repoGroupId);
91
- this.logger.log('Incremental import completed successfully');
92
- }
93
- else {
94
- this.logger.log('No files changed, updating commit hash only');
95
- }
96
- await metadataManager.markImportFinished(refChatId);
97
- }
98
- catch (error) {
99
- console.trace();
100
- this.logger.log('Incremental import failed: ', error instanceof Error ? error.message : String(error));
101
- await metadataManager.markImportFailed(refChatId, error);
102
- }
103
- }
104
- /**
105
- * Processes a new import by performing a full import of the repository.
106
- */
107
- async processNewImport(refChatId, repoGroupId) {
108
- const metadataManager = this.getMetadataManager();
109
- this.logger.log('Performing full import');
110
- await metadataManager.markImportStarted(refChatId, this.ref);
111
- // Process all files
112
- const directoryProcessor = new DirectoryProcessor(this.dbClient, this.gitRepo, this.getFileProcessor(repoGroupId), this.getTreeProcessor(repoGroupId), this.getMetadataManager(), this.chatManager, this.logger);
113
- await directoryProcessor.processFiles(refChatId);
114
- await metadataManager.markImportFinished(refChatId);
115
- this.logger.log('Full import completed successfully');
116
- }
117
- /**
118
- * Gets the chat hierarchy from git-repos down to git-ref
119
- */
120
- async getChatHierarchy(refChatId) {
121
- const hierarchy = [];
122
- let currentChatId = refChatId;
123
- while (currentChatId) {
124
- const chat = await this.chatManager.getChatById(currentChatId);
125
- if (!chat || !chat.id)
126
- break;
127
- hierarchy.unshift({
128
- id: chat.id,
129
- type: chat.type
130
- });
131
- currentChatId = chat.parentId || 0;
132
- }
133
- return hierarchy;
134
- }
135
- /**
136
- * Lazily initializes and returns the MetadataManager instance.
137
- */
138
- getMetadataManager() {
139
- if (!this._metadataManager) {
140
- this._metadataManager = new MetadataManager(this.dbClient, this.logger, this.gitRepo, this.chatManager);
141
- }
142
- return this._metadataManager;
143
- }
144
- /**
145
- * Lazily initializes and returns the FileProcessor instance.
146
- */
147
- getFileProcessor(repoGroupId) {
148
- if (!this._fileProcessor) {
149
- this._fileProcessor = new FileProcessor(this.dbClient, this.gitRepo, this.chatManager, this.options, repoGroupId, this.logger);
150
- }
151
- return this._fileProcessor;
152
- }
153
- /**
154
- * Lazily initializes and returns the TreeProcessor instance.
155
- */
156
- getTreeProcessor(repoGroupId) {
157
- if (!this._treeProcessor) {
158
- this._treeProcessor = new TreeProcessor(this.gitRepo, this.chatManager, this.getFileProcessor(repoGroupId), repoGroupId, this.logger);
159
- }
160
- return this._treeProcessor;
161
- }
162
- }
163
-
164
- export { ImportProcessor };
165
- //# sourceMappingURL=import-processor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"import-processor.js","sources":["../../../../src/importer/core/import-processor.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;;;AAWG;MAcU,eAAe,CAAA;AAQH,IAAA,QAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,QAAA;AACA,IAAA,GAAA;AACA,IAAA,OAAA;AACA,IAAA,OAAA;AACA,IAAA,MAAA;AAdJ,IAAA,WAAW;AACX,IAAA,cAAc;IACvB,gBAAgB,GAA2B,IAAI;IAC/C,cAAc,GAAyB,IAAI;IAC3C,cAAc,GAAyB,IAAI;AAEnD,IAAA,WAAA,CACqB,QAAwB,EACxB,OAAmB,EACnB,SAAiB,EACjB,QAAgB,EAChB,GAAW,EACX,OAAgB,EAChB,OAAsB,EACtB,MAAc,EAAA;QAPd,IAAQ,CAAA,QAAA,GAAR,QAAQ;QACR,IAAO,CAAA,OAAA,GAAP,OAAO;QACP,IAAS,CAAA,SAAA,GAAT,SAAS;QACT,IAAQ,CAAA,QAAA,GAAR,QAAQ;QACR,IAAG,CAAA,GAAA,GAAH,GAAG;QACH,IAAO,CAAA,OAAA,GAAP,OAAO;QACP,IAAO,CAAA,OAAA,GAAP,OAAO;QACP,IAAM,CAAA,MAAA,GAAN,MAAM;QAEvB,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAC9B,QAAQ,EACR,OAAO,EACP,SAAS,EACT,QAAQ,EACR,GAAG,EACH,OAAO,EACP,OAAO,EACP,MAAM,CACT;QAED,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,CAAC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