Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/core/models/kimi.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Kimi"
description: "This guide walks you through setting up your Kimi (Moonshot AI) API key within Eigent to enable the Kimi model for your AI workforce."
title: 'Kimi'
description: 'This guide walks you through setting up your Kimi (Moonshot AI) API key within Eigent to enable the Kimi model for your AI workforce.'
---

### Prerequisites
Expand Down
63 changes: 43 additions & 20 deletions electron/main/fileReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,13 @@ export class FileReader {
'terminal_logs',
];

private getFilesRecursive(dirPath: string, basePath: string): FileInfo[] {
private getFilesRecursive(
dirPath: string,
basePath: string,
baseReal?: string
): FileInfo[] {
try {
const resolvedBase = baseReal ?? fs.realpathSync(basePath);
const files = fs.readdirSync(dirPath);
const result: FileInfo[] = [];

Expand All @@ -579,25 +584,43 @@ export class FileReader {
if (this.hiddenFolders.includes(file)) continue;

const filePath = path.join(dirPath, file);
const stats = fs.statSync(filePath);
const isFolder = stats.isDirectory();
const relativePath = path.relative(basePath, dirPath);

const fileInfo: FileInfo = {
path: filePath,
name: file,
type: isFolder
? 'folder'
: file.split('.').pop()?.toLowerCase() || '',
isFolder: isFolder,
relativePath: relativePath === '' ? '' : relativePath,
};

result.push(fileInfo);

if (isFolder) {
const subFiles = this.getFilesRecursive(filePath, basePath);
result.push(...subFiles);
try {
const stats = fs.lstatSync(filePath);
if (stats.isSymbolicLink()) continue;
const realPath = fs.realpathSync(filePath);
const relativeToBase = path.relative(resolvedBase, realPath);
if (
relativeToBase.startsWith('..') ||
path.isAbsolute(relativeToBase)
) {
continue;
}
const isFolder = stats.isDirectory();
const relativePath = path.relative(basePath, dirPath);

const fileInfo: FileInfo = {
path: filePath,
name: file,
type: isFolder
? 'folder'
: file.split('.').pop()?.toLowerCase() || '',
isFolder: isFolder,
relativePath: relativePath === '' ? '' : relativePath,
};

result.push(fileInfo);

if (isFolder) {
const subFiles = this.getFilesRecursive(
filePath,
basePath,
resolvedBase
);
result.push(...subFiles);
}
} catch (fileErr) {
console.warn('Skipping inaccessible file:', filePath, fileErr);
continue;
}
}

Expand Down