OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
Some checks failed
Security Audit / Composer Security Audit (push) Has been cancelled
Security Audit / NPM Security Audit (push) Has been cancelled
Security Audit / CodeQL Analysis (push) Has been cancelled

This commit is contained in:
wangruiguo
2026-09-03 18:49:20 +08:00
commit d647428529
3501 changed files with 1988906 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
<?php
namespace Leantime\Domain\Tickets\Tools;
use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\ToolInputSchema;
use Laravel\Mcp\Server\Tools\ToolResult;
use Leantime\Domain\Tickets\Services\Tickets;
/**
* Create a subtask for an existing task.
*/
class AddSubtaskTool extends Tool
{
public function __construct(
private Tickets $ticketsService,
) {}
/**
* Get the tool name.
*/
public function name(): string
{
return 'addSubtask';
}
/**
* Get the tool description.
*/
public function description(): string
{
return 'Creates a new subtask of another existing task. Tool to break down large tasks into smaller elements.';
}
/**
* Define the tool input schema.
*/
public function schema(ToolInputSchema $schema): ToolInputSchema
{
return $schema
->integer('parentTicket')->description('ID of the parent ticket.')->required()
->string('headline')->description('Title of the subtask.')->required()
->string('description')->description('Subtask description.')
->integer('projectId')->description('Project ID.')
->integer('editorId')->description('Assigned user ID.')
->integer('userId')->description('Creator user ID.')
->string('dateToFinish')->description('Due date in ISO8601 format.')
->integer('status')->description('Status ID.')
->string('editFrom')->description('Scheduled start date in ISO8601 format.')
->string('editTo')->description('Scheduled end date in ISO8601 format.')
->integer('effort')->description('Effort T-shirt size: 1=XS, 2=S, 3=M, 5=L, 8=XL, 13=XXL.')
->integer('planHours')->description('Planned hours for this subtask.')
->integer('priority')->description('Priority: 1=Critical, 2=High, 3=Medium, 4=Low, 5=Lowest.');
}
/**
* Handle the tool request.
*/
public function handle(array $arguments): ToolResult
{
$params = [
'headline' => $arguments['headline'],
'description' => ($arguments['description'] ?? ''),
'projectId' => ($arguments['projectId'] ?? null),
'editorId' => ($arguments['editorId'] ?? null),
'userId' => ($arguments['userId'] ?? null),
'dateToFinish' => ($arguments['dateToFinish'] ?? null),
'status' => (int) ($arguments['status'] ?? 3),
'sprint' => null,
'editFrom' => ($arguments['editFrom'] ?? null),
'editTo' => ($arguments['editTo'] ?? null),
'milestone' => null,
'type' => 'subtask',
'dependingTicketId' => (int) ($arguments['parentTicket'] ?? 0),
'storypoints' => (int) ($arguments['effort'] ?? 3),
'priority' => (int) ($arguments['priority'] ?? 3),
'planHours' => (int) ($arguments['planHours'] ?? 0),
];
$result = $this->ticketsService->quickAddTicket($params);
if ($result) {
return ToolResult::text("Subtask created successfully. ID: {$result}");
}
return ToolResult::error('Failed to create subtask.');
}
}