@@ -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