
    "j@                        U d Z ddlZddlZddlmZ ddlmZ ddlZddlm	Z	m
Z
mZ ddlmZ ddlmZ dd	lmZ dd
lmZ dZdZde dZdZ ed          Z ed          Z ed          Z ed          Zh dZdhZdddZee e f         e!d<    ed          Z"de	de fdZ#ded e
d!e$e          de$e%e$e          e	f                  fd"Z&de	fd#Z'dd$de	d%e(e          dz  de$e          fd&Z)d'e$e%e$e          e	f                  dee e%e e f         f         fd(Z*d!e$e          de	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-defd0Z/d1ed/e d2ed,e-def
d3Z0d4e-d5e-d6edz  de$e         fd7Z1e"2                    d8          dQd9            Z3e"2                    d:g d;<          ed=d=dd=fd>ee  ej4        d?d=@          f         d4ee- ej5        dAdB          f         d5ee- ej5        dCdDdE          f         d6eedz   ej5        dF          f         d,ee- ej5        dGdH          f         ddfdI            Z6e"2                    dJg dK<          	 	 	 	 dRd>ee dz   ej4        dLd=@          f         d4ee- ej5        dAdM          f         d5ee- ej5        dCdDdN          f         d6eedz   ej5        dO          f         ddf
dP            Z7dS )Sa  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 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)CommandContextGroup)get_command)CLIError   )_skills)typer_factoryzhf-clia  Hugging Face Hub CLI (`hf`) for downloading, uploading, and managing models, datasets, spaces, buckets, repos, papers, jobs, and more on the Hugging Face Hub. Use when: handling authentication; managing local cache; managing Hugging Face Buckets; running or scheduling jobs on Hugging Face infrastructure; managing Hugging Face repos; discussions and pull requests; browsing models, datasets and spaces; reading, searching, or browsing academic papers; managing collections; querying datasets; configuring spaces; setting up webhooks; or deploying and managing HF Inference Endpoints. Make sure to use this skill whenever the user mentions 'hf', 'huggingface', 'Hugging Face', 'huggingface-cli', or 'hugging face cli', or wants to do anything related to the Hugging Face ecosystem and to AI and ML in general. Also use for cloud storage needs like training checkpoints, data pipelines, or agent traces. Use even if the user doesn't explicitly ask for a CLI command. Replaces the deprecated `huggingface-cli`.z---
name: hf-cli
description: "a?  "
---

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`.
u  
## Mounting repos as local filesystems

To mount Hub repositories or buckets as local filesystems — no download, no copy, no waiting — use `hf-mount`. Files are fetched on demand. GitHub: https://github.com/huggingface/hf-mount

Install: `curl -fsSL https://raw.githubusercontent.com/huggingface/hf-mount/main/install.sh | sh`

Some command examples:
- `hf-mount start repo openai-community/gpt2 /tmp/gpt2` — mount a repo (read-only)
- `hf-mount start --hf-token $HF_TOKEN bucket myuser/my-bucket /tmp/data` — mount a bucket (read-write)
- `hf-mount status` / `hf-mount stop /tmp/data` — list or unmount

## Tips

- Use `hf <command> --help` for full options, descriptions, usage, and real-world examples
- Authenticate with `HF_TOKEN` env var (recommended) or with `--token`
z.agents/skillsz~/.agents/skillsz.claude/skillsz~/.claude/skills>   --type--quiet
--revision--token--formatr   zKOutput format: `--format json` (or `--json`) or `--format table` (default).zXUse a User Access Token. Prefer setting `HF_TOKEN` env var instead of passing `--token`.)r   r   _COMMON_FLAG_HELP_OVERRIDESz Manage skills for AI assistants.)helpcmdreturnc           	         g }| j         D ]}|j        r|j        dk    r|j        r|j                            d          r7t          d t          |dg           D             d          }|Et          |j        dd                                          pd}|	                    | d	|            |j        r|	                    |j                   d	
                    |          S )
zMFormat required params: positional as UPPER_CASE, options as ``--name TYPE``.--help_c              3   D   K   | ]}|                     d           |V  dS )--N)
startswith).0os     d/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/huggingface_hub/cli/skills.py	<genexpr>z!_format_params.<locals>.<genexpr>   s3      RRq||D?Q?QR!RRRRRR    optsNname VALUE )paramsrequiredhuman_readable_namer"   r   nextgetattrtypeupperappendjoin)r   partsp	long_name	type_names        r   _format_paramsr3   |   s    EZ 
0 
0z 	Q2h>>6 	af'',, 	RRWQ%;%;RRRTXYY	 3399;;FwILLI33	334444V 	0LL.///88E??r    groupctx
path_partsc                 X   g }t          | ||d                   }|                     |          D ]y}|                     ||          }||j        r"g ||}t	          |t
                    r%|                    t          |||                     b|                    ||f           z|S )zXRecursively walk a Click Group, returning (full_path_parts, cmd) for every leaf command.)parent	info_name)	r   list_commandsr   hidden
isinstancer   extend_collect_leaf_commandsr-   )r4   r5   r6   leavessub_ctxr"   r   
child_paths           r   r?   r?      s    .0FeC:b>BBBG##G,, - -..;#*;(z(4(
c5!! 	-MM0gzJJKKKKMM:s+,,,,Mr    c              #   ,  K   | j         D ]}|j        s|j        dk    r|j        r|j                            d          r7d}d}t          |dg           D ]3}|                    d          r|p|}|                    d          r|}4|r|||fV  dS )zKYield (param, long_name, short_name) for each optional, non-internal param.r   r   Nr!   r   -)r&   r'   r(   r"   r   r*   )r   r0   r1   
short_nameopts        r   _iter_optional_paramsrG      s      Z + +: 	.(::6 	af'',, 		
1fb)) 	! 	!C~~d## !%,		$$ ! 
 	+Y
****+ +r    excluderI   c                   g }t          |           D ]x\  }}}|r||v rt          |dd          r|                    |           4t          |j        dd                                          pd}|                    | d|            y|S )zReturn long-form flag names (--foo) for optional, non-internal params.

    Boolean flags are bare (``--dry-run``).  Value-taking options include a
    type hint (``--include TEXT``, ``--max-workers INTEGER``).
    is_flagFr"   r#   r$   r%   )rG   r*   r-   r+   r,   )r   rI   flagsr0   r1   _shortr2   s          r   _get_flag_namesrN      s     E 5c : : 5 59f 	yG++1i'' 	5LL####3399;;FwILLI33	334444Lr    leaf_commandsc                 &   i }| D ]\  }}t          |          D ]v\  }}}|t          vr||vs|r`d||         d         vrP|r| d| n|}t          |dd          pd                    d          d                                         }||f||<   w|S )z0Collect display info for flags in the allowlist.z / r   r   Nr#   
)rG   _COMMON_FLAG_ALLOWLISTr*   splitstrip)	rO   	flag_info_pathr   r0   r1   rE   display	help_texts	            r   _compute_common_flagsrY      s     -/I# < <
s(=c(B(B 	< 	<$Ay* 666	))j)U)T]J^_`Ja=a=a;ETZ77I7779$Q55;BB4HHKQQSS	(/';	)$	< r    c                 D   |j         pd                    d          d                                         }t          |          }dg| |r|gng z   }dd                    |           d| }t          |t                    }|r|d	d                    |           d
z  }|S )z6Render a single leaf command as a markdown list entry.r#   rQ   r   hf- `r%      ` — rH   z `[z]`)r   rS   rT   r3   r.   rN   _INLINE_FLAG_EXCLUDE)r6   r   rX   r&   r/   entryrL   s          r   _render_leafr`      s    R&&t,,Q/5577IC  FJv#=F882>E4#((5//4444EC)=>>>E +*sxx****Lr    c                  @   ddl m}  ddlm} t	          |          }t          |d          }g }g }t          |                    |                    D ]g}|                    ||          }||j        r"t          |t                    r|                    ||f           O|                    |g|f           hg }t          |          }	|D ]C\  }}
t          |
||g          }|                    ||f           |	                    |           Dt          |	          }t          t                                                     }|                    d           |                    d|  d           |                    d           |                    d	           |                    d           |D ](\  }}|                    t%          ||                     )t'          |          }|D ]\  }}||         }|j        pd                    d
          d                                         }|                    d           |                    d| d|            |                    d           |D ](\  }}|                    t%          ||                     )|r|                    d           |                    d           |                    d           t          |                                          D ]Z\  }\  }}t0                              ||          }|r|                    d| d|            A|                    d| d           [|                    t4                                                     d
                    |          S )Nr   )__version__)appr[   )r:   r#   z!Generated with `huggingface_hub vz-`. Run `hf skills add --force` to regenerate.z## CommandsrQ   z### `hf r]   z## Common optionsr\   `)huggingface_hubrb   huggingface_hub.cli.hfrc   r   r   sortedr;   r<   r=   r   r-   listr?   r>   rY   _SKILL_YAML_PREFIX
splitlinesr`   dictr   rS   rT   itemsr   get_SKILL_TIPSr.   )rb   rc   	click_appr5   	top_levelgroupsr"   r   group_leavesall_leaf_commandsr4   r@   common_flagslinesr6   groups_dict	group_cmdrX   r1   rW   s                       r   build_skill_mdrx      s   ++++++******C  I
)t
,
,
,C13I&(Fy..s3344 , ,##C..;#*;c5!! 	,MM4+&&&&tfc]++++FHL9=i ) )e'sTF;;T6N+++  ((((():;;L .99;;<<E	LL	LLo[oooppp	LL	LL	LL$ 4 4
C\*c223333v,,K$ 8 8f%	^)r0066q9??AA	R777I77888R% 	8 	8OJLLj#667777	8  	/R()))R/5l6H6H6J6J/K/K 	/ 	/+I+377	9MMI /=7==)==>>>>-7---....	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_symlinkr	   is_dirshutilrmtreeunlink)ry   rz   s     r   _remove_existingr   !  s    KKMM T__..  ^\$\\\]]]{{}} T__.. dr    
skills_dir
skill_namec                     t          j        |          }	 t          j        || |          S # t          $ r}t	          | d          |d}~ww xY w)zPInstall a marketplace skill into a skills directory. Returns the installed path.)rz   z"
Re-run with --force to overwrite.N)r   get_marketplace_skillinstall_marketplace_skillFileExistsErrorr	   )r   r   rz   skillexcs        r   _install_tor   -  sl    )*55EM0
%PPPP M M M#BBBCCLMs   - 
AA

Aagent_skills_dircentral_skill_pathc                    |                                                                  } |                     dd           | |z  }t          ||           |                    t
          j                            ||                      |S )zMCreate a relative symlink from agent directory to the central skill location.T)parentsexist_ok)
expanduserresolvemkdirr   
symlink_toosry   relpath)r   r   r   rz   	link_paths        r   _create_symlinkr   6  s    '2244<<>>4$777 :-IY&&&);=MNNOOOr    claudeglobal_destc                     |:| s|rt          d          |                                                                gS |rt          nt          g}| r#|                    |rt          nt                     d |D             S )N4--dest cannot be combined with --claude or --global.c                 Z    g | ](}|                                                                 )S  )r   r   )r   roots     r   
<listcomp>z)_resolve_update_roots.<locals>.<listcomp>P  s.    :::DDOO%%'':::r    )r	   r   r   CENTRAL_GLOBALCENTRAL_LOCALr-   CLAUDE_GLOBALCLAUDE_LOCAL)r   r   r   rootss       r   _resolve_update_rootsr   B  s      	SW 	SQRRR!!))++,,+2EFE Ag?]]<@@@::E::::r    previewc                  <    t          t                                 dS )z0Print the generated `hf-cli` SKILL.md to stdout.N)printrx   r   r    r   skills_previewr   S  s     
.

r    add)zhf skills addz3hf skills add huggingface-gradio --dest=~/my-skillszhf skills add --globalzhf skills add --claudez2hf skills add huggingface-gradio --claude --global)examplesFr"   zMarketplace skill name.)r   show_defaultz--claudezInstall for Claude.z--globalz-gzJInstall globally (user-level) instead of in the current project directory.z=Install into a custom destination (path to skills directory).z--forcez-Overwrite existing skills in the destination.c                 \   |;|s|rt          d          t          || |          }t          d|  d|            dS |rt          nt          }t          || |          }t          d|  d|            |r6|rt
          nt          }t          || ||          }	t          d|	            dS dS )a  Download a Hugging Face skill and install it for an AI assistant.

    Default location is in the current directory (.agents/skills) or user-level (~/.agents/skills).
    If `--claude` is specified, the skill is also symlinked into Claude's legacy skills directory.
    Nr   zInstalled 'z' to z' to central location: zCreated symlink: )r	   r   r   r   r   r   r   r   )
r"   r   r   r   rz   
skill_destcentral_pathr   agent_targetr   s
             r   
skills_addr   Y  s    V  	SW 	SQRRR tU33
3D33z33444 &-?>>-L$\4??	
I
I
I5G
I
IJJJ /(/A}}\#L$8JERR	-)--...../ /r    upgrade)zhf skills upgradezhf skills upgrade hf-cliz7hf skills upgrade huggingface-gradio --dest=~/my-skillszhf skills upgrade --claudez)Optional installed skill name to upgrade.z$Upgrade skills installed for Claude.z=Use global skills directories instead of the current project.z,Upgrade skills in a custom skills directory.c                     t          |||          }t          j        ||           }|st          d           dS |D ]6}|j        rd|j         dnd}t          |j         d|j         |            7dS )	z2Upgrade installed Hugging Face marketplace skills.)r   r   r   )selectorzNo installed skills found.Nz ()r#   z: )r   r   apply_updatesr   detailr"   status)r"   r   r   r   r   resultsresultr   s           r   skills_upgrader     s    > "tLLLE#ED999G *+++ 9 9*0-?&fm&&&&R777v7788889 9r    )r   N)NFFN)8__doc__r   r   pathlibr   typingr   typerclickr   r   r   
typer.mainr   huggingface_hub.errorsr	   r#   r   
_cli_utilsr   DEFAULT_SKILL_ID_SKILL_DESCRIPTIONri   rn   r   r   r   r   rR   r^   r   rk   str__annotations__
skills_clir3   rh   tupler?   rG   setrN   rY   r`   rx   boolr   r   r   r   commandr   ArgumentOptionr   r   r   r    r   <module>r      s    ( 
			               ) ) ) ) ) ) ) ) ) ) " " " " " " + + + + + +       % % % % % %  2 0 "   $ %&&())t$%%'(( TSS !{  ^i/ / T#s(^   
 ] BCCC
 C    "% g 49 QUV[\`ad\egn\nVoQp     +w + + + +$ AE    c#ho c    $d3i012	#uS#X
   &	T#Y 	W 	 	 	 	 	> > > > >B	4 	 	 	 	 	 	MD Mc M$ M4 M M M M	d 	 	QU 	^b 	gk 	 	 	 	;; ; +	;
 
$Z; ; ; ;" I   
 	    	 	 	TY 	 	 	50/ 0/
5EJJJ	L0/
 dLEL:OPPPPQ0/ ]	
 	
 	
	0/ tP	
 	
 	
	0/( @	
 	
 	
	)0/6 
70/ 0/ 0/	 	0/f       	ej 	 	'9 9
d
GV[\\\	^9
 dLEL:`aaaab9 P	
 	
 	
	9 t?	
 	
 	
	9( 
)9 9 9 9 9 9r    