o
    Zix#                     @   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
startswithZhuman_readable_nameappendjoin)cmdpartsp r   Q/home/app/Keep/.python/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__)appZhf)	info_name z!Generated with `huggingface_hub vz-`. Run `hf skills add --force` to regenerate.z## Commands
z- `r   u   ` — z### `hf )parentr!   )Zhuggingface_hubr   Zhuggingface_hub.cli.hfr    r   r   list_SKILL_YAML_PREFIX
splitlinesr   sortedZlist_commandsZhidden
isinstancer   r   splitstripr   r   extend_SKILL_TIPS)r   r    Z	click_appctxlinesZ	top_levelgroupsr   r   	help_textr   r   Zsub_ctxZsub_nameZsub_cmdZsub_helpr   r   r   build_skill_mdg   sR   






	
r2   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)r3   r4   r   r   r   _remove_existing   s   r<   
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_IDr<   
write_textr2   )r=   r4   destr   r   r   _install_to   s   
rH   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>   )	rB   rC   rD   rE   r<   
symlink_toosr3   relpath)rI   rJ   r4   	link_pathr   r   r   _create_symlink   s   
rO   add)zhf skills add --claudezhf skills add --cursorzhf skills add --claude --globalz)hf skills add --codex --opencode --cursor)Z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.rG   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typerZExitrH   rE   GLOBAL_TARGETSLOCAL_TARGETSr   CENTRAL_GLOBALCENTRAL_LOCALrO   )r   r   r   r   rQ   rG   r4   Z
skill_destZtargets_dictZagent_targetsZcentral_pathrJ   Zagent_targetrN   r   r   r   
skills_add   s4   %

rY   )FFFFFNF)$__doc__rL   r9   pathlibr   typingr   r   rT   Zclickr   r   Z
typer.mainr   Zhuggingface_hub.errorsr   Z
_cli_utilsr
   rE   r&   r-   rX   rW   rU   rV   Z
skills_clistrr   r2   boolr<   rH   rO   commandOptionrY   r   r   r   r   <module>   s   	
	5
