
    qi$                     b   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jC                  d%      d?d&       Z"ejC                  d'g d()      	 	 	 	 	 	 	 d@d*ee ejF                  d+d,      f   d-ee ejF                  d.d/      f   d0ee ejF                  d1d2      f   d3ee ejF                  d4d5      f   d6ee ejF                  d7d8d9      f   d:eee    ejF                  d;      f   dee ejF                  d<d=      f   ddfd>       Z$y)AaK  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 ]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      L/opt/pipecat/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_mdrA   g   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)rB   rC   s     r   _remove_existingrL      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_IDrL   
write_textrA   )rM   rC   dests      r   _install_torY      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.TrO   )	rS   rT   rU   rV   rL   
symlink_toosrB   relpath)rZ   r[   rC   	link_paths       r   _create_symlinkra      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)printrA    r!   r   skills_previewrf      s     
.
r!   add)zhf skills add --claudezhf skills add --cursorzhf skills add --claude --globalz)hf skills add --codex --opencode --cursor)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.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      |rM| s|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|	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.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	   rd   typerExitrY   rV   GLOBAL_TARGETSLOCAL_TARGETSr   CENTRAL_GLOBALCENTRAL_LOCALra   )r   r   r   r   ri   rX   rC   
skill_desttargets_dictagent_targetscentral_pathr[   agent_targetr`   s                 r   
skills_addrw      s,   J evTcddUfGhi**!$$ u-
,-U:,?@%,>-L "M\(34\'23\(34\*56%,>-L$\59	K())@AS@T
UV% /#L2DeL	!)-./r!   )r   N)FFFFFNF)%__doc__r^   rI   pathlibr   typingr   r   rl   clickr   r   
typer.mainr   huggingface_hub.errorsr	   
_cli_utilsr   rV   r-   r6   rq   rp   rn   ro   
skills_clistrr    rA   boolrL   rY   ra   commandrf   Optionrw   re   r!   r   <module>r      s  , 
   &    " + %    %&() #$%&%&01	 /"#$#$'(	  BC
3 2 2j	4 	 	 	D  $ 	d 	 	T 	VZ 	 I 
 	   UZQVTYZ_ 	 	 	38/dLELL:OPPQ8/T<5<<	8LMMN8/ dLELL:OPPQ8/ lell<>UVVW	8/
 ]	
	8/ P	
	8/& @	
	'8/4 
58/8/r!   