
    Zix#                        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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!                    d%g d&'          	 	 	 	 	 	 	 d>d)ee ej"        d*d+          f         d,ee ej"        d-d.          f         d/ee ej"        d0d1          f         d2ee ej"        d3d4          f         d5ee ej"        d6d7d8          f         d9eee          ej"        d:          f         dee ej"        d;d<          f         ddfd=            Z#dS )?aK  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 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)CLIError   )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 ]H}|j        r?|j                            d          s%|j        dk    r|                    |j                   Id                    |          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      U/root/projects/butler/venv/lib/python3.11/site-packages/huggingface_hub/cli/skills.py_format_paramsr    ^   sm    EZ 0 0: 	0af//44 	09NRZ9Z9ZLL.///88E??    c                     ddl m}  ddlm} t	          |          }t          |d          }t          t                                                    }|	                    d           |	                    d|  d           |	                    d           |	                    d	           |	                    d           g }g }t          |                    |                    D ]f}|                    ||          }||j        r"t          |t                    r|	                    ||f           O|	                    ||f           g|D ]\  }}|j        pd                    d
          d                                         }	t%          |          }
d|g|
r|
gng z   }|	                    dd                    |           d|	            |D ]G\  }}|j        pd                    d
          d                                         }	|	                    d           |	                    d| d|	            |	                    d           t          |||          }|                    |          D ]}|                    ||          }||j        r"|j        pd                    d
          d                                         }t%          |          }
d||g|
r|
gng z   }|	                    dd                    |           d|            I|                    t*                                                     d
                    |          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_mdrA   g   s   ++++++******C  I
)t
,
,
,C .99;;<<E	LL	LLo[oooppp	LL	LL	LLIFy..s3344 * *##C..;#*;c5!! 	*MM4+&&&&dC[)))) ? ?	cX^**400399;;	$$tF :;=388E??==)==>>>> B B	cX^**400399;;	R777I77888R#cT:::))'22 	B 	BHoogx88G'.*11$77:@@BBH#G,,F4*&.HvhhbIELL@sxx@@h@@AAAA	B 
LL''))***99Ur!   pathforcec                 (   |                                  s|                                 sdS |st          d|  d          |                                 r*|                                 st	          j        |            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)rB   rC   s     r   _remove_existingrL      s    KKMM T__..  `^D^^^___{{}} T__.. dr!   
skills_dirc                 (   |                                                                  } |                     dd           | t          z  }t	          ||           |                                 |dz                      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_IDrL   
write_textrA   )rM   rC   dests      r   _install_torY      s    &&((0022JTD111((DT5!!!JJLLL	J"">#3#3g"FFFKr!   agent_skills_dircentral_skill_pathc                    |                                                                  } |                     dd           | t          z  }t	          ||           |                    t          j                            ||                      |S )zMCreate a relative symlink from agent directory to the central skill location.TrO   )	rS   rT   rU   rV   rL   
symlink_toosrB   relpath)rZ   r[   rC   	link_paths       r   _create_symlinkra      s    '2244<<>>4$777 #33IY&&&);=MNNOOOr!   add)zhf skills add --claudezhf skills add --cursorzhf skills add --claude --globalz)hf skills add --codex --opencode --cursor)examplesFr   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.rX   z=Install into a custom destination (path to skills directory).z--forcez-Overwrite existing skills in the destination.c                    | s|s|s|s|st          d          |rZ| s|s|s|s|r$t          d           t          j        d          t	          ||          }t          dt
           d|            dS |rt          nt          }g }	| r|	                    |d                    |r|	                    |d	                    |r|	                    |d
                    |r|	                    |d                    |rt          nt          }
t	          |
|          }t          dt
           d|            |	D ]%}t          |||          }t          d|            &dS )z4Download a skill and install it for an AI assistant.zJPick a destination via --claude, --codex, --cursor, --opencode, or --dest.zT--dest cannot be combined with --claude, --codex, --cursor, --opencode, or --global.r
   )codezInstalled 'z' to Nr   r   r   r   z' to central location: zCreated symlink: )r	   printtyperExitrY   rV   GLOBAL_TARGETSLOCAL_TARGETSr   CENTRAL_GLOBALCENTRAL_LOCALra   )r   r   r   r   rd   rX   rC   
skill_desttargets_dictagent_targetscentral_pathr[   agent_targetr`   s                 r   
skills_addrs      s   J  ee ev e eT ecddd  	%U 	%f 	% 	%G 	%hiii*!$$$$ u--
?,??:??@@@%,?>>-L "M 5\(3444 4\'2333 5\(3444 7\*5666%,?>>-L$\599	
U(
U
UAS
U
UVVV% / /#L2DeLL	-)--..../ /r!   )FFFFFNF)$__doc__r^   rI   pathlibr   typingr   r   rh   clickr   r   
typer.mainr   huggingface_hub.errorsr	   
_cli_utilsr   rV   r-   r6   rm   rl   rj   rk   
skills_clistrr    rA   boolrL   rY   ra   commandOptionrs    r!   r   <module>r      s   , 
			        & & & & & & & &                  " " " " " " + + + + + + % % % % % %    %&&()) T#$$d%&&d%&&011	  T/""d#$$d#$$'((	  ] BCCC
3    2 2 2 2 2j	4 	 	 	 	 	 	D  $    	d 	 	T 	VZ 	 	 	 	 	      UZQVTYZ_ 	 	 	38/ 8/dLEL:OPPPPQ8/T<5<	8LMMMMN8/ dLEL:OPPPPQ8/ lel<>UVVVVW	8/
 ]	
 	
 	
	8/ P	
 	
 	
	8/& @	
 	
 	
	'8/4 
58/ 8/ 8/ 8/ 8/ 8/r!   