
    (Gj                     P    d Z ddlmZmZmZ dedeegef         dee         fdZdS )u  Validation for the ``platform_toolsets`` config section.

Pure, side-effect-free helpers so the logic is unit-testable without importing
the tool registry or launching Hermes (mirrors the decoupled-helper pattern used
elsewhere in the CLI).

Motivated by #38798: a config migration silently rewrote the valid toolset name
``hermes-cli`` to the non-existent ``hermes``. ``resolve_toolset('hermes')``
returns an empty list, so every tool silently disappeared with no error, warning,
or log entry — the agent degraded to text-only replies and the cause took
significant debugging to find. Surfacing invalid toolset names (and the
zero-tools end state) loudly turns that silent failure into an actionable one.
    )CallableDictListplatform_toolsetsis_valid_toolsetreturnc           
         g }t          | t                    r| s|S d}|                                 D ]\  }}t          |t                    r|n|g}|D ]a}t          |t                    r|s ||          r|dz  }+d| } ||          rd| dnd}	|                    d| d| d	|	            b|dk    r|                    d
           |S )u(  Return human-readable warnings for a ``platform_toolsets`` mapping.

    Two failure modes are reported:

    1. A toolset name that ``is_valid_toolset`` rejects — usually a corrupted or
       renamed entry. When ``hermes-<platform>`` would have been valid (the exact
       #38798 shape, where ``cli`` held ``hermes`` instead of ``hermes-cli``),
       the warning includes that as a suggestion.
    2. The mapping is non-empty but resolves to *zero* valid toolsets, so the
       agent would start with no tools at all.

    ``is_valid_toolset`` is injected (normally :func:`toolsets.validate_toolset`)
    so this function performs no imports or I/O and is testable in isolation.

    Args:
        platform_toolsets: The raw ``platform_toolsets`` value from config. Only
            ``dict`` values carry toolset entries; anything else yields no
            warnings (nothing to validate).
        is_valid_toolset: Predicate returning ``True`` for a known toolset name.

    Returns:
        A list of warning strings (empty when everything is valid).
    r      zhermes-u    — did you mean 'z'? z
platform 'z' references unknown toolset ''uv   platform_toolsets resolves to zero valid toolsets — the agent will have no tools. Run `hermes tools` to reconfigure.)
isinstancedictitemsliststrappend)
r   r   warningsvalid_countplatformrawnamesname
suggestionhints
             C/home/rurouni/.hermes/hermes-agent/hermes_cli/toolset_validation.pyvalidate_platform_toolsetsr      sj   6 H'.. 6G K*0022  #!#t,,73% 	 	DdC((  %% q -8--J $#J//4j4444 
 OO"X " "" "" "   	" a@	
 	
 	
 O    N)	__doc__typingr   r   r   objectr   boolr    r   r   <module>r#      sv     ( ' ' ' ' ' ' ' ' '88ud{+8 
#Y8 8 8 8 8 8r   