
    nSjI                    l   U d Z ddlZddlZddlZddlmZmZ ddlZddlZddl	m
Z
 ddlmZmZmZ ddlmZmZmZmZmZmZ ddlmZmZ ddlmZ dd	lmZ dd
lmZm Z!  ej"        e#          Z$i Z%e&e'd<   dZ(dZ)dZ*de+fdZ, e            Z-e-dz  Z.e.Z/defdZ0dZ1dZ2ddddZ3 ej4        d          Z5 e6h d          Z7da8de9dee9         fdZ:dee9e9f         fdZ; G d de9e
          Z<g d Z=e>e'd!<   dd"Z?d#ee9ef         de@fd$ZAd#ee9ef         de@fd%ZBd&edee9         fd'ZCd#ee9ef         deee9         ee9         f         fd(ZDd#ee9ef         dee9ef         fd)ZE	 dd#ee9ef         d*ee9         dz  deee9ef                  fd+ZFd,e9d-eee9ef                  dee9ef         fd.ZGde@fd/ZHde9fd0ZI	 dd1e9d2ee9e9f         dz  de@fd3ZJdd4d5eee9ef                  d6ee9ef         d2ee9e9f         dz  dee9         fd7ZKde9fd8ZL	 dd9e<d:ee9         d;e9dz  de9dz  fd<ZMde@fd=ZNd>e9deee9ef         e9f         fd?ZOd@edee9         fdAZPdee9         fdBZQdee9         fdCZRde9fdDZSdde9dEe9de@fdFZTdGdHdIe@deee9ef                  fdJZUdeee9ef                  deee9ef                  fdKZVddLe9dMe9de9fdNZWdOddPdQedRe9dSe9dTe@dUe9dz  de9fdVZX	 	 	 dde9dWe9dMe9dTe@de9f
dXZYe#dYk    ro	  eZdZ            eZd[            eZd\            ej[         eW                      Z\e\d]         r eZd^e\d_          d` e]e\^                    dag                      db            eZdce\^                    dag                        eZdd           e\d         dde         D ]MZ_e_^                    dL          rdfe_dL          dgndhZ` eZdie` e_d          dje_dk         ddl          dm           Nn eZdne\do                      eZdp            ej[         eYdq                    Z\e\d]         r eZdre\d                      eZdse\^                    dkdt          ddu          dm            eZdv e]e\d>                    dw           e\^                    dx          r eZdye\dx                     n eZdne\do                      eZdz            ej[         eYdqd{                    Z\e\d]         rP eZd|e\d}                      eZdv e]e\d>                    dw            eZd~e\d>         dd          dm           n eZdne\do                     ddddLdddig ddZadddddddddddgddZb ejc        ddead eNd           d Zd ejc        ddebedeNd           dS )u  
Skills Tool Module

This module provides tools for listing and viewing skill documents.
Skills are organized as directories containing a SKILL.md file (the main instructions)
and optional supporting files like references, templates, and examples.

Inspired by Anthropic's Claude Skills system with progressive disclosure architecture:
- Metadata (name ≤64 chars, description ≤1024 chars) - shown in skills_list
- Full Instructions - loaded via skill_view when needed
- Linked Files (references, templates) - loaded on demand

Directory Structure:
    skills/
    ├── my-skill/
    │   ├── SKILL.md           # Main instructions (required)
    │   ├── references/        # Supporting documentation
    │   │   ├── api.md
    │   │   └── examples.md
    │   ├── templates/         # Templates for output
    │   │   └── template.md
    │   └── assets/            # Supplementary files (agentskills.io standard)
    └── category/              # Category folder for organization
        └── another-skill/
            └── SKILL.md

SKILL.md Format (YAML Frontmatter, agentskills.io compatible):
    ---
    name: skill-name              # Required, max 64 chars
    description: Brief description # Required, max 1024 chars
    version: 1.0.0                # Optional
    license: MIT                  # Optional (agentskills.io)
    platforms: [macos]            # Optional — restrict to specific OS platforms
                                  #   Valid: macos, linux, windows
                                  #   Omit to load on all platforms (default)
    prerequisites:                # Optional — legacy runtime requirements
      env_vars: [API_KEY]         #   Legacy env var names are normalized into
                                  #   required_environment_variables on load.
      commands: [curl, jq]        #   Command checks remain advisory only.
    compatibility: Requires X     # Optional (agentskills.io)
    metadata:                     # Optional, arbitrary key-value (agentskills.io)
      hermes:
        tags: [fine-tuning, llm]
        related_skills: [peft, lora]
    ---

    # Skill Title

    Full instructions and content here...

Available tools:
- skills_list: List skills with metadata (progressive disclosure tier 1)
- skill_view: Load full skill content (progressive disclosure tier 2-3)

Usage:
    from tools.skills_tool import skills_list, skill_view, check_skills_requirements

    # List all skills (returns metadata only - token efficient)
    result = skills_list()

    # View a skill's main content (loads full instructions)
    content = skill_view("axolotl")

    # View a reference file within a skill (loads linked file)
    content = skill_view("axolotl", "references/dataset-formats.md")
    N)get_hermes_homedisplay_hermes_home)Enum)PathPurePosixPathPureWindowsPath)DictAnyListOptionalSetTuple)registry
tool_error)cfg_get)env_var_enabled)EXCLUDED_SKILL_DIRSis_skill_support_path_SKILLS_CACHEg      >@with_disabledfilteredreturnc                 T   ddl m} t          t          |dd          dd          }g }| D ]}	 |                                j        }n# t
          $ r Y )w xY w	 t          j        |          5 }|D ]L}	 |                    d          r#|                    d          j        }	|	|k    r|	}=# t
          $ r Y Iw xY w	 ddd           n# 1 swxY w Y   n# t
          $ r Y nw xY w|	                    t          |          |f           t          |          t          |          |fS )	uN  Cheap change-signature for the skill scan inputs.

    O(#dirs + #categories) stat calls, not a recursive walk. Includes the
    platform the scan's ``skill_matches_platform`` filter will use (read
    from ``agent.skill_utils``'s ``sys`` so test patches of that module
    are honored) — the scan result is platform-dependent.
    r   )skill_utilssysNplatform F)follow_symlinks)agentr   getattrstatst_mtimeOSErrorosscandiris_dirappendstrtuple	frozenset)
dirs_to_scandisabled_skill_utilsr   sigdmitentryems
             3/home/ice/.hermes/hermes-agent/tools/skills_tool.py_skills_scan_signaturer5   j   s    211111w|UD99:rJJH
C    	!AA 	 	 	H		A !" ! !E! <<<>> '!&E!B!B!KB!Avv$&" ! ! ! !!! ! ! ! ! ! ! ! ! ! ! ! ! ! !  	 	 	D	

CFFA;#JJ	(++X66sk   A
AAC-C
39B-,C
-
B:	7C
9B:	:C
>C
C	CC	C
C#"C#skillsc                  f    t          t                    } | t          k    r| S t                      dz  S )aZ  Return the active profile's skills directory at call time.

    Some long-lived runtimes import this module before the active profile has
    set HERMES_HOME. Keep the legacy SKILLS_DIR module attribute for tests and
    external patchers, but when it has not been patched, resolve from the live
    profile-scoped HERMES_HOME on every call.
    r6   )r   
SKILLS_DIR_SKILLS_DIR_AT_IMPORTr   )
configureds    r4   _skills_dirr;      s4     j!!J***x''    @   i   darwinlinuxwin32)macosr?   windowsz^[A-Za-z_][A-Za-z0-9_]*$>   sshmodaldockerdaytonasingularitynamec                 2   ddl m} t          | t                    sdS |                                 }t          |                                          s5t          |                                          st          |          j        rdS  ||          rdS dS )uD  Return an error if a local skill lookup *name* can escape search roots.

    The skill ``name`` is joined onto each trusted search dir to build the
    on-disk lookup path, so it must stay relative and free of ``..`` segments —
    otherwise ``name="../outside"`` or an absolute path could select a skill
    (and read files) outside the skills directory. Mirrors the ``file_path``
    validation done later via ``tools.path_security``. We also reject Windows
    drive paths (e.g. ``C:\skills``), whose ``:`` would otherwise be misread as
    a plugin namespace separator.
    r   )has_traversal_componentzSkill name must be a string.z?Skill name must be a relative path within the skills directory.z9Skill name cannot contain '..' path traversal components.N)	tools.path_securityrJ   
isinstancer(   stripr   is_absoluter   drive)rH   rJ   	candidates      r4   _skill_lookup_path_errorrQ      s     <;;;;;dC   .--

Ii  ,,..Q9%%1133Q 9%%+Q
 QPy)) KJJ4r<   c                     t                      dz  } i }|                                 s|S |                     d          5 }|D ]}|                                }|r|                    d          sxd|v rt|                    d          r
|dd         }|                    d          \  }}}|                                                    d	          ||                                <   	 ddd           n# 1 swxY w Y   |S )
z@Load profile-scoped environment variables from HERMES_HOME/.env.z.envutf-8encoding#=zexport    N"')r   existsopenrM   
startswith	partition)env_pathenv_varsflinekey_values          r4   load_envre      sU     6)H!H?? 		(	( CA 	C 	CD::<<D CDOOC00 CSD[[??9-- $8D $s 3 3Q(-(;(;E(B(B%	CC C C C C C C C C C C C C C C Os    B)C66C:=C:c                       e Zd ZdZdZdZdS )SkillReadinessStatus	availablesetup_neededunsupportedN)__name__
__module____qualname__	AVAILABLESETUP_NEEDEDUNSUPPORTED r<   r4   rg   rg      s        I!LKKKr<   rg   )	zignore previous instructionszignore all previouszyou are nowzdisregard yourzforget your instructionsznew instructions:zsystem prompt:z<system>z]]>_INJECTION_PATTERNSc                 
    | a d S N)_secret_capture_callback)callbacks    r4   set_secret_capture_callbackrw      s    'r<   frontmatterc                 $    ddl m}  ||           S )u   Check if a skill is compatible with the current OS platform.

    Delegates to ``agent.skill_utils.skill_matches_platform`` — kept here
    as a public re-export so existing callers don't need updating.
    r   )skill_matches_platform)agent.skill_utilsrz   rx   _impls     r4   rz   rz      s'     BAAAAA5r<   c                 $    ddl m}  ||           S )uX  Check if a skill is relevant to the current runtime environment.

    Delegates to ``agent.skill_utils.skill_matches_environment`` — kept here
    as a public re-export so existing callers don't need updating. This is an
    offer-time relevance gate (kanban/docker/s6), NOT a hard-compatibility gate;
    explicit skill loads bypass it.
    r   )skill_matches_environment)r{   r   r|   s     r4   r   r     s'     EDDDDD5r<   rd   c                 R    | sg S t          | t                    r| g} d | D             S )Nc                 n    g | ]2}t          |                                          #t          |          3S rq   r(   rM   ).0items     r4   
<listcomp>z2_normalize_prerequisite_values.<locals>.<listcomp>  s3    ===$3t99??+<+<=CII===r<   )rL   r(   )rd   s    r4   _normalize_prerequisite_valuesr     s<     	% ==%====r<   c                     |                      d          }|rt          |t                    sg g fS t          |                     d                    t          |                     d                    fS )Nprerequisitesr_   commands)getrL   dictr   )rx   prereqss     r4   _collect_prerequisite_valuesr     so     ooo..G *Wd33 2v&w{{:'>'>??&w{{:'>'>?? r<   c           	         |                      d          }t          |t                    sd g dS |                     d          }t          |t                    r5|                                r!t          |                                          nd }|                     d          }t          |t                    r|g}t          |t
                    sg }g }|D ]}t          |t                    st          |                     d          pd                                          }|sRt          |                     d          pd|                                           }t          |                     d	          p|                     d
          pd                                          }	||t          |                     dd                    d}
|	r|	|
d	<   |                    |
           ||dS )Nsetup)helpcollect_secretsr   r   env_varr   promptEnter value for provider_urlurlsecretT)r   r   r   )r   rL   r   r(   rM   listboolr'   )rx   r   	help_textnormalized_helpcollect_secrets_rawr   r   r   r   r   r2   s              r4   _normalize_setup_metadatar   #  s   OOG$$EeT"" 5444		&!!I i%%	*3//*;*;	I   ))$566%t,, 423)400 ! ,.O# & &$%% 	dhhy))/R006688 	TXXh''G+Gg+G+GHHNNPP488N33LtxxL"MMSSUU 488Hd3344!
 !

  	1$0E.!u%%%%  *  r<   legacy_env_varsc                   	 t          |           	|                     d          }t          |t                    r|g}t          |t                    sg }g t                      dt          t          t          f         dd f	fd}|D ]E}t          |t                    r |d|i           %t          |t                    r ||           F	d         D ]_} ||                    d          |                    d          |                    d	          p	                    d
          d           `|t          |           \  }}|D ]} |d|i           S )Nrequired_environment_variablesr2   r   c                    t          |                     d          p|                     d          pd                                          }|r|v rd S t                              |          sd S |t          |                     d          pd|                                           d}|                     d          p>|                     d          p)|                     d	          p                    d          }t          |t                     r+|                                r|                                |d<   |                     d
          }t          |t                     r+|                                r|                                |d
<   |                     d          rd|d<                       |                               |           d S )NrH   r   r   r   r   )rH   r   r   r   r   required_foroptionalT)r(   r   rM   _ENV_VAR_NAME_REmatchrL   addr'   )r2   env_name
normalizedr   r   requiredseenr   s        r4   _append_requiredz=_get_required_environment_variables.<locals>._append_required^  s   uyy((FEIIi,@,@FBGGMMOO 	8t++F%%h// 	F %))H--N1NH1N1NOOUUWW&
 &

 IIf !yy((!yy! yy  	 	 i%% 	3)//*;*; 	3!*!2!2Jvyy00lC(( 	>\-?-?-A-A 	>)5););)=)=J~&99Z   	*%)Jz"
#####r<   rH   r   r   r   r   r   )rH   r   r   )
r   r   rL   r   r   setr	   r(   r
   r   )
rx   r   required_rawr   r   rc   r   r   r   r   s
          @@@r4   #_get_required_environment_variablesr   P  s    &k22E??#CDDL,%% &$~lD)) %'HUUD$S#X $4 $ $ $ $ $ $ $ $>  # #dC   	fd^,,,dD!! 	#T"""'( 
 
++((8,,00EEIIf4E4E 	
 	
 	
 	
 9+FF" , ,&'*++++Or<   
skill_namemissing_entriesc                 0   |sg dd dS d |D             }t                      r!t          d          s|dt                      dS t          |dd dS d}g }|D ]9}d| i}|                    d          r|d         |d<   |                    d          r|d         |d<   	 t          |d         |d	         |          }nB# t
          $ r5 t                              d
|d          d           d|d         ddd}Y nw xY wt          |t                    o!t          |                    d                    }t          |t                    o!t          |                    d                    }	|r|	sd}|                    |d                    ;||d dS )NF)missing_namessetup_skippedgateway_setup_hintc                     g | ]
}|d          S rH   rq   )r   r2   s     r4   r   z;_capture_required_environment_variables.<locals>.<listcomp>  s    @@@uU6]@@@r<   HERMES_INTERACTIVEr   r   r   rH   r   z#Secret capture callback failed for Texc_info)success	stored_as	validatedskippedr   r   )_is_gateway_surfacer   _gateway_setup_hintru   r   	ExceptionloggerwarningrL   r   r   r'   )
r   r   r   r   remaining_namesr2   metadatacallback_resultr   r   s
             r4   '_capture_required_environment_variablesr     sI     
""&
 
 	
 A@@@@M  
_5I%J%J 
*""5"7"7
 
 	
  '*""&
 
 	
 M!#O  ". ". *-99V 	-$V}HV99^$$ 	=',^'<H^$	6fh OO
  		 		 		NNEeFmEEPT     !"6]"	 OOO			 _d33 
	**9
 9
 _d33 
	**9
 9
  	7 	uV}---- )&"  s   B==<C<;C<c                  `    t          d          rdS ddlm}  t           | d                    S )NHERMES_GATEWAY_SESSIONTr   get_session_envHERMES_SESSION_PLATFORM)r   gateway.session_contextr   r   r   s    r4   r   r     sC    /00 t777777 9::;;;r<   c                      t          t          j        dd                                                                                    pdS )NTERMINAL_ENVlocal)r(   r$   getenvrM   lowerrq   r<   r4   _get_terminal_backend_namer     s9    ry112288::@@BBMgMr<   var_nameenv_snapshotc                     |t                      }| |v r"t          |                    |                     S t          t          j        |                     S rt   )re   r   r   r$   r   )r   r   s     r4   _is_env_var_persistedr     sR     zz<L$$X..///	(##$$$r<   r   required_env_varscapture_resultc                    t          |d                   }|t                      }g }| D ]I}|d         }|                    d          r ||v st          ||          s|                    |           J|S )Nr   rH   r   )r   re   r   r   r'   )r   r   r   r   	remainingr2   rH   s          r4   %_remaining_required_environment_namesr     s     788MzzI" # #V}99Z   	=  (=dL(Q(Q T"""r<   c                  X    	 ddl m}  | S # t          $ r dt                       dcY S w xY w)Nr   *GATEWAY_SECRET_CAPTURE_UNSUPPORTED_MESSAGEziSecure secret entry is not available. Load this skill in the local CLI to be prompted, or add the key to z/.env manually.)gateway.platforms.baser   r   r   r   s    r4   r   r     s~    bUUUUUU99 b b b b  |O  |Q  |Q  b  b  b  	b  	b  	bbs   
 ))readiness_statusmissing
setup_helpc                 z    | t           j        k    r*|rd                    |          nd}d| d}|r| d| S |S d S )N, zrequired prerequisitesz.Setup needed before using this skill: missing . )rg   ro   join)r   r   r   missing_strnotes        r4   _build_setup_noter     se    
 /<<<,3Qdii(((9QNNNN 	*))Z)))4r<   c                      dS )zOSkills are always available -- the directory is created on first use if needed.Trq   rq   r<   r4   check_skills_requirementsr   #  s    4r<   contentc                 $    ddl m}  ||           S )u   Parse YAML frontmatter from markdown content.

    Delegates to ``agent.skill_utils.parse_frontmatter`` — kept here
    as a public re-export so existing callers don't need updating.
    r   )parse_frontmatter)r{   r   )r   r   s     r4   _parse_frontmatterr   (  s'     433333W%%%r<   
skill_pathc                 ,   t                      g}	 ddlm} |                     |                       n# t          $ r Y nw xY w|D ]L}	 |                     |          }|j        }t          |          dk    r
|d         c S =# t          $ r Y Iw xY wdS )z
    Extract category from skill path based on directory structure.

    For paths like: ~/.hermes/skills/mlops/axolotl/SKILL.md -> "mlops"
    Also works for external skill dirs configured via skills.external_dirs.
    r   get_external_skills_dirs   N)	r;   r{   r   extendr   relative_topartslen
ValueError)r   dirs_to_checkr   
skills_dirrel_pathr   s         r4   _get_category_from_pathr   2  s     !]]OM>>>>>>55778888   #  
	!--j99HNE5zzQQx  	 	 	H	4s!   #5 
AA
6B
BBc                 4   | sg S t          | t                    rd | D             S t          |                                           } |                     d          r|                     d          r
| dd         } d |                     d          D             S )uB  
    Parse tags from frontmatter value.

    Handles:
    - Already-parsed list (from yaml.safe_load): [tag1, tag2]
    - String with brackets: "[tag1, tag2]"
    - Comma-separated string: "tag1, tag2"

    Args:
        tags_value: Raw tags value — may be a list or string

    Returns:
        List of tag strings
    c                 T    g | ]%}|t          |                                          &S rq   r   r   ts     r4   r   z_parse_tags.<locals>.<listcomp>`  s+    8881a8A888r<   []   c                     g | ]=}|                                 |                                                      d           >S )rY   )rM   r  s     r4   r   z_parse_tags.<locals>.<listcomp>g  s9    OOOqQWWYYOAGGIIOOE""OOOr<   ,)rL   r   r(   rM   r\   endswithsplit)
tags_values    r4   _parse_tagsr  L  s      	 *d## 988
8888 Z&&((JS!! &j&9&9#&>&> &"%
OOJ,<,<S,A,AOOOOr<   c                  "    ddl m}   |             S )u   Load disabled skill names from config.

    Delegates to ``agent.skill_utils.get_disabled_skill_names`` — kept here
    as a public re-export so existing callers don't need updating.
    r   get_disabled_skill_names)r{   r  r  s    r4   _get_disabled_skill_namesr  k  s%     ;:::::##%%%r<   c                  L    	 ddl m}   | d          pdS # t          $ r Y dS w xY w)zResolve the current platform from gateway session context.

    Mirrors the platform-resolution logic in
    ``agent.skill_utils.get_disabled_skill_names`` so that
    ``_is_skill_disabled`` respects ``HERMES_SESSION_PLATFORM``.
    r   r   r   r   )r   r   r   r   s    r4   _get_session_platformr  u  sQ    ;;;;;;899?R?   rrs    
##r   c                 (   	 ddl m}  |            }|                    di           }|p!t          j        d          pt                      }|                    dg           }|rt          |d|          }|| |v p| |v S | |v S # t          $ r Y dS w xY w)	a  Check if a skill is disabled in config.

    Resolves the active platform from (in order of precedence):
    1. Explicit ``platform`` argument
    2. ``HERMES_PLATFORM`` environment variable
    3. ``HERMES_SESSION_PLATFORM`` from gateway session context
    r   )load_configr6   HERMES_PLATFORMr,   platform_disabledNF)hermes_cli.configr  r   r$   r   r  r   r   )rH   r   r  config
skills_cfgresolved_platformglobal_disabledr  s           r4   _is_skill_disabledr    s    111111ZZ"--
$_	2C(D(D_H]H_H_$..R88 	L '
4GIZ [ [ , 00KDO4KK&&   uus   A<B ?B 
BBF)skip_disabledr  c           	      ^   ddl m}m} | rt          nt          }| rt                      nt                      }g }t                      }|                                r|	                    |           |
                     |                       t          ||          }t          j                    }t                              |          }	|	2|	d         |k    r&||	d         z
  t           k     rd |	d         D             S g }
t                      }|D ]} ||d          D ]}t#          d |j        D                       r"|j        }	 |                    d	
          dd         }t+          |          \  }}t-          |          sjt/          |          sz|                    d|j                  dt2                   }||v r||v r|                    dd          }|sY|                                                    d          D ]1}|                                }|r|                    d          s|} n2t;          |          t<          k    r|dt<          dz
           dz   }t?          |          }|                     |           |
	                    |||d           # tB          tD          f$ r'}tF          $                    d||           Y d}~d}~wtJ          $ r)}tF          $                    d||d           Y d}~d}~ww xY w|||
ft          |<   d |
D             S )a=  Recursively find all skills in ~/.hermes/skills/ and external dirs.

    Args:
        skip_disabled: If True, return ALL skills regardless of disabled
            state (used by ``hermes skills`` config UI). Default False
            filters out disabled skills.

    Returns:
        List of skill metadata dicts (name, description, category).

    Results are cached per-session; the cache is invalidated when the scan
    signature changes (dir/category mtimes or the disabled-set) and expires
    after a short TTL to bound staleness from in-place SKILL.md edits.
    r   )r   iter_skill_index_filesNr  c                 ,    g | ]}t          |          S rq   r   r   ss     r4   r   z$_find_all_skills.<locals>.<listcomp>  s    +++AQ+++r<      SKILL.mdc              3   (   K   | ]}|t           v V  d S rt   )_EXCLUDED_SKILL_DIRS)r   parts     r4   	<genexpr>z#_find_all_skills.<locals>.<genexpr>  s(      KKD4//KKKKKKr<   rS   rT   i  rH   descriptionr   
rV   r   ...)rH   r+  categoryz Failed to read skill file %s: %sz)Skipping skill at %s: failed to parse: %sTr   c                 ,    g | ]}t          |          S rq   r"  r#  s     r4   r   z$_find_all_skills.<locals>.<listcomp>	  s    $$$DGG$$$r<   )&r{   r   r   _SKILLS_CACHE_KEY_DISABLED_SKILLS_CACHE_KEY_FILTEREDr   r  r;   rZ   r'   r   r5   time	monotonicr   r   _SKILLS_CACHE_TTL_SECONDSanyr   parent	read_textr   rz   r   rH   MAX_NAME_LENGTHrM   r  r\   r   MAX_DESCRIPTION_LENGTHr   r   UnicodeDecodeErrorPermissionErrorr   debugr   )r  r   r   	cache_keyr,   r+   active_skills_dir	signaturenowcachedr6   
seen_namesscan_dirskill_md	skill_dirr   rx   bodyrH   r+  ra   r.  es                          r4   _find_all_skillsrH    s    SRRRRRRR.;[**A[I &Fsuuu+D+F+FH
 L#!! /-...0022333&|X>>I
.

Cy))F1I""6!9_ 999
 ,+++++FeeJ ! 2 2..xDD 1	 1	HKKHNKKKKK  I+",,g,>>uuE$6w$?$?!T-k:: 0== "vy~>>?O?OP:%%8##)oomR@@" " $

 2 24 8 8 " "#zz|| "(<(< "*.K!E{##&<<<"-.I/E/I.I"JU"RK28<<t$$$ #. (      '8   ?1MMM   ?1W[     	[1	n !*37M)$$V$$$$s=   	?J(	J(,J(J(CJ((L9KL(LLc                 &    t          | d           S )z3Keep every skill listing path ordered the same way.c                 @    |                      d          pd| d         fS )Nr.  r   rH   r   )r$  s    r4   <lambda>z_sort_skills.<locals>.<lambda>  s     z):):)@b!F)(L r<   )rb   )sorted)r6   s    r4   _sort_skillsrN    s    &LLMMMMr<   r.  task_idc                 P    	 t                      }|                                sB|                    dd           t          j        dg g dt                       ddd          S t                      }|st          j        dg g ddd          S  r fd	|D             }t          |          }t          d
 |D                       }t          j        d||t          |          ddd          S # t          $ r(}t          t          |          d          cY d}~S d}~ww xY w)a  
    List all available skills (progressive disclosure tier 1 - minimal metadata).

    Returns only name + description to minimize token usage. Use skill_view() to
    load full content, tags, related files, etc.

    Args:
        category: Optional category filter (e.g., "mlops")
        task_id: Optional task identifier used to probe the active backend

    Returns:
        JSON string with minimal skill info: name, description, category
    T)parentsexist_okz-No skills found. Skills directory created at z/skills/)r   r6   
categoriesmessageFensure_asciiz%No skills found in skills/ directory.c                 F    g | ]}|                     d           k    |S r.  rK  )r   r$  r.  s     r4   r   zskills_list.<locals>.<listcomp>=  s/    QQQ1553D3D3P3P!3P3P3Pr<   c                 b    h | ],}|                     d           |                     d           -S rX  rK  r#  s     r4   	<setcomp>zskills_list.<locals>.<setcomp>D  s5    HHH1aeeJ6G6GHQUU:HHHr<   z@Use skill_view(name) to see full content, tags, and linked files)r   r6   rS  counthintr   N)r;   rZ   mkdirjsondumpsr   rH  rN  rM  r   r   r   r(   )r.  rO  r>  
all_skillsrS  rG  s   `     r4   skills_listrb    s   41'MM '')) 
	##D4#@@@:# "$nObOdOdnnn	  #    &''
 		:# "$F	  #     	RQQQQZQQQJ "*--
 HH
HHH
 

 z$(ZZ  	
 	
 	
 		
  1 1 1#a&&%0000000001s+   A#C3 '*C3 A C3 3
D%=D D% D%T
preprocess
session_idrD  	namespacebarerd  re  c          
         ddl m}m} | |            v rt          j        dd| d| dd          S 	 |                     d	          n9# t          $ r,}t          j        dd
| d d| dd          cY d}~S d}~ww xY wi }	 t                    \  }}	n# t          $ r Y nw xY wt          |          s0t          j        dd| d dt          j
        j        dd          S t          fdt          D                       rt                              d|           t!          |                    dd                    }
t%          |
          t&          k    r|
dt&          dz
           dz   }
	 fd |                                |          D             }|r+d                    |          }d| d| d| d|d          d	}nd| d}n# t          $ r d}Y nw xY w}|rI	 ddlm}  || j        |          }n.# t          $ r! t                              d |d!"           Y nw xY wt          j        d!| d |r| | n||
dt          j        j        d#d          S )$z8Read a plugin-provided skill, apply guards, return JSON.r   )_get_disabled_pluginsget_plugin_managerFzPlugin 'z5' is disabled. Re-enable with: hermes plugins enable r   errorrU  rS   rT   Failed to read skill ':': NSkill '$' is not supported on this platform.r   rl  r   c              3   D   K   | ]}|                                 v V  d S rt   )r   )r   pr   s     r4   r*  z&_serve_plugin_skill.<locals>.<genexpr>  s0      
=
=A1
=
=
=
=
=
=r<   zIPlugin skill '%s:%s' contains patterns that may indicate prompt injectionr+  r   r   r-  c                      g | ]
}|k    |S rq   rq   )r   r$  rg  s     r4   r   z'_serve_plugin_skill.<locals>.<listcomp>  s*     
 
 
Dyy yyr<   r   z,[Bundle context: This skill is part of the 'z' plugin.
Sibling skills: z..
Use qualified form to invoke siblings (e.g. z).]

z' plugin.]

preprocess_skill_contentre  z'Could not preprocess plugin skill %s:%sTr   )r   rH   r   r+  linked_filesr   )hermes_cli.pluginsri  rj  r_  r`  r7  r   r   rz   rg   rp   rd   r5  rr   r   r   r(   r   r   r9  list_plugin_skillsr   agent.skill_preprocessingrw  r6  r<  rn   )rD  rf  rg  rd  re  ri  rj  rG  parsed_frontmatterrc   r+  siblingssib_listbannerrendered_contentrw  r   s     `             @r4   _serve_plugin_skillr  Y  s7    MLLLLLLL))++++z Iy I I=FI I  	
 	
 	
 		

$$g$66 
 
 
z(Y(Y(YT(Y(YVW(Y(YZZ
 
 
 	
 	
 	
 	
 	
 	

 *, 27 ; ;AA    ""455 
z Y9YYtYYY$8$D$J 
 
 
 
 	
 
=
=
=
=)<
=
=
=== 
Wt	
 	
 	

 (,,]B??@@K
;000!">$:Q$>">?%G
 
 
 
))++>>yII
 
 
  	^yy**H`y ` `#+` `?H` `KSTU;` ` ` F ^I]]]F     	JJJJJJ77%     
  	 	 	LL99dUY      	
 : ))4))8>T&4"2444DT&  4 > D	
 	
 
 
 
 
sT   A 
B!A?9B?B
B 
B*)B*9AG G%$G%-H (H21H2	file_pathc                 !  PQRSTUV 	 t          |           }|rt          j        d|ddd          S d}d| v r3ddlm}m} dd	lm}m}	  ||           \  S}
 |S          s t          j        dd
S d|  ddd          S  |              |	            }|	                    |           }|]|
                                s5|                    |            t          j        dd|  d| ddd          S t          |S|
||          S |                    S          }|rBt          j        dd|
 dS dSfd|D             dS dt          |           ddd          S |
rS d|
 }ddlm} |r+t          |          }|rt          j        d|ddd          S g }t!                      }|
                                r|                    |           |                     |                       |st          j        dddd          S dVd}ddlm} g Qt)                      Udt*          t,                   dt,          ddfQUfd }|D ]K}|| z  }t/          |          s;|                                r'|d!z  
                                r |||d!z             nh|                    d"          
                                rAt/          |                    d"                    s |d|                    d"                     |r||z  }t/          |          s;|                                r'|d!z  
                                r |||d!z             nh|                    d"          
                                rAt/          |                    d"                    s |d|                    d"                      ||d!          D ]}|j        j        | k    r ||j        |           $	 |                    d#$          }t;          |          \  }}n# t<          $ r i }Y nw xY w|                    d%          | k    r ||j        |           |                     |  d"          D ](}|j        d!k    rt/          |          s |d|           )Mt          Q          d&k    rd' QD             }tC          j"        tF                    $                    d(| t          Q          d)%                    |                     t          j        dd*|  d+t          Q           d,|d-d.d          S QrQd         \  V}|r|
                                sLd/ tM          tO                                dd0         D             }t          j        dd|  d1|d2dd          S 	 |                    d#$          }n6# t<          $ r)}t          j        dd3|  d+| dd          cY d}~S d}~ww xY wd4}|(                                g} 	 |                     d5 |d&d         D                        n# t<          $ r Y nw xY w| D ]=}!	 |(                                )                    |!           d} n# tT          $ r Y :w xY w|+                                PtY          Pfd6tZ          D                       }"|s|"rtg }#|r|#                    d7|            |"r|#                    d8           tC          j"        tF                    $                    d9| d)%                    |#                     i }$	 t;          |          \  }$}n# t<          $ r i }$Y nw xY wt]          |$          s-t          j        dd|  d:t^          j0        j1        d;d          S |$                    d%|j        j                  }%te          |%          rt          j        dd|% d<dd          S |rȉVrdd=l3m4}&m5}'  |'|          rt          j        dd>d?dd          S V|z  }( |&|(V          })|)rt          j        d|)d?dd          S |(
                                sg g g g g d@}*V                     dA          D ]/}+|+6                                r|+j        d!k    rto          |+)                    V                    },|,8                    dB          r|*dC                             |,           w|,8                    dD          r|*dE                             |,           |,8                    dF          r|*dG                             |,           |,8                    dH          r|*dI                             |,           |+j9        dJv r|*dK                             |,           1dL |*:                                D             }*t          j        ddM| dN|  d|*dOdPd          S 	 |(                    d#$          }nO# tv          $ rB t          j        d4| |dQ|(j         dR|(<                                j=         dSd4dTd          cY S w xY w	 ddUl>m?}-  |-|(           n-# t<          $ r  t          A                    dV|(d4W           Y nw xY wt          j        d4| |||(j9        dXd          S |$}.g }/g }0g }1g }2VrXVdCz  }3|3
                                r!VfdY|3B                    dZ          D             }/VdEz  }4|4
                                r9d[D ]6}5|0                    Vfd\|4                     |5          D                        7VdGz  }6|6
                                ra|6                     dA          D ]K}+|+6                                r5|1                    to          |+)                    V                               LVdIz  }7|7
                                r9d]D ]6}5|2                    Vfd^|7B                    |5          D                        7i }8|.                    d_          }9t          |9t                    r|9                    d`i           pi }8t          |8                    da          p|.                    dadb                    }:t          |8                    dc          p|.                    dcdb                    };i }<|/r|/|<dC<   |0r|0|<dE<   |1r|1|<dG<   |2r|2|<dI<   	 to          |)                    |                    }=nO# tT          $ rB |j        j        r,to          |)                    |j        j                            n|j        }=Y nw xY w|.                    d%Vs|jF        nVj                  }>t          |.          \  }?}t          |.|?          }@t                      }At                      RRfdd|@D             }Bt          |>|B          }C|Brt                      Rt          |@|CRe          Tt          T          }DTfdf|@D             }E|Er@	 ddglNmO}F  |F|E           n-# t<          $ r  t          A                    dh|>d4W           Y nw xY w|.                    dig           }Gt          |Gt                    sg }Gg }H|GrD	 ddjlQmR}I  |I|G          }H|Hrd4}Dn-# t<          $ r  t          A                    dk|>d4W           Y nw xY w|}J|rC	 ddllSmT}K  |K|V|m          }Jn-# t<          $ r  t          A                    dn|>d4W           Y nw xY wi dod4d%|>dp|.                    dpdb          da|:dc|;dq|Jdr|=dsVrto          V          nddt|<r|<nddu|<rdvnddw|@dxg dyTdz|Hd{g d||Dd}|Cd}         d~|Drt^          jU        j1        nt^          jV        j1        i}Lt          d |@D             d          }M|Mr|M|Ld<   |Cd         r|Cd         |Ld<   	 ddUl>m?}-  |-|           n-# t<          $ r  t          A                    dV|d4W           Y nw xY w|Dr`d TD             d |HD             z   }Nt          t^          jU        |N|M          }O|At          v r|Or|O d|AZ                                 d}O|Or|O|Ld<   |.                    d          r|.d         |Ld<   t          |9t                    r|9|Ld_<   t          j        |Ld          S # t<          $ r(}t          to          |          d          cY d}~S d}~ww xY w)a  
    View the content of a skill or a specific file within a skill directory.

    Args:
        name: Name or path of the skill (e.g., "axolotl" or "03-fine-tuning/axolotl").
            Qualified names like "plugin:skill" resolve to plugin-provided skills.
        file_path: Optional path to a specific file within the skill (e.g., "references/api.md")
        task_id: Optional task identifier used to probe the active backend
        preprocess: Apply configured SKILL.md template and inline shell rendering
            to main skill content. Internal slash/preload callers disable this
            because they render the skill message themselves.

    Returns:
        JSON string with skill content or error message
    Fz>Use a skill name or relative path within the skills directory.)r   rl  r\  rU  Nrn  r   )is_valid_namespaceparse_qualified_name)discover_pluginsrj  zInvalid namespace 'z' in 'z('. Namespaces must match [a-zA-Z0-9_-]+.rk  rp  z' file no longer exists at uT   . The registry entry has been cleaned up — try again after the plugin is reloaded.rc  z' not found in plugin 'z'.c                     g | ]	} d | 
S )rn  rq   )r   r$  rf  s     r4   r   zskill_view.<locals>.<listcomp>  s'    ,S,S,SA	-?-?A-?-?,S,S,Sr<   zThe 'z' plugin provides z
 skill(s).)r   rl  available_skillsr\  /r   zISkills directory does not exist yet. It will be created on first install.)r   sdsmdr   c                     	 |                                 }n# t          $ r |}Y nw xY w|v rd S                     |                               | |f           d S rt   )resolver   r   r'   )r  r  rb   
candidatesseen_mds      r4   _recordzskill_view.<locals>._recordX  sy    kkmm   g~~KKr3i(((((s    ''r&  .mdrS   rT   rH   r  c                 2    g | ]\  }}t          |          S rq   )r(   )r   rc   r  s      r4   r   zskill_view.<locals>.<listcomp>  s"    777&!SSXX777r<   u3   Skill name collision for '%s': %d candidates — %sz; zAmbiguous skill name 'ro  u    skills match across your local skills dir and external_dirs. Refusing to guess — load one explicitly by its categorized path.zPass the full relative path instead of the bare name (e.g., 'category/skill-name'), or rename one of the colliding skills so each name is unique.)r   rl  matchesr\  c                     g | ]
}|d          S r   rq   r#  s     r4   r   zskill_view.<locals>.<listcomp>  s    RRRq6RRRr<      z' not found.z+Use skills_list to see all available skillsrm  Tc              3   >   K   | ]}|                                 V  d S rt   )r  )r   r/   s     r4   r*  zskill_view.<locals>.<genexpr>  s*       C C C C C C C Cr<   c              3       K   | ]}|v V  	d S rt   rq   )r   rt  _content_lowers     r4   r*  zskill_view.<locals>.<genexpr>  s(      !S!S!!~"5!S!S!S!S!S!Sr<   zHskill file is outside the trusted skills directory (~/.hermes/skills/): zBskill content contains patterns that may indicate prompt injectionz#Skill security warning for '%s': %srq  rr  zT' is disabled. Enable it with `hermes skills` or inspect the files directly on disk.)validate_within_dirrJ   z%Path traversal ('..') is not allowed.z.Use a relative path within the skill directory)
references	templatesassetsscriptsother*zreferences/r  z
templates/r  zassets/r  zscripts/r  >   .py.sh.tex.yml.json.yamlr  r  c                     i | ]
\  }}|||S rq   rq   )r   kvs      r4   
<dictcomp>zskill_view.<locals>.<dictcomp>J  s#    "Q"Q"QDAqq"Q1a"Q"Q"Qr<   zFile 'z' not found in skill 'z0Use one of the available file paths listed above)r   rl  available_filesr\  z[Binary file: z, size: z bytes])r   rH   filer   	is_binary)!mark_background_review_skill_readz4Could not record background-review skill read for %sr   )r   rH   r  r   	file_typec                 T    g | ]$}t          |                                        %S rq   r(   r   r   r`   rE  s     r4   r   zskill_view.<locals>.<listcomp>  s:     # # #67Ci0011# # #r<   *.md)r  *.pyz*.yamlz*.ymlz*.jsonz*.tex*.shc                 T    g | ]$}t          |                                        %S rq   r  r  s     r4   r   zskill_view.<locals>.<listcomp>  s=        !  i 8 899  r<   )r  r  z*.bashz*.jsz*.tsz*.rbc                 T    g | ]$}t          |                                        %S rq   r  r  s     r4   r   zskill_view.<locals>.<listcomp>  s-    VVV1Q]]95566VVVr<   r   hermestagsr   related_skillsc                 j    g | ]/}|                     d           t          |d                   -|0S )r   rH   )r   r   )r   rG  r   s     r4   r   zskill_view.<locals>.<listcomp>  sS     %
 %
 %
55$$%
 *!F)\BB	%
%
 %
 %
r<   r   c                 4    g | ]}|d          v|d          S r   rq   )r   rG  remaining_missing_required_envss     r4   r   zskill_view.<locals>.<listcomp>  s7     
 
 
y ??? fI???r<   )register_env_passthroughz/Could not register env passthrough for skill %srequired_credential_files)register_credential_filesz0Could not register credential files for skill %srv  rx  z)Could not preprocess skill content for %sr   r+  r   pathrE  ry  
usage_hintzzTo view linked files, call skill_view(name, file_path) where file_path is e.g. 'references/api.md' or 'assets/config.yaml'r   required_commands&missing_required_environment_variablesmissing_credential_filesmissing_required_commandsri   r   r   c              3   P   K   | ]!}|                     d           |d          V  "dS )r   NrK  )r   rG  s     r4   r*  zskill_view.<locals>.<genexpr>5  s5      QQ155==Q1V9QQQQQQr<   r   r   c                     g | ]}d | S )zenv $rq   )r   r   s     r4   r   zskill_view.<locals>.<listcomp>H  s.       '/"""  r<   c                     g | ]}d | S )zfile rq   )r   r  s     r4   r   zskill_view.<locals>.<listcomp>J  s+       #'  r<   r   zW-backed skills need these requirements available inside the remote environment as well.
setup_notecompatibilityr]  )\rQ   r_  r`  r{   r  r  rz  r  rj  find_plugin_skillrZ   remove_plugin_skillr  r{  r   r   r;   r'   r   r   r   r   r   _is_skill_support_pathr&   with_suffixr6  rH   r7  r   r   r   rgloblogging	getLoggerrk   r   r   rN  rH  r  r   r   r   r5  rr   rz   rg   rp   rd   r  rK   r  rJ   is_filer(   r\   suffixitemsr:  r!   st_sizetools.skill_manager_toolr  r   r<  globrL   r   r  stemr   r   r   re   r   r   r   tools.env_passthroughr  r   tools.credential_filesr  r|  rw  ro   rn   nextr   _REMOTE_ENV_BACKENDSupperr   )WrH   r  rO  rd  lookup_errorlocal_category_namer  r  r  rj  rg  pmplugin_skill_mdrh   r   all_dirsr>  rD  r   r  
search_dirdirect_pathcategorized_pathfound_skill_md
fm_contentfmrc   found_mdpathsr   rG  _outside_skills_dir_trusted_dirs_td_injection_detected	_warningsr}  resolved_namer  rJ   target_filetraversal_errorr  r`   relr  rx   reference_filestemplate_filesasset_filesscript_filesreferences_dirtemplates_dirext
assets_dirscripts_dirhermes_metar   r  r  ry  r   r   r   r   backendmissing_required_env_varsr   ri   available_env_namesr  required_cred_files_rawmissing_cred_filesr  r  rw  resultr   missing_itemsr  r  r  r   rf  r  r  rE  sW                                                                                   @@@@@@@r4   
skill_viewr    s   *J
1
 055 	:$)\ 
 #    +/ $;;RRRRRRRROOOOOOOO22488OIt%%i00 
z#(E) E E4 E E E  "'	 	 	 	 ##%%B 22488O*&--// **4000:',!7$ !7 !7#2!7 !7 !7  &+    +#)&    --i88I 	z#(!U4!U!U	!U!U!U,S,S,S,S,S,S,S _	 _ _S^^ _ _ _	  "'     <)2&;&;T&;&;#>>>>>>  
	34GHHL z#(!- ` 
 "'    'MM##%% 	/OO-...0022333 	:$h  #    	 	=<<<<<8:
uu	) 	)T 	)d 	) 	) 	) 	) 	) 	) 	) # :	, :	,J %t+K*;77	>&&((	> !:-5577	>
 [:%=>>>>((//6688 >AW''..B B > k55e<<===
 # G#-0C#C ./?@@G(//11G *J6>>@@G
 G,.>.KLLLL%11 &((G#9$0077$ $G
 GD"2">">u"E"EFFF #9"8Z"P"P 
C 
C!(-55GN1>BBB!/!9!97!9!K!KJ.z::EB    BBB66&>>T))GN1>BBB ',,\\\:: , ,=J..7M8 8. GD(+++	, z??Q77J777Eh''//Ec*ootyy'7'7   :$] ] ]#j// ] ] ]  %C  #   $  	0",Q-Ix 
	x00 
	RRL9I9K9K,L,LSbS,QRRRI:$9t999(1I	  #   		(('(::GG 	 	 	:$BdBBqBB  #        	 #*22445	   C Chqrrl C C CCCCC 	 	 	D	  	 	C  ""..s333&+#   
 !!!S!S!S!S?R!S!S!SSS 	s"5 	sI" x  !vlt!v!vwww" g  !efffh''//0UW[]a]f]fgp]q]qrrr-/	$$6w$?$?! 	$ 	$ 	$!#	$ &&899 	:$QtQQQ(<(H(N 
 #    +..vx7KLLm,, 
	:$`- ` ` `  #	 	 	 	  m	 m	XXXXXXXX '&y11 z#(!H P 
 "'    $i/K 21+yIIO z#(!0 P 
 "'    %%'' , #%!# !# # #-- A AAyy{{ Aqv';';!!--	":":;;>>-88 A+L9@@EEEE ^^L99 A+K8??DDDD ^^I66 A+H5<<SAAAA ^^J77 A+I6==cBBBBX *   ,G4;;C@@@ #R"QO4I4I4K4K"Q"Q"Qz#(!S)!S!S4!S!S!S+: R	  "'   %///AA%   z#' $ )#qK4D#q#qkN^N^N`N`Nh#q#q#q%)  "'	 	 	 	 	 		VVVVVV11+>>>>   J!       :# %&!,!3  #	 	 	 	 )  %	&5N$$&& # # # #;I;N;Nv;V;V# # # &3M##%%   C #))   %2%8%8%=%=      #X-J  "" J#))#.. J JAyy{{ J#**3q}}Y/G/G+H+HIII#i/K!!## M  C ''VVVV@P@PQT@U@UVVV    ??:..h%% 	;",,x44:K;??622Qkoofb6Q6QRR$OO,--VAQSU1V1V
 

  	9)8L& 	7(6L% 	1%0L" 	3&2L#	v8//0ABBCCHH 	v 	v 	vLTOLbus8//0FGGHHHhphuHHH	v !__FHMM	
 

 :+FF?
 
 -..zz%
 %
 %
 %
&%
 %
 %
! A%
 
 % 	&#::L*O%+
 +
 +
'
 ;<<

 
 
 
&
 
 

  
		JJJJJJ(()<====   E!       #.//2Mr"R"R1488 	)&(##%" 	LLLLLL%>%>?V%W%W"% (#'L   F!       # 	NNNNNN#;#;&$ $ $  
    ?VZ      

t
J
 ;??="==
 D	

 n
 '
 H
 9>Y$
 LBLLd
   W  W
 -.?
  
 56U
  '(:!
" (#
$ L%
& ^O<'
( !6 4 A G G%/5-
 
2 QQ.?QQQSWXX
 	.#-F< ./ 	P+9:N+OF'(		RRRRRR--h7777 	 	 	LLF      	  	2 3R   +=  M
 +$1 J
 ...:. *  V  VW]]__  V  V  V
 2'1|$ ???++ 	C&1/&BF?#h%% 	*!)F:z&u5555 1 1 1#a&&%0000000001su  *AC	 AAC	 A3AC	 8AC	 AAC	 %;AC	 !A0AC	 G!AC	 4(PAC	 P,)AC	 +P,,DAC	 :A.AC	 *W  AC	 
W4W/)W4*AC	 /W44AC	 'X7 6AC	 7
YAC	 YAC	 )Y75AC	 7
ZAC	 ZB1AC	 6]	 AC	 	]AC	 ]>AC	 AAC	 #2AC	 ,AC	 F"AC	 'g> =AC	 >A	i
AC	 	i

AC	 i  AC	  'j
AC	 	j

#AC	 .H7AC	 &"t	 AC	 	A	uAC	 uCAC	 x, +AC	 ,'yAC	 y4AC	 z!  AC	 !'{AC	 
{AC	 {( 'AC	 ('|AC	 |CAC	 * )AC	 *'A@@AC	 @A@@B4AC	 C	
AC;CAC6C0AC;C6AC;__main__u   🎯 Skills Tool Testz<============================================================u   
📋 Listing all skills:r   zFound r[  z skills in rS  z categorieszCategories: z
First 10 skills:
   r  z] r   u     • z: r+  <   r-  zError: rl  u   
📖 Viewing skill 'axolotl':axolotlzName: zDescription: zN/Ad   zContent length: z charsry  zLinked files: uE   
📄 Viewing reference file 'axolotl/references/dataset-formats.md':zreferences/dataset-formats.mdzFile: r  z	Preview:    rb  zVList available skills (name + description). Use skill_view(name) to load full content.objectstringz*Optional category filter to narrow results)typer+  )r  
propertiesr   )rH   r+  
parametersr  ah  Skills allow for loading information about specific tasks and workflows, as well as scripts and templates. Load a skill's full content or access its linked files (references, templates, scripts). First call returns SKILL.md content plus a 'linked_files' dict showing available references/templates/scripts. To access those, call again with file_path parameter.zThe skill name (use skills_list to see available skills). For plugin-provided skills, use the qualified form 'plugin:skill' (e.g. 'superpowers:writing-plans').zOPTIONAL: Path to a linked file within the skill (e.g., 'references/api.md', 'templates/config.yaml', 'scripts/validate.py'). Omit to get the main SKILL.md content.)rH   r  c                 p    t          |                     d          |                    d                    S )Nr.  rO  )r.  rO  )rb  r   )argskws     r4   rL  rL    s2    {*%%rvvi/@/@      r<   u   📚)rH   toolsetschemahandlercheck_fnemojic                    |                      dd          }t          ||                      d          |                     d                    }	 t          j        |          }t	          |t
                    rf|                     d          rQ|                     d          p|}|r8ddlm}m}  |t          |                      |t          |                     n# t          $ r Y nw xY w|S )	ztInvoke skill_view, then bump view_count on success. Best-effort: a
    telemetry failure never breaks the tool call.rH   r   r  rO  )r  rO  r   r   )bump_use	bump_view)r   r  r_  loadsrL   r   tools.skill_usager  r  r(   r   )r  r  rH   r  parsedresolvedr  r  s           r4   _skill_view_with_bumpr!    s    88FBD--rvvi7H7H  FF##fd## 
	(

9(=(= 
	( zz&))1TH (AAAAAAAA	#h--((( X'''   Ms   BC   
C-,C-)r   Nrt   )NN)NNT)e__doc__r_  r  r2  hermes_constantsr   r   r$   reenumr   pathlibr   r   r   typingr	   r
   r   r   r   r   tools.registryr   r   r  r   utilsr   r{   r   r(  r   r  r  rk   r   r   r   __annotations__r4  r0  r1  r)   r5   HERMES_HOMEr8   r9   r;   r8  r9  _PLATFORM_MAPcompiler   r*   r  ru   r(   rQ   re   rg   rr   r   rw   r   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  rH  rN  rb  r  r  printr  r  r   r   skillcatSKILLS_LIST_SCHEMASKILL_VIEW_SCHEMAregisterr!  rq   r<   r4   <module>r4     s  A A AF    A A A A A A A A 				 				       8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 / / / / / / / / % % % % % % ! ! ! ! ! !       
 
	8	$	$ t     , ' 7e 7 7 7 7H o8#
" (T ( ( ( (  
  
 2:9::  y888     3 8C=    6$sCx.    $         3      
 
 
 T 
 
 
( ( ( (
S#X 4    	4S> 	d 	 	 	 	># >$s) > > > >	c3h	
49d3i 	 	 	 	*4S> *d38n * * * *^ )-B Bc3hB#Y%B 
$sCx.B B B BJKK$sCx.)K 
#s(^K K K K\<T < < < <NC N N N N
 :>% %%!%c3h$!6%	% % % % +/	  DcN+cN sCx.4'	
 
#Y   (bS b b b b " *#Y d
 	4Z	   4    
& &d38nc.A(B & & & & #    4PtCy P P P P>&3s8 & & & &s     S C 4    4 /4 l% l% l%t l%T#s(^8L l% l% l% l%^Nd38n- N$tCH~2F N N N N
B1 B1# B1s B1c B1 B1 B1 B1Z !e e eee e
 e d
e 	e e e eT 	_
1 _
1
_
1_
1 _
1 	_
1
 	_
1 _
1 _
1 _
1H z	E
!"""	E(OOO 
E
&'''TZ&&Fi 
+_VG___VZZb5Q5Q1R1R___	
 	
 	
 	;VZZb99;;<<<"###H%crc* 	Q 	QE/4yy/D/DL+eJ'++++"CEO3OfOO}1Ecrc1JOOOPPPP	Q 	)w))*** 
E
+,,,TZ

9--..Fi +'vf~''(((Ifjj>>ttDIIIJJJ?VI%6!7!7???@@@::n%% 	=E;6.#9;;<<<)w))*** 
E
RSSSTZ

9.MNNOOFi +'vf~''(((?VI%6!7!7???@@@6&+DSD16667777)w))*** k K 
 	 	     ~ !  A 
 !  F 	
 	
 H   &  	  '
	 	 	 	  2  	!&
     r<   