Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/Core/Http/Controllers/OAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
use App\Core\Models\User;
use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Illuminate\Support\Str;

Expand Down Expand Up @@ -75,7 +77,7 @@ public function register(Request $request): JsonResponse
}

// POIESIS-40: Authorization endpoint (consent screen)
public function authorize(Request $request): \Illuminate\Http\Response|JsonResponse|\Illuminate\Http\RedirectResponse
public function authorize(Request $request): Response|JsonResponse|RedirectResponse
{
$validated = $request->validate([
'client_id' => 'required|string',
Expand Down Expand Up @@ -119,7 +121,7 @@ private function renderConsentScreen(
array $validated,
array $scopes,
string $state,
): \Illuminate\Http\Response {
): Response {
$scopeList = ! empty($scopes)
? '<ul>'.implode('', array_map(fn ($s) => "<li>{$s}</li>", $scopes)).'</ul>'
: '<p>No specific scopes requested.</p>';
Expand Down Expand Up @@ -175,7 +177,7 @@ private function handleAuthorizationDecision(
array $validated,
array $scopes,
string $state,
): \Illuminate\Http\RedirectResponse {
): RedirectResponse {
$redirectUri = $validated['redirect_uri'];

if ($request->input('decision') !== 'approve') {
Expand Down
13 changes: 7 additions & 6 deletions app/Core/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Core\Http\Resources\ProjectResource;
use App\Core\Models\Project;
use App\Core\Models\ProjectMember;
use App\Core\Models\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
Expand All @@ -15,7 +16,7 @@ class ProjectController extends Controller
{
public function index(Request $request): JsonResponse
{
/** @var \App\Core\Models\User $user */
/** @var User $user */
$user = $request->user();

$perPage = min((int) $request->input('per_page', 25), 100);
Expand All @@ -35,7 +36,7 @@ public function index(Request $request): JsonResponse

public function store(StoreProjectRequest $request): JsonResponse
{
/** @var \App\Core\Models\User $user */
/** @var User $user */
$user = $request->user();

$project = Project::create($request->validated());
Expand All @@ -53,15 +54,15 @@ public function store(StoreProjectRequest $request): JsonResponse

public function show(Request $request, string $code): JsonResponse
{
/** @var \App\Core\Models\Project $project */
/** @var Project $project */
$project = $request->attributes->get('project');

return (new ProjectResource($project))->response();
}

public function update(UpdateProjectRequest $request, string $code): JsonResponse
{
/** @var \App\Core\Models\Project $project */
/** @var Project $project */
$project = $request->attributes->get('project');

$project->update($request->validated());
Expand All @@ -71,10 +72,10 @@ public function update(UpdateProjectRequest $request, string $code): JsonRespons

public function destroy(Request $request, string $code): JsonResponse
{
/** @var \App\Core\Models\Project $project */
/** @var Project $project */
$project = $request->attributes->get('project');

/** @var \App\Core\Models\User $user */
/** @var User $user */
$user = $request->user();

$isOwner = ProjectMember::where('project_id', $project->id)
Expand Down
16 changes: 9 additions & 7 deletions app/Core/Http/Controllers/ProjectMemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace App\Core\Http\Controllers;

use App\Core\Models\Project;
use App\Core\Models\ProjectMember;
use App\Core\Models\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
Expand All @@ -11,7 +13,7 @@ class ProjectMemberController extends Controller
{
public function index(Request $request): JsonResponse
{
/** @var \App\Core\Models\Project $project */
/** @var Project $project */
$project = $request->attributes->get('project');

$perPage = min((int) $request->input('per_page', 25), 100);
Expand All @@ -38,10 +40,10 @@ public function index(Request $request): JsonResponse

public function store(Request $request): JsonResponse
{
/** @var \App\Core\Models\Project $project */
/** @var Project $project */
$project = $request->attributes->get('project');

/** @var \App\Core\Models\User $authUser */
/** @var User $authUser */
$authUser = $request->user();

if (! $this->isOwner($project->id, $authUser->id)) {
Expand Down Expand Up @@ -79,10 +81,10 @@ public function store(Request $request): JsonResponse

public function update(Request $request, string $code, string $memberId): JsonResponse
{
/** @var \App\Core\Models\Project $project */
/** @var Project $project */
$project = $request->attributes->get('project');

/** @var \App\Core\Models\User $authUser */
/** @var User $authUser */
$authUser = $request->user();

if (! $this->isOwner($project->id, $authUser->id)) {
Expand Down Expand Up @@ -118,10 +120,10 @@ public function update(Request $request, string $code, string $memberId): JsonRe

public function destroy(Request $request, string $code, string $memberId): JsonResponse
{
/** @var \App\Core\Models\Project $project */
/** @var Project $project */
$project = $request->attributes->get('project');

/** @var \App\Core\Models\User $authUser */
/** @var User $authUser */
$authUser = $request->user();

if (! $this->isOwner($project->id, $authUser->id)) {
Expand Down
3 changes: 2 additions & 1 deletion app/Core/Http/Middleware/EnsureProjectAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Core\Http\Middleware;

use App\Core\Models\Project;
use App\Core\Models\User;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -23,7 +24,7 @@ public function handle(Request $request, Closure $next): Response
return response()->json(['message' => 'Project not found.'], 404);
}

/** @var \App\Core\Models\User $user */
/** @var User $user */
$user = $request->user();

$isMember = $project->users()
Expand Down
9 changes: 6 additions & 3 deletions app/Core/Http/Resources/ArtifactSearchResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

namespace App\Core\Http\Resources;

use App\Core\Models\Epic;
use App\Core\Models\Story;
use App\Core\Models\Task;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class ArtifactSearchResource extends JsonResource
{
/** @var array<class-string, string> */
private const TYPE_MAP = [
\App\Core\Models\Epic::class => 'epic',
\App\Core\Models\Story::class => 'story',
\App\Core\Models\Task::class => 'task',
Epic::class => 'epic',
Story::class => 'story',
Task::class => 'task',
];

public function toArray(Request $request): array
Expand Down
6 changes: 4 additions & 2 deletions app/Core/Mcp/Http/Controllers/McpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

use App\Core\Mcp\Server\McpServer;
use App\Core\Mcp\Server\McpTransport;
use App\Core\Models\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Symfony\Component\HttpFoundation\StreamedResponse;

Expand All @@ -18,7 +20,7 @@ public function __construct(
private readonly McpTransport $transport,
) {}

public function handle(Request $request): JsonResponse|\Illuminate\Http\Response
public function handle(Request $request): JsonResponse|Response
{
try {
$jsonRpc = $this->transport->decodeRequest($request);
Expand All @@ -28,7 +30,7 @@ public function handle(Request $request): JsonResponse|\Illuminate\Http\Response
);
}

/** @var \App\Core\Models\User $user */
/** @var User $user */
$user = $request->user();

$response = $this->mcpServer->handleRequest($jsonRpc, $user);
Expand Down
3 changes: 2 additions & 1 deletion app/Core/Mcp/Resources/ProjectConfigResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Core\Mcp\Contracts\McpResourceInterface;
use App\Core\Models\Project;
use App\Core\Models\User;
use Illuminate\Database\Eloquent\ModelNotFoundException;

class ProjectConfigResource implements McpResourceInterface
{
Expand Down Expand Up @@ -43,7 +44,7 @@ public function description(): string
* @param User $user Authenticated user (reserved for future access control).
* @return array<string, mixed> Configuration payload with all enumerated values and active modules.
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException When no project matches the code.
* @throws ModelNotFoundException When no project matches the code.
*/
public function read(array $params, User $user): array
{
Expand Down
3 changes: 2 additions & 1 deletion app/Core/Mcp/Resources/ProjectOverviewResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Core\Models\Project;
use App\Core\Models\Story;
use App\Core\Models\User;
use Illuminate\Database\Eloquent\ModelNotFoundException;

class ProjectOverviewResource implements McpResourceInterface
{
Expand Down Expand Up @@ -44,7 +45,7 @@ public function description(): string
* @param User $user Authenticated user (reserved for future access control).
* @return array<string, mixed> Overview payload with counts and active modules.
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException When no project matches the code.
* @throws ModelNotFoundException When no project matches the code.
*/
public function read(array $params, User $user): array
{
Expand Down
6 changes: 4 additions & 2 deletions app/Core/Mcp/Server/McpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use App\Core\Mcp\Contracts\McpToolInterface;
use App\Core\Models\Project;
use App\Core\Models\User;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Validation\ValidationException;

class McpServer
{
Expand Down Expand Up @@ -175,9 +177,9 @@ private function executeToolSafely(McpToolInterface $provider, string $toolName,
['type' => 'text', 'text' => json_encode($result, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE)],
],
], $id);
} catch (\Illuminate\Validation\ValidationException $e) {
} catch (ValidationException $e) {
return $transport->encodeError(-32602, $e->getMessage(), $id, $e->errors());
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
} catch (ModelNotFoundException $e) {
return $transport->encodeError(-32602, 'Resource not found.', $id);
} catch (\Throwable $e) {
return $transport->encodeError(-32603, $e->getMessage(), $id);
Expand Down
5 changes: 3 additions & 2 deletions app/Core/Mcp/Tools/ArtifactTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Core\Models\Story;
use App\Core\Models\Task;
use App\Core\Models\User;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Validation\ValidationException;

class ArtifactTools implements McpToolInterface
Expand All @@ -38,8 +39,8 @@ public function tools(): array
* @return array<string, mixed>
*
* @throws \InvalidArgumentException When the tool name is not handled by this class.
* @throws \Illuminate\Validation\ValidationException On invalid input or access denial.
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException When the project does not exist.
* @throws ValidationException On invalid input or access denial.
* @throws ModelNotFoundException When the project does not exist.
*/
public function execute(string $toolName, array $params, User $user): mixed
{
Expand Down
5 changes: 3 additions & 2 deletions app/Core/Mcp/Tools/DependencyTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Core\Models\Artifact;
use App\Core\Models\User;
use App\Core\Services\DependencyService;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Validation\ValidationException;

class DependencyTools implements McpToolInterface
Expand Down Expand Up @@ -39,7 +40,7 @@ public function tools(): array
* @return array<string, mixed>
*
* @throws \InvalidArgumentException When the tool name is not handled by this class.
* @throws \Illuminate\Validation\ValidationException When an identifier cannot be resolved.
* @throws ValidationException When an identifier cannot be resolved.
*/
public function execute(string $toolName, array $params, User $user): mixed
{
Expand Down Expand Up @@ -136,7 +137,7 @@ private function listDependencies(array $params): array
];
}

private function resolveItem(string $identifier): \Illuminate\Database\Eloquent\Model
private function resolveItem(string $identifier): Model
{
$model = Artifact::resolveIdentifier($identifier);

Expand Down
5 changes: 3 additions & 2 deletions app/Core/Mcp/Tools/EpicTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Core\Models\ProjectMember;
use App\Core\Models\User;
use App\Core\Support\Role;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Validation\ValidationException;

class EpicTools implements McpToolInterface
Expand Down Expand Up @@ -40,8 +41,8 @@ public function tools(): array
* @return array<string, mixed>
*
* @throws \InvalidArgumentException When the tool name is not handled by this class.
* @throws \Illuminate\Validation\ValidationException On invalid input or access denial.
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException When the project does not exist.
* @throws ValidationException On invalid input or access denial.
* @throws ModelNotFoundException When the project does not exist.
*/
public function execute(string $toolName, array $params, User $user): mixed
{
Expand Down
5 changes: 3 additions & 2 deletions app/Core/Mcp/Tools/ModuleTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Core\Models\ProjectMember;
use App\Core\Models\User;
use App\Core\Module\ModuleRegistry;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Validation\ValidationException;

class ModuleTools implements McpToolInterface
Expand Down Expand Up @@ -41,8 +42,8 @@ public function tools(): array
* @return array<string, mixed>
*
* @throws \InvalidArgumentException When the tool name is not handled by this class.
* @throws \Illuminate\Validation\ValidationException On invalid input, access denial, or dependency conflict.
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException When the project does not exist.
* @throws ValidationException On invalid input, access denial, or dependency conflict.
* @throws ModelNotFoundException When the project does not exist.
*/
public function execute(string $toolName, array $params, User $user): mixed
{
Expand Down
5 changes: 3 additions & 2 deletions app/Core/Mcp/Tools/ProjectTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Core\Models\ProjectMember;
use App\Core\Models\User;
use App\Core\Support\Role;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Validation\ValidationException;

class ProjectTools implements McpToolInterface
Expand Down Expand Up @@ -38,8 +39,8 @@ public function tools(): array
* @return array<string, mixed>
*
* @throws \InvalidArgumentException When the tool name is not handled by this class.
* @throws \Illuminate\Validation\ValidationException On invalid input or access denial.
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException When the project does not exist.
* @throws ValidationException On invalid input or access denial.
* @throws ModelNotFoundException When the project does not exist.
*/
public function execute(string $toolName, array $params, User $user): mixed
{
Expand Down
Loading
Loading