From 70dfad8071dea6e76e468021d2458a5235a25111 Mon Sep 17 00:00:00 2001 From: Veronika Golska Date: Mon, 9 Nov 2026 09:34:10 +0100 Subject: [PATCH] Offer each AI tool once in the ai-dev:setup tool choice The tool choice listed the values of the detection map. GitHub Copilot has four indicator paths in that map, so the choice showed it four times. The console now removes the duplicate tool names before it asks. --- .../Console/AiToolSetupConsole.php | 14 +++++- .../Console/AiToolSetupConsoleTest.php | 43 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tests/SprykerSdkTest/Zed/AiDev/Communication/Console/AiToolSetupConsoleTest.php diff --git a/src/SprykerSdk/Zed/AiDev/Communication/Console/AiToolSetupConsole.php b/src/SprykerSdk/Zed/AiDev/Communication/Console/AiToolSetupConsole.php index 0d382ba..33d028a 100644 --- a/src/SprykerSdk/Zed/AiDev/Communication/Console/AiToolSetupConsole.php +++ b/src/SprykerSdk/Zed/AiDev/Communication/Console/AiToolSetupConsole.php @@ -75,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int protected function resolveToolSelection(array $detectionMap, string $toolRequiringConfirmation): ?string { $detected = $this->getFactory()->createAiToolDetector()->detect($detectionMap); - $tools = array_values($detectionMap); + $tools = $this->getSelectableTools($detectionMap); if ($detected === null || !$this->isDetectedToolAccepted($detected, $toolRequiringConfirmation)) { return $this->select('Select your AI tool:', $tools, $tools[0]); @@ -84,6 +84,18 @@ protected function resolveToolSelection(array $detectionMap, string $toolRequiri return $detected; } + /** + * Several indicator paths can detect the same tool, so each tool is offered once. + * + * @param array $detectionMap + * + * @return list + */ + protected function getSelectableTools(array $detectionMap): array + { + return array_values(array_unique($detectionMap)); + } + protected function isDetectedToolAccepted(string $detected, string $toolRequiringConfirmation): bool { if ($detected === $toolRequiringConfirmation) { diff --git a/tests/SprykerSdkTest/Zed/AiDev/Communication/Console/AiToolSetupConsoleTest.php b/tests/SprykerSdkTest/Zed/AiDev/Communication/Console/AiToolSetupConsoleTest.php new file mode 100644 index 0000000..e618add --- /dev/null +++ b/tests/SprykerSdkTest/Zed/AiDev/Communication/Console/AiToolSetupConsoleTest.php @@ -0,0 +1,43 @@ +newInstanceWithoutConstructor(); + $method = $reflection->getMethod('getSelectableTools'); + $method->setAccessible(true); + $detectionMap = (new AiDevConfig())->getToolDetectionMap(); + + // Act + $tools = $method->invoke($console, $detectionMap); + + // Assert + $this->assertSame( + ['Claude Code', 'Windsurf', 'GitHub Copilot', 'Cursor', 'OpenCode', 'Codex CLI'], + $tools, + ); + } +}