executeImpl method
Implement the actual tool logic
params are the validated parameters (never null here)
Returns the result data to send in the response
Implementation
@override
Future<dynamic> executeImpl(Map<String, dynamic> params) async {
final project = ServerPodLocator.getProject();
if (project == null || !project.isValid) {
return {'error': 'Not a valid ServerPod project'};
}
final directory = params['directory'] as String?;
final depth = params['depth'] as int? ?? 3;
final includeFiles = params['include_files'] as bool? ?? true;
final excludePatterns = params['exclude_patterns'] as List<String>?;
// Determine scan path
String scanPath = project.rootPath;
if (directory != null && directory.isNotEmpty) {
scanPath = p.join(project.rootPath, directory);
}
final scanDir = Directory(scanPath);
if (!scanDir.existsSync()) {
return {
'error': 'Directory not found',
'path': scanPath,
};
}
// Build file tree
final tree = await _buildTree(
scanDir,
depth,
includeFiles,
excludePatterns ?? _getDefaultExcludes(),
0,
);
return {
'root': tree.toJson(),
'path': scanPath,
'relativePath': directory ?? '.',
'depth': depth,
'excludedPatterns': excludePatterns ?? _getDefaultExcludes(),
};
}