executeImpl method

  1. @override
Future executeImpl(
  1. Map<String, dynamic> params
)
override

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 skillName = params['skill_name'] as String;
  final category = params['category'] as String? ?? 'authentication';
  final source = params['source'] as String? ?? 'any';

  // Get project to locate skills directory
  final project = ServerPodLocator.getProject();

  // Try to find the skill file
  final skillFile = await _findSkillFile(
    skillName,
    category,
    project?.rootPath,
    source,
  );

  if (skillFile == null) {
    // Get available skills for helpful error message
    final availableSkills = await _getAvailableSkills();
    return {
      'error': 'Skill not found',
      'message': 'Could not find skill "$skillName" in category "$category". '
          'Use list_skills to see all available skills.',
      'skill_name': skillName,
      'category': category,
      'source': source,
      'availableSkills': availableSkills,
    };
  }

  // Read skill content
  final content = await skillFile.readAsString();

  // Load metadata if available
  final metadata = await _loadMetadata(skillFile);

  // Extract template variables from the project context
  final templateVars = await _extractTemplateVars(project);

  // Determine if this is a built-in or custom skill
  final isBuiltIn = skillFile.path.contains('/lib/resources/skills/');

  return {
    'name': skillName,
    'category': category,
    'content': content,
    'metadata': metadata,
    'template_vars': templateVars,
    'path': skillFile.path,
    'isBuiltIn': isBuiltIn,
    'source': isBuiltIn ? 'built-in' : 'custom',
  };
}