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, + ); + } +}