
    $ɷi%                     V   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
mZ ddlmZ ddlmZ d	Zd
ZdZ ed      Z ed      Z ed       ed       ed       ed      dZ ed       ed       ed       ed      dZ ed      ZdefdZ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$      d>d%       Z ej?                  d&g d'(      	 	 	 	 	 	 	 d?d)ee ejB                  d*d+      f   d,ee ejB                  d-d.      f   d/ee ejB                  d0d1      f   d2ee ejB                  d3d4      f   d5ee ejB                  d6d7d8      f   d9eee    ejB                  d:      f   dee ejB                  d;d<      f   ddfd=       Z"y)@a  Contains commands to manage skills for AI assistants.

Usage:
    # install the hf-cli skill in common .agents/skills directory (either in current directory or user-level)
    hf skills add
    hf skills add --global

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

    # install for Cursor (project-level, in current directory)
    hf skills add --cursor

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

    # 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)ContextGroup)get_command   )typer_factoryzhf-clia  ---
name: hf-cli
description: "Hugging Face Hub CLI (`hf`) for downloading, uploading, and managing repositories, models, datasets, and Spaces on the Hugging Face Hub. Replaces now deprecated `huggingface-cli` command."
---

Install: `curl -LsSf https://hf.co/cli/install.sh | bash -s`.

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`.
a
  
## Tips

- Use `hf <command> --help` for full options, usage, and real-world examples
- Use `--format json` for machine-readable output on list commands
- Use `-q` / `--quiet` to print only IDs
- Authenticate with `HF_TOKEN` env var (recommended) or with `--token`
z.agents/skillsz~/.agents/skillsz~/.codex/skillsz~/.claude/skillsz~/.cursor/skillsz~/.config/opencode/skills)codexclaudecursoropencodez.codex/skillsz.claude/skillsz.cursor/skillsz.opencode/skillsz Manage skills for AI assistants.)helpreturnc                     g }| j                   D ]V  }|j                  s|j                  j                  d      r,|j                  dk7  s<|j                  |j                         X dj                  |      S )z?Format required params for a command as uppercase placeholders._z--help )paramsrequiredname
startswithhuman_readable_nameappendjoin)cmdpartsps      M/var/www/html/venv/lib/python3.12/site-packages/huggingface_hub/cli/skills.py_format_paramsr   `   sb    EZZ 0::aff//49N9NRZ9ZLL../0 88E?    c                     ddl m}  ddlm} t	        |      }t        |d      }t        t        j                               }|j                  d       |j                  d|  d       |j                  d       |j                  d	       |j                  d       g }g }t        |j                  |            D ]Z  }|j	                  ||      }||j                  r$t        |t              r|j                  ||f       H|j                  ||f       \ |D ]r  \  }}|j                  xs dj!                  d
      d   j#                         }	t%        |      }
d|g|
r|
gng z   }|j                  ddj'                  |       d|	        t |D ]"  \  }}|j                  xs dj!                  d
      d   j#                         }	|j                  d       |j                  d| d|	        |j                  d       t        |||      }|j                  |      D ]  }|j	                  ||      }||j                  r$|j                  xs dj!                  d
      d   j#                         }t%        |      }
d||g|
r|
gng z   }|j                  ddj'                  |       d|         % |j)                  t*        j                                d
j'                  |      S )Nr   )__version__)apphf)	info_name z!Generated with `huggingface_hub vz-`. Run `hf skills add --force` to regenerate.z## Commands
z- `r   u   ` — z### `hf )parentr%   )huggingface_hubr"   huggingface_hub.cli.hfr#   r   r   list_SKILL_YAML_PREFIX
splitlinesr   sortedlist_commandshidden
isinstancer   r   splitstripr   r   extend_SKILL_TIPS)r"   r#   	click_appctxlines	top_levelgroupsr   r   	help_textr   r   sub_ctxsub_namesub_cmdsub_helps                   r   build_skill_mdr@   i   s   +*C I
)t
,C .99;<E	LL	LL4[MAnop	LL	LL	LLIFy..s34 *##C.;#**c5!MM4+&dC[)*  ?	cXX^**40399;	$tF;s388E?+6)=>	?  B	cXX^**40399;	RxvVI;78R#cT:))'2 	BHoogx8G'..*11$7:@@BH#G,F4*&vhbIELL3sxx/vhZ@A	BB 
LL'')*99Ur    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)rA   rB   s     r   _remove_existingrK      sW    KKMT__.3D69]^__{{}T__.dr    
skills_dirc                     | j                         j                         } | j                  dd       | t        z  }t	        ||       |j                          |dz  j                  t               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)
expanduserresolvemkdirDEFAULT_SKILL_IDrK   
write_textr@   )rL   rB   dests      r   _install_torX      sj    &&(002JTD1((DT5!JJL	J"">#3g"F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.TrN   )	rR   rS   rT   rU   rK   
symlink_toosrA   relpath)rY   rZ   rB   	link_paths       r   _create_symlinkr`      sg    '224<<>4$7 #33IY&);=MNOr    previewc                  *    t        t                      y)z'Print the generated SKILL.md to stdout.N)printr@    r    r   skills_previewre      s     
.
r    add)zhf skills addzhf skills add --globalzhf skills add --claude --cursorz2hf skills add --codex --opencode --cursor --global)examplesr   z--claudezInstall for Claude.r   z--codexzInstall for Codex.r   z--cursorzInstall for Cursor.r   z
--opencodezInstall for OpenCode.global_z--globalz-gzJInstall globally (user-level) instead of in the current project directory.rW   z=Install into a custom destination (path to skills directory).z--forcez-Overwrite existing skills in the destination.c                    |rM| s|s|s|s|r!t        d       t        j                  d      t        ||      }t        dt         d|        y|rt
        nt        }t        ||      }	t        dt         d|	        |rt        nt        }
g }| r|j                  |
d          |r|j                  |
d	          |r|j                  |
d
          |r|j                  |
d          |D ]  }t        ||	|      }t        d|         y)a0  Download a skill and install it for an AI assistant.

    Default location is in the current directory (.agents/skills) or user-level (~/.agents/skills).
    If custom agents are specified (e.g. --claude --codex --cursor --opencode, etc), the skill will be symlinked to the agent's skills directory.
    zT--dest cannot be combined with --claude, --codex, --cursor, --opencode, or --global.r	   )codezInstalled 'z' to Nz' to central location: r   r   r   r   zCreated symlink: )rc   typerExitrX   rU   CENTRAL_GLOBALCENTRAL_LOCALGLOBAL_TARGETSLOCAL_TARGETSr   r`   )r   r   r   r   rh   rW   rB   
skill_destcentral_pathrZ   targets_dictagent_targetsagent_targetr_   s                 r   
skills_addrv      s   R UfGhi**!$$ u-
,-U:,?@ &->-L$\59	K())@AS@T
UV &->-L "M\(34\'23\(34\*56% /#L2DeL	!)-./r    )r   N)FFFFFNF)#__doc__r]   rH   pathlibr   typingr   r   rk   clickr   r   
typer.mainr   
_cli_utilsr
   rU   r,   r5   rn   rm   ro   rp   
skills_clistrr   r@   boolrK   rX   r`   commandre   Optionrv   rd   r    r   <module>r      s  4 
   &    " %    %&() #$%&%&01	 /"#$#$'(	  BC
3 2 2j	4 	 	 	D  $ 	d 	 	T 	VZ 	 I 
 	   UZQVTYZ_ 	 	 	3;/dLELL:OPPQ;/T<5<<	8LMMN;/ dLELL:OPPQ;/ lell<>UVVW	;/
 ]	
	;/ P	
	;/& @	
	';/4 
5;/;/r    