diff --git a/app/Mcp/Prompts/AddFrameworkIntegration.php b/app/Mcp/Prompts/AddFrameworkIntegration.php index d5dd69c..741a8ef 100644 --- a/app/Mcp/Prompts/AddFrameworkIntegration.php +++ b/app/Mcp/Prompts/AddFrameworkIntegration.php @@ -29,15 +29,15 @@ class AddFrameworkIntegration extends Prompt $parts[] = sprintf( "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n\n%s", - "Please:", - "1. Update the fxmanifest.lua with framework dependencies", - "2. Replace custom player systems with framework functions", - "3. Convert money/inventory operations to framework equivalents", - "4. Update event handlers to use framework events", - "5. Add framework-specific features if beneficial", - "6. Maintain backward compatibility where possible", - "7. Add comments explaining the integration changes", - "Use the GetEventReference tool to find relevant framework events." + 'Please:', + '1. Update the fxmanifest.lua with framework dependencies', + '2. Replace custom player systems with framework functions', + '3. Convert money/inventory operations to framework equivalents', + '4. Update event handlers to use framework events', + '5. Add framework-specific features if beneficial', + '6. Maintain backward compatibility where possible', + '7. Add comments explaining the integration changes', + 'Use the GetEventReference tool to find relevant framework events.' ); return Response::prompt(implode('', $parts)); diff --git a/app/Mcp/Prompts/ConvertLanguage.php b/app/Mcp/Prompts/ConvertLanguage.php index fa14484..c30a4d9 100644 --- a/app/Mcp/Prompts/ConvertLanguage.php +++ b/app/Mcp/Prompts/ConvertLanguage.php @@ -25,19 +25,19 @@ class ConvertLanguage extends Prompt $parts[] = sprintf( "%s\n%s\n%s\n%s\n%s\n%s\n%s\n\n%s\n%s\n%s\n%s\n%s\n%s", - "Please:", - "1. Convert the code while maintaining functionality", - "2. Use idiomatic patterns for the target language", - "3. Update native function calls to match language syntax", - "4. Adjust event handlers and callbacks", - "5. Explain major differences in the conversion", - "6. Ensure FiveM compatibility in the target language", - "Key differences to consider:", - "- Array/table indexing (0 vs 1-based)", - "- String formatting", - "- Event registration syntax", - "- Async patterns", - "- Native return values" + 'Please:', + '1. Convert the code while maintaining functionality', + '2. Use idiomatic patterns for the target language', + '3. Update native function calls to match language syntax', + '4. Adjust event handlers and callbacks', + '5. Explain major differences in the conversion', + '6. Ensure FiveM compatibility in the target language', + 'Key differences to consider:', + '- Array/table indexing (0 vs 1-based)', + '- String formatting', + '- Event registration syntax', + '- Async patterns', + '- Native return values' ); return Response::prompt(implode('', $parts)); diff --git a/app/Mcp/Prompts/CreateNewResource.php b/app/Mcp/Prompts/CreateNewResource.php index a75d7fb..8c1d652 100644 --- a/app/Mcp/Prompts/CreateNewResource.php +++ b/app/Mcp/Prompts/CreateNewResource.php @@ -18,17 +18,17 @@ class CreateNewResource extends Prompt $language = $request->get('language', 'lua'); return Response::prompt(sprintf( - "Create a new FiveM resource called '%s' with the following requirements:\n\n" . - "Framework: %s\n" . - "Language: %s\n\n" . - "Please:\n" . - "1. Generate a complete fxmanifest.lua\n" . - "2. Create a config file with common settings\n" . - "3. Generate boilerplate client and server files\n" . - "4. Include proper error handling and validation\n" . - "5. Follow FiveM best practices\n" . - "6. Add helpful comments explaining the code structure\n\n" . - "Use the available tools to generate the manifest and boilerplate code.", + "Create a new FiveM resource called '%s' with the following requirements:\n\n". + "Framework: %s\n". + "Language: %s\n\n". + "Please:\n". + "1. Generate a complete fxmanifest.lua\n". + "2. Create a config file with common settings\n". + "3. Generate boilerplate client and server files\n". + "4. Include proper error handling and validation\n". + "5. Follow FiveM best practices\n". + "6. Add helpful comments explaining the code structure\n\n". + 'Use the available tools to generate the manifest and boilerplate code.', $resourceName, $framework, $language diff --git a/app/Mcp/Prompts/DebugIssues.php b/app/Mcp/Prompts/DebugIssues.php index d6bf1d2..71577d2 100644 --- a/app/Mcp/Prompts/DebugIssues.php +++ b/app/Mcp/Prompts/DebugIssues.php @@ -28,13 +28,13 @@ class DebugIssues extends Prompt $parts[] = sprintf( "%s\n%s\n%s\n%s\n%s\n%s\n\n%s", - "Please analyze this issue and:", - "1. Identify the likely cause", - "2. Suggest fixes with code examples", - "3. Explain common mistakes that lead to this issue", - "4. Provide preventive measures", - "5. Reference FiveM best practices if applicable", - "Use the SearchFiveMDocs and GetNativeFunction tools to find relevant information." + 'Please analyze this issue and:', + '1. Identify the likely cause', + '2. Suggest fixes with code examples', + '3. Explain common mistakes that lead to this issue', + '4. Provide preventive measures', + '5. Reference FiveM best practices if applicable', + 'Use the SearchFiveMDocs and GetNativeFunction tools to find relevant information.' ); return Response::prompt(implode('', $parts)); diff --git a/app/Mcp/Prompts/OptimizePerformance.php b/app/Mcp/Prompts/OptimizePerformance.php index cf5fb6c..b602f83 100644 --- a/app/Mcp/Prompts/OptimizePerformance.php +++ b/app/Mcp/Prompts/OptimizePerformance.php @@ -25,18 +25,18 @@ class OptimizePerformance extends Prompt $parts[] = sprintf( "Script Type: %s\n\n%s\n%s\n%s\n%s\n%s\n%s\n\n%s\n%s\n%s\n%s\n%s\n%s", $scriptType, - "Please analyze the code and:", - "1. Identify performance issues (unnecessary loops, missing waits, etc.)", - "2. Suggest optimizations with code examples", - "3. Explain why each optimization improves performance", - "4. Provide the optimized version of the code", - "5. Reference FiveM best practices for performance", - "Focus on:", - "- Proper Citizen.Wait() usage", - "- Distance checks before expensive operations", - "- Caching frequently accessed values", - "- Reducing server-client communication", - "- Efficient event handling" + 'Please analyze the code and:', + '1. Identify performance issues (unnecessary loops, missing waits, etc.)', + '2. Suggest optimizations with code examples', + '3. Explain why each optimization improves performance', + '4. Provide the optimized version of the code', + '5. Reference FiveM best practices for performance', + 'Focus on:', + '- Proper Citizen.Wait() usage', + '- Distance checks before expensive operations', + '- Caching frequently accessed values', + '- Reducing server-client communication', + '- Efficient event handling' ); return Response::prompt(implode('', $parts)); diff --git a/app/Mcp/Tools/COX/Inventory/Client/GetInventoryClientFunction.php b/app/Mcp/Tools/COX/Inventory/Client/GetInventoryClientFunction.php index 8da27ae..f49985b 100644 --- a/app/Mcp/Tools/COX/Inventory/Client/GetInventoryClientFunction.php +++ b/app/Mcp/Tools/COX/Inventory/Client/GetInventoryClientFunction.php @@ -150,7 +150,7 @@ class GetInventoryClientFunction extends Tool */ protected function formatFunctionInfo(array $function, string $language): string { - return view('mcp.cox-function', [ + return view('mcp.cox.cox-function', [ 'function' => $function, 'language' => $language, ])->render(); diff --git a/app/Mcp/Tools/COX/Inventory/Server/GetInventoryServerFunction.php b/app/Mcp/Tools/COX/Inventory/Server/GetInventoryServerFunction.php index 60bf47a..a8f1345 100644 --- a/app/Mcp/Tools/COX/Inventory/Server/GetInventoryServerFunction.php +++ b/app/Mcp/Tools/COX/Inventory/Server/GetInventoryServerFunction.php @@ -309,7 +309,7 @@ class GetInventoryServerFunction extends Tool */ protected function formatFunctionInfo(array $function, string $language): string { - return view('mcp.cox-function', [ + return view('mcp.cox.cox-function', [ 'function' => $function, 'language' => $language, ])->render(); diff --git a/app/Mcp/Tools/COX/MySQL/GetCOXEventReference.php b/app/Mcp/Tools/COX/MySQL/GetCOXEventReference.php index cb9baa0..e5b2888 100644 --- a/app/Mcp/Tools/COX/MySQL/GetCOXEventReference.php +++ b/app/Mcp/Tools/COX/MySQL/GetCOXEventReference.php @@ -60,7 +60,7 @@ class GetCOXEventReference extends Tool } return Response::text( - view('mcp.cox-event-list', [ + view('mcp.cox.cox-event-list', [ 'eventsByType' => $eventsByType, ])->render() ); @@ -71,7 +71,7 @@ class GetCOXEventReference extends Tool */ protected function formatEventInfo(array $event, string $language): string { - return view('mcp.cox-event-reference', [ + return view('mcp.cox.cox-event-reference', [ 'event' => $event, 'language' => $language, ])->render(); diff --git a/app/Mcp/Tools/COX/MySQL/GetCOXFunction.php b/app/Mcp/Tools/COX/MySQL/GetCOXFunction.php index a1ea323..fbccaec 100644 --- a/app/Mcp/Tools/COX/MySQL/GetCOXFunction.php +++ b/app/Mcp/Tools/COX/MySQL/GetCOXFunction.php @@ -163,7 +163,7 @@ class GetCOXFunction extends Tool */ protected function formatFunctionInfo(array $function, string $language): string { - return view('mcp.cox-function', [ + return view('mcp.cox.cox-function', [ 'function' => $function, 'language' => $language, ])->render(); diff --git a/app/Mcp/Tools/FiveM/Client/GetEventClientReference.php b/app/Mcp/Tools/FiveM/Client/GetEventClientReference.php index e866d29..b79baca 100644 --- a/app/Mcp/Tools/FiveM/Client/GetEventClientReference.php +++ b/app/Mcp/Tools/FiveM/Client/GetEventClientReference.php @@ -60,7 +60,7 @@ class GetEventClientReference extends Tool } return Response::text( - view('mcp.event-list', [ + view('mcp.fivem.event-list', [ 'eventsByType' => $eventsByType, ])->render() ); @@ -71,7 +71,7 @@ class GetEventClientReference extends Tool */ protected function formatEventInfo(array $event, string $language): string { - return view('mcp.event-reference', [ + return view('mcp.fivem.event-reference', [ 'event' => $event, 'language' => $language, ])->render(); diff --git a/app/Mcp/Tools/FiveM/Client/GetNativeClientFunction.php b/app/Mcp/Tools/FiveM/Client/GetNativeClientFunction.php index 4174fbb..df8822d 100644 --- a/app/Mcp/Tools/FiveM/Client/GetNativeClientFunction.php +++ b/app/Mcp/Tools/FiveM/Client/GetNativeClientFunction.php @@ -193,7 +193,7 @@ class GetNativeClientFunction extends Tool */ protected function formatNativeInfo(array $native, string $language): string { - return view('mcp.native-function', [ + return view('mcp.fivem.native-function', [ 'native' => $native, 'language' => $language, ])->render(); diff --git a/app/Mcp/Tools/FiveM/GenerateResourceBoilerplate.php b/app/Mcp/Tools/FiveM/GenerateResourceBoilerplate.php index ca4bfcd..8204ca1 100644 --- a/app/Mcp/Tools/FiveM/GenerateResourceBoilerplate.php +++ b/app/Mcp/Tools/FiveM/GenerateResourceBoilerplate.php @@ -29,7 +29,7 @@ class GenerateResourceBoilerplate extends Tool ]); return Response::text( - view('mcp.resource-boilerplate', [ + view('mcp.shared.resource-boilerplate', [ 'resourceName' => $resourceName, 'files' => $files, ])->render() diff --git a/app/Mcp/Tools/FiveM/SearchFiveMDocs.php b/app/Mcp/Tools/FiveM/SearchFiveMDocs.php index 88edf84..02b45cc 100644 --- a/app/Mcp/Tools/FiveM/SearchFiveMDocs.php +++ b/app/Mcp/Tools/FiveM/SearchFiveMDocs.php @@ -26,7 +26,7 @@ class SearchFiveMDocs extends Tool } return Response::text( - view('mcp.search-results', [ + view('mcp.shared.search-results', [ 'query' => $query, 'results' => $results, ])->render() diff --git a/app/Mcp/Tools/FiveM/Server/GetEventServerReference.php b/app/Mcp/Tools/FiveM/Server/GetEventServerReference.php index d88cc7c..2c1d132 100644 --- a/app/Mcp/Tools/FiveM/Server/GetEventServerReference.php +++ b/app/Mcp/Tools/FiveM/Server/GetEventServerReference.php @@ -60,7 +60,7 @@ class GetEventServerReference extends Tool } return Response::text( - view('mcp.event-list', [ + view('mcp.fivem.event-list', [ 'eventsByType' => $eventsByType, ])->render() ); @@ -71,7 +71,7 @@ class GetEventServerReference extends Tool */ protected function formatEventInfo(array $event, string $language): string { - return view('mcp.event-reference', [ + return view('mcp.fivem.event-reference', [ 'event' => $event, 'language' => $language, ])->render(); diff --git a/app/Mcp/Tools/FiveM/Server/GetNativeServerFunction.php b/app/Mcp/Tools/FiveM/Server/GetNativeServerFunction.php index b9336b7..4ae49ee 100644 --- a/app/Mcp/Tools/FiveM/Server/GetNativeServerFunction.php +++ b/app/Mcp/Tools/FiveM/Server/GetNativeServerFunction.php @@ -182,7 +182,7 @@ class GetNativeServerFunction extends Tool */ protected function formatNativeInfo(array $native, string $language): string { - return view('mcp.native-function', [ + return view('mcp.fivem.native-function', [ 'native' => $native, 'language' => $language, ])->render(); diff --git a/app/Mcp/Tools/QBCore/Client/GetQBCoreClientEventReference.php b/app/Mcp/Tools/QBCore/Client/GetQBCoreClientEventReference.php index 96ab0ed..1c16be0 100644 --- a/app/Mcp/Tools/QBCore/Client/GetQBCoreClientEventReference.php +++ b/app/Mcp/Tools/QBCore/Client/GetQBCoreClientEventReference.php @@ -94,26 +94,9 @@ class GetQBCoreClientEventReference extends Tool */ protected function formatEvent(array $event): string { - return <<formatParameters($event['parameters'])} - -**Lua Example:** -\`\`\`lua -{$event['lua_example']} -\`\`\` - -**JavaScript Example:** -\`\`\`javascript -{$event['js_example']} -\`\`\` -EOT; + return view('mcp.qbcore.qbcore-event-reference', [ + 'event' => $event, + ])->render(); } /** @@ -121,10 +104,10 @@ EOT; */ protected function formatEventList(array $events, string $title): string { - $list = "# {$title}\n\n"; + $list = sprintf("# %s\n\n", $title); foreach ($events as $event) { - $list .= "- **{$event['name']}**: {$event['description']}\n"; + $list .= sprintf("- **%s**: %s\n", $event['name'], $event['description']); } return $list; @@ -137,7 +120,7 @@ EOT; { $formatted = ''; foreach ($parameters as $name => $description) { - $formatted .= "- `{$name}`: {$description}\n"; + $formatted .= sprintf("- `%s`: %s\n", $name, $description); } return $formatted; diff --git a/app/Mcp/Tools/QBCore/Client/GetQBCoreClientFunction.php b/app/Mcp/Tools/QBCore/Client/GetQBCoreClientFunction.php index 7423526..f062aaf 100644 --- a/app/Mcp/Tools/QBCore/Client/GetQBCoreClientFunction.php +++ b/app/Mcp/Tools/QBCore/Client/GetQBCoreClientFunction.php @@ -131,7 +131,7 @@ class GetQBCoreClientFunction extends Tool */ protected function formatFunctionInfo(array $function, string $language): string { - return view('mcp.qbcore-function', [ + return view('mcp.qbcore.qbcore-function', [ 'function' => $function, 'language' => $language, ])->render(); diff --git a/app/Mcp/Tools/QBCore/Server/GetQBCoreServerEventReference.php b/app/Mcp/Tools/QBCore/Server/GetQBCoreServerEventReference.php index 38965a8..0d11185 100644 --- a/app/Mcp/Tools/QBCore/Server/GetQBCoreServerEventReference.php +++ b/app/Mcp/Tools/QBCore/Server/GetQBCoreServerEventReference.php @@ -94,26 +94,9 @@ class GetQBCoreServerEventReference extends Tool */ protected function formatEvent(array $event): string { - return <<formatParameters($event['parameters'])} - -**Lua Example:** -\`\`\`lua -{$event['lua_example']} -\`\`\` - -**JavaScript Example:** -\`\`\`javascript -{$event['js_example']} -\`\`\` -EOT; + return view('mcp.qbcore.qbcore-event-reference', [ + 'event' => $event, + ])->render(); } /** @@ -121,10 +104,10 @@ EOT; */ protected function formatEventList(array $events, string $title): string { - $list = "# {$title}\n\n"; + $list = sprintf("# %s\n\n", $title); foreach ($events as $event) { - $list .= "- **{$event['name']}**: {$event['description']}\n"; + $list .= sprintf("- **%s**: %s\n", $event['name'], $event['description']); } return $list; @@ -137,7 +120,7 @@ EOT; { $formatted = ''; foreach ($parameters as $name => $description) { - $formatted .= "- `{$name}`: {$description}\n"; + $formatted .= sprintf("- `%s`: %s\n", $name, $description); } return $formatted; diff --git a/app/Mcp/Tools/QBCore/Server/GetQBCoreServerFunction.php b/app/Mcp/Tools/QBCore/Server/GetQBCoreServerFunction.php index 0954a54..c717d00 100644 --- a/app/Mcp/Tools/QBCore/Server/GetQBCoreServerFunction.php +++ b/app/Mcp/Tools/QBCore/Server/GetQBCoreServerFunction.php @@ -196,7 +196,7 @@ class GetQBCoreServerFunction extends Tool */ protected function formatFunctionInfo(array $function, string $language): string { - return view('mcp.qbcore-function', [ + return view('mcp.qbcore.qbcore-function', [ 'function' => $function, 'language' => $language, ])->render(); diff --git a/resources/views/mcp/cox-event-list.blade.php b/resources/views/mcp/cox/cox-event-list.blade.php similarity index 100% rename from resources/views/mcp/cox-event-list.blade.php rename to resources/views/mcp/cox/cox-event-list.blade.php diff --git a/resources/views/mcp/cox-event-reference.blade.php b/resources/views/mcp/cox/cox-event-reference.blade.php similarity index 100% rename from resources/views/mcp/cox-event-reference.blade.php rename to resources/views/mcp/cox/cox-event-reference.blade.php diff --git a/resources/views/mcp/cox-function.blade.php b/resources/views/mcp/cox/cox-function.blade.php similarity index 100% rename from resources/views/mcp/cox-function.blade.php rename to resources/views/mcp/cox/cox-function.blade.php diff --git a/resources/views/mcp/event-list.blade.php b/resources/views/mcp/fivem/event-list.blade.php similarity index 100% rename from resources/views/mcp/event-list.blade.php rename to resources/views/mcp/fivem/event-list.blade.php diff --git a/resources/views/mcp/event-reference.blade.php b/resources/views/mcp/fivem/event-reference.blade.php similarity index 100% rename from resources/views/mcp/event-reference.blade.php rename to resources/views/mcp/fivem/event-reference.blade.php diff --git a/resources/views/mcp/native-function.blade.php b/resources/views/mcp/fivem/native-function.blade.php similarity index 100% rename from resources/views/mcp/native-function.blade.php rename to resources/views/mcp/fivem/native-function.blade.php diff --git a/resources/views/mcp/qbcore-event-list.blade.php b/resources/views/mcp/qbcore/qbcore-event-list.blade.php similarity index 100% rename from resources/views/mcp/qbcore-event-list.blade.php rename to resources/views/mcp/qbcore/qbcore-event-list.blade.php diff --git a/resources/views/mcp/qbcore-event-reference.blade.php b/resources/views/mcp/qbcore/qbcore-event-reference.blade.php similarity index 75% rename from resources/views/mcp/qbcore-event-reference.blade.php rename to resources/views/mcp/qbcore/qbcore-event-reference.blade.php index 4376bcf..ff29a20 100644 --- a/resources/views/mcp/qbcore-event-reference.blade.php +++ b/resources/views/mcp/qbcore/qbcore-event-reference.blade.php @@ -2,7 +2,6 @@ ## {{ $event['name'] }} -**Category:** {{ $event['category'] }} **Side:** {{ ucfirst($event['side']) }} ### Description @@ -10,8 +9,8 @@ ### Parameters @if(count($event['parameters']) > 0) -@foreach($event['parameters'] as $param) -- **{{ $param['name'] }}** ({{ $param['type'] }}): {{ $param['description'] }} +@foreach($event['parameters'] as $name => $description) +- `{{ $name }}`: {{ $description }} @endforeach @else This event takes no parameters. diff --git a/resources/views/mcp/qbcore-function.blade.php b/resources/views/mcp/qbcore/qbcore-function.blade.php similarity index 100% rename from resources/views/mcp/qbcore-function.blade.php rename to resources/views/mcp/qbcore/qbcore-function.blade.php diff --git a/resources/views/mcp/resource-boilerplate.blade.php b/resources/views/mcp/shared/resource-boilerplate.blade.php similarity index 100% rename from resources/views/mcp/resource-boilerplate.blade.php rename to resources/views/mcp/shared/resource-boilerplate.blade.php diff --git a/resources/views/mcp/search-results.blade.php b/resources/views/mcp/shared/search-results.blade.php similarity index 100% rename from resources/views/mcp/search-results.blade.php rename to resources/views/mcp/shared/search-results.blade.php diff --git a/tests/Feature/McpResourcesTest.php b/tests/Feature/McpResourcesTest.php index 19a9fc9..12ba482 100644 --- a/tests/Feature/McpResourcesTest.php +++ b/tests/Feature/McpResourcesTest.php @@ -4,7 +4,7 @@ use App\Mcp\Resources\CodeSnippets; use Laravel\Mcp\Request; it('code snippets resource returns response with content', function () { - $resource = new CodeSnippets(); + $resource = new CodeSnippets; $request = new Request([]); $response = $resource->handle($request); @@ -14,7 +14,7 @@ it('code snippets resource returns response with content', function () { }); it('code snippets response contains content', function () { - $resource = new CodeSnippets(); + $resource = new CodeSnippets; $request = new Request([]); $response = $resource->handle($request); @@ -24,7 +24,7 @@ it('code snippets response contains content', function () { }); it('best practices resource returns response with content', function () { - $resource = new \App\Mcp\Resources\BestPractices(); + $resource = new \App\Mcp\Resources\BestPractices; $request = new Request([]); $response = $resource->handle($request); @@ -34,7 +34,7 @@ it('best practices resource returns response with content', function () { }); it('best practices response contains content', function () { - $resource = new \App\Mcp\Resources\BestPractices(); + $resource = new \App\Mcp\Resources\BestPractices; $request = new Request([]); $response = $resource->handle($request); @@ -44,7 +44,7 @@ it('best practices response contains content', function () { }); it('framework comparison resource returns response with content', function () { - $resource = new \App\Mcp\Resources\FrameworkComparison(); + $resource = new \App\Mcp\Resources\FrameworkComparison; $request = new Request([]); $response = $resource->handle($request); @@ -54,7 +54,7 @@ it('framework comparison resource returns response with content', function () { }); it('framework comparison response contains content', function () { - $resource = new \App\Mcp\Resources\FrameworkComparison(); + $resource = new \App\Mcp\Resources\FrameworkComparison; $request = new Request([]); $response = $resource->handle($request);