@gitsense/gscb-git-tools 0.5.0 → 0.7.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.
- package/dist/cjs/common/logger.js +39 -14
- package/dist/cjs/common/logger.js.map +1 -1
- package/dist/cjs/importer/core/directory-processor.js +16 -9
- package/dist/cjs/importer/core/directory-processor.js.map +1 -1
- package/dist/cjs/importer/core/import-processor.js +70 -6
- package/dist/cjs/importer/core/import-processor.js.map +1 -1
- package/dist/cjs/importer/core/importer.js +26 -7
- package/dist/cjs/importer/core/importer.js.map +1 -1
- package/dist/cjs/importer/file-processor.js +72 -40
- package/dist/cjs/importer/file-processor.js.map +1 -1
- package/dist/cjs/importer/tree-processor.js +35 -8
- package/dist/cjs/importer/tree-processor.js.map +1 -1
- package/dist/esm/common/logger.js +39 -14
- package/dist/esm/common/logger.js.map +1 -1
- package/dist/esm/importer/core/directory-processor.js +16 -9
- package/dist/esm/importer/core/directory-processor.js.map +1 -1
- package/dist/esm/importer/core/import-processor.js +70 -6
- package/dist/esm/importer/core/import-processor.js.map +1 -1
- package/dist/esm/importer/core/importer.js +26 -7
- package/dist/esm/importer/core/importer.js.map +1 -1
- package/dist/esm/importer/file-processor.js +72 -40
- package/dist/esm/importer/file-processor.js.map +1 -1
- package/dist/esm/importer/tree-processor.js +35 -8
- package/dist/esm/importer/tree-processor.js.map +1 -1
- package/dist/index.d.ts +46 -26
- package/package.json +2 -2
|
@@ -4,13 +4,14 @@ import { getHighlightSyntax, detectLanguage } from './language-utils.js';
|
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
* Component: File Processor
|
|
7
|
-
* Block-UUID:
|
|
8
|
-
* Parent-UUID:
|
|
9
|
-
* Version: 5.
|
|
10
|
-
* Description:
|
|
7
|
+
* Block-UUID: e6936ca9-9ce1-429c-b1c8-080f62c654f9
|
|
8
|
+
* Parent-UUID: b4e137b5-4954-4a9f-b3ef-c87d0a75efc9
|
|
9
|
+
* Version: 5.5.0
|
|
10
|
+
* Description: Fix double file read by returning token count from create/update methods
|
|
11
11
|
* Language: TypeScript
|
|
12
12
|
* Created-at: 2025-09-18T21:48:15.228Z
|
|
13
|
-
*
|
|
13
|
+
* Updated-at: 2026-05-13T15:00:00.000Z
|
|
14
|
+
* Authors: Claude 3.5 Sonnet (v3.0.0), Bard, together.ai - DeepSeek v3 (v3.3.0), together.ai - DeepSeek v3 (v4.0.0), together.ai - DeepSeek v3 (v5.0.0), Claude 3.7 Sonnet (v5.1.0), Qwen 3 Coder 480B - Cerebras (v5.2.0), Claude 4.0 Sonnet (v5.3.0), GLM-4.7 (v5.4.0), GLM-4.7 (v5.5.0)
|
|
14
15
|
*/
|
|
15
16
|
class FileProcessor {
|
|
16
17
|
dbClient;
|
|
@@ -40,26 +41,84 @@ class FileProcessor {
|
|
|
40
41
|
const wordCount = text.split(/\s+/).filter(Boolean).length;
|
|
41
42
|
return Math.ceil(wordCount * 1.33);
|
|
42
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Determines if a file should be skipped and returns the reason.
|
|
46
|
+
*/
|
|
47
|
+
async getSkipReason(filePath) {
|
|
48
|
+
const { skipPatterns, includePatterns, skipBinaryFiles, maxFileSize } = this.options;
|
|
49
|
+
// Check against skip patterns first (fastest check)
|
|
50
|
+
if (skipPatterns?.some(pattern => pattern.test(filePath))) {
|
|
51
|
+
return 'pattern';
|
|
52
|
+
}
|
|
53
|
+
// Check if file is binary (if skipBinaryFiles is enabled)
|
|
54
|
+
if (skipBinaryFiles) {
|
|
55
|
+
try {
|
|
56
|
+
const isBinary = await FSUtils.isBinaryFile(filePath);
|
|
57
|
+
if (isBinary) {
|
|
58
|
+
return 'binary';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
this.logger.log(`Error checking if file '${filePath}' is binary: ${error instanceof Error ? error.message : String(error)}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Check against include patterns if specified
|
|
66
|
+
if (includePatterns?.length && !includePatterns.some(pattern => pattern.test(filePath))) {
|
|
67
|
+
return 'include_pattern';
|
|
68
|
+
}
|
|
69
|
+
// Check file size
|
|
70
|
+
if (maxFileSize) {
|
|
71
|
+
try {
|
|
72
|
+
const fileInfo = await this.gitRepo.getFileInfo(filePath);
|
|
73
|
+
if (fileInfo.size > maxFileSize) {
|
|
74
|
+
return 'max_size';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
// If we can't get file info, we probably can't process it anyway, so skip
|
|
79
|
+
return 'file_info_error';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
43
84
|
/**
|
|
44
85
|
* Processes a file and returns its GitCommitInfo.
|
|
45
86
|
* If the file already exists in the database, it will update the existing chat.
|
|
87
|
+
* Returns null if the file was skipped.
|
|
46
88
|
*/
|
|
47
89
|
async processFile(filePath, parentChatId, orderWeight) {
|
|
48
90
|
try {
|
|
91
|
+
// Check if we should skip this file
|
|
92
|
+
const skipReason = await this.getSkipReason(filePath);
|
|
93
|
+
if (skipReason) {
|
|
94
|
+
this.logger.emit('file_skip', { path: filePath, reason: skipReason });
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
// Emit file start event
|
|
98
|
+
this.logger.emit('file_start', { path: filePath });
|
|
49
99
|
// Check if a chat for this file already exists
|
|
50
100
|
const fileName = path.basename(filePath);
|
|
51
101
|
const childChats = await this.dbClient.getChatsByParentId(parentChatId);
|
|
52
102
|
const existingFileChat = childChats.find(chat => chat.type === 'git-blob' &&
|
|
53
103
|
chat.name === fileName &&
|
|
54
104
|
chat.meta?.path === filePath);
|
|
105
|
+
let commitInfo;
|
|
106
|
+
let fileTokens;
|
|
55
107
|
if (existingFileChat) {
|
|
56
108
|
// Update existing file chat
|
|
57
|
-
|
|
109
|
+
const result = await this.updateExistingFile(existingFileChat.id, filePath);
|
|
110
|
+
commitInfo = result.commitInfo;
|
|
111
|
+
fileTokens = result.tokens;
|
|
58
112
|
}
|
|
59
113
|
else {
|
|
60
114
|
// Create new file chat
|
|
61
|
-
|
|
115
|
+
const result = await this.createNewFile(filePath, parentChatId, orderWeight);
|
|
116
|
+
commitInfo = result.commitInfo;
|
|
117
|
+
fileTokens = result.tokens;
|
|
62
118
|
}
|
|
119
|
+
// Emit file done event with the token count we already calculated
|
|
120
|
+
this.logger.emit('file_done', { path: filePath, tokens: fileTokens });
|
|
121
|
+
return commitInfo;
|
|
63
122
|
}
|
|
64
123
|
catch (error) {
|
|
65
124
|
throw new Error(`Failed to process file '${filePath}': ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -67,6 +126,7 @@ class FileProcessor {
|
|
|
67
126
|
}
|
|
68
127
|
/**
|
|
69
128
|
* Creates a new file chat.
|
|
129
|
+
* Returns both the commit info and the calculated token count.
|
|
70
130
|
*/
|
|
71
131
|
async createNewFile(filePath, parentChatId, orderWeight) {
|
|
72
132
|
const fileInfo = await this.gitRepo.getFileInfo(filePath);
|
|
@@ -112,10 +172,11 @@ class FileProcessor {
|
|
|
112
172
|
}
|
|
113
173
|
};
|
|
114
174
|
await this.chatManager.createChat(type, path.basename(filePath), parentChatId, this.repoGroupId, meta, content.toString(), orderWeight);
|
|
115
|
-
return commitInfo;
|
|
175
|
+
return { commitInfo, tokens: contentTokens };
|
|
116
176
|
}
|
|
117
177
|
/**
|
|
118
178
|
* Updates an existing file chat.
|
|
179
|
+
* Returns both the commit info and the calculated token count.
|
|
119
180
|
*/
|
|
120
181
|
async updateExistingFile(chatId, filePath) {
|
|
121
182
|
// Get the current file information
|
|
@@ -130,7 +191,8 @@ class FileProcessor {
|
|
|
130
191
|
// Skip update if the commit hash hasn't changed
|
|
131
192
|
if (oldMeta.commit?.hash === commitInfo.hash) {
|
|
132
193
|
this.logger.log(`Skipping update for file '${filePath}' (commit hash unchanged)`);
|
|
133
|
-
|
|
194
|
+
// Return 0 tokens since we didn't actually process the content
|
|
195
|
+
return { commitInfo, tokens: 0 };
|
|
134
196
|
}
|
|
135
197
|
// Estimate tokens for content and metadata
|
|
136
198
|
const contentTokens = this.estimateTokens(content.toString());
|
|
@@ -173,37 +235,7 @@ class FileProcessor {
|
|
|
173
235
|
await this.chatManager.updateMessage(mainMessage.id, {
|
|
174
236
|
message: gitBlobMessage
|
|
175
237
|
});
|
|
176
|
-
return commitInfo;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Determines whether a file should be skipped based on the provided patterns.
|
|
180
|
-
*/
|
|
181
|
-
async shouldSkipFile(filePath) {
|
|
182
|
-
const { skipPatterns, includePatterns, skipBinaryFiles } = this.options;
|
|
183
|
-
// Check against skip patterns first (fastest check)
|
|
184
|
-
if (skipPatterns?.some(pattern => pattern.test(filePath))) {
|
|
185
|
-
this.logger.log(`Skipping file '${filePath}' (matched skip pattern)`);
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
188
|
-
// Check if file is binary (if skipBinaryFiles is enabled)
|
|
189
|
-
if (skipBinaryFiles) {
|
|
190
|
-
try {
|
|
191
|
-
const isBinary = await FSUtils.isBinaryFile(filePath);
|
|
192
|
-
if (isBinary) {
|
|
193
|
-
this.logger.log(`Skipping binary file '${filePath}'`);
|
|
194
|
-
return true;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
this.logger.log(`Error checking if file '${filePath}' is binary: ${error instanceof Error ? error.message : String(error)}`);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
// Check against include patterns if specified
|
|
202
|
-
if (includePatterns?.length && !includePatterns.some(pattern => pattern.test(filePath))) {
|
|
203
|
-
this.logger.log(`Skipping file '${filePath}' (did not match include pattern)`);
|
|
204
|
-
return true;
|
|
205
|
-
}
|
|
206
|
-
return false;
|
|
238
|
+
return { commitInfo, tokens: contentTokens };
|
|
207
239
|
}
|
|
208
240
|
}
|
|
209
241
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-processor.js","sources":["../../../src/importer/file-processor.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA
|
|
1
|
+
{"version":3,"file":"file-processor.js","sources":["../../../src/importer/file-processor.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;;;;;;AAUG;MAcU,aAAa,CAAA;AAED,IAAA,QAAA;AACA,IAAA,OAAA;AACA,IAAA,WAAA;AACA,IAAA,SAAA;AACA,IAAA,OAAA;AACA,IAAA,OAAA;AACA,IAAA,OAAA;AACA,IAAA,WAAA;AACA,IAAA,MAAA;AATrB,IAAA,WAAA,CACqB,QAAwB,EACxB,OAAmB,EACnB,WAAwB,EACxB,SAAiB,EACjB,OAAe,EACf,OAAgB,EAChB,OAAsB,EACtB,WAAmB,EACnB,MAAc,EAAA;QARd,IAAQ,CAAA,QAAA,GAAR,QAAQ;QACR,IAAO,CAAA,OAAA,GAAP,OAAO;QACP,IAAW,CAAA,WAAA,GAAX,WAAW;QACX,IAAS,CAAA,SAAA,GAAT,SAAS;QACT,IAAO,CAAA,OAAA,GAAP,OAAO;QACP,IAAO,CAAA,OAAA,GAAP,OAAO;QACP,IAAO,CAAA,OAAA,GAAP,OAAO;QACP,IAAW,CAAA,WAAA,GAAX,WAAW;QACX,IAAM,CAAA,MAAA,GAAN,MAAM;;AAI3B;;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,aAAa,CAAC,QAAgB,EAAA;AAChC,QAAA,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,OAAO;;AAGpF,QAAA,IAAI,YAAY,EAAE,IAAI,CAAC,OAAO,IAAI,OAAO,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:
|
|
7
|
+
* Block-UUID: a3b2c07c-a9c7-446e-978e-fba599e6e584
|
|
8
|
+
* Parent-UUID: f14f5d7f-deb7-4610-bfc7-b7f99120de05
|
|
9
|
+
* Version: 4.4.0
|
|
10
|
+
* Description: Make countFiles public so it can be called by DirectoryProcessor
|
|
11
11
|
* Language: TypeScript
|
|
12
12
|
* Created-at: 2025-09-18T21:48:15.228Z
|
|
13
|
-
*
|
|
13
|
+
* Updated-at: 2026-05-13T15:45:00.000Z
|
|
14
|
+
* Authors: Claude 3.5 Sonnet (v3.0.0), Bard, Claude 3.5 Sonnet (v3.1.0), together.ai - DeepSeek v3 (v3.3.0), Claude 3.7 Sonnet (v3.4.0), together.ai - DeepSeek v3 (v4.0.0), Qwen 3 Coder 480B - Cerebras (v4.1.0), Claude 4.0 Sonnet (v4.2.0), GLM-4.7 (v4.3.0), GLM-4.7 (v4.4.0)
|
|
14
15
|
*/
|
|
15
16
|
class TreeProcessor {
|
|
16
17
|
gitRepo;
|
|
@@ -36,6 +37,12 @@ class TreeProcessor {
|
|
|
36
37
|
*/
|
|
37
38
|
async processFiles(rootChatId) {
|
|
38
39
|
try {
|
|
40
|
+
// Pre-scan to get the total file count for the progress bar
|
|
41
|
+
const totalFiles = await this.countFiles('');
|
|
42
|
+
this.logger.emit('scan_complete', {
|
|
43
|
+
total_files: totalFiles,
|
|
44
|
+
mode: 'full'
|
|
45
|
+
});
|
|
39
46
|
// Start processing from the root directory. Empty string is root.
|
|
40
47
|
await this.processDirectory('', rootChatId);
|
|
41
48
|
}
|
|
@@ -43,6 +50,27 @@ class TreeProcessor {
|
|
|
43
50
|
throw new Error(`Failed to process files: ${error instanceof Error ? error.message : String(error)}`);
|
|
44
51
|
}
|
|
45
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Recursively counts files that will be processed (not skipped).
|
|
55
|
+
* Made public to allow DirectoryProcessor to call it.
|
|
56
|
+
*/
|
|
57
|
+
async countFiles(dirPath) {
|
|
58
|
+
const entries = await this.gitRepo.listDirectory(dirPath);
|
|
59
|
+
let count = 0;
|
|
60
|
+
for (const entry of entries) {
|
|
61
|
+
if (entry.type === 'tree') {
|
|
62
|
+
count += await this.countFiles(dirPath + (dirPath === '' ? '' : '/') + entry.path);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// Check if we would skip this file
|
|
66
|
+
const fullPath = dirPath + (dirPath === '' ? '' : '/') + entry.path;
|
|
67
|
+
if (!(await this.fileProcessor.getSkipReason(fullPath))) {
|
|
68
|
+
count++;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return count;
|
|
73
|
+
}
|
|
46
74
|
/**
|
|
47
75
|
* Recursively processes a directory and its contents.
|
|
48
76
|
* Returns the latest GitCommitInfo for the directory.
|
|
@@ -74,12 +102,11 @@ class TreeProcessor {
|
|
|
74
102
|
}
|
|
75
103
|
for (const file of files) {
|
|
76
104
|
const { path } = file;
|
|
77
|
-
if
|
|
78
|
-
continue;
|
|
79
|
-
orderWeight += 10;
|
|
105
|
+
// FileProcessor now handles skip checks internally and returns null if skipped
|
|
80
106
|
const fileCommit = await this.fileProcessor.processFile(dirPath + (dirPath === "" ? "" : "/") + path, dirChatId, orderWeight);
|
|
81
107
|
if (fileCommit)
|
|
82
108
|
childCommits.push(fileCommit);
|
|
109
|
+
orderWeight += 10;
|
|
83
110
|
}
|
|
84
111
|
// Determine the latest commit for the directory
|
|
85
112
|
const latestCommit = Utils.getLatestCommit(childCommits);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-processor.js","sources":["../../../src/importer/tree-processor.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA
|
|
1
|
+
{"version":3,"file":"tree-processor.js","sources":["../../../src/importer/tree-processor.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;;;;;;AAUG;MAcU,aAAa,CAAA;AAED,IAAA,OAAA;AACA,IAAA,WAAA;AACA,IAAA,aAAA;AACA,IAAA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AAS,CAAC,SAAS,CAAC,OAAO,CAAC;QACnD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,MAAM,IAAI,GAAG,UAAU;AAEvB,QAAA,MAAM,UAAU,GAAe;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC;SACjB;AAED,QAAA,MAAM,IAAI,GAAgB;YACtB,IAAI;AACJ,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,IAAI,EAAE,cAAc;AACpB,YAAA,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;AAC5B,YAAA,MAAM,EAAE,IAAI;AACZ,YAAA,MAAM,EAAE,IAAI;YACZ,UAAU;AACV,YAAA,MAAM,EAAE;AACJ,gBAAA,MAAM,EAAE,WAAW;AACnB,gBAAA,SAAS,EAAE,GAAG;AACd,gBAAA,UAAU,EAAE;AACf;SACJ;;AAGD,QAAA,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAC5C,IAAI,EACJ,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EACtB,YAAY,EACZ,IAAI,CAAC,WAAW,EAChB,IAAI,EACJ,EAAE,EACF,WAAW,CACd;AAED,QAAA,OAAO,MAAM;;AAEpB;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,16 +3,17 @@ import { Repository, GitCommitInfo } from '@gitsense/gscb-git';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Component: Shared Types
|
|
6
|
-
* Block-UUID:
|
|
7
|
-
* Parent-UUID:
|
|
8
|
-
* Version:
|
|
9
|
-
* Description: Add
|
|
6
|
+
* Block-UUID: 63f9f2ef-c6b2-47d4-87d4-d39946090fa1
|
|
7
|
+
* Parent-UUID: a4699409-238b-4360-9ac0-ca441128fe55
|
|
8
|
+
* Version: 6.0.0
|
|
9
|
+
* Description: Add structured output types and ImportEvent interface
|
|
10
10
|
* Language: TypeScript
|
|
11
11
|
* Created-at: 2025-02-28T12:00:00.000Z
|
|
12
|
-
* Updated-at:
|
|
12
|
+
* Updated-at: 2026-05-13T14:30:00.000Z
|
|
13
13
|
* Authors: OpenRouter - DeepSeek v3 (v1.0.0), Claude 3.5 Sonnet (v2.0.0), Bard, together.ai - DeepSeek v3 (v3.2.0),
|
|
14
14
|
* DeepSeek v3 (v4.0.0), together.ai - DeepSeek v3 (v5.0.0), Qwen 3 Coder 480B - Cerebras (v5.1.0),
|
|
15
|
-
* Qwen 3 Coder 480B - Cerebras (v5.2.0), Qwen 3 Coder 480B - Cerebras (v5.3.0), Claude 4.0 Sonnet (v5.4.0)
|
|
15
|
+
* Qwen 3 Coder 480B - Cerebras (v5.2.0), Qwen 3 Coder 480B - Cerebras (v5.3.0), Claude 4.0 Sonnet (v5.4.0),
|
|
16
|
+
* GLM-4.7 (v6.0.0)
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -26,6 +27,7 @@ interface ImportOptions {
|
|
|
26
27
|
promptName?: string;
|
|
27
28
|
skipBinaryFiles?: boolean;
|
|
28
29
|
verbose?: boolean;
|
|
30
|
+
structuredOutput?: boolean;
|
|
29
31
|
}
|
|
30
32
|
/**
|
|
31
33
|
* Allowed group types
|
|
@@ -47,16 +49,29 @@ interface ChatManagerOptions {
|
|
|
47
49
|
skipPatterns?: RegExp[];
|
|
48
50
|
includePatterns?: RegExp[];
|
|
49
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Event types for structured output
|
|
54
|
+
*/
|
|
55
|
+
type ImportEventType = 'init' | 'resume_detected' | 'scan_complete' | 'plan' | 'file_start' | 'file_done' | 'file_skip' | 'complete' | 'error';
|
|
56
|
+
/**
|
|
57
|
+
* Event payload for structured output
|
|
58
|
+
*/
|
|
59
|
+
interface ImportEvent {
|
|
60
|
+
type: ImportEventType;
|
|
61
|
+
timestamp: string;
|
|
62
|
+
data: Record<string, unknown>;
|
|
63
|
+
}
|
|
50
64
|
|
|
51
65
|
/**
|
|
52
66
|
* Component: Git Repository Importer (Core)
|
|
53
|
-
* Block-UUID:
|
|
54
|
-
* Parent-UUID:
|
|
55
|
-
* Version: 6.
|
|
56
|
-
* Purpose:
|
|
67
|
+
* Block-UUID: 23dda2c0-82ba-4d2e-bf83-c26bc2d394da
|
|
68
|
+
* Parent-UUID: 90d78242-374a-4a78-9ce6-e502bf172d87
|
|
69
|
+
* Version: 6.7.0
|
|
70
|
+
* Purpose: Add structured output event emission (init, complete, error)
|
|
57
71
|
* Language: TypeScript
|
|
58
72
|
* Created-at: 2025-03-15T05:57:33.811Z
|
|
59
|
-
*
|
|
73
|
+
* Updated-at: 2026-05-13T14:46:00.000Z
|
|
74
|
+
* 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), GLM-4.7 (v6.7.0)
|
|
60
75
|
*/
|
|
61
76
|
|
|
62
77
|
declare class GitImporter {
|
|
@@ -95,43 +110,48 @@ declare class GitImporter {
|
|
|
95
110
|
|
|
96
111
|
/**
|
|
97
112
|
* Component: Logger
|
|
98
|
-
* Block-UUID:
|
|
99
|
-
* Parent-UUID:
|
|
100
|
-
* Version: 1.0
|
|
101
|
-
* Purpose:
|
|
113
|
+
* Block-UUID: 7c6851c4-f157-4955-a840-11b6e8b9b513
|
|
114
|
+
* Parent-UUID: 7c3b5d3f-96bd-4626-b408-a3322720c1d3
|
|
115
|
+
* Version: 2.1.0
|
|
116
|
+
* Purpose: Ensure error messages always go to stderr, even in structured mode
|
|
102
117
|
* Language: TypeScript
|
|
103
118
|
* Created-at: 2025-03-12T18:06:11.373Z
|
|
104
|
-
*
|
|
119
|
+
* Updated-at: 2026-05-13T15:10:00.000Z
|
|
120
|
+
* Authors: OpenRouter - Gemini Flash 2.0 (v1.0.0), GLM-4.7 (v2.0.0), GLM-4.7 (v2.1.0)
|
|
105
121
|
*/
|
|
106
122
|
declare class Logger {
|
|
107
123
|
private readonly verbose;
|
|
108
|
-
|
|
124
|
+
private readonly structuredOutput;
|
|
125
|
+
constructor(verbose?: boolean, structuredOutput?: boolean);
|
|
126
|
+
/**
|
|
127
|
+
* Emits a structured event to stdout.
|
|
128
|
+
* Only writes if structuredOutput is enabled.
|
|
129
|
+
*/
|
|
130
|
+
emit(type: string, data?: Record<string, unknown>): void;
|
|
109
131
|
/**
|
|
110
132
|
* Logs messages to the console if verbose mode is enabled.
|
|
133
|
+
* Suppressed in structured mode to avoid polluting the NDJSON stream.
|
|
111
134
|
*/
|
|
112
135
|
log(message: string, details?: unknown, isError?: boolean): void;
|
|
113
136
|
/**
|
|
114
137
|
* Logs a debug message.
|
|
115
|
-
*
|
|
116
|
-
* @param details - Optional details to include in the log.
|
|
138
|
+
* Suppressed in structured mode.
|
|
117
139
|
*/
|
|
118
140
|
debug(message: string, details?: unknown): void;
|
|
119
141
|
/**
|
|
120
142
|
* Logs an info message.
|
|
121
|
-
*
|
|
122
|
-
* @param details - Optional details to include in the log.
|
|
143
|
+
* Suppressed in structured mode.
|
|
123
144
|
*/
|
|
124
145
|
info(message: string, details?: unknown): void;
|
|
125
146
|
/**
|
|
126
147
|
* Logs a warning message.
|
|
127
|
-
*
|
|
128
|
-
* @param details - Optional details to include in the log.
|
|
148
|
+
* Suppressed in structured mode.
|
|
129
149
|
*/
|
|
130
150
|
warn(message: string, details?: unknown): void;
|
|
131
151
|
/**
|
|
132
152
|
* Logs an error message.
|
|
133
|
-
*
|
|
134
|
-
*
|
|
153
|
+
* IMPORTANT: Always writes to stderr, even in structured mode.
|
|
154
|
+
* This ensures non-fatal errors (e.g., rollback failures) are visible for debugging.
|
|
135
155
|
*/
|
|
136
156
|
error(message: string, error?: unknown): void;
|
|
137
157
|
}
|
|
@@ -214,4 +234,4 @@ declare class ChatManager {
|
|
|
214
234
|
getChatById(chatId: number): Promise<Chat>;
|
|
215
235
|
}
|
|
216
236
|
|
|
217
|
-
export { ChatManager, GitImporter, type ImportOptions, Logger };
|
|
237
|
+
export { ChatManager, GitImporter, type ImportEvent, type ImportEventType, type ImportOptions, Logger };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitsense/gscb-git-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Git repository tools for the GitSense Chat Bridge (GSCB)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"events": "^3.3.0",
|
|
27
|
-
"@gitsense/gscb-db": "^0.
|
|
27
|
+
"@gitsense/gscb-db": "^0.6.0",
|
|
28
28
|
"@gitsense/gscb-git": "^0.2.0",
|
|
29
29
|
"@gitsense/gscb-utils": "^0.1.0"
|
|
30
30
|
},
|