
    `gj                    h    d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	m
Z
 ddlmZ ddZdd	Zdd
Zy)u   CLI handlers for ``hermes migrate ...``.

Currently exposes only ``hermes migrate xai`` — diagnoses and (with --apply)
rewrites references to xAI models retired on May 15, 2026.
    )annotationsN)Path)Any)Colorscolor)load_configc                t    t        | dd      }|dk(  rt        |       S t        dt        j                         y)z,Dispatcher for ``hermes migrate <subtype>``.migrate_typeNxaiz1usage: hermes migrate xai [--apply] [--no-backup]file   )getattrcmd_migrate_xaiprintsysstderr)argssubs     E/root/.hermes/venv/lib/python3.12/site-packages/hermes_cli/migrate.pycmd_migrater      s4    
$
-C
e|t$$	
=CJJO    c           	        ddl m}m}m}m}m} t        t        | dd            }t        t        | dd            }t               } ||      }	t                t        t        d| dt        j                  t        j                               t                |	s(t        dt        d	t        j                         d
       yt        dt        |	       d       t                |	D ]1  }
t        dt        dt        j                          d ||
              3 t                t        dt        dt        j                         d|        t                t#               }|sKt        t        dt        j$                               t        t        d| dt        j$                               y|r|j'                         s;t        dt        dt        j(                         d| dt*        j,                         y	  |||	|       }|j0                  s(t        dt        dt        j                          d       y|j2                  3t        dt        d	t        j                         d|j2                          t        dt        d	t        j                         dt        |j4                         d|j6                          t                t        t        d t        j$                               y# t.        $ rC}t        dt        dt        j(                         d| t*        j,                         Y d}~yd}~ww xY w)!z8Run xAI May-15 model migration in dry-run or apply mode.r   )MIGRATION_GUIDE_URLRETIREMENT_DATEapply_migrationfind_retired_xai_refsformat_issueapplyF	no_backupu$   ◆ xAI Model Retirement Migration ()z  u   ✓u8    No retired xAI models in config — nothing to migrate.z  Found z  retired xAI model reference(s):z    u   ⚠ u   →z Migration guide: u$   Dry-run mode — no changes written.z4Re-run with `hermes migrate xai --apply` to rewrite z) in-place (backup created automatically).u   ✗z* Could not locate config.yaml (looked at: r      )config_pathissuesbackupz Migration failed: Nz No changes written.z	 Backup: z	 Updated z slot(s) in z<Run `hermes doctor` to confirm no retired xAI models remain.)hermes_cli.xai_retirementr   r   r   r   r   boolr   r   r   r   r   CYANBOLDGREENlenYELLOW_resolve_config_pathDIMexistsREDr   r   	Exceptionconfig_changedbackup_pathissues_resolved	file_path)r   r   r   r   r   r   r   r    configr%   issuer$   resultexcs                 r   r   r      s     w./EWT;67I]F"6*F	G	%
..?qAV[[  
G5-..fgh	HS[M!A
BC	G JU5&--01<3F2GHIJ	G	Dufkk*++=>Q=R
ST	G&(Ke:FJJGHeBmDFJJ
 	
 k002ufjj)* +&-q*	

  # =
   5.//CDE%5-.i8J8J7KLM	
U5&,,'(	#f6L6L2M1N O&&'	) 
G	%F

  -  ufjj)**=cUC	
 s   ;K1 1	L=:9L88L=c                 "    ddl m}   |        dz  S )z3Best-effort: locate the active config.yaml on disk.r   get_hermes_homezconfig.yaml)hermes_cli.configr=   r<   s    r   r.   r.   o   s    1},,r   )r   r   returnint)r?   r   )__doc__
__future__r   r   pathlibr   typingr   hermes_cli.colorsr   r   r>   r   r   r   r.    r   r   <module>rG      s/   
 # 
   + )Rj-r   