Skip to content

Commit 0a9e788

Browse files
committed
Add support for multiple auto-detected platforms in install
When no --platform is specified and multiple platforms are detected, install now adds all of them to config.yml instead of erroring. This simplifies setup for projects using multiple AI platforms. Changes: - Modified install to detect and add all available platforms when no specific platform is specified - Updated success message to list all installed platforms - Added test fixtures for gemini and multi-platform projects - Added test for multi-platform auto-detection behavior
1 parent 846e738 commit 0a9e788

4 files changed

Lines changed: 77 additions & 25 deletions

File tree

src/deepwork/cli/install.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ def _install_deepwork(platform_name: str | None, project_path: Path) -> None:
174174
)
175175
console.print(" [green]✓[/green] Git repository found")
176176

177-
# Step 2: Detect or validate platform
177+
# Step 2: Detect or validate platform(s)
178178
detector = PlatformDetector(project_path)
179+
platforms_to_add: list[str] = []
180+
detected_adapters: list[AgentAdapter] = []
179181

180182
if platform_name:
181183
# User specified platform - check if it's available
@@ -192,10 +194,11 @@ def _install_deepwork(platform_name: str | None, project_path: Path) -> None:
192194
)
193195

194196
console.print(f" [green]✓[/green] {adapter.display_name} detected")
195-
platform_to_add = adapter.name
197+
platforms_to_add = [adapter.name]
198+
detected_adapters = [adapter]
196199
else:
197-
# Auto-detect platform
198-
console.print("[yellow]→[/yellow] Auto-detecting AI platform...")
200+
# Auto-detect all available platforms
201+
console.print("[yellow]→[/yellow] Auto-detecting AI platforms...")
199202
available_adapters = detector.detect_all_platforms()
200203

201204
if not available_adapters:
@@ -209,17 +212,11 @@ def _install_deepwork(platform_name: str | None, project_path: Path) -> None:
209212
"Please set up one of these platforms first, or use --platform to specify."
210213
)
211214

212-
if len(available_adapters) > 1:
213-
# Multiple platforms - ask user to specify
214-
platform_names = ", ".join(a.display_name for a in available_adapters)
215-
raise InstallError(
216-
f"Multiple AI platforms detected: {platform_names}\n"
217-
"Please specify which platform to use with --platform option."
218-
)
219-
220-
adapter = available_adapters[0]
221-
console.print(f" [green]✓[/green] {adapter.display_name} detected")
222-
platform_to_add = adapter.name
215+
# Add all detected platforms
216+
for adapter in available_adapters:
217+
console.print(f" [green]✓[/green] {adapter.display_name} detected")
218+
platforms_to_add.append(adapter.name)
219+
detected_adapters = available_adapters
223220

224221
# Step 3: Create .deepwork/ directory structure
225222
console.print("[yellow]→[/yellow] Creating DeepWork directory structure...")
@@ -256,12 +253,16 @@ def _install_deepwork(platform_name: str | None, project_path: Path) -> None:
256253
if "platforms" not in config_data:
257254
config_data["platforms"] = []
258255

259-
# Add platform if not already present
260-
if platform_to_add not in config_data["platforms"]:
261-
config_data["platforms"].append(platform_to_add)
262-
console.print(f" [green]✓[/green] Added {adapter.display_name} to platforms")
263-
else:
264-
console.print(f" [dim]•[/dim] {adapter.display_name} already configured")
256+
# Add each platform if not already present
257+
added_platforms: list[str] = []
258+
for i, platform in enumerate(platforms_to_add):
259+
adapter = detected_adapters[i]
260+
if platform not in config_data["platforms"]:
261+
config_data["platforms"].append(platform)
262+
added_platforms.append(adapter.display_name)
263+
console.print(f" [green]✓[/green] Added {adapter.display_name} to platforms")
264+
else:
265+
console.print(f" [dim]•[/dim] {adapter.display_name} already configured")
265266

266267
save_yaml(config_file, config_data)
267268
console.print(f" [green]✓[/green] Updated {config_file.relative_to(project_path)}")
@@ -280,8 +281,9 @@ def _install_deepwork(platform_name: str | None, project_path: Path) -> None:
280281

281282
# Success message
282283
console.print()
284+
platform_names = ", ".join(a.display_name for a in detected_adapters)
283285
console.print(
284-
f"[bold green]✓ DeepWork installed successfully for {adapter.display_name}![/bold green]"
286+
f"[bold green]✓ DeepWork installed successfully for {platform_names}![/bold green]"
285287
)
286288
console.print()
287289
console.print("[bold]Next steps:[/bold]")

tests/conftest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,26 @@ def mock_claude_project(mock_git_repo: Path) -> Path:
3535
return mock_git_repo
3636

3737

38+
@pytest.fixture
39+
def mock_gemini_project(mock_git_repo: Path) -> Path:
40+
"""Create a mock project with Gemini CLI setup."""
41+
gemini_dir = mock_git_repo / ".gemini"
42+
gemini_dir.mkdir(exist_ok=True)
43+
return mock_git_repo
44+
45+
46+
@pytest.fixture
47+
def mock_multi_platform_project(mock_git_repo: Path) -> Path:
48+
"""Create a mock project with multiple AI platforms setup."""
49+
claude_dir = mock_git_repo / ".claude"
50+
claude_dir.mkdir(exist_ok=True)
51+
(claude_dir / "settings.json").write_text('{"version": "1.0"}')
52+
53+
gemini_dir = mock_git_repo / ".gemini"
54+
gemini_dir.mkdir(exist_ok=True)
55+
return mock_git_repo
56+
57+
3858
@pytest.fixture
3959
def fixtures_dir() -> Path:
4060
"""Return the path to the fixtures directory."""

tests/integration/test_install_flow.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,38 @@ def test_install_fails_without_platform(self, mock_git_repo: Path) -> None:
7979
assert result.exit_code != 0
8080
assert "No AI platform detected" in result.output
8181

82-
# NOTE: Multiple platform detection test removed since we currently only support Claude.
83-
# When more adapters are added, this test should be reinstated.
82+
def test_install_with_multiple_platforms_auto_detect(
83+
self, mock_multi_platform_project: Path
84+
) -> None:
85+
"""Test installing with auto-detection when multiple platforms are present."""
86+
runner = CliRunner()
87+
88+
result = runner.invoke(
89+
cli,
90+
["install", "--path", str(mock_multi_platform_project)],
91+
catch_exceptions=False,
92+
)
93+
94+
assert result.exit_code == 0
95+
assert "Auto-detecting AI platforms" in result.output
96+
assert "Claude Code detected" in result.output
97+
assert "Gemini CLI detected" in result.output
98+
assert "DeepWork installed successfully for Claude Code, Gemini CLI" in result.output
99+
100+
# Verify config.yml has both platforms
101+
config_file = mock_multi_platform_project / ".deepwork" / "config.yml"
102+
config = load_yaml(config_file)
103+
assert config is not None
104+
assert "claude" in config["platforms"]
105+
assert "gemini" in config["platforms"]
106+
107+
# Verify commands were created for both platforms
108+
claude_dir = mock_multi_platform_project / ".claude" / "commands"
109+
assert (claude_dir / "deepwork_jobs.define.md").exists()
110+
111+
# Gemini uses job_name/step_id.toml structure
112+
gemini_dir = mock_multi_platform_project / ".gemini" / "commands"
113+
assert (gemini_dir / "deepwork_jobs" / "define.toml").exists()
84114

85115
def test_install_with_specified_platform_when_missing(self, mock_git_repo: Path) -> None:
86116
"""Test that install fails when specified platform is not present."""

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)