
    `gj                     B    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y)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           
      j   g }t        | t              r| s|S d}| j                         D ]q  \  }}t        |t              r|n|g}|D ]R  }t        |t              r|s ||      r|dz  }$d| } ||      rd| dnd}	|j                  d| d| d	|	        T s |dk(  r|j                  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
             P/root/.hermes/venv/lib/python3.12/site-packages/hermes_cli/toolset_validation.pyvalidate_platform_toolsetsr      s    6 H'.6GK*002 #!#t,3% 	DdC(%q "8*-J $J/ &j\4 
 OOXJ '64&"	& a@	
 O    N)	__doc__typingr   r   r   objectr   boolr    r   r   <module>r#      s@    ( '88ud{+8 
#Y8r   