
    .:i:                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r
  SSKJrJr  SSKrSSKrSSKJr  SSKJr  SSKJrJrJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSK J!r!  SSK"J#r#  SSK$r$SSK%r%SSK&r&SSK'J'r'J(r(  \&RR                  " \%RT                  5      r+\RX                  " \+S9r-SS\.S-  S\.S-  4S jjr/SS\.S-  S\04S jjr1S\Rd                  S\04S jr3S\4S\Rd                  S\.S\.4S jr50 SSSSSS._SSS S!S"S._S#S$S%S&S"S._S'S(S)SSS._S*S+S,S-S"S._S.S.S/S0S"S._S1S2S3S4S"S._S5S6S7SSS._S8S9S:SSS._S;S<S=S>S"S._S?S@SASBS"S._SCSDSESFS"S._SGSHSISSS._SJSKSLSMS"S._SNSOSPSQS"S._SRSSSTSUS"S._SVSWSXSSS._r6SYSZS[.r7\
Rp                  " 5       S\-  S]-  S-  r9S^r:S_r; " S` Sa5      r<Sb r=SSc\0Sd\.Se\.S\.4Sf jjr>\" 5       r? " Sg Sh\#5      r@\R                  " SiSjSS"\@Sk9rBSl rC\BR                  5       Sm\R                  4Sn j5       rDSSo\F\.   Sp\GSq\GSr\GS\\.   4
Ss jjrHSSt\.Su\<S\G4Sv jjrISSw\
S\G4Sx jjrJSSy\
Sz\GS\\G\\.   4   4S{ jjrKSSS| jjrLSS}\
S~\0S\GS\04S jjrMSS"S"SSSS.S\.S\
S\.S\GS\GS\RX                  S\GS\.S\\
\04   4S jjrNSS"SSSSS.Sy\
S\.S\.S\GS\GSu\<S-  S\RX                  S\GS\.S\
4S jjjrOSSy\
Su\<S-  SS4S jjrP\BR                  5       \R                  " SSS9\R                  " SSSS9\R                  " SSSS9\R                  " SSSS9\R                  " SSSS9\R                  " SSSS9\R                  " SSSS9\R                  " SSSS9\R                  " SSSS9\R                  " SSSS94
S\.S\.S\.S\GS\GS\GS\GS\GS\GS\.4S jj5       rT\BR                  5       S 5       rU\BR                  5       S 5       rVS rW\XS:X  a  \W" 5         gg)a:  
Specify CLI - Setup tool for Specify projects

Usage:
    uvx specify-cli.py init <project-name>
    uvx specify-cli.py init .
    uvx specify-cli.py init --here

Or install globally:
    uv tool install --from specify-cli.py specify-cli
    specify init <project-name>
    specify init .
    specify init --here
    N)Path)OptionalTuple)Console)Panel)ProgressSpinnerColumn
TextColumn)Text)Live)Align)Table)Tree)
TyperGroup)datetimetimezoneverify	cli_tokenreturnc                     U =(       d<    [         R                  " S5      =(       d    [         R                  " S5      =(       d    SR                  5       =(       d    S$ )zAReturn sanitized GitHub token (cli arg takes precedence) or None.GH_TOKENGITHUB_TOKEN N)osgetenvstrip)r   s    N/home/james-whalen/.local/lib/python3.13/site-packages/specify_cli/__init__.py_github_tokenr   ;   s9    R"))J/R299^3LRPRYY[d`dd    c                 8    [        U 5      nU(       a  SSU 30$ 0 $ )zDReturn Authorization header dict only when a non-empty token exists.AuthorizationzBearer )r   )r   tokens     r   _github_auth_headersr$   ?   s%    )$E38Owug./@b@r    headersc                    0 nSU ;   a  U R                  S5      US'   SU ;   a  U R                  S5      US'   SU ;   a`  [        U R                  SS5      5      nU(       a>  [        R                  " U[        R
                  S9nX!S'   X1S	'   UR                  5       US
'   SU ;   a"  U R                  S5      n [        U5      US'   U$ U$ ! [         a    XAS'    U$ f = f)z,Extract and parse GitHub rate-limit headers.zX-RateLimit-LimitlimitzX-RateLimit-Remaining	remainingzX-RateLimit-Reset0)tzreset_epoch
reset_timereset_localzRetry-Afterretry_after_secondsretry_after)getintr   fromtimestampr   utc
astimezone
ValueError)r%   infor+   r,   r/   s        r   _parse_rate_limit_headersr7   D   s    D g%$78W')#KK(?@[g%'++&93?@!//MJ"-!+","7"7"9D kk-0	.*-k*:D&'
 K4K	  	."-K		.s   5C CCstatus_codeurlc                 x   [        U5      nSU  SU 3/nUR                  S5        U(       a  UR                  S5        SU;   a  UR                  SUS    S35        SU;   a  UR                  S	US    35        S
U;   a(  US
   R                  S5      nUR                  SU 35        SU;   a  UR                  SUS    S35        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        SR                  U5      $ )zAFormat a user-friendly error message with rate-limit information.zGitHub API returned status z for r   z$[bold]Rate Limit Information:[/bold]r'   u     • Rate Limit: z requests/hourr(   u     • Remaining: r-   z%Y-%m-%d %H:%M:%S %Zu     • Resets at: r.   u     • Retry after: z secondsz"[bold]Troubleshooting Tips:[/bold]uQ     • If you're on a shared CI or corporate environment, you may be rate-limited.uS     • Consider using a GitHub token via --github-token or the GH_TOKEN/GITHUB_TOKENz1    environment variable to increase rate limits.uW     • Authenticated requests have a limit of 5,000/hour vs 60/hour for unauthenticated.
)r7   appendstrftimejoin)r8   r%   r9   	rate_infolines	reset_strs         r   _format_rate_limit_errorrB   `   s9   )'2I*;-uSEBCE	LL;<iLL-i.@-APQ)#LL,Y{-C,DEFI%!-099:PQILL,YK89 I-LL.y9N/O.PPXYZR 
LL56	LLde	LLfg	LLDE	LLjk99Ur    copilotzGitHub Copilotz.github/F)namefolderinstall_urlrequires_cliclaudezClaude Codez.claude/z4https://docs.anthropic.com/en/docs/claude-code/setupTgeminiz
Gemini CLIz.gemini/z+https://github.com/google-gemini/gemini-clizcursor-agentCursorz.cursor/qwenz	Qwen Codez.qwen/z#https://github.com/QwenLM/qwen-codeopencodez
.opencode/zhttps://opencode.aicodexz	Codex CLIz.codex/zhttps://github.com/openai/codexwindsurfWindsurfz
.windsurf/kilocodez	Kilo Codez
.kilocode/auggiez
Auggie CLIz	.augment/z@https://docs.augmentcode.com/cli/setup-auggie/install-auggie-cli	codebuddy	CodeBuddyz.codebuddy/zhttps://www.codebuddy.ai/cliqoderz	Qoder CLIz.qoder/zhttps://qoder.com/cliroozRoo Codez.roo/qzAmazon Q Developer CLIz	.amazonq/z:https://aws.amazon.com/developer/learning/q-developer-cli/ampAmpz.agents/z"https://ampcode.com/manual#installshaiSHAIz.shai/zhttps://github.com/ovh/shaibobzIBM Bobz.bob/zPOSIX Shell (bash/zsh)
PowerShell)shpsz.claudelocalu/  
███████╗██████╗ ███████╗ ██████╗██╗███████╗██╗   ██╗
██╔════╝██╔══██╗██╔════╝██╔════╝██║██╔════╝╚██╗ ██╔╝
███████╗██████╔╝█████╗  ██║     ██║█████╗   ╚████╔╝ 
╚════██║██╔═══╝ ██╔══╝  ██║     ██║██╔══╝    ╚██╔╝  
███████║██║     ███████╗╚██████╗██║██║        ██║   
╚══════╝╚═╝     ╚══════╝ ╚═════╝╚═╝╚═╝        ╚═╝   
z1GitHub Spec Kit - Spec-Driven Development Toolkitc                       \ rS rSrSrS\4S jrS rS\S\4S jrSS\S	\4S
 jjr	SS\S	\4S jjr
SS\S	\4S jjrSS\S	\4S jjrS\S\S	\4S jrS rS rSrg)StepTracker   zTrack and render hierarchical steps without emojis, similar to Claude Code tree output.
Supports live auto-refresh via an attached refresh callback.
titlec                 F    Xl         / U l        SSSSSS.U l        S U l        g )Nr               )pendingrunningdoneerrorskipped)rc   stepsstatus_order_refresh_cb)selfrc   s     r   __init__StepTracker.__init__   s*    

()aQ[\]r    c                     Xl         g N)rp   )rq   cbs     r   attach_refreshStepTracker.attach_refresh   s    r    keylabelc                     XR                    Vs/ s H  o3S   PM	     sn;  a0  U R                   R                  XSSS.5        U R                  5         g g s  snf )Nry   ri   r   ry   rz   statusdetail)rn   r<   _maybe_refresh)rq   ry   rz   ss       r   addStepTracker.add  sK    4Ax44JJcYZ\]^! 54s   Ar~   c                 &    U R                  USUS9  g )Nrj   r}   r~   _updaterq   ry   r~   s      r   startStepTracker.start      S6:r    c                 &    U R                  USUS9  g )Nrk   r   r   r   s      r   completeStepTracker.complete
  s    S7r    c                 &    U R                  USUS9  g )Nrl   r   r   r   s      r   rl   StepTracker.error  s    S8r    c                 &    U R                  USUS9  g )Nrm   r   r   r   s      r   skipStepTracker.skip  r   r    r}   c                     U R                    H-  nUS   U:X  d  M  X$S'   U(       a  X4S'   U R                  5           g    U R                   R                  XX#S.5        U R                  5         g )Nry   r}   r~   r|   )rn   r   r<   )rq   ry   r}   r~   r   s        r   r   StepTracker._update  s`    Ax3$("(hK##%  	

#vXYr    c                 j    U R                   (       a   U R                  5         g g ! [         a     g f = fru   )rp   	Exception)rq   s    r   r   StepTracker._maybe_refresh  s5      "   s   % 
22c                    [        SU R                   S3SS9nU R                   H  nUS   nUS   (       a  US   R                  5       OSnUS   nUS	:X  a  S
nO&US:X  a  SnOUS:X  a  SnOUS:X  a  SnOUS:X  a  SnOSnUS:X  a  U(       a  U SU SU S3nO$U SU S3nOU(       a  U SU SU S3nOU SU S3nUR	                  U5        M     U$ )N[cyan][/cyan]grey50)guide_stylerz   r~   r   r}   rk   u   [green]●[/green]ri   u   [green dim]○[/green dim]rj   u   [cyan]○[/cyan]rl   u   [red]●[/red]rm   u   [yellow]○[/yellow] z [bright_black] (z)[/bright_black][/bright_black]z [white]z[/white] [bright_black](z[/white])r   rc   rn   r   r   )rq   treesteprz   detail_textr}   symbollines           r   renderStepTracker.render&  s   fTZZL0hGJJDME48N$x...0K(^F-9$59$+7")9$/"$X_UG2k]JZ[D$X_UG?KD $XXeW4L[MYijD$XXeWH=DHHTN? @ r    )rp   ro   rn   rc   N)r   )__name__
__module____qualname____firstlineno____doc__strrr   rw   r   r   r   rl   r   r   r   r   __static_attributes__ r    r   ra   ra      s     c  "s "3 "
; ;c ;8C 8 89 9c 9; ;S ;
3 
 
S 
"r    ra   c                     [         R                  " 5       n U [         R                  R                  :X  d  U [         R                  R                  :X  a  gU [         R                  R
                  :X  d  U [         R                  R                  :X  a  gU [         R                  R                  :X  a  gU [         R                  R                  :X  a  gU [         R                  R                  :X  a  [        eU $ )z=Get a single keypress in a cross-platform way using readchar.updownenterescape)readcharreadkeyry   UPCTRL_PDOWNCTRL_NENTERESCCTRL_CKeyboardInterrupt)ry   s    r   get_keyr   J  s    



C
hlloo(;(;!;
hll3(,,*=*=#=
hll   
hll
hll!!!Jr    optionsprompt_textdefault_keyc                 @  ^ ^^^^^ [        T R                  5       5      mU(       a  UT;   a  TR                  U5      mOSmSmUU UU4S jm[        R	                  5         UUUU4S jnU" 5         Tc+  [        R	                  S5        [
        R                  " S5      eT$ )a  
Interactive selection using arrow keys with Rich Live display.

Args:
    options: Dict with keys as option keys and values as descriptions
    prompt_text: Text to show above the options
    default_key: Default option key to start with
    
Returns:
    Selected option key
r   Nc            	      ~  > [         R                  " SS9n U R                  SSSS9  U R                  SSS9  [        T5       HE  u  pUT:X  a  U R	                  S	S
U STU    S35        M)  U R	                  SS
U STU    S35        MG     U R	                  SS5        U R	                  SS5        [        U ST S3SSS9$ )z>Create the selection panel with current selection highlighted.r   rf   )paddingcyanleftrg   )stylejustifywidthwhiter   r   u   ▶r   z[/cyan] [dim](z)[/dim]r   r   uB   [dim]Use ↑/↓ to navigate, Enter to select, Esc to cancel[/dim]z[bold]z[/bold]re   rf   rc   border_styler   )r   grid
add_column	enumerateadd_rowr   )tableiry   option_keysr   r   selected_indexs      r   create_selection_panel2select_with_arrows.<locals>.create_selection_panelr  s    

6*vvQ?w7,FAN"evcU.g%VWcVC5ws|nG#TU	 - 	b"b^_;-w/	
 	
r    c                    > [        T" 5       [        SSS9 n   [        5       nUS:X  a  TS-
  [        T5      -  mOUUS:X  a  TS-   [        T5      -  mO=US:X  a  TT   mOHUS:X  a+  [        R	                  S	5        [
        R                  " S5      eU R                  T" 5       SS
9  M  S S S 5        g ! [         a,    [        R	                  S	5        [
        R                  " S5      ef = f! , (       d  f       g = f)NTF)console	transientauto_refreshr   re   r   r   r   z%
[yellow]Selection cancelled[/yellow])refresh)	r   r   r   lenprinttyperExitupdater   )livery   r   r   r   selected_keys     r   run_selection_loop.select_with_arrows.<locals>.run_selection_loop  s    (*GtZ_`dh(!)Cd{*81*<K@P)P*81*<K@P)P'2>'B&NO#jjm+KK 6 8$KG  a`" ) (MM"JK**Q-'(# a`s0   C*AB1C* AB1&C*16C''C**
C8z
[red]Selection failed.[/red]re   )listkeysindexr   r   r   r   )r   r   r   r   r   r   r   r   s   ``  @@@@r   select_with_arrowsr   ^  s     w||~&K{k1$**;7L
 
, MMO( (. 67jjmr    c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )BannerGroupi  z+Custom group that shows banner before help.c                 8   > [        5         [        TU ]	  X5        g ru   )show_bannersuperformat_help)rq   ctx	formatter	__class__s      r   r   BannerGroup.format_help  s    C+r    r   )r   r   r   r   r   r   r   __classcell__)r   s   @r   r   r     s    5, ,r    r   specifyz7Setup tool for Specify spec-driven development projects)rD   helpadd_completioninvoke_without_commandclsc            	         [         R                  5       R                  S5      n / SQn[        5       n[	        U 5       H(  u  p4X[        U5      -     nUR                  US-   US9  M*     [        R                  [        R                  " U5      5        [        R                  [        R                  " [        [        SS95      5        [        R                  5         g)zDisplay the ASCII art banner.r;   )bright_bluebluer   bright_cyanr   bright_whiter   zitalic bright_yellowN)BANNERr   splitr   r   r   r<   r   r   r   centerTAGLINE)banner_linescolorsstyled_bannerr   r   colors         r   r   r     s    <<>''-LTFFM\*3v;'TD[6 + MM%,,}-.MM%,,tG3IJKLMMOr    r   c                    U R                   cr  S[        R                  ;  a]  S[        R                  ;  aH  [        5         [        R                  [        R                  " S5      5        [        R                  5         gggg)z+Show banner when no subcommand is provided.Nz--helpz-hz5[dim]Run 'specify --help' for usage information[/dim])invoked_subcommandsysargvr   r   r   r   r  )r   s    r   callbackr    sZ     %(#((*BtSVS[S[G[ell#Z[\ H\*B%r    cmdcheck_returncaptureshellc                     U(       a1  [         R                  " XSSUS9nUR                  R                  5       $ [         R                  " XUS9  g! [         R                   a  nU(       a  [
        R                  SSR                  U 5       35        [
        R                  SUR                   35        [        US5      (       a3  UR                  (       a"  [
        R                  S	UR                   35        e  SnAgSnAff = f)
z2Run a shell command and optionally capture output.T)checkcapture_outputtextr  )r  r  Nz"[red]Error running command:[/red] r   z[red]Exit code:[/red] stderrz[red]Error output:[/red] )
subprocessrunstdoutr   CalledProcessErrorr   r   r>   
returncodehasattrr  )r  r  r  r  resultes         r   run_commandr     s    ^^CDW[chiF==&&((NN3%@(( MM>sxx}oNOMM21<<.ABq(## 9!((DEs   7A A D$BC>>Dtooltrackerc                 B   U S:X  aL  [         R                  5       (       a3  [         R                  5       (       a  U(       a  UR                  U S5        g[        R
                  " U 5      SLnU(       a-  U(       a  UR                  U S5        U$ UR                  U S5        U$ )zCheck if a tool is installed. Optionally update tracker.

Args:
    tool: Name of the tool to check
    tracker: Optional StepTracker to update with results
    
Returns:
    True if tool is found, False otherwise
rH   	availableTNz	not found)CLAUDE_LOCAL_PATHexistsis_filer   shutilwhichrl   )r!  r"  founds      r   
check_toolr+    s     x##%%*;*C*C*E*E  {3LLd*ET;/ L MM$,Lr    pathc                     U c  [         R                  " 5       n U R                  5       (       d  g [        R                  " / SQSSU S9  g! [        R
                  [        4 a     gf = f)z7Check if the specified path is inside a git repository.F)gitz	rev-parsez--is-inside-work-treeT)r  r  cwd)r   r/  is_dirr  r  r  FileNotFoundError)r,  s    r   is_git_repor2    s`    |xxz;;==
9		
 ))+<= s   A
 
A'&A'project_pathquietc                     [         R                  " 5       n[        R                  " U 5        U(       d  [        R                  S5        [        R                  " SS/SSSS9  [        R                  " / SQSSSS9  [        R                  " / SQSSSS9  U(       d  [        R                  S5         [        R                  " U5        g	! [        R                   a  nS
SR                  UR                  5       SUR                   3nUR                  (       a!  USUR                  R                  5        3-  nO1UR                  (       a   USUR                  R                  5        3-  nU(       d  [        R                  SU 35        SU4s SnA[        R                  " W5        $ SnAff = f! [        R                  " W5        f = f)zInitialize a git repository in the specified path.

Args:
    project_path: Path to initialize git repository in
    quiet: if True suppress console output (tracker handles status)

Returns:
    Tuple of (success: bool, error_message: Optional[str])
z+[cyan]Initializing git repository...[/cyan]r.  initT)r  r  r  )r.  r   .)r.  commitz-mz$Initial commit from Specify templateu-   [green]✓[/green] Git repository initialized)TNz	Command: r   z
Exit code: z
Error: z	
Output: z.[red]Error initializing git repository:[/red] FN)r   r/  r   chdirr   r   r  r  r  r>   r  r  r  r   r  )r3  r4  original_cwdr  	error_msgs        r   init_git_repor<    sV   xxz
MMGHvd4dS*$tRVWV^bsw  C  	DMMIJ 	 (( 	 0all^L	889QXX^^%5$677IXX:ahhnn&6%788IMMJ1#NOi
	  	s1   B.C F-B0F(F-F0 (F--F0 0Gc                 L  ^^^ SUUU4S jjn [        U SSS9 n[        R                  " U5      nSSS5        UR                  5       (       a]  [	        UWT=(       a    T(       + S9n[        USSS9 n[        R
                  " XS	S
9  UR                  S5        SSS5        U" SS5        g[        R                  " X5        U" SS5        g! , (       d  f       N= f! , (       d  f       NI= f! [         a,  n	U" SU	 3S5        [        R                  " X5         Sn	A	gSn	A	ff = f)z9Handle merging or copying of .vscode/settings.json files.greenc                 b   > T(       a'  T(       d  [         R                  SU SU  ST 35        g g g )N[]z[/] )r   r   )messager	  rel_pathr"  verboses     r   log#handle_vscode_settings.<locals>.log<  s.    7MMAeWAgYd8*=> #7r    rutf-8encodingN)rD  wrh   )indentr;   zMerged:z#Copied (no existing settings.json):r   z+Warning: Could not merge, copying instead: yellow)r>  )
openjsonloadr&  merge_json_filesdumpwriter(  copy2r   )
sub_item	dest_filerC  rD  r"  rE  fnew_settingsmergedr  s
     ```     r   handle_vscode_settingsrZ  :  s    ? ?*(C'2a99Q<L 3 %iwG^W^S^_Fiw71		&A. 8 	7#LL-5v> 32
 87  *9!=xHX))*sL   C- CAC- 2'CC- +C- 
CC- 
C*&C- -
D#7"DD#existing_pathnew_contentrD  c                 \  ^  [        U SSS9 n[        R                  " U5      nSSS5        S[
        S[
        S[
        4U4S jjmT" WU5      nU(       a"  [        R                  S	U R                   35        U$ ! , (       d  f       N\= f! [        [        R                  4 a    Us $ f = f)
a  Merge new JSON content into existing JSON file.

Performs a deep merge where:
- New keys are added
- Existing keys are preserved unless overwritten by new content
- Nested dictionaries are merged recursively
- Lists and other values are replaced (not merged)

Args:
    existing_path: Path to existing JSON file
    new_content: New JSON content to merge in
    verbose: Whether to print merge details

Returns:
    Merged JSON content as dict
rG  rH  rI  Nbaser   r   c                    > U R                  5       nUR                  5        HI  u  p4X2;   a;  [        X#   [        5      (       a$  [        U[        5      (       a  T" X#   U5      X#'   ME  XBU'   MK     U$ )z-Recursively merge update dict into base dict.)copyitems
isinstancedict)r^  r   r  ry   value
deep_merges        r   re  $merge_json_files.<locals>.deep_mergej  s`     ,,.JC}FK!>!>:eUYCZCZ(e< $s ) r    z[cyan]Merged JSON file:[/cyan] )	rN  rO  rP  r1  JSONDecodeErrorrc  r   r   rD   )r[  r\  rD  rW  existing_contentrY  re  s         @r   rQ  rQ  R  s    "-w71#yy| 8
 
t 
 
 (+6F78J8J7KLMM/ 87t334 s-   B A;B ;
B	B 	B B+*B+r]   script_typerD  show_progressclientdebuggithub_tokenai_assistantdownload_dirrj  rk  rl  rm  rn  c          	      
   SnSn	Uc  [         R                  " [        S9nU(       a  [        R	                  S5        SU SU	 S3n
 UR                  U
SS	[        U5      S
9nUR                  nUS:w  a=  [        XR                  U
5      nU(       a  USUR                  S S  3-  n[        U5      e UR                  5       nUR                  S/ 5      nSU  SU 3nU Vs/ s H+  nUUS   ;   d  M  US   R'                  S5      (       d  M)  UPM-     nnU(       a  US   OS nUc  [        R	                  SU  SU S35        U Vs/ s H  nUR                  SS5      PM     nn[        R	                  [        S R)                  U5      =(       d    S!S"S#S95        ["        R$                  " S5      eUS$   nUS   nUS%   nU(       aM  [        R	                  S&U 35        [        R	                  S'US( S)35        [        R	                  S*US+    35        UU-  nU(       a  [        R	                  S,5         UR+                  S-US.S	[        U5      S
9 nUR                  S:w  aH  [        UR                  UR                  U5      nU(       a  US/UR                  S S  3-  n[        U5      e[-        UR                  R                  S0S5      5      n[/        US15       nUS:X  a(  UR1                  S2S39 H  nUR3                  U5        M     OU(       a  [5        [7        5       [9        S45      [9        S55      [        S69 nUR;                  S7US89nSn UR1                  S2S39 H2  nUR3                  U5        U [=        U5      -  n UR?                  UU S99  M4     S S S 5        O'UR1                  S2S39 H  nUR3                  U5        M     S S S 5        S S S 5        U(       a  [        R	                  S<U 35        UUUS+   US=.n"UU"4$ ! [         a#  n[        SU SUR                  S S  35      eS nAff = f! [         aW  n[        R	                  S5        [        R	                  [        [!        U5      SSS95        ["        R$                  " S5      eS nAff = fs  snf s  snf ! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f! [         a~  n[        R	                  S:5        [!        U5      n!URA                  5       (       a  URC                  5         [        R	                  [        U!S;SS95        ["        R$                  " S5      eS nAff = f)>Ngithubspec-kitr   z3[cyan]Fetching latest release information...[/cyan]https://api.github.com/repos///releases/latest   Ttimeoutfollow_redirectsr%      z,

[dim]Response body (truncated 500):[/dim]
i  zFailed to parse release JSON: z
Raw (truncated 400): i  z-[red]Error fetching release information[/red]zFetch Errorredrc   r   re   assetszspec-kit-template--rD   z.zipr   z5[red]No matching release asset found[/red] for [bold]z![/bold] (expected pattern: [bold]z[/bold])?r;   z(no assets)zAvailable AssetsrM  browser_download_urlsizez[cyan]Found template:[/cyan] z[cyan]Size:[/cyan] ,z bytesz[cyan]Release:[/cyan] tag_namez$[cyan]Downloading template...[/cyan]GET<   z,

[dim]Response body (truncated 400):[/dim]
zcontent-lengthwbi    )
chunk_sizez([progress.description]{task.description}z-[progress.percentage]{task.percentage:>3.0f}%)r   zDownloading...)total)	completedz%[red]Error downloading template[/red]zDownload ErrorzDownloaded: )filenamer  release	asset_url)"httpxClientssl_contextr   r   r0   r$   r8   rB   r%   r  RuntimeErrorrO  r5   r   r   r   r   r   endswithr>   streamr1   rN  
iter_bytesrS  r   r	   r
   add_taskr   r   r&  unlink)#ro  rp  rj  rD  rk  rl  rm  rn  
repo_owner	repo_nameapi_urlresponser}   r;  release_datajer  r~  patternassetmatching_assetsaasset_namesdownload_urlr  	file_sizezip_path
total_sizerW  chunkprogresstask
downloadedr~   metadatas#                                      r   download_template_from_githubr  }  sA   JI~[1KL-j\9+EUVG::!(6	  
 %%S=09I9I7SINx}}]a^aObNcdd	y))	r#==?L h+F"<.+?G!!%eFm# 	(-f(>(>v(F 	6  
 #2OAtE}Ml^[|  ~E  }F  FN  O  	P39:6aquuVS)6:eDIIk2CmK]ltuvjjm/0LV}HfI5hZ@A+Ia=?@.|J/G.HIJh&H<>*]]!(6  
 ##s*4X5I5I8K[K[]ij	#RS[S`S`aebeSfRg!hhI"9--X--112BAFGJh%?!)!4!4!4!E "F %%)O&'QR&'VW$+	
 &#+#4#45EZ#4#XD)*J)1)<)<)<)M ! *c%j 8
 (
 K *N  &.%8%8D%8%IEGGEN &J' &
T XJ/0
+!	H Xm  	r!?tCZ[c[h[himjm[nZopqq	r EGeCF-eLMjjm ;L  &%
 
F  =?Q??OOeF*:OPjjms   A*P. 1O> R0RRR3S B
R>A R-9AR0R-R>	S >
P+P&&P++P. .
R8AR

R
R*&R--
R;	7R>>
SS S 
UA9UUrD  r"  rl  rm  rn  is_current_dirc                l   [         R                  " 5       n	U(       a  UR                  SS5         [        UU	UU=(       a    USL USL UUUS9u  pU(       aG  UR	                  SSUS    SUS   S	 S
35        UR                  SS5        UR	                  SUS   5        U(       a$  UR                  SS5        UR                  S5        OU(       a  [        R                  S5         U(       d  U R                  SS9  [        R                  " U
S5       nUR                  5       nU(       a0  UR                  S5        UR	                  S[        U5       S35        O)U(       a"  [        R                  S[        U5       S35        U(       Ga  [         R"                  " 5        n[        U5      nUR%                  U5        ['        UR)                  5       5      nU(       a1  UR                  S5        UR	                  SS[        U5       S35        O)U(       a"  [        R                  S[        U5       S35        Un[        U5      S:X  ad  US   R+                  5       (       aL  US   nU(       a$  UR                  S S!5        UR	                  S 5        OU(       a  [        R                  S"5        UR)                  5        GH  nU UR,                  -  nUR+                  5       (       Ga  UR/                  5       (       a  U(       a)  U(       d"  [        R                  S#UR,                   35        UR1                  S$5       H  nUR3                  5       (       d  M  UR5                  U5      nUU-  nUR6                  R                  SSS%9  UR,                  S&:X  a*  UR6                  R,                  S':X  a  [9        UUUXE5        M  [:        R<                  " UU5        M     GM!  [:        R>                  " UU5        GM;  UR/                  5       (       a0  U(       a)  U(       d"  [        R                  S(UR,                   35        [:        R<                  " UU5        GM     U(       a  U(       d  [        R                  S)5        SSS5        GOUR%                  U 5        ['        U R)                  5       5      nU(       a0  UR                  S5        UR	                  S[        U5       S*35        OrU(       ak  [        R                  S[        U5       S+U  S,35        U H@  n[        R                  S-UR,                   SUR+                  5       (       a  S.OS/ S035        MB     [        U5      S:X  a  US   R+                  5       (       a  US   nU R6                  U R,                   S13-  n[:        R@                  " [        U5      [        U5      5        U RC                  5         [:        R@                  " [        U5      [        U 5      5        U(       a$  UR                  S S!5        UR	                  S 5        OU(       a  [        R                  S25        SSS5        U(       a  UR	                  S5        U(       a  UR                  S7S85        U
R/                  5       (       aS  U
RM                  5         U(       a  UR	                  S75        U $ U(       a"  [        R                  S9U
R,                   35        U $ ! [         aH  nU(       a  UR                  S[        U5      5        e U(       a  [        R                  SU 35        e SnAff = f! , (       d  f       GN= f! , (       d  f       GN= f! [         a  nU(       a  UR                  S[        U5      5        OMU(       aF  [        R                  S3U 35        U(       a'  [        R                  [E        [        U5      S4S5S695        U(       d+  U R/                  5       (       a  [:        RF                  " U 5        [H        RJ                  " S5      eSnAff = f! U(       a  UR                  S7S85        U
R/                  5       (       aT  U
RM                  5         U(       a  UR	                  S75        f U(       a#  [        R                  S9U
R,                   35        f f f = f):zDownload the latest release and extract it to create a new project.
Returns project_path. Uses tracker if provided (with keys: fetch, download, extract, cleanup)
fetchzcontacting GitHub APINri  zrelease r  r   r  r  z bytes)downloadDownload templater  z'[red]Error downloading template:[/red] extractExtract templatezExtracting template...T)parentsrG  zip-listz entriesz[cyan]ZIP contains z items[/cyan]extracted-summaryztemp z itemsz[cyan]Extracted z items to temp location[/cyan]re   r   flattenzFlatten nested directoryz-[cyan]Found nested directory structure[/cyan]z$[yellow]Merging directory:[/yellow] *)r  exist_okzsettings.jsonz.vscodez#[yellow]Overwriting file:[/yellow] z9[cyan]Template files merged into current directory[/cyan]z top-level itemsz
 items to z:[/cyan]  - dirfile)_tempz1[cyan]Flattened nested directory structure[/cyan]z&[red]Error extracting template:[/red] zExtraction Errorr|  r}  cleanupzRemove temporary archivezCleaned up: )'r   r/  r   r  r   r   r   rl   r   r   r   mkdirzipfileZipFilenamelistr   tempfileTemporaryDirectory
extractallr   iterdirr0  rD   r&  rglobr'  relative_toparentrZ  r(  rT  copytreemovermdirr   rmtreer   r   r  )r3  ro  rj  r  rD  r"  rl  rm  rn  current_dirr  metar  zip_refzip_contentstemp_dir	temp_pathextracted_items
source_diritem	dest_pathrU  rC  rV  
nested_dirtemp_move_dirs                             r   download_and_extract_templater    s    ((*Kg676#/4"d?%	
 Wi0ADLQRCSSZ&[\KK
$78Zj)9: I12i 	./l>t,__Xs+w"++-Lj)  L0A/B(-KL 3C4E3FmTU002h $XI&&y1&*9+<+<+>&?O&9:(()<c/FZE[[a>bc (8_9M8NNl&mn!*J?+q0_Q5G5N5N5P5P%4Q%7
"#KK	3MN#,,Y7$#MM,Y[ * 2 2 4$0499$<	;;==(//11#*7$+MM4XY]YbYbXc2d$e04

3H'/'7'7'9'93;3G3G3M4=4H	(1(8(8(>(>tVZ(>([+4>>_+LQZQaQaQfQfjsQs,B8YX`bi,s,2LL9,M 1@ !'i @(//11gg '0STXT]T]S^._ `"LLy9+ !5, w(acW 32Z ""<0"&|';';'=">MM"56$$%8S=Q<RRb:cdMM$4S5I4J*UaTbbj"kl /TYYKr4;;==%V\9]]^&_` !0 '1,1C1J1J1L1L!0!3J$0$7$7\=N=N<Ou:U$UMKKJ]1CD &&(KKM 2C4EFI/IJ((3 (Y[] ,z Y'KK	#=>??OO  +  X]]O<=y  MM'3q6* 	  GsKL6 32 ,+`  MM)SV, FqcJKMM%A6HW\"]^,"5"5"7"7MM,'jjm  KK	#=>??OO  +X]]O<= 	 s   A-[, %-]% B] F1]D&];G]	]% `/ ,
\>6A\99\>
]	]
]"]% %
`,/B8`''`,,`/ /Bb3c                    [         R                  S:X  a  gU S-  S-  nUR                  5       (       d  g/ nSnUR                  S5       H  n UR	                  5       (       d  UR                  5       (       d  M0   UR                  S5       nUR                  S5      S	:w  a   SSS5        Mc   SSS5        UR                  5       owR                  nUS
-  (       a  M  Un	US-  (       a  U	S-  n	US-  (       a  U	S-  n	US-  (       a  U	S-  n	U	S-  (       d  U	S-  n	[         R                  " XY5        US-  nM     U(       aW  U S3U(       a  S[        U5       S3OS-   nUR                  SS5        U(       a  UR                   OUR"                  " SU5        gU(       a  [$        R'                  SU S35        U(       a7  [$        R'                  S5        U H  n[$        R'                  SU 35        M     gg! , (       d  f       GNP= f! [         a     GM  f = f! [         a1  n
UR                  UR                  U5       SU
 35         Sn
A
GM  Sn
A
ff = f)zcEnsure POSIX .sh scripts under .specify/scripts (recursively) have execute bits (no-op on Windows).ntNz.specifyscriptsr   z*.shrbrf   s   #!I      @          rh   re   z: z updated, z failedr   chmodz"Set script permissions recursivelyz%[cyan]Updated execute permissions on z script(s) recursively[/cyan]z3[yellow]Some scripts could not be updated:[/yellow]r  )r   rD   r0  r  
is_symlinkr'  rN  readr   statst_moder  r<   r  r   r   rl   r   r   r   )r3  r"  scripts_rootfailuresupdatedscriptrW  stmodenew_moder  r~   s               r   ensure_executable_scriptsr    s   	ww$*,y8L  HG$$V,	H  ""&..*:*:[[&!vvayE)  '&) '
 Bzze|He|X.Xe|X.Xe|X.Xu$E!HHV&qLG) -. 9H%2c(m_G)DVXYGAB"(8(8	8'6JMMA'JghiMMOPQCj)  3 '&    	HOOv11,?@1#FGG	Hsm   *H:HG6"H-H5%HAH6
H	 HHH
HHHH
I$%IIz`Name for your new project directory (optional if using --here, or use '.' for current directory))r   z--aizAI assistant to use: claude, gemini, copilot, cursor-agent, qwen, opencode, codex, windsurf, kilocode, auggie, codebuddy, amp, shai, q, bob, or qoder z--scriptzScript type to use: sh or psz--ignore-agent-toolsz/Skip checks for AI agent tools like Claude Codez--no-gitz"Skip git repository initializationz--herezIInitialize project in the current directory instead of creating a new onez--forcez;Force merge/overwrite when using --here (skip confirmation)z
--skip-tlsz+Skip SSL/TLS verification (not recommended)z--debugzBShow verbose diagnostic output for network and extraction failuresz--github-tokenz[GitHub token to use for API requests (or set GH_TOKEN or GITHUB_TOKEN environment variable)project_nameignore_agent_toolsno_githereforceskip_tlsc
                 2  ^1^2 [        5         U S:X  a  SnSn U(       a2  U (       a+  [        R                  S5        [        R                  " S5      eU(       d2  U (       d+  [        R                  S5        [        R                  " S5      eU(       a  [
        R                  " 5       R                  n [
        R                  " 5       n
[        U
R                  5       5      nU(       a  [        R                  S[        U5       S35        [        R                  S	5        U(       a  [        R                  S
5        O[        R                  " S5      nU(       d+  [        R                  S5        [        R                  " S5      eO}[        U 5      R                  5       n
U
R                  5       (       aO  [        SU  S3SSSS9n[        R                  5         [        R                  U5        [        R                  " S5      e[
        R                  " 5       nSSSS SU
R                   S3SS SU S3/nU(       d  UR                  SS SU
 S35        [        R                  [        SR!                  U5      SSS 95        S!nU(       d'  [#        S"5      nU(       d  [        R                  S#5        U(       a_  U[$        ;  aR  [        R                  S$U S%S&R!                  [$        R'                  5       5       35        [        R                  " S5      eUnO:[$        R)                  5        VVs0 s H  u  nnUUS'   _M     nnn[+        US(S)5      nU(       d  [$        R-                  U5      nU(       aw  US*   (       am  US+   n[#        U5      (       dX  [        S,U S-U S.US'    S/3S0SSS9n[        R                  5         [        R                  U5        [        R                  " S5      eU(       a_  U[.        ;  aR  [        R                  S1U S%S&R!                  [.        R'                  5       5       35        [        R                  " S5      eUnOO[0        R                  S2:X  a  S3OS4n[2        R4                  R7                  5       (       a  [+        [.        S5U5      nOUn[        R                  S6U 35        [        R                  S7U 35        [9        S85      m2S[2        l        T2R=                  S9S:5        T2R?                  S9S;5        T2R=                  S<S=5        T2R?                  S<U 5        T2R=                  S>S?5        T2R?                  S>U5        S@ H  u  nnT2R=                  UU5        M     Sn[A        T2RC                  5       [        SASSB9 m1T2RE                  U1U24SC j5         U(       + nU(       a  [F        OS!n[H        RJ                  " USD9n[M        U
UUUS!T2UXSE9	  [O        U
T2SF9  U(       d  T2RQ                  S"5        [S        U
5      (       a  T2R?                  S"SG5        OhU(       a<  [U        U
SSH9u  nnU(       a  T2R?                  S"SI5        O:T2RW                  S"SJ5        UnO%T2RY                  S"SK5        OT2RY                  S"SL5        T2R?                  SMSN5          SSS5        [        R                  T2RC                  5       5        [        R                  SZ5        U(       aE  [        R                  5         [        S[U S\U(       d  U
OS S]3S^SSS9n&[        R                  U&5        [$        R-                  U5      nU(       a>  US_   n'[        S`U' Sa3SbScSS9n([        R                  5         [        R                  U(5        / n)U(       d  U)R                  SdU  Se35        Sfn*OU)R                  Sg5        Sfn*USh:X  a_  U
Si-  n+[l        Rn                  " []        U+5      5      n,[0        R                  S2:X  a  SjU, 3n-OSkU, 3n-U)R                  U* SlU- Se35        U*S-  n*U)R                  U* Sm35        U)R                  Sn5        U)R                  So5        U)R                  Sp5        U)R                  Sq5        U)R                  Sr5        [        SR!                  U)5      SsSSS9n.[        R                  5         [        R                  U.5        StSSuSvSw/n/[        SR!                  U/5      SxSSS9n0[        R                  5         [        R                  U05        gs  snnf ! [Z         GaV  n T2RW                  SM[]        U 5      5        [        R                  [        SOU  3SPSSQ95        U(       a  SR[2        R^                  Ra                  5       S   4SS[2        Rb                  4ST[]        [
        R                  " 5       5      4/n![e        SU U! 5       5      n"U! V#V$s/ s H  u  n#n$U#Rg                  U"5       SVU$ SW3PM     Os  sn$n#f n%n#n$[        R                  [        SR!                  U%5      SXSYSQ95        U(       d+  U
R                  5       (       a  [h        Rj                  " U
5        [        R                  " S5      eSn A ff = f! f = f! , (       d  f       GN= f)ya
  
Initialize a new Specify project from the latest template.

This command will:
1. Check that required tools are installed (git is optional)
2. Let you choose your AI assistant
3. Download the appropriate template from GitHub
4. Extract the template to a new project directory or current directory
5. Initialize a fresh git repository (if not --no-git and no existing repo)
6. Optionally set up AI assistant commands

Examples:
    specify init my-project
    specify init my-project --ai claude
    specify init my-project --ai copilot --no-git
    specify init --ignore-agent-tools my-project
    specify init . --ai claude         # Initialize in current directory
    specify init .                     # Initialize in current directory (interactive AI selection)
    specify init --here --ai claude    # Alternative syntax for current directory
    specify init --here --ai codex
    specify init --here --ai codebuddy
    specify init --here
    specify init --here --force  # Skip confirmation when current directory not empty
r7  TNzB[red]Error:[/red] Cannot specify both project name and --here flagre   zg[red]Error:[/red] Must specify either a project name, use '.' for current directory, or use --here flagz:[yellow]Warning:[/yellow] Current directory is not empty (z items)ze[yellow]Template files will be merged with existing content and may overwrite existing files[/yellow]zN[cyan]--force supplied: skipping confirmation and proceeding with merge[/cyan]zDo you want to continue?z$[yellow]Operation cancelled[/yellow]r   zDirectory '[cyan]z`[/cyan]' already exists
Please choose a different project name or remove the existing directory.z[red]Directory Conflict[/red]r|  r   r   z"[cyan]Specify Project Setup[/cyan]r   Projectz<15z [green]z[/green]zWorking Pathz [dim]z[/dim]zTarget Pathr;   r   )r   r   Fr.  zD[yellow]Git not found - will skip repository initialization[/yellow]z([red]Error:[/red] Invalid AI assistant 'z'. Choose from: r  rD   zChoose your AI assistant:rC   rG   rF   r   z&[/cyan] not found
Install from: [cyan]z[/cyan]
zo is required to continue with this project type.

Tip: Use [cyan]--ignore-agent-tools[/cyan] to skip this checkz [red]Agent Detection Error[/red]z'[red]Error:[/red] Invalid script type 'r  r^   r]   z#Choose script type (or press Enter)z$[cyan]Selected AI assistant:[/cyan] z#[cyan]Selected script type:[/cyan] zInitialize Specify ProjectprecheckzCheck required toolsokz	ai-selectzSelect AI assistantzscript-selectzSelect script type)	)r  zFetch latest release)r  r  )r  r  )r  zArchive contents)r  zExtraction summary)r  zEnsure scripts executable)r  Cleanup)r.  zInitialize git repository)finalFinalizer  )r   refresh_per_secondr   c                  B   > T R                  TR                  5       5      $ ru   )r   r   )r   r"  s   r   <lambda>init.<locals>.<lambda>a  s    t{{7>>3C'Dr    r   r  r"  zexisting repo detected)r4  initializedzinit failedzgit not availablez--no-git flagr  zproject readyzInitialization failed: Failurer}  PythonPlatformCWDc              3   <   #    U  H  u  p[        U5      v   M     g 7fru   )r   ).0k_s      r   	<genexpr>init.<locals>.<genexpr>  s     "Ajda3q66js   u    → [bright_black]r   zDebug Environmentmagentaz(
[bold green]Project ready.[/bold green]z@[yellow]Warning:[/yellow] Git repository initialization failed

zB

[dim]You can initialize git manually later with:[/dim]
[cyan]cd z`[/cyan]
[cyan]git init[/cyan]
[cyan]git add .[/cyan]
[cyan]git commit -m "Initial commit"[/cyan]z$[red]Git Initialization Failed[/red]rE   zSome agents may store credentials, auth tokens, or other identifying and private artifacts in the agent folder within your project.
Consider adding [cyan]z][/cyan] (or parts of it) to [cyan].gitignore[/cyan] to prevent accidental credential leakage.z&[yellow]Agent Folder Security[/yellow]rM  z&1. Go to the project folder: [cyan]cd r   rf   z+1. You're already in the project directory!rM   z.codexzsetx CODEX_HOME zexport CODEX_HOME=zO. Set [cyan]CODEX_HOME[/cyan] environment variable before running Codex: [cyan]z0. Start using slash commands with your AI agent:zD   2.1 [cyan]/speckit.constitution[/] - Establish project principlesz@   2.2 [cyan]/speckit.specify[/] - Create baseline specificationz:   2.3 [cyan]/speckit.plan[/] - Create implementation planz:   2.4 [cyan]/speckit.tasks[/] - Generate actionable tasksz;   2.5 [cyan]/speckit.implement[/] - Execute implementationz
Next StepszmOptional commands that you can use for your specs [bright_black](improve quality & confidence)[/bright_black]u   ○ [cyan]/speckit.clarify[/] [bright_black](optional)[/bright_black] - Ask structured questions to de-risk ambiguous areas before planning (run before [cyan]/speckit.plan[/] if used)u   ○ [cyan]/speckit.analyze[/] [bright_black](optional)[/bright_black] - Cross-artifact consistency & alignment report (after [cyan]/speckit.tasks[/], before [cyan]/speckit.implement[/])u   ○ [cyan]/speckit.checklist[/] [bright_black](optional)[/bright_black] - Generate quality checklists to validate requirements completeness, clarity, and consistency (after [cyan]/speckit.plan[/])zEnhancement Commands)8r   r   r   r   r   r   r/  rD   r   r  r   confirmresolver&  r   r<   r>   r+  AGENT_CONFIGr   ra  r   r0   SCRIPT_TYPE_CHOICESr   r  stdinisattyra   _specify_tracker_activer   r   r   r   rw   r  r  r  r  r  r   r2  r<  rl   r   r   r   versionr  platformmaxljustr(  r  shlexquote)3r  ro  rj  r  r  r  r  r  rm  rn  r3  existing_itemsr  error_panelr  setup_linesshould_init_gitselected_airy   config
ai_choicesagent_configrF   selected_scriptdefault_scriptrz   git_error_messager   local_ssl_contextlocal_clientsuccessr;  r  
_env_pairs_label_widthr  v	env_linesgit_error_panelagent_foldersecurity_noticesteps_linesstep_num
codex_pathquoted_pathr  steps_panelenhancement_linesenhancements_panelr   r"  s3                                                    @@r   r6  r6    s	   L MsZ[jjm  	Ajjmxxzxxzl2245MMVWZ[iWjVkkrstMM  B  Cno ==)CDMM"HI**Q-'L)113  #L> 2[ [5"K MMOMM+&**Q-((*K 	-
S/,"3"3!4H=#
f[M8	K mC0|nFKLMM%		+.VVTUO$U+MM`a|+MMD\NRbcgclclmym~m~  nA  dB  cC  D  E**Q-" >J=O=O=QR=Qkc6c6&>)=Q
R('
 #''4L8&}5Kk**#[M *++6-y#F+, -TT =!&" k*jjm#11MMCK=P`aeajajk~  lD  lD  lF  bG  aH  I  J**Q-%!#Dd9901DFkm{|O,OMM8FGMM77HIJ67G"&CKK
23Z&KK23[[M3KK!56_o6

U 	C
 	gnnAQU	VZ^DE*	!\F/55 <</@AL),_VZdisz  DP  X]  y%lGDe$|,,$$U,DE$)6|4)P&GY((>e];,5)LL(;<UO4Wo6" Y 
W\ MM'.."#MM=> P ! ",0c: ;<= 9
 	o&  ##K0L#H-%%1N  3PQ:!
 	o&KCL>QXYZHI g!H,
kk#j/277d?$[M2C&{m4ChZ'vwzv{  |C  D  	EA(#STU]^YZSTSTTU		+.lQWafgKMMOMM+ 	x
 B D O tyy):;CYhnx}~MMOMM$%y S~  	 MM'3q6*MM%"9! =Y]bcds{{002156.C
O,

  #"Aj"AAistisaeabde 566I!O\ist	teDIIi$8@SbklmL//11l+**Q-	   Y 
W	VsK   *dj%C9di?)B.i:$g<
;A?i::i??jjj
jc                     [        5         [        R                  S5        [        S5      n U R	                  SS5        [        SU S9n0 n[        R                  5        HJ  u  p4US   nUS   nU R	                  X55        U(       a  [        X0S9X#'   M4  U R                  US5        S	X#'   ML     U R	                  S
S5        [        S
U S9nU R	                  SS5        [        SU S9n[        R                  U R                  5       5        [        R                  S5        U(       d  [        R                  S5        [        UR                  5       5      (       d  [        R                  S5        gg)z,Check that all required tools are installed.z-[bold]Checking for installed tools...[/bold]
zCheck Available Toolsr.  zGit version controlr  rD   rG   zIDE-based, no CLI checkFcodezVisual Studio Codezcode-insiderszVisual Studio Code Insidersz6
[bold green]Specify CLI is ready to use![/bold green]z5[dim]Tip: Install git for repository management[/dim]z?[dim]Tip: Install an AI assistant for the best experience[/dim]N)r   r   r   ra   r   r+  r  ra  r   r   anyvalues)	r"  git_okagent_results	agent_keyr%  
agent_namerG   code_okcode_insiders_oks	            r   r  r    s/    MMMBC12GKK,-w/FM#/#5#5#7	!&)
#N3I*'1)'MM$ LL$=>',M$ $8 KK,-1GKK!>?!/7CMM'.."#MMKLMN}##%&&WX 'r    c                  ,   SSK n SSKn[        5         Sn UR                  R	                  S5      nS	nS
nSU SU S3n	Sn
Sn [        R                  U	SS[        5       S9nUR                   S:X  a  UR#                  5       nUR                  SS5      n
U
R%                  S5      (       a  U
SS n
UR                  SS5      nUS:w  a8   [&        R(                  " UR+                  SS5      5      nUR-                  S5      n[/        SSSS9nUR1                  SSSS9  UR1                  S S!S"9  UR3                  S#U5        UR3                  S$U
5        UR3                  S%U5        UR3                  S&S&5        UR3                  S'U R5                  5       5        UR3                  S(U R7                  5       5        UR3                  S)U R9                  5       5        UR3                  S*U R	                  5       5        [;        US+SS,S-9n[<        R?                  U5        [<        R?                  5         g! [
         a     SSKn[        [        5      R                  R                  R                  S-  nUR                  5       (       a_  [        US5       nUR                  U5      nUR                  S0 5      R                  SS5      nSSS5         GM  ! , (       d  f        GN= f GN! [
         a      GNf = ff = f! [
         a     GNf = f! [
         a     GNf = f).z'Display version and system information.r   Nunknownzspecify-clizpyproject.tomlr  projectr  rr  rs  rt  ru  rv  
   Trx  r{  r  r.  re   published_atZz+00:00z%Y-%m-%dFr   )show_headerboxr   Keyr   rightr   Valuer   r  zCLI VersionzTemplate VersionReleasedr   r  r  Architecturez
OS Versionz.[bold cyan]Specify CLI Information[/bold cyan]r   r   ) r  importlib.metadatar   r  r  r   tomllibr   __file__r  r&  rN  rP  r0   rl  r$   r8   rO  
startswithr   fromisoformatreplacer=   r   r   r   python_versionsystemmachiner   r   r   )r  	importlibcli_versionrR  pyproject_pathrW  datar  r  r  template_versionrelease_dater  r  dt
info_tablepanels                    r   r  r    s    M K((00? JI-j\9+EUVG L::!(*	  
 3&#==?L+//
IF**3//#3AB#7 '++NIFLy(!//0D0DS(0STB#%;;z#:L 5dFCJ%vw?'1}k2)+;<z<0r2x!8!8!:;z8??#45~x'7'7'9:|X%5%5%78>	E MM%MMOC  
	!(^2299@@CSSN$$&&.$/1"<<?D"&((9b"9"="=i"SK 0/// '  		
N !  sy   H( BL 7K4 (
K13AK4K<K
K	KK
K-(K1,K--K14
L>L LL 
LLc                      [        5         g ru   )appr   r    r   mainre  T  s    Er    __main__ru   )zSelect an optionN)TFF)F)FN)r   N)Yr   r   r  r  r  r  r(  r  rO  pathlibr   typingr   r   r   r  rich.consoler   
rich.panelr   rich.progressr   r	   r
   	rich.textr   	rich.liver   
rich.alignr   
rich.tabler   	rich.treer   
typer.corer   r   ssl
truststorer   r   
SSLContextPROTOCOL_TLS_CLIENTr  r  rl  r   r   rc  r$   Headersr7   r1   rB   r  r  homer%  r  r  ra   r   r   r   r   Typerrd  r   r  Contextr   boolr   r+  r2  r<  rZ  rQ  r  r  r  commandArgumentOptionr6  r  r  re  r   r   r    r   <module>r~     s   
  
       "      = =      !  
  '##C$;$;<	[	)eS4Z e3: eAC$J A$ A
u}}  8#  C TW <g 	g M	g D	g& 	'g2 <	3g> ,	?gJ 8	KgV 	Wgb 	cgn Y	ogz 5	{gF .	GgR 
	Sg^ (S	
_gj 
;	kgv 4	wgB 
	CgR 6\J IIK)+g5@ 
 >S Sj(I I3 IZ] Iil IV ),* , kk		B %--  T#Y d D Y] jrsvjw $S ; $ >d d (! !T !eD(SV-DW>X !F*0)D )t )d )W[ )V `duy  RV  os  CH  ^b p p4 pY\ pnr p  KO p  `e  `l  `l p  |@ p  X[ p  gl  mq  sw  mw  gx pdS  MQ  qu  NR  bg  }A S SC SVY Sko S  FJ S  \g  jn  \n S  D  K  K S  [_ S  wz S  FJ Sl**D **;;M **Y] **X t  3U  VT6  9Q  R||D*;YZ$||E3I  QB   C<<z8\]eX4  A,,ui6st\\%<ij,,ui6z{T+;  C`  ag&g&g& g& 	g&
 g& g& g& g& g& g& g&R	 'Y 'YR L L\
 zF r    