@@ -1775,6 +1775,142 @@ def version():
17751775 console .print ()
17761776
17771777
1778+ @app .command ()
1779+ def status ():
1780+ """Show current project status and SDD workflow progress."""
1781+ show_banner ()
1782+
1783+ project_root = Path .cwd ()
1784+
1785+ # Check if we're in a spec-kit project
1786+ specify_dir = project_root / ".specify"
1787+ if not specify_dir .exists ():
1788+ console .print ("[red]Error:[/red] Not a spec-kit project (no .specify/ directory)" )
1789+ console .print ("Run [cyan]specify init[/cyan] first to create a project, or cd into an existing one." )
1790+ raise typer .Exit (1 )
1791+
1792+ project_name = project_root .name
1793+
1794+ # --- Detect AI agent(s) by scanning for known agent folders ---
1795+ detected_agents = []
1796+ for agent_key , agent_config in AGENT_CONFIG .items ():
1797+ if agent_key == "generic" :
1798+ continue
1799+ folder = agent_config .get ("folder" )
1800+ if folder and (project_root / folder .rstrip ("/" )).is_dir ():
1801+ commands_subdir = agent_config .get ("commands_subdir" , "commands" )
1802+ commands_dir = project_root / folder .rstrip ("/" ) / commands_subdir
1803+ has_commands = commands_dir .is_dir () and any (commands_dir .iterdir ())
1804+ detected_agents .append ({
1805+ "key" : agent_key ,
1806+ "name" : agent_config ["name" ],
1807+ "folder" : folder ,
1808+ "has_commands" : has_commands ,
1809+ })
1810+
1811+ # --- Detect script type ---
1812+ script_type = None
1813+ if (specify_dir / "scripts" / "bash" ).is_dir ():
1814+ script_type = "sh"
1815+ if (specify_dir / "scripts" / "powershell" ).is_dir ():
1816+ script_type = "ps" if script_type is None else "sh + ps"
1817+
1818+ # --- Detect current feature ---
1819+ current_branch = None
1820+ has_git = False
1821+
1822+ # 1. Check SPECIFY_FEATURE env var
1823+ env_feature = os .environ .get ("SPECIFY_FEATURE" , "" ).strip ()
1824+ if env_feature :
1825+ current_branch = env_feature
1826+
1827+ # 2. Try git branch
1828+ if not current_branch :
1829+ try :
1830+ result = subprocess .run (
1831+ ["git" , "rev-parse" , "--abbrev-ref" , "HEAD" ],
1832+ capture_output = True , text = True , timeout = 5 ,
1833+ cwd = str (project_root ),
1834+ )
1835+ if result .returncode == 0 :
1836+ has_git = True
1837+ current_branch = result .stdout .strip ()
1838+ except (FileNotFoundError , subprocess .TimeoutExpired ):
1839+ pass
1840+
1841+ # 3. Fallback: scan specs/ for highest-numbered directory
1842+ if not current_branch or not current_branch [0 :3 ].isdigit ():
1843+ specs_dir = project_root / "specs"
1844+ if specs_dir .is_dir ():
1845+ highest_num = 0
1846+ latest_feature = None
1847+ for d in specs_dir .iterdir ():
1848+ if d .is_dir () and len (d .name ) >= 4 and d .name [:3 ].isdigit () and d .name [3 ] == "-" :
1849+ num = int (d .name [:3 ])
1850+ if num > highest_num :
1851+ highest_num = num
1852+ latest_feature = d .name
1853+ if latest_feature and (not current_branch or current_branch in ("main" , "master" )):
1854+ current_branch = latest_feature
1855+
1856+ # --- Resolve feature directory (prefix-based matching like common.sh) ---
1857+ feature_dir = None
1858+ if current_branch and len (current_branch ) >= 4 and current_branch [:3 ].isdigit () and current_branch [3 ] == "-" :
1859+ prefix = current_branch [:3 ]
1860+ specs_dir = project_root / "specs"
1861+ if specs_dir .is_dir ():
1862+ matches = [d for d in specs_dir .iterdir () if d .is_dir () and d .name .startswith (f"{ prefix } -" )]
1863+ if len (matches ) == 1 :
1864+ feature_dir = matches [0 ]
1865+ elif len (matches ) > 1 :
1866+ # Try exact match first
1867+ exact = specs_dir / current_branch
1868+ if exact .is_dir ():
1869+ feature_dir = exact
1870+ else :
1871+ feature_dir = matches [0 ] # Use first match
1872+
1873+ # --- Build output ---
1874+ info_table = Table (show_header = False , box = None , padding = (0 , 2 ))
1875+ info_table .add_column ("Key" , style = "cyan" , justify = "right" , min_width = 16 )
1876+ info_table .add_column ("Value" , style = "white" )
1877+
1878+ info_table .add_row ("Project" , f"[bold]{ project_name } [/bold]" )
1879+
1880+ if detected_agents :
1881+ for i , agent in enumerate (detected_agents ):
1882+ label = "AI Agent" if i == 0 else ""
1883+ cmd_status = "[green]commands present[/green]" if agent ["has_commands" ] else "[yellow]no commands[/yellow]"
1884+ info_table .add_row (label , f"{ agent ['name' ]} ({ agent ['folder' ]} ) { cmd_status } " )
1885+ else :
1886+ info_table .add_row ("AI Agent" , "[yellow]none detected[/yellow]" )
1887+
1888+ if script_type :
1889+ info_table .add_row ("Script Type" , script_type )
1890+
1891+ if has_git :
1892+ info_table .add_row ("Git Branch" , current_branch or "[dim]unknown[/dim]" )
1893+ else :
1894+ if env_feature :
1895+ info_table .add_row ("Feature" , f"{ env_feature } [dim](from SPECIFY_FEATURE)[/dim]" )
1896+ else :
1897+ info_table .add_row ("Git" , "[yellow]not available[/yellow]" )
1898+
1899+ if feature_dir :
1900+ info_table .add_row ("Feature Dir" , f"specs/{ feature_dir .name } /" )
1901+ elif current_branch and current_branch not in ("main" , "master" ):
1902+ info_table .add_row ("Feature Dir" , f"[yellow]not found for { current_branch } [/yellow]" )
1903+
1904+ panel = Panel (
1905+ info_table ,
1906+ title = "[bold cyan]Specify Project Status[/bold cyan]" ,
1907+ border_style = "cyan" ,
1908+ padding = (1 , 2 ),
1909+ )
1910+ console .print (panel )
1911+ console .print ()
1912+
1913+
17781914# ===== Extension Commands =====
17791915
17801916extension_app = typer .Typer (
0 commit comments