@@ -1419,16 +1419,12 @@ def init(
14191419 if spec_sync :
14201420 tracker .start ("spec_sync" , "setting up spec-code synchronization" )
14211421 try :
1422- # Run the spec-hooks install command
1423- result = subprocess .run ([
1424- sys .executable , "-m" , "specify_cli" , "spec-hooks" , "install" , "--quiet"
1425- ], cwd = project_path , capture_output = True , text = True , check = True )
1422+ # Run the spec hooks installation script directly
1423+ script_path = Path (__file__ ).parent .parent / "scripts" / "bash" / "spec-hooks-install.sh"
1424+ run_command (["bash" , str (script_path )], check_return = True , capture = True )
14261425 tracker .complete ("spec_sync" , "hooks installed" )
1427- except subprocess .CalledProcessError as e :
1428- tracker .error ("spec_sync" , f"failed to install hooks: { e .stderr } " )
1429- console .print (f"[yellow]Warning:[/yellow] Spec sync setup failed: { e .stderr } " )
14301426 except Exception as e :
1431- tracker .error ("spec_sync" , f"unexpected error : { str (e )} " )
1427+ tracker .error ("spec_sync" , f"failed to install hooks : { str (e )} " )
14321428 console .print (f"[yellow]Warning:[/yellow] Spec sync setup failed: { str (e )} " )
14331429 else :
14341430 tracker .skip ("spec_sync" , "not requested" )
@@ -1600,68 +1596,6 @@ def check():
16001596 console .print ("[dim]Tip: Install an AI assistant for the best experience[/dim]" )
16011597
16021598
1603- @app .command ()
1604- def spec_hooks (
1605- action : str = typer .Argument (..., help = "Action: install, uninstall, status" ),
1606- quiet : bool = typer .Option (False , "--quiet" , help = "Suppress output for automated usage" ),
1607- ):
1608- """Manage specification synchronization hooks."""
1609- if action == "install" :
1610- success = install_spec_hooks (quiet = quiet )
1611- if not quiet :
1612- if success :
1613- console .print ("[green]✓[/green] Specification synchronization hooks installed" )
1614- console .print (" Background spec-code sync is now active" )
1615- console .print (" Use 'specify spec-hooks --help' for management commands" )
1616- else :
1617- console .print ("[red]✗[/red] Failed to install specification synchronization hooks" )
1618- raise typer .Exit (1 )
1619- elif action == "uninstall" :
1620- if not quiet :
1621- console .print ("[yellow]Uninstall functionality not yet implemented[/yellow]" )
1622- elif action == "status" :
1623- if not quiet :
1624- console .print ("[yellow]Status check not yet implemented[/yellow]" )
1625- else :
1626- if not quiet :
1627- console .print (f"[red]Unknown action: { action } [/red]" )
1628- console .print ("Available actions: install, uninstall, status" )
1629- raise typer .Exit (1 )
1630-
1631-
1632- def install_spec_hooks (quiet : bool = False ) -> bool :
1633- """Install specification synchronization hooks for the current project."""
1634- try :
1635- # Check if we're in a git repository
1636- if not is_git_repo ():
1637- if not quiet :
1638- console .print ("[yellow]Warning:[/yellow] Not in a git repository. Spec sync requires git." )
1639- return False
1640-
1641- # Run the hook installation script
1642- script_dir = Path (__file__ ).parent .parent / "scripts" / "bash"
1643- hook_script = script_dir / "spec-hooks-install.sh"
1644-
1645- if not hook_script .exists ():
1646- if not quiet :
1647- console .print ("[red]Error:[/red] Spec hooks installation script not found." )
1648- return False
1649-
1650- result = subprocess .run ([
1651- "bash" , str (hook_script )
1652- ], capture_output = quiet , text = True , check = True )
1653-
1654- return True
1655-
1656- except subprocess .CalledProcessError as e :
1657- if not quiet :
1658- console .print (f"[red]Error installing spec hooks:[/red] { e .stderr } " )
1659- return False
1660- except Exception as e :
1661- if not quiet :
1662- console .print (f"[red]Unexpected error:[/red] { str (e )} " )
1663- return False
1664-
16651599
16661600def main ():
16671601 app ()
0 commit comments