Add FiveM resources and templates for documentation and code snippets
- Introduced a new code snippets resource for common FiveM patterns in Lua and JavaScript. - Added a framework comparison document outlining Standalone, ESX, and QBCore features. - Created search results view for FiveM documentation queries. - Developed client and server template scripts for ESX and QBCore frameworks. - Implemented NUI templates including HTML, CSS, and JavaScript for user interfaces. - Established routes for documentation and console commands. - Added tests for various features including documentation routes and tool functionalities. - Configured Vite for asset management with Laravel. - Updated .gitignore files for storage and framework directories.
This commit is contained in:
112 files changed
+51106
No files matched your search
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Prompts;
|
||||
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Prompt;
|
||||
|
||||
#[Description('Add ESX or QBCore framework integration to existing resource')]
|
||||
class AddFrameworkIntegration extends Prompt
|
||||
{
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$code = $request->get('code', '');
|
||||
$currentFramework = $request->get('current_framework', 'standalone');
|
||||
$targetFramework = $request->get('target_framework', 'esx');
|
||||
|
||||
$parts = [sprintf(
|
||||
"Convert this FiveM resource from %s to %s:\n\n",
|
||||
$currentFramework,
|
||||
$targetFramework
|
||||
)];
|
||||
|
||||
if ($code) {
|
||||
$parts[] = sprintf("Current Code:\n```\n%s\n```\n\n", $code);
|
||||
}
|
||||
|
||||
$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."
|
||||
);
|
||||
|
||||
return Response::prompt(implode('', $parts));
|
||||
}
|
||||
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'code' => $schema->string()
|
||||
->description('Current resource code')
|
||||
->default(''),
|
||||
'current_framework' => $schema->enum(['standalone', 'esx', 'qbcore'])
|
||||
->description('Current framework')
|
||||
->default('standalone'),
|
||||
'target_framework' => $schema->enum(['esx', 'qbcore'])
|
||||
->description('Target framework')
|
||||
->default('esx'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Prompts;
|
||||
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Prompt;
|
||||
|
||||
#[Description('Convert code between Lua and JavaScript')]
|
||||
class ConvertLanguage extends Prompt
|
||||
{
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$code = $request->get('code', '');
|
||||
$from = $request->get('from', 'lua');
|
||||
$to = $request->get('to', 'js');
|
||||
|
||||
$parts = [sprintf("Convert this FiveM code from %s to %s:\n\n", $from, $to)];
|
||||
|
||||
if ($code) {
|
||||
$parts[] = sprintf("```%s\n%s\n```\n\n", $from, $code);
|
||||
}
|
||||
|
||||
$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"
|
||||
);
|
||||
|
||||
return Response::prompt(implode('', $parts));
|
||||
}
|
||||
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'code' => $schema->string()
|
||||
->description('Code to convert')
|
||||
->required(),
|
||||
'from' => $schema->enum(['lua', 'js'])
|
||||
->description('Source language')
|
||||
->default('lua'),
|
||||
'to' => $schema->enum(['lua', 'js'])
|
||||
->description('Target language')
|
||||
->default('js'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Prompts;
|
||||
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Prompt;
|
||||
|
||||
#[Description('Create a new FiveM resource with framework and language selection')]
|
||||
class CreateNewResource extends Prompt
|
||||
{
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$resourceName = $request->get('resource_name', 'my-resource');
|
||||
$framework = $request->get('framework', 'standalone');
|
||||
$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.",
|
||||
$resourceName,
|
||||
$framework,
|
||||
$language
|
||||
));
|
||||
}
|
||||
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'resource_name' => $schema->string()
|
||||
->description('Name of the resource to create')
|
||||
->default('my-resource'),
|
||||
'framework' => $schema->enum(['standalone', 'esx', 'qbcore'])
|
||||
->description('Framework to use')
|
||||
->default('standalone'),
|
||||
'language' => $schema->enum(['lua', 'js'])
|
||||
->description('Scripting language')
|
||||
->default('lua'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Prompts;
|
||||
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Prompt;
|
||||
|
||||
#[Description('Debug common FiveM issues and errors')]
|
||||
class DebugIssues extends Prompt
|
||||
{
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$issue = $request->get('issue', '');
|
||||
$errorMessage = $request->get('error_message', '');
|
||||
|
||||
$parts = ["Help me debug a FiveM issue:\n\n"];
|
||||
|
||||
if ($issue) {
|
||||
$parts[] = sprintf("Issue Description: %s\n\n", $issue);
|
||||
}
|
||||
|
||||
if ($errorMessage) {
|
||||
$parts[] = sprintf("Error Message: %s\n\n", $errorMessage);
|
||||
}
|
||||
|
||||
$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."
|
||||
);
|
||||
|
||||
return Response::prompt(implode('', $parts));
|
||||
}
|
||||
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'issue' => $schema->string()
|
||||
->description('Description of the issue or problem')
|
||||
->default(''),
|
||||
'error_message' => $schema->string()
|
||||
->description('Error message from console or logs')
|
||||
->default(''),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Prompts;
|
||||
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Prompt;
|
||||
|
||||
#[Description('Optimize FiveM script performance')]
|
||||
class OptimizePerformance extends Prompt
|
||||
{
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$code = $request->get('code', '');
|
||||
$scriptType = $request->get('script_type', 'client');
|
||||
|
||||
$parts = ["Review and optimize this FiveM script for better performance:\n\n"];
|
||||
|
||||
if ($code) {
|
||||
$parts[] = sprintf("```\n%s\n```\n\n", $code);
|
||||
}
|
||||
|
||||
$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"
|
||||
);
|
||||
|
||||
return Response::prompt(implode('', $parts));
|
||||
}
|
||||
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'code' => $schema->string()
|
||||
->description('The code to optimize')
|
||||
->default(''),
|
||||
'script_type' => $schema->enum(['client', 'server', 'shared'])
|
||||
->description('Type of script')
|
||||
->default('client'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user