o
    Ďi                     @   s  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dZdedefddZdededdfdd Zd!ededefd"d#Zd$ed%ededefd&d'Zejd(g d)d*	+	+	+	+		+d?d,eeej d-d.df d/eeej d0d1df d2eeej d3d4df d5eeej d6d7d8df d9eee ej d:df deeej d;d<df ddfd=d>Z!dS )@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                 C   s   t  | }|  |jS )z!Download text content from a URL.)r   getraise_for_statustext)r   response r   V/home/jeff/fluffinator/venv/lib/python3.10/site-packages/huggingface_hub/cli/skills.py	_downloadS   s   r   pathforcec                 C   sR   |   s
|  s
dS |std|  d|  r#|  s#t|  dS |   dS )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   r   r   r   _remove_existingZ   s   r   
skills_dirc                 C   s   |    } | jddd | t }t|| |  tt}|d jt| dd |d }|  tt	}|d j|d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_contentr   r   r   _install_tof   s   
r2   agent_skills_dircentral_skill_pathc                 C   sD   |    } | jddd | t }t|| |tj||  |S )zMCreate a relative symlink from agent directory to the central skill location.Tr!   )	r&   r'   r(   r)   r   
symlink_toosr   relpath)r3   r4   r   	link_pathr   r   r   _create_symlink|   s   
r9   add)zhf skills add --claudezhf skills add --claude --globalz hf skills add --codex --opencode)examplesFr
   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.r.   z=Install into a custom destination (path to skills directory).z--forcez-Overwrite existing skills in the destination.c                 C   s   | s|s|s|st d|r1| s|s|s|r td tjddt||}tdt d|  dS |r5tnt}g }| rB||d  |rK||d	  |rT||d
  |rXt	nt
}	t|	|}
tdt d|
  |D ]}t||
|}td|  qkdS )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Exitr2   r)   GLOBAL_TARGETSLOCAL_TARGETSappendCENTRAL_GLOBALCENTRAL_LOCALr9   )r
   r	   r   r<   r.   r   
skill_desttargets_dictagent_targetscentral_pathr4   agent_targetr8   r   r   r   
skills_add   s0   #

rK   )FFFFNF)"__doc__r6   r   pathlibr   typingr   r   r?   huggingface_hub.errorsr   huggingface_hub.utilsr   
_cli_utilsr   r)   _GITHUB_RAW_BASEr*   r-   r,   rE   rD   rA   rB   
skills_clistrr   boolr   r2   r9   commandOptionrK   r   r   r   r   <module>   s   


	