Skip to content
This repository was archived by the owner on Nov 30, 2026. It is now read-only.
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
14 changes: 11 additions & 3 deletions app/Middleware/OffersSkillsInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Support\DetectsNonInteractiveEnvironments;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;
use Symfony\Component\Console\Output\ConsoleOutput;

use function Laravel\Prompts\confirm;
use function Laravel\Prompts\info;
Expand Down Expand Up @@ -66,17 +67,24 @@ public function handle($command, callable $next)
);

if ($install) {
$this->runInstall();
$this->runInstall($detectedAgents);
} else {
$this->showDeclineHint();
}

return $next();
}

protected function runInstall(): void
/**
* @param array<int, string> $agents
*/
protected function runInstall(array $agents): void
{
Artisan::call(SkillsInstall::class);
// A bare Artisan::call buffers output, then waits on a prompt the user cannot see.
Artisan::call(SkillsInstall::class, [
'--global' => true,
'--agent' => $agents,
], new ConsoleOutput);
}

protected function showDeclineHint(): void
Expand Down
24 changes: 23 additions & 1 deletion tests/Feature/OffersSkillsInstallTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php

use App\Commands\SkillsInstall;
use App\ConfigRepository;
use App\Middleware\OffersSkillsInstall;
use Illuminate\Support\Facades\Artisan;
use Laravel\Prompts\Key;
use Laravel\Prompts\Prompt;
use Symfony\Component\Console\Output\ConsoleOutput;

beforeEach(function () {
$this->mockConfig = Mockery::mock(ConfigRepository::class);
Expand Down Expand Up @@ -95,12 +98,31 @@ function partialMiddleware(array $overrides = []): OffersSkillsInstall
->once();

$middleware = partialMiddleware();
$middleware->shouldReceive('runInstall')->once();
$middleware->shouldReceive('runInstall')->once()->with(['claude']);
$middleware->shouldReceive('showDeclineHint')->never();

expect(runMiddleware($middleware))->toBeTrue();
});

it('installs the detected agents on the terminal when the user confirms', function () {
Prompt::fake([Key::ENTER]);

$this->mockConfig->shouldReceive('get')->with('skills_install_prompted_at')->andReturn(null);
$this->mockConfig->shouldReceive('set')
->with('skills_install_prompted_at', Mockery::type('string'))
->once();

Artisan::shouldReceive('call')
->once()
->with(
SkillsInstall::class,
['--global' => true, '--agent' => ['claude']],
Mockery::type(ConsoleOutput::class),
);

expect(runMiddleware(partialMiddleware()))->toBeTrue();
});

it('records the choice without installing when the user declines', function () {
Prompt::fake([Key::TAB, Key::ENTER]);

Expand Down
Loading