o
    eix#                     @   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
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dZdefddZ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,	-	-	-	-	-		-dDd.eeej"d/d0df d1eeej"d2d3df d4eeej"d5d6df d7eeej"d8d9df d:eeej"d;d<d=df d>eee ej"d?df d eeej"d@dAdf ddfdBdCZ#dS )EaK  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                 C   sB   g }| j D ]}|jr|jds|jdkr||j qd|S )z?Format required params for a command as uppercase placeholders._z--help )paramsrequiredname
startswithhuman_readable_nameappendjoin)cmdpartsp r   X/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/huggingface_hub/cli/skills.py_format_params^   s   

r   c                  C   s(  ddl m}  ddlm} t|}t|dd}tt }|	d |	d|  d |	d |	d	 |	d g }g }t
||D ]$}|||}|d u sS|jrTqDt|tra|	||f qD|	||f qD|D ]-\}}|jpsdd
d  }	t|}
d|g|
r|
gng  }|	dd| d|	  qk|D ]l\}}|jpdd
d  }	|	d |	d| d|	  |	d t|||d}||D ]:}|||}|d u s|jrq|jpdd
d  }t|}
d||g|
r|
gng  }|	dd| d|  qq|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_helpr   r   r   build_skill_mdg   sR   






	
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_existing   s   rH   
skills_dirc                 C   sL   |    } | jddd | t }t|| |  |d jt 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)
expanduserresolvemkdirDEFAULT_SKILL_IDrH   
write_textr>   )rI   r@   destr   r   r   _install_to   s   
rT   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.TrJ   )	rN   rO   rP   rQ   rH   
symlink_toosr?   relpath)rU   rV   r@   	link_pathr   r   r   _create_symlink   s   
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.rS   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|st d|r5| s|s|s|s|r$td tjddt||}tdt d|  dS |r9tnt}g }	| rF|	|d  |rO|	|d	  |rX|	|d
  |ra|	|d  |ret	nt
}
t|
|}tdt d|  |	D ]}t|||}td|  qxd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ExitrT   rQ   GLOBAL_TARGETSLOCAL_TARGETSr   CENTRAL_GLOBALCENTRAL_LOCALr[   )r   r   r   r   r^   rS   r@   
skill_desttargets_dictagent_targetscentral_pathrV   agent_targetrZ   r   r   r   
skills_add   s4   %

rl   )FFFFFNF)$__doc__rX   rE   pathlibr   typingr   r   ra   clickr   r   
typer.mainr   huggingface_hub.errorsr   
_cli_utilsr
   rQ   r*   r3   rf   re   rc   rd   
skills_clistrr   r>   boolrH   rT   r[   commandOptionrl   r   r   r   r   <module>   s   	
	5
