
    Wi                        d Z ddlZddlZddlmZ ddlmZmZ ddlZddl	m
Z
 ddlmZ ddlmZ d	Zd
Ze dZe dZdZ ed      Z ed      Z ed       ed       ed      dZ ed       ed       ed      dZ ed      ZdedefdZdededdfdZdededefd Zd!ed"ededefd#Zej?                  d$g d%&      	 	 	 	 	 	 d9d'ee ej@                  d(d)      f   d*ee ej@                  d+d,      f   d-ee ej@                  d.d/      f   d0ee ej@                  d1d2d3      f   d4eee    ej@                  d5      f   dee ej@                  d6d7      f   ddfd8       Z!y):a  Contains commands to manage skills for AI assistants.

Usage:
    # install the hf-cli skill for Claude (project-level, in current directory)
    hf skills add --claude

    # install for multiple assistants (project-level)
    hf skills add --claude --codex --opencode

    # install globally (user-level)
    hf skills add --claude --global

    # install to a custom directory
    hf skills add --dest=~/my-skills

    # overwrite an existing skill
    hf skills add --claude --force
    N)Path)	AnnotatedOptional)CLIError)get_session   )typer_factoryzhf-clizQhttps://raw.githubusercontent.com/huggingface/huggingface_hub/main/docs/source/enz/guides/cli.mdz/package_reference/cli.mda  ---
name: hf-cli
description: >
  Hugging Face Hub CLI (`hf`) for downloading, uploading, and managing
  repositories, models, datasets, and Spaces on the Hugging Face Hub.
---

The Hugging Face Hub CLI tool `hf` is available. IMPORTANT: The `hf` command replaces the deprecated `huggingface_cli` command.

Use `hf --help` to view available functions. Note that auth commands are now all under `hf auth` e.g. `hf auth whoami`.
z.agents/skillsz~/.agents/skillsz~/.codex/skillsz~/.claude/skillsz~/.config/opencode/skills)codexclaudeopencodez.codex/skillsz.claude/skillsz.opencode/skillsz Manage skills for AI assistants.)helpurlreturnc                 l    t               j                  |       }|j                          |j                  S )z!Download text content from a URL.)r   getraise_for_statustext)r   responses     f/home/sietch6/trending-topics-pipeline/venv/lib/python3.12/site-packages/huggingface_hub/cli/skills.py	_downloadr   S   s*    }  %H==    pathforcec                     | j                         s| j                         sy|st        d|  d      | j                         r&| j                         st	        j
                  |        y| j                          y)zRRemove existing file/directory/symlink if force is True, otherwise raise an error.NzSkill already exists at z#.
Re-run with --force to overwrite.)exists
is_symlink
SystemExitis_dirshutilrmtreeunlink)r   r   s     r   _remove_existingr"   Z   sW    KKMT__.3D69]^__{{}T__.dr   
skills_dirc                 ~   | j                         j                         } | j                  dd       | t        z  }t	        ||       |j                          t        t              }|dz  j                  t        |z   d       |dz  }|j                          t        t              }|dz  j                  |d       |S )zYDownload and install the skill files into a skills directory. Returns the installed path.Tparentsexist_okzSKILL.mdzutf-8)encoding
referenceszcli.md)

expanduserresolvemkdirDEFAULT_SKILL_IDr"   r   _SKILL_MD_URL
write_text_SKILL_YAML_PREFIX_REFERENCE_URL)r#   r   destskill_contentref_dirref_contents         r   _install_tor6   f   s    &&(002JTD1((DT5!JJL m,M	J""#5#EPW"X \!GMMON+Kx##K'#BKr   agent_skills_dircentral_skill_pathc                     | j                         j                         } | j                  dd       | t        z  }t	        ||       |j                  t        j                  j                  ||              |S )zMCreate a relative symlink from agent directory to the central skill location.Tr%   )	r*   r+   r,   r-   r"   
symlink_toosr   relpath)r7   r8   r   	link_paths       r   _create_symlinkr>   |   sg    '224<<>4$7 #33IY&);=MNOr   add)zhf skills add --claudezhf skills add --claude --globalz hf skills add --codex --opencode)examplesr   z--claudezInstall for Claude.r
   z--codexzInstall for Codex.r   z
--opencodezInstall for OpenCode.global_z--globalz-gzJInstall globally (user-level) instead of in the current project directory.r2   z=Install into a custom destination (path to skills directory).z--forcez-Overwrite existing skills in the destination.c                 
   | s|s|s|st        d      |rK| s|s|s|r!t        d       t        j                  d      t	        ||      }t        dt
         d|        y|rt        nt        }g }| r|j                  |d          |r|j                  |d	          |r|j                  |d
          |rt        nt        }	t	        |	|      }
t        dt
         d|
        |D ]  }t        ||
|      }t        d|         y)z4Download a skill and install it for an AI assistant.z@Pick a destination via --claude, --codex, --opencode, or --dest.zJ--dest cannot be combined with --claude, --codex, --opencode, or --global.r   )codezInstalled 'z' to Nr   r
   r   z' to central location: zCreated symlink: )r   printtyperExitr6   r-   GLOBAL_TARGETSLOCAL_TARGETSappendCENTRAL_GLOBALCENTRAL_LOCALr>   )r   r
   r   rA   r2   r   
skill_desttargets_dictagent_targetscentral_pathr8   agent_targetr=   s                r   
skills_addrQ      s   F ex4YZZUh'^_**!$$ u-
,-U:,?@%,>-L "M\(34\'23\*56%,>-L$\59	K())@AS@T
UV% /#L2DeL	!)-./r   )FFFFNF)"__doc__r;   r   pathlibr   typingr   r   rE   huggingface_hub.errorsr   huggingface_hub.utilsr   
_cli_utilsr	   r-   _GITHUB_RAW_BASEr.   r1   r0   rK   rJ   rG   rH   
skills_clistrr   boolr"   r6   r>   commandOptionrQ    r   r   <module>r_      sc  & 
   &  + - %  f #$N3$%%>?  %&() #$%&01 /"#$'(  BC
3 3 	4 	 	 	D  $ ,	d 	 	T 	VZ 	 	   UZQVZ_ 	 	 	15/dLELL:OPPQ5/T<5<<	8LMMN5/ lell<>UVVW5/ ]	
		5/ P	
	5/$ @	
	%5/2 
35/5/r   