Skip to content

Commit 6ed58ec

Browse files
committed
fix(integrations): backfill extensions for installed switch targets
1 parent 2fdbc41 commit 6ed58ec

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

src/specify_cli/integrations/_migrate_commands.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ def integration_switch(
122122
parsed_options=parsed_options,
123123
refresh_templates_force=force,
124124
)
125+
_register_extensions_for_agent(
126+
project_root,
127+
target,
128+
continuing=(
129+
"The integration switch succeeded, but installed extensions may "
130+
"need re-registration."
131+
),
132+
)
125133
console.print(f"\n[green]✓[/green] Default integration set to [bold]{target}[/bold].")
126134
raise typer.Exit(0)
127135

tests/integrations/test_integration_subcommand.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,40 @@ def test_switch_migrates_extension_commands(self, tmp_path):
18581858
assert "claude" in registered_commands
18591859
assert "opencode" not in registered_commands
18601860

1861+
def test_switch_installed_target_backfills_extension_commands(self, tmp_path):
1862+
"""Switching to an already-installed agent should register extensions."""
1863+
project = _init_project(tmp_path, "claude")
1864+
1865+
result = _run_in_project(project, ["extension", "add", "git"])
1866+
assert result.exit_code == 0, f"extension add failed: {result.output}"
1867+
1868+
registry_path = project / ".specify" / "extensions" / ".registry"
1869+
registered = json.loads(registry_path.read_text(encoding="utf-8"))[
1870+
"extensions"
1871+
]["git"]["registered_commands"]
1872+
assert "claude" in registered
1873+
assert "codex" not in registered, "precondition: codex not yet installed"
1874+
1875+
result = _run_in_project(project, [
1876+
"integration", "install", "codex",
1877+
"--script", "sh",
1878+
])
1879+
assert result.exit_code == 0, result.output
1880+
1881+
codex_git_feature = (
1882+
project / ".agents" / "skills" / "speckit-git-feature" / "SKILL.md"
1883+
)
1884+
assert not codex_git_feature.exists()
1885+
1886+
result = _run_in_project(project, ["integration", "switch", "codex"])
1887+
assert result.exit_code == 0, result.output
1888+
1889+
registered = json.loads(registry_path.read_text(encoding="utf-8"))[
1890+
"extensions"
1891+
]["git"]["registered_commands"]
1892+
assert "codex" in registered
1893+
assert codex_git_feature.exists()
1894+
18611895
def test_switch_migrates_copilot_skills_extension_commands(self, tmp_path):
18621896
"""Copilot --skills should receive extension skills, not .agent.md files."""
18631897
project = _init_project(tmp_path, "opencode")

0 commit comments

Comments
 (0)