
    ژj                    j    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dS )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_configargsr   returnintc                    t          | dd          }|dk    rt          |           S t          dt          j                   dS )z,Dispatcher for ``hermes migrate <subtype>``.migrate_typeNxaiz1usage: hermes migrate xai [--apply] [--no-backup]file   )getattrcmd_migrate_xaiprintsysstderr)r	   subs     7/home/ubuntu/.hermes/hermes-agent/hermes_cli/migrate.pycmd_migrater      sE    
$
-
-C
e||t$$$	
=CJOOOO1    c           	     4   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
           dS t          dt          |	           d           t                       |	D ]8}
t          dt          dt          j                   d ||
                      9t                       t          dt          dt          j                   d|            t                       t#                      }|sTt          t          dt          j                             t          t          d| dt          j                             dS |r|                                s<t          dt          dt          j                   d| dt*          j                   dS 	  |||	|           }nQ# t.          $ rD}t          dt          dt          j                   d| t*          j                   Y d}~dS d}~ww xY w|j        s-t          dt          dt          j                   d           dS |j        2t          dt          d	t          j                   d|j                    t          dt          d	t          j                   dt          |j                   d|j                    t                       t          t          d t          j                             dS )!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      s1                 w..//EWT;6677I]]F""6**F	GGG	%AAAAV[     
GGG g5--ggghhhq	
BS[[
B
B
BCCC	GGG J JHU5&-00HH<<3F3FHHIIII	GGG	
Sufk**
S
S>Q
S
STTT	GGG&((K e:FJGGHHHeFF F FJ
 
 	 	 	
 q k0022 *ufj)) * *&* * *	
 	
 	
 	

 q # =
 
 

    Cufj))CCcCC	
 	
 	
 	
 qqqqq   D5..DDDEEEq%L5--LL8JLLMMM		)U5&,'' 	) 	)#f6L2M2M 	) 	)&	) 	)   
GGG	%F
     1s   I 
J,(9J''J,r   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   r0   r0   o   s'    111111?},,r   )r	   r   r
   r   )r
   r   )__doc__
__future__r   r   pathlibr   typingr   hermes_cli.colorsr   r   r@   r   r   r   r0    r   r   <module>rG      s    
 # " " " " " 



             + + + + + + + + ) ) ) ) ) )   R R R Rj- - - - - -r   