@codebolt/agent 6.1.6 → 6.1.7
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.
|
@@ -18,7 +18,6 @@ export declare class AtFileProcessorModifier extends BaseMessageModifier {
|
|
|
18
18
|
private findFiles;
|
|
19
19
|
private readManyFiles;
|
|
20
20
|
private readFileContent;
|
|
21
|
-
private getFilesInFolder;
|
|
22
21
|
private getFolderStructure;
|
|
23
22
|
private findLastUserMessage;
|
|
24
23
|
private getProjectPath;
|
|
@@ -182,40 +182,12 @@ class AtFileProcessorModifier extends base_1.BaseMessageModifier {
|
|
|
182
182
|
const resolvedPath = await this.resolvePath(folderPath, workspaceDirectories);
|
|
183
183
|
const structure = await this.getFolderStructure(resolvedPath);
|
|
184
184
|
filesRead.push(folderPath);
|
|
185
|
-
contextParts.push(`\
|
|
185
|
+
contextParts.push(`\nDirectory listing for @${folderPath}:\n`);
|
|
186
186
|
contextParts.push(structure);
|
|
187
|
-
// Also read files within the folder
|
|
188
|
-
const filesInFolder = await this.getFilesInFolder(resolvedPath);
|
|
189
|
-
// console.log(`Found ${filesInFolder.length} files in ${folderPath}:`, filesInFolder.map(f => path.basename(f)));
|
|
190
|
-
if (filesInFolder.length > 0) {
|
|
191
|
-
contextParts.push(`\n--- Files in ${folderPath} ---`);
|
|
192
|
-
for (const filePath of filesInFolder) {
|
|
193
|
-
try {
|
|
194
|
-
// console.log(`Attempting to read file: ${filePath}`);
|
|
195
|
-
const content = await this.readFileContent(filePath);
|
|
196
|
-
const relativePath = path.relative(resolvedPath, filePath);
|
|
197
|
-
const displayPath = `${folderPath}/${relativePath}`;
|
|
198
|
-
contextParts.push(`\nContent from @${displayPath}:\n`);
|
|
199
|
-
contextParts.push(content);
|
|
200
|
-
// console.log(`Successfully read file: ${displayPath} (${content.length} chars)`);
|
|
201
|
-
}
|
|
202
|
-
catch (error) {
|
|
203
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
204
|
-
const relativePath = path.relative(resolvedPath, filePath);
|
|
205
|
-
const displayPath = `${folderPath}/${relativePath}`;
|
|
206
|
-
console.error(`Error reading file ${displayPath}:`, errorMessage);
|
|
207
|
-
contextParts.push(`\nContent from @${displayPath}:\n`);
|
|
208
|
-
contextParts.push(`[Error reading file: ${errorMessage}]`);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
console.log(`No files found in ${folderPath} (resolved to ${resolvedPath})`);
|
|
214
|
-
}
|
|
215
187
|
}
|
|
216
188
|
catch (error) {
|
|
217
189
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
218
|
-
contextParts.push(`\
|
|
190
|
+
contextParts.push(`\nDirectory listing for @${folderPath}:\n`);
|
|
219
191
|
contextParts.push(`[Error reading folder ${folderPath}: ${errorMessage}]`);
|
|
220
192
|
}
|
|
221
193
|
}
|
|
@@ -360,26 +332,6 @@ class AtFileProcessorModifier extends base_1.BaseMessageModifier {
|
|
|
360
332
|
const content = await fs.readFile(filePath, 'utf-8');
|
|
361
333
|
return content;
|
|
362
334
|
}
|
|
363
|
-
async getFilesInFolder(folderPath) {
|
|
364
|
-
try {
|
|
365
|
-
const entries = await fs.readdir(folderPath, { withFileTypes: true });
|
|
366
|
-
const files = [];
|
|
367
|
-
for (const entry of entries) {
|
|
368
|
-
if (entry.isFile() && !entry.name.startsWith('.')) {
|
|
369
|
-
const filePath = path.join(folderPath, entry.name);
|
|
370
|
-
if (await this.isReadableTextFile(filePath)) {
|
|
371
|
-
files.push(path.join(folderPath, entry.name));
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
// Limit number of files to avoid overwhelming output
|
|
376
|
-
return files.slice(0, 10);
|
|
377
|
-
}
|
|
378
|
-
catch (error) {
|
|
379
|
-
console.error('Error reading files in folder:', error);
|
|
380
|
-
return [];
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
335
|
async getFolderStructure(folderPath) {
|
|
384
336
|
// Check if folder exists and is readable
|
|
385
337
|
const stats = await fs.stat(folderPath);
|
|
@@ -388,30 +340,10 @@ class AtFileProcessorModifier extends base_1.BaseMessageModifier {
|
|
|
388
340
|
}
|
|
389
341
|
// Read directory structure
|
|
390
342
|
const entries = await fs.readdir(folderPath, { withFileTypes: true });
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return -1;
|
|
396
|
-
if (!a.isDirectory() && b.isDirectory())
|
|
397
|
-
return 1;
|
|
398
|
-
return a.name.localeCompare(b.name);
|
|
399
|
-
});
|
|
400
|
-
for (const entry of sortedEntries.slice(0, 50)) { // Limit to 50 entries
|
|
401
|
-
if (entry.name.startsWith('.'))
|
|
402
|
-
continue; // Skip hidden files
|
|
403
|
-
if (entry.isDirectory()) {
|
|
404
|
-
lines.push(`${path.basename(folderPath)}/${entry.name}/`);
|
|
405
|
-
}
|
|
406
|
-
else {
|
|
407
|
-
const filePath = path.join(folderPath, entry.name);
|
|
408
|
-
const fileStats = await fs.stat(filePath);
|
|
409
|
-
const size = fileStats.size < 1024 ? `${fileStats.size}B` : `${Math.round(fileStats.size / 1024)}KB`;
|
|
410
|
-
lines.push(`${path.basename(folderPath)}/${entry.name} (${size})`);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
if (entries.length > 50) {
|
|
414
|
-
lines.push(`... and ${entries.length - 50} more items`);
|
|
343
|
+
const maxDirectoryEntries = 1000;
|
|
344
|
+
const lines = entries.slice(0, maxDirectoryEntries).map((entry) => entry.name);
|
|
345
|
+
if (entries.length > maxDirectoryEntries) {
|
|
346
|
+
lines.push(`\u2026 and ${entries.length - maxDirectoryEntries} more entries`);
|
|
415
347
|
}
|
|
416
348
|
return lines.join('\n');
|
|
417
349
|
}
|