@@ -1650,15 +1650,7 @@ def integration_install(
16501650 )
16511651 manifest .save ()
16521652 _write_integration_json (project_root , integration .key , selected_script )
1653-
1654- # Update init-options.json to reflect the new integration
1655- opts = load_init_options (project_root )
1656- opts ["integration" ] = integration .key
1657- opts ["ai" ] = integration .key
1658- from .integrations .base import SkillsIntegration
1659- if isinstance (integration , SkillsIntegration ):
1660- opts ["ai_skills" ] = True
1661- save_init_options (project_root , opts )
1653+ _update_init_options_for_integration (project_root , integration )
16621654
16631655 except Exception as e :
16641656 console .print (f"[red]Error:[/red] Failed to install integration: { e } " )
@@ -1668,8 +1660,11 @@ def integration_install(
16681660 console .print (f"\n [green]✓[/green] Integration '{ name } ' installed successfully" )
16691661
16701662
1671- def _parse_integration_options (integration : Any , raw_options : str ) -> dict [str , Any ]:
1672- """Parse --integration-options string into a dict matching the integration's declared options."""
1663+ def _parse_integration_options (integration : Any , raw_options : str ) -> dict [str , Any ] | None :
1664+ """Parse --integration-options string into a dict matching the integration's declared options.
1665+
1666+ Returns ``None`` when no recognised options are found.
1667+ """
16731668 import shlex
16741669 parsed : dict [str , Any ] = {}
16751670 tokens = shlex .split (raw_options )
@@ -1690,6 +1685,22 @@ def _parse_integration_options(integration: Any, raw_options: str) -> dict[str,
16901685 return parsed or None
16911686
16921687
1688+ def _update_init_options_for_integration (
1689+ project_root : Path ,
1690+ integration : Any ,
1691+ ) -> None :
1692+ """Update ``init-options.json`` to reflect *integration* as the active one."""
1693+ from .integrations .base import SkillsIntegration
1694+ opts = load_init_options (project_root )
1695+ opts ["integration" ] = integration .key
1696+ opts ["ai" ] = integration .key
1697+ if isinstance (integration , SkillsIntegration ):
1698+ opts ["ai_skills" ] = True
1699+ else :
1700+ opts .pop ("ai_skills" , None )
1701+ save_init_options (project_root , opts )
1702+
1703+
16931704@integration_app .command ("uninstall" )
16941705def integration_uninstall (
16951706 key : str = typer .Argument (None , help = "Integration key to uninstall (default: current integration)" ),
@@ -1828,17 +1839,7 @@ def integration_switch(
18281839 )
18291840 manifest .save ()
18301841 _write_integration_json (project_root , target_integration .key , selected_script )
1831-
1832- # Update init-options.json
1833- opts = load_init_options (project_root )
1834- opts ["integration" ] = target_integration .key
1835- opts ["ai" ] = target_integration .key
1836- from .integrations .base import SkillsIntegration
1837- if isinstance (target_integration , SkillsIntegration ):
1838- opts ["ai_skills" ] = True
1839- else :
1840- opts .pop ("ai_skills" , None )
1841- save_init_options (project_root , opts )
1842+ _update_init_options_for_integration (project_root , target_integration )
18421843
18431844 except Exception as e :
18441845 console .print (f"[red]Error:[/red] Failed to install integration '{ target } ': { e } " )
0 commit comments