This commit is contained in:
2025-12-15 15:11:22 +00:00
parent 8662b73adb
commit 19ba58ca40
3 changed files with 231 additions and 25 deletions

View File

@@ -494,32 +494,27 @@ export class FilesystemTool extends BaseToolWrapper {
const items = await dir.list();
for (const item of items) {
const itemPath = plugins.path.join(dirPath, item);
const itemRelPath = relativePath ? `${relativePath}/${item}` : item;
// item is IDirectoryEntry with name, path, isFile, isDirectory properties
const itemPath = item.path;
const itemRelPath = relativePath ? `${relativePath}/${item.name}` : item.name;
const isDir = item.isDirectory;
try {
const stats = await this.smartfs.file(itemPath).stat();
const isDir = stats.isDirectory;
const entry: ITreeEntry = {
path: itemPath,
relativePath: itemRelPath,
isDir,
depth,
};
const entry: ITreeEntry = {
path: itemPath,
relativePath: itemRelPath,
isDir,
depth,
};
if (showSizes && !isDir && item.stats) {
entry.size = item.stats.size;
}
if (showSizes && !isDir) {
entry.size = stats.size;
}
entries.push(entry);
entries.push(entry);
// Recurse into directories
if (isDir && depth < maxDepth) {
await collectEntries(itemPath, depth + 1, itemRelPath);
}
} catch {
// Skip items we can't stat
// Recurse into directories
if (isDir && depth < maxDepth) {
await collectEntries(itemPath, depth + 1, itemRelPath);
}
}
};
@@ -607,13 +602,20 @@ export class FilesystemTool extends BaseToolWrapper {
const dir = this.smartfs.directory(basePath).recursive().filter(pattern);
const matches = await dir.list();
// Return file paths relative to base path for readability
const files = matches.map((entry) => ({
path: entry.path,
relativePath: plugins.path.relative(basePath, entry.path),
isDirectory: entry.isDirectory,
}));
return {
success: true,
result: {
pattern,
basePath,
matches,
count: matches.length,
files,
count: files.length,
},
};
}