+
    iL              
      2
  a  0 t $ R t^ RIHt ^ RIt^ RIt^ RIHtHt ^ RI	H
t
 ^ RIHt ^ RIHtHt ^ RIHtHt ]
! RR	7       ! R
 R4      4       t. ]! RRRRR7      N]! RRRRR7      N]! RRRRR7      N]! RRRRR7      N]! RRR4      N]! RRR4      N]! RRRRR7      N]! RR RRRR!7      N]! R"R#R4      N]! R$R%RR&R7      N]! R'R(R4      N]! R)R*RRR+R,7      N]! R-R.RRR/7      N]! R0R1RRR2R!7      N]! R3R4RR5R7      N]! R6R7RRR2R!7      N]! R8R9RRR/7      N]! R:R;R<4      N]! R=R>RRRR?7      N]! R@RARRR7      N]! RBRCRDRR7      N]! RERFRDRGR7      N]! RHRIRD4      N]! RJRKRDRRLRRM7      N]! RNRORDRR7      N]! RPRQRDRRRR7      N]! RSRTRDRRURV7      N]! RWRXRD4      N]! RYRZRDR[RR\7      N]! R]R^RDRRR_7      N]! R`RaRDRbRR\7      N]! RcRdReRfRRg7      N]! RhRiReRR7      N]! RjRkReRRRl7      N]! RmRnReRRoRRM7      N]! RpRqReRR7      N]! RrRsReRRtRRM7      N]! RuRvReRR7      N]! RwRxR<RRyR,7      N]! RzR{R<4      N]! R|R}R<4      N]! R~RR<RR7      N]! RRR<RRRR7      N]! RRR<RR7      N]! RRR<RR/7      N]! RRRRRRR7      NtR]R&   R R lt]! 4       tR]R&   R R ltR R ltR R ltR R lt/ tR]R&   ] Fd  t]P<                  '       d   K  ]! ]4      ]R]P>                   2&   ]P@                   F%  t!]PD                   R]P>                   R2]R]! 2&   K'  	  Kf  	  / t#R]R&   ] F~  t]P<                  '       d   K  ]#PI                  ]PJ                  / 4      t&]R]P>                   2,          ]&R]P>                   2&   ]P@                   F  t!]R]! 2,          ]&R]! 2&   K  	  K  	  / t'R]R&   ] F9  t]PP                  '       g   K  ])! ]PP                  4      ]'R]P>                   2&   K;  	  ]PT                  ! R4      t+] Fu  tR]P>                   2t,],]'9   g   ]PZ                  '       g   K-  ]+P]                  ]PZ                  4      t/]/'       g   KR  ]/Pa                  ^ 4      Pc                  R4      ]'],&   Kw  	  ]2! R ] 4       4      s3R]R&   R R lt4RR R llt5R R lt6R R lt7^ t8 ]8t9]PT                  ! R4      t:]PT                  ! R4      t;R R lt<R R lt=]=t>RR R llt?RR R llt@R R ltAR R ltB ! R R]4      tC ! R R]4      tDR R ltER# )a  Slash command definitions and autocomplete for the Hermes CLI.

Central registry for all slash commands. Every consumer -- CLI help, gateway
dispatch, Telegram BotCommands, Slack subcommand mapping, autocomplete --
derives its data from ``COMMAND_REGISTRY``.

To add a command: add a ``CommandDef`` entry to ``COMMAND_REGISTRY``.
To add an alias: set ``aliases=("short",)`` on the existing ``CommandDef``.
)annotationsN)CallableMapping)	dataclass)Any)AutoSuggest
Suggestion)	Completer
CompletionT)frozenc                      ] tR t^t$ RtR]R&   R]R&   R]R&   RtR]R&   RtR]R	&   RtR]R
&   Rt	R]R&   Rt
R]R&   RtR]R&   RtR# )
CommandDefz%Definition of a single slash command.strnamedescriptioncategoryztuple[str, ...]aliases 	args_hintsubcommandsFboolcli_onlygateway_onlyN
str | Nonegateway_config_gate )__name__
__module____qualname____firstlineno____doc____annotations__r   r   r   r   r   r   __static_attributes__r       0/home/ubuntu/hermes-agent/hermes_cli/commands.pyr   r      sR    /
IM!G_!Is#%K%HdL$&**r#   r   newz0Start a new session (fresh session ID + history)Session)r   clearz$Clear screen and start a new session)r   historyzShow conversation historysavezSave the current conversationretryz(Retry the last message (resend to agent)undoz'Remove the last user/assistant exchangetitlez#Set a title for the current sessionz[name])r   branchz5Branch the current session (explore a different path))r   r   compressz&Manually compress conversation contextrollbackz&List or restore filesystem checkpointsz[number]stopz%Kill all running background processesapprovez#Approve a pending dangerous commandz[session|always])r   r   denyz Deny a pending dangerous command)r   
backgroundzRun a prompt in the backgroundz<prompt>btwzGEphemeral side question using session context (no tools, not persisted)z
<question>queuez4Queue a prompt for the next turn (doesn't interrupt)statuszShow session infoprofilez+Show active profile name and home directoryInfosethomez!Set this chat as the home channel)r   r   resumez!Resume a previously-named sessionconfigzShow current configurationConfigurationmodelzSwitch model for this sessionz[model] [--global]providerz-Show available providers and current providerpromptzView/set custom system promptz[text])r   r   r   personalityzSet a predefined personality	statusbarz#Toggle the context/model status bar)r   r   verbosez9Cycle tool progress display: off -> new -> all -> verbosezdisplay.tool_progress_command)r   r   yoloz7Toggle YOLO mode (skip all dangerous command approvals)	reasoningz#Manage reasoning effort and displayz[level|show|hide])r   r   skinz%Show or change the display skin/theme)r   r   voicezToggle voice modez[on|off|tts|status]toolsz4Manage tools: /tools [list|disable|enable] [name...]zTools & Skillsz[list|disable|enable] [name...])r   r   toolsetszList available toolsetsskillsz*Search, install, inspect, or manage skills)r   r   cronzManage scheduled tasksz[subcommand]z
reload-mcpzReload MCP servers from configbrowserz1Connect browser tools to your live Chrome via CDPz[connect|disconnect|status]pluginsz'List installed plugins and their statuscommandsz*Browse all commands and skills (paginated)z[page]helpzShow available commandsusagez(Show token usage for the current sessioninsightsz!Show usage insights and analyticsz[days]	platformsz&Show gateway/messaging platform statuspastez*Check clipboard for an image and attach itupdatez)Update Hermes Agent to the latest versionquitzExit the CLIExitzlist[CommandDef]COMMAND_REGISTRYc                   V ^8  d   QhRR/# )   returndict[str, CommandDef]r   )formats   "r$   __annotate__r\      s      4 r#   c                 n    / p \          F(  pWVP                  &   VP                   F  pWV&   K	  	  K*  	  V # )z+Map every name and alias to its CommandDef.)rV   r   r   )lookupcmdaliass      r$   _build_command_lookupra      s9    $&Fsxx[[E5M !   Mr#   rZ   _COMMAND_LOOKUPc                    V ^8  d   QhRRRR/# )rX   r   r   rY   zCommandDef | Noner   )r[   s   "r$   r\   r\      s     9 9# 9"3 9r#   c                f    \         P                  V P                  4       P                  R4      4      # )zeResolve a command name or alias to its CommandDef.

Accepts names with or without the leading slash.
/)rb   getlowerlstrip)r   s   &r$   resolve_commandri      s&    
 tzz|223788r#   c                    V ^8  d   QhRRRR/# )rX   r_   r   rY   Noner   )r[   s   "r$   r\   r\      s        r#   c                D    \         P                  V 4       \        4        R# )zDAppend a plugin-defined command to the registry and refresh lookups.N)rV   appendrebuild_lookupsr_   s   &r$   register_plugin_commandrp      s    C r#   c                   V ^8  d   QhRR/# )rX   rY   rk   r   )r[   s   "r$   r\   r\      s     + + +r#   c                    \         P                  4        \         P                  \        4       4       \        P                  4        \
         Fo  p V P                  '       d   K  \        V 4      \        RV P                   2&   V P                   F)  pV P                   RV P                   R2\        RV 2&   K+  	  Kq  	  \        P                  4        \
         F  p V P                  '       d   K  \        P                  V P                  / 4      p\        RV P                   2,          VRV P                   2&   V P                   F  p\        RV 2,          VRV 2&   K  	  K  	  \        P                  4        \
         F@  p V P                  '       g   K  \!        V P                  4      \        RV P                   2&   KB  	  \
         F  p RV P                   2pV\        9   g   V P"                  '       g   K1  \$        P'                  V P"                  4      pV'       g   KZ  VP)                  ^ 4      P+                  R4      \        V&   K  	  \-        R \
         4       4      sR# )zRebuild all derived lookup dicts from the current COMMAND_REGISTRY.

Called after plugin commands are registered so they appear in help,
autocomplete, gateway dispatch, Telegram menu, and Slack mapping.
re    (alias for /)|c              3     "   T FM  pVP                   '       d   VP                  '       g   K)  VP                  .VP                  O F  pVx  K	  	  KO  	  R # 5iNr   r   r   r   .0r_   r   s   &  r$   	<genexpr>"rebuild_lookups.<locals>.<genexpr>   sN      '#C|||s66 	 XX,,D 	 - 	#   AA*AN)rb   r'   rS   ra   COMMANDSrV   r   _build_descriptionr   r   r   COMMANDS_BY_CATEGORY
setdefaultr   SUBCOMMANDSr   listr   _PIPE_SUBS_REsearchgroupsplit	frozensetGATEWAY_KNOWN_COMMANDS)r_   r`   catkeyms        r$   rn   rn      s    023NN'9#'>Hq
^$+.??*;=
RS(T1UG% %    &11#,,CC"*Qsxxj>":C!CHH:#+awK#8awK  %	   ???*.s*?K!CHH:'    #((n+S]]]  /1 wwqz//4K   ' '#' r#   c                    V ^8  d   QhRRRR/# )rX   r_   r   rY   r   r   )r[   s   "r$   r\   r\      s      J 3 r#   c                    V P                   '       d*   V P                   RV P                   RV P                    R2# V P                  # )z;Build a CLI-facing description string including usage hint.z
 (usage: / rt   )r   r   r   ro   s   &r$   r   r      s;    
}}}//"*SXXJaaHH??r#   dict[str, str]r~   re   rs   rt   zdict[str, dict[str, str]]r   zdict[str, list[str]]r   z[a-z]+(?:\|[a-z]+)+ru   c              #     "   T FM  pVP                   '       d   VP                  '       g   K)  VP                  .VP                  O F  pVx  K	  	  KO  	  R # 5irw   rx   ry   s   &  r$   r{   r{     sN      3<<<322 	 (CKK( 	 ) 	r}   zfrozenset[str]r   c                   V ^8  d   QhRR/# )rX   rY   set[str]r   )r[   s   "r$   r\   r\     s     " "x "r#   c                 `   \          U u. uF  q P                  '       g   K  V NK  	  pp V'       g   \        4       #  ^ RIp\        P
                  P                  \        P                  ! R\        P
                  P                  R4      4      R4      p\        P
                  P                  V4      '       d;   \        VRR7      ;_uu_ 4       pVP                  V4      ;'       g    / pRRR4       M/ p \        4       pV Fw  pXpVP                  P                  R4       F.  p	\        V\        4      '       d   VP!                  V	4      pK,  Rp M	  V'       g   K\  VP#                  VP$                  4       Ky  	  V# u up i   + '       g   i     L; i  \         d    \        4       u # i ; i)zReturn canonical names of commands whose ``gateway_config_gate`` is truthy.

Reads ``config.yaml`` and walks the dot-separated key path for each
config-gated command.  Returns an empty set on any error so callers
degrade gracefully.
NHERMES_HOMEz	~/.hermeszconfig.yamlzutf-8)encoding.)rV   r   setyamlospathjoingetenv
expanduserexistsopen	safe_load	Exceptionr   
isinstancedictrf   addr   )
cgatedr   config_pathfcfgresultr_   valr   s
             r$   _resolve_config_gatesr     sH    )B(1,A,AQQ(EBuggllIImRWW%7%7%DE
 77>>+&&kG44nnQ'--2 54 C uF**005C#t$$ggcl 6 3JJsxx   M7 C 54  usF   E=E=A:F 7F F(F 1F F	F F F-,F-c               $    V ^8  d   QhRRRRRR/# )rX   r_   r   config_overrideszset[str] | NonerY   r   r   )r[   s   "r$   r\   r\   B  s"      z _ X\ r#   c                    V P                   '       g   R# V P                  '       d    Ve   TM	\        4       pV P                  V9   # R# )ai  Check if *cmd* should appear in gateway surfaces (help, menus, mappings).

Unconditionally available when ``cli_only`` is False.  When ``cli_only``
is True but ``gateway_config_gate`` is set, the command is available only
when the config value is truthy.  Pass *config_overrides* (from
``_resolve_config_gates()``) to avoid re-reading config for every command.
TF)r   r   r   r   )r_   r   	overridess   && r$   _is_gateway_availabler   B  s?     <<<
(8(D$J_Ja	xx9$$r#   c                   V ^8  d   QhRR/# )rX   rY   z	list[str]r   )r[   s   "r$   r\   r\   R  s      I r#   c            	        \        4       p . p\         F  p\        W 4      '       g   K  VP                  '       d   RVP                   2MRp. pVP                   F[  pVP                  RR4      VP                  P                  RR4      8X  d   WRP                  8w  d   KF  VP                  RV R24       K]  	  V'       d   RRP                  V4       R	2MRpVP                  RVP                   V R
VP                   V 24       K  	  V# )z3Generate gateway help text lines from the registry.r   r   -_z`/`z	 (alias: z, rt   z` -- )
r   rV   r   r   r   replacer   rm   r   r   )r   linesr_   argsalias_partsa
alias_notes          r$   gateway_help_linesr   R  s    %'IE$S44&)mmm3==/"!#Ayyc"chh&6&6sC&@@Q((]A3ay)	 
 ?Jy;!7 8:r
r#((D6s.?
|LM   Lr#   c                   V ^8  d   QhRR/# )rX   rY   list[tuple[str, str]]r   )r[   s   "r$   r\   r\   e  s      4 r#   c                     \        4       p . p\         FQ  p\        W 4      '       g   K  \        VP                  4      pV'       g   K5  VP                  W2P                  34       KS  	  V# )zReturn (command_name, description) pairs for Telegram setMyCommands.

Telegram command names cannot contain hyphens, so they are replaced with
underscores.  Aliases are skipped -- Telegram shows one menu entry per
canonical command.
)r   rV   r   _sanitize_telegram_namer   rm   r   )r   r   r_   tg_names       r$   telegram_bot_commandsr   e  sV     &'I$&F$S44)#((37MM7OO45   Mr#   z
[^a-z0-9_]z_{2,}c                    V ^8  d   QhRRRR/# )rX   rawr   rY   r   )r[   s   "r$   r\   r\     s        r#   c                    V P                  4       P                  RR4      p\        P                  RV4      p\        P                  RV4      pVP                  R4      # )u>  Convert a command/skill/plugin name to a valid Telegram command name.

Telegram requires: 1-32 chars, lowercase a-z, digits 0-9, underscores only.
Steps: lowercase → replace hyphens with underscores → strip all other
invalid characters → collapse consecutive underscores → strip leading/
trailing underscores.
r   r   r   )rg   r   _TG_INVALID_CHARSsub_TG_MULTI_UNDERSCOREstrip)r   r   s   & r$   r   r     sN     99;sC(D  T*D##C.D::c?r#   c               $    V ^8  d   QhRRRRRR/# )rX   entriesr   reservedr   rY   r   )r[   s   "r$   r\   r\     s&      " r#   c                :   \        V4      p. pV  F  w  rE\        V4      \        8  dD   VR\         pWb9   d3   VR\        ^,
           p\        ^
4       F  pV V 2pWb9  g   K   M	  KZ  TpWB9   d   Kd  VP	                  V4       VP                  WE34       K  	  V# )a  Enforce 32-char command name limit with collision avoidance.

Both Telegram and Discord cap slash command names at 32 characters.
Names exceeding the limit are truncated.  If truncation creates a duplicate
(against *reserved* names or earlier entries in the same batch), the name is
shortened to 31 chars and a digit ``0``-``9`` is appended to differentiate.
If all 10 digit slots are taken the entry is silently dropped.
N)r   len_CMD_NAME_LIMITranger   rm   )	r   r   usedr   r   desc	candidateprefixdigits	   &&       r$   _clamp_command_namesr     s     ]D$&F
t9&-o.I 223"2YE#)(5' 2I , ' D<tl#! " Mr#   c               0    V ^8  d   QhRRRRRRRRRR	R
R/# )rX   platformr   	max_slotsintreserved_namesr   
desc_limitsanitize_namez'Callable[[str], str] | None'rY   &tuple[list[tuple[str, str, str]], int]r   )r[   s   "r$   r\   r\     sL     l1 l1l1l1 l1 	l1
 1l1 ,l1r#   c           	     "   . p. p ^ RI Hp V! 4       p\        VR/ 4      p	\        V	4       FV  p
V'       d	   V! V
4      MT
pV'       g   K  Rp\	        V4      V8  d   VRV^,
           R,           pVP                  W34       KX  	  \        Wb4      pVP                  R V 4       4       V F  w  rVP                  WR34       K  	  \        4       p ^ RI
Hp V! V R	7      p. p ^ R
IHp ^ RIHp \!        VP#                  4       4      p\!        VR,          P#                  4       4      pV! 4       p\        V4       F  pVV,          pVP%                  RR4      pVP'                  V4      '       g   K7  VP'                  V4      '       d   KP  VP%                  RR4      pVV9   d   Kk  VP)                  R4      pV'       d	   V! V4      MTpV'       g   K  VP%                  RR4      p\	        V4      V8  d   VRV^,
           R,           pVP                  WV34       K  	  V UUUu. uF	  w  rpW3NK  	  ppppV UUUu/ uF
  w  rpW3VbK  	  pppp\        VV4      p\+        ^ V\	        V4      ,
          4      p \+        ^ \	        V4      V ,
          4      p!VRV   F)  w  rVP                  WVP%                  W3R4      34       K+  	  VRV V!3#   \         d     ELWi ; i  \         d     ELi ; i  \         d     Li ; iu upppi u upppi )a  Collect plugin + skill entries for a gateway platform.

Priority order:
  1. Plugin slash commands (take precedence over skills)
  2. Built-in skill commands (fill remaining slots, alphabetical)

Only skills are trimmed when the cap is reached.
Hub-installed skills are excluded.  Per-platform disabled skills are
excluded.

Args:
    platform: Platform identifier for per-platform skill filtering
        (``"telegram"``, ``"discord"``, etc.).
    max_slots: Maximum number of entries to return (remaining slots after
        built-in/core commands).
    reserved_names: Names already taken by built-in commands.  Mutated
        in-place as new names are added.
    desc_limit: Max description length (40 for Telegram, 100 for Discord).
    sanitize_name: Optional name transform applied before clamping, e.g.
        :func:`_sanitize_telegram_name` for Telegram.  May return an
        empty string to signal "skip this entry".

Returns:
    ``(entries, hidden_count)`` where *entries* is a list of
    ``(name, description, cmd_key)`` triples and *hidden_count* is the
    number of skill entries dropped due to the cap.  ``cmd_key`` is the
    original ``/skill-name`` key from :func:`get_skill_commands`.
)get_plugin_manager_plugin_commandszPlugin commandN...c              3  *   "   T F	  w  rVx  K  	  R # 5irw   r   )rz   nr   s   &  r$   r{   1_collect_gateway_skill_entries.<locals>.<genexpr>  s     5!s   r   )get_disabled_skill_names)r   )get_skill_commands)
SKILLS_DIRz.hubskill_md_pathr   re   r   )hermes_cli.pluginsr   getattrsortedr   rm   r   r   rS   r   agent.skill_utilsr   agent.skill_commandsr   tools.skills_toolr   r   resolverf   
startswithrh   max)"r   r   r   r   r   all_entriesplugin_pairsr   pmplugin_cmdscmd_namer   r   r   d_platform_disabledr   skill_triplesr   r   _skills_dir_hub_dir
skill_cmdscmd_keyinfo
skill_path
skill_nameraw_namer   skill_pairskkey_by_pair	remaininghidden_counts"   &&&&&                             r$   _collect_gateway_skill_entriesr
    s   F /1K +-L9!b"4b9{+H.;=*D#D4y:%OZ!^,u4- , (EL555A":&  $'5>5xH 13M;0*,,./
V+4467')
j)Gg&D/26J((55$$X..&"-J//~~c*H.;=*D88M2.D4y:%OZ!^,u4  $g!67# *. *77gaAA6K7,9:MqA619MK:&{NCK Ay3{#334Iq#k*Y67LJY'A+//1&""=>? ( z	"L00s    8  
 8:s\   AK =K K  #B$K2 5K2 >K2 AK2 $L=L
KK K/.K/2L ?L c                    V ^8  d   QhRRRR/# )rX   max_commandsr   rY   z!tuple[list[tuple[str, str]], int]r   )r[   s   "r$   r\   r\   .  s     5 5 57X 5r#   c                   \        \        4       4      pV UUu0 uF  w  r#VkK	  	  ppp\        V4      p\        ^ V \        V4      ,
          4      p\	        RVV^(\
        R7      w  rxVP                  R V 4       4       VRV  V3# u uppi )u  Return Telegram menu commands capped to the Bot API limit.

Priority order (higher priority = never bumped by overflow):
  1. Core CommandDef commands (always included)
  2. Plugin slash commands (take precedence over skills)
  3. Built-in skill commands (fill remaining slots, alphabetical)

Skills are the only tier that gets trimmed when the cap is hit.
User-installed hub skills are excluded — accessible via /skills.
Skills disabled for the ``"telegram"`` platform (via ``hermes skills
config``) are excluded from the menu entirely.

Returns:
    (menu_commands, hidden_count) where hidden_count is the number of
    skill commands omitted due to the cap.
telegram)r   r   r   r   r   c              3  .   "   T F  w  rq1V3x  K  	  R # 5irw   r   )rz   r   r   _ks   &   r$   r{   )telegram_menu_commands.<locals>.<genexpr>L  s     7w81Aws   N)r   r   r   r   r
  r   extend)	r  core_commandsr   r   r   all_commandsremaining_slotsr   r	  s	   &        r$   telegram_menu_commandsr  .  s    " .01M$12MDAaMN2&L!\C,==>O:!%-G 7w77&44 3s   Bc               $    V ^8  d   QhRRRRRR/# )rX   r   r   r   r   rY   r   r   )r[   s   "r$   r\   r\   P  s&       ,r#   c                2    \        RV \        V4      ^dR7      # )u  Return skill entries for Discord slash command registration.

Same priority and filtering logic as :func:`telegram_menu_commands`
(plugins > skills, hub excluded, per-platform disabled excluded), but
adapted for Discord's constraints:

- Hyphens are allowed in names (no ``-`` → ``_`` sanitization)
- Descriptions capped at 100 chars (Discord's per-field max)

Args:
    max_slots: Available command slots (100 minus existing built-in count).
    reserved_names: Names of already-registered built-in commands.

Returns:
    ``(entries, hidden_count)`` where *entries* is a list of
    ``(discord_name, description, cmd_key)`` triples.  ``cmd_key`` is
    the original ``/skill-name`` key needed for the slash handler callback.
discord)r   r   r   r   )r
  r   )r   r   s   &&r$   discord_skill_commandsr  P  s"    , *>*	 r#   c                   V ^8  d   QhRR/# )rX   rY   r   r   )r[   s   "r$   r\   r\   n  s      n r#   c                     \        4       p / p\         FK  p\        W 4      '       g   K  RVP                   2WP                  &   VP                   F
  pRV 2W&   K  	  KM  	  V# )zReturn subcommand -> /command mapping for Slack /hermes handler.

Maps both canonical names and aliases so /hermes bg do stuff works
the same as /hermes background do stuff.
re   )r   rV   r   r   r   )r   mappingr_   r`   s       r$   slack_subcommand_mapr  n  sa     &'I G$S44zN[[E [GN !	   Nr#   c                      ] tR tRtRtRR R lltR R lt]R R	 l4       t]R
 R l4       t	]RR R ll4       t
]R R l4       t]RR R ll4       tR R ltR tRtR# )SlashCommandCompleteri  zJAutocomplete for built-in slash commands, subcommands, and skill commands.Nc                    V ^8  d   QhRRRR/# )rX   skill_commands_providerz1Callable[[], Mapping[str, dict[str, Any]]] | NonerY   rk   r   )r[   s   "r$   r\   "SlashCommandCompleter.__annotate__  s"     @ @!R@ 
@r#   c                	    Wn         R # rw   _skill_commands_provider)selfr"  s   &&r$   __init__SlashCommandCompleter.__init__  s     )@%r#   c                   V ^8  d   QhRR/# )rX   rY   zMapping[str, dict[str, Any]]r   )r[   s   "r$   r\   r#    s      &B r#   c                	~    V P                   f   / #  V P                  4       ;'       g    / #   \         d    / u # i ; irw   )r&  r   )r'  s   &r$   _iter_skill_commands*SlashCommandCompleter._iter_skill_commands  sC    ((0I	00288b8 	I	s   , , <<c               $    V ^8  d   QhRRRRRR/# )rX   r   r   wordrY   r   )r[   s   "r$   r\   r#    s&     @ @3 @c @c @r#   c                    W8X  d   V  R2# T # )a!  Return replacement text for a completion.

When the user has already typed the full command exactly (``/help``),
returning ``help`` would be a no-op and prompt_toolkit suppresses the
menu. Appending a trailing space keeps the dropdown visible and makes
backspacing retrigger it naturally.
r   r   )r   r/  s   &&r$   _completion_text&SlashCommandCompleter._completion_text  s     "*!1(1~?x?r#   c                    V ^8  d   QhRRRR/# rX   textr   rY   r   r   )r[   s   "r$   r\   r#    s        r#   c                    V '       g   R# \        V 4      ^,
          pV^ 8  d   W,          R8w  d   V^,          pK  W^,           R pV'       g   R# VP                  R4      '       g   RV9   d   V# R# )a  Extract the current word if it looks like a file path.

Returns the path-like token under the cursor, or None if the
current word doesn't look like a path.  A word is path-like when
it starts with ``./``, ``../``, ``~/``, ``/``, or contains a
``/`` separator (e.g. ``src/main.py``).
Nr   re   )z./z../~/re   r   r   r5  ir/  s   &  r$   _extract_path_word(SlashCommandCompleter._extract_path_word  sb      IM1fCFAEF|??344tKr#   c                    V ^8  d   QhRRRR/# rX   r/  r   limitr   r   )r[   s   "r$   r\   r#    s     0 0 0C 0r#   c              #    "   \         P                  P                  V 4      pVP                  R4      '       d   TpRpMH\         P                  P	                  V4      ;'       g    Rp\         P                  P                  V4      p \         P                  ! V4      p^ pTP                  4       p\        T4       EFy  pT'       d(   TP                  4       P                  T4      '       g   K3  Ya8  d    R# \         P                  P                  Y84      p	\         P                  P                  T	4      p
T P                  R4      '       dF   R\         P                  P                  T	\         P                  P                  R4      4      ,           pMG\         P                  P                  T 4      '       d   T	pM\         P                  P                  T	4      pT
'       d
   TR,          pT
'       d   RMRpT
'       d   RM
\        T	4      p\!        T\#        T 4      ) Y,           TR7      x  T^,          pEK|  	  R#   \         d     R# i ; i5i)	z8Yield Completion objects for file paths matching *word*.re   r   r   N~r7  dirstart_positiondisplaydisplay_meta)r   r   r   endswithdirnamebasenamelistdirOSErrorrg   r   r   r   isdirrelpathisabs_file_size_labelr
   r   )r/  r?  expanded
search_dirr   r   countprefix_lowerentry	full_pathis_dirdisplay_pathsuffixmetas   &&            r$   _path_completions'SlashCommandCompleter._path_completions  s     77%%d+S!!!JF299cJWW%%h/F	jj,G ||~G_Eekkm66|DD~Z7IWW]]9-F s###bggooiASASTWAX&YYt$$(  "wwy9#"SF"5(8(CD #D	z!	  QJE= %  		sP   A!I$"IH: AI+C	I5)II0I<>I:I	II		Ic                    V ^8  d   QhRRRR/# r4  r   )r[   s   "r$   r\   r#    s      C J r#   c                    V '       g   R# \        V 4      ^,
          pV^ 8  d   W,          R8w  d   V^,          pK  W^,           R pVP                  R4      '       g   R# V# )z=Extract a bare ``@`` token for context reference completions.Nr   @r8  r9  s   &  r$   _extract_context_word+SlashCommandCompleter._extract_context_word  sS     IM1fCFAEF|s##r#   c                    V ^8  d   QhRRRR/# r>  r   )r[   s   "r$   r\   r#    s     i i3 is ir#   c           	   #    "   V P                  4       pRpV F^  w  rEVP                  4       P                  V4      '       g   K,  VP                  4       V8w  g   KC  \        V\        V 4      ) VVR7      x  K`  	  R EF  pV P                  V4      '       g   K  V \        V4      R ;'       g    Rp\        P
                  P                  V4      pVP                  R4      '       d   TRrMH\        P
                  P                  V4      ;'       g    Rp	\        P
                  P                  V4      p
 \        P                  ! V	4      p^ pT
P                  4       p\        T4       F  pT
'       d(   TP                  4       P                  T4      '       g   K2  Y8  d     R# \        P
                  P                  Y4      p\        P
                  P                  T4      p\        P
                  P                  T4      pT'       d   RMRpT'       d   RMRpT'       d   RM
\!        T4      pR	T R
T T 2p\        T\        T 4      ) TT,           TR7      x  T^,          pK  	   R# 	  V R,          pV'       g   RRrM\        P
                  P                  V4      pVP                  R4      '       d   TRrMH\        P
                  P                  V4      ;'       g    Rp	\        P
                  P                  V4      p
 \        P                  ! V	4      p^ pT
P                  4       p\        T4       EF  pT
'       d(   TP                  4       P                  T4      '       g   K3  TP                  R4      '       d   KL  Y8  d    R# \        P
                  P                  Y4      p\        P
                  P                  T4      p\        P
                  P                  T4      pT'       d   RMRpT'       d   RMRpT'       d   RM
\!        T4      pR	T R
T T 2p\        T\        T 4      ) TT,           TR7      x  T^,          pEK  	  R#   \         d      R# i ; i  \         d     R# i ; i5i)zYield Claude Code-style @ context completions.

Bare ``@`` or ``@partial`` shows static references and matching
files/folders.  ``@file:path`` and ``@folder:path`` are handled
by the existing path completion path.
rC  Nr   re   r   folderfilerB  r^  :   NN))z@diffzGit working tree diff)z@stagedzGit staged diff)@file:zAttach a file)@folder:zAttach a folder)z@git:z Git log with diffs (e.g. @git:5))z@url:zFetch web content)rh  ri  )rg   r   r
   r   r   r   r   rG  rH  rI  rJ  rK  r   r   rL  rM  rO  )r/  r?  lowered_STATIC_REFSr   rY  r   	path_partrP  rQ  match_prefixr   rR  rS  rT  rU  rV  rW  rX  kind
completionquerys   &&                    r$   _context_completions*SlashCommandCompleter._context_completions  s     **,
  ,OI ++G449Jg9U $'I:%!%	   , -Fv&& V.55#	77--i8$$S))/7!#!:!A!AcJ#%77#3#3H#=L jj4G +113#G_E#EKKM,D,D\,R,R ~  !#Z ?IWW]]95F#%77??9#=L$*SF'-86D$*50@0KD#$TF!L>&!BJ$"(+D	z %%)	  QJE% -& I -N R'*Bww))%0H  %%+3RLWW__X6==#
!ww//9	jj,G #))+G_EEKKM$<$<\$J$J$$~Z7IWW]]9-F77??95L"SF%86D"5(8(CDTF!L>&:J #D	z!	  QJE) %[  P  		s   <Q5Q59Q5Q5-8Q5&)Q5"Q53Q	AQ5A<Q5Q5AQ5;9Q55)Q5"Q5Q# AQ5&Q5?A;Q5;Q5A	Q5Q Q5Q  Q5#Q2.Q51Q22Q5c                    V ^8  d   QhRRRR/# )rX   sub_textr   	sub_lowerr   )r[   s   "r$   r\   r#  d  s      3 3 r#   c           
   #  t  "   \        4       p ^ RIHpHpHp V! 4        VP                  4        Fl  w  rxVP                  V4      '       g   K  Wr8w  g   K&  VP                  V4       \        V\        V4      ) VVP                   RVP                   R2R7      x  Kn  	  \        VP                  4       4       Fh  pWs9   d   K  VP                  V4      '       g   K$  Wr8w  g   K,  Wg,          p	\        V\        V4      ) VV	P                   RV	P                   2R7      x  Kj  	  R#   \          d     R# i ; i5i)zDYield completions for /model from config aliases + built-in aliases.)_ensure_direct_aliasesDIRECT_ALIASESMODEL_ALIASESz (rt   rC  re   N)r   hermes_cli.model_switchrw  rx  ry  itemsr   r   r
   r   r=   r>   r   keysvendorfamilyr   )
r'  rt  ru  seenrw  rx  ry  r   daidentitys
   &&&       r$   _model_completions(SlashCommandCompleter._model_completionsd  s    u	  #$*002??9--$2CHHTN$(+H~ $(*zBKK=%B	  3 }1134<??9--$2C,2H$(+H~ $(0'8(//9J%K	  5  		sB   D8:D& D& BD& D& $A D& $D8&D51D84D55D8c              #  	  "   VP                   pVP                  R 4      '       ga   V P                  V4      pVe   V P                  V4       Rj  xL
  R# V P	                  V4      pVe   V P                  V4       Rj  xL
  R# VP                  ^R7      pV^ ,          P                  4       p\        V4      ^8  g(   \        V4      ^8X  d   VP                  R4      '       d   \        V4      ^8  d
   V^,          MRpVP                  4       p	RV9  d#   VR8X  d   V P                  W4       Rj  xL
  R# RV9  d[   V\        9   dP   \        V,           F>  p
V
P                  V	4      '       g   K  W8w  g   K$  \        V
\        V4      ) V
R7      x  K@  	  R# VR,          p\        P                  4        FQ  w  rVR,          pVP                  V4      '       g   K'  \        V P                  W4      \        V4      ) VVR7      x  KS  	  V P!                  4       P                  4        F  w  rVR,          pVP                  V4      '       g   K'  \#        VP%                  R	R
4      4      pVR,          \        V4      ^28  d   RMR,           p\        V P                  W4      \        V4      ) VRV 2R7      x  K  	  R#  ELu ELH EL5i)re   Nmaxsplitr   r   z/model)rD  rE  rf  rC  r   zSkill command:N2   Nr   u   ⚡ )text_before_cursorr   r_  rq  r;  rZ  r   rg   r   rG  r  r   r
   r~   r{  r1  r,  r   rf   )r'  documentcomplete_eventr5  ctx_word	path_wordpartsbase_cmdrt  ru  r   r/  r_   r   r   r  r   
short_descs   &&&               r$   get_completions%SlashCommandCompleter.get_completions  sn    **s##11$7H#44X>>>//5I$11)<<< 

A
&8>>#u:>c%jAo$--2D2D#&u:>uQxrH (I ("x8';228GGG ("x;'>&x00C~~i00S5E(,/M>$'  1 Bx!)IC2wH""4(( ))(9$'I:!%	  * 224::<IC2wH""4((!$((=/"JK(-#k:JR:OUWX
 ))(9$'I:#'
|!4	  =W ?
 = HsY   AKK/K?K A%K&AK3K
4<K5K=AK!A.KA1KK
Kr%  rw   )   )r   r   r   r   r    r(  r,  staticmethodr1  r;  rZ  r_  rq  r  r  r"   r   r#   r$   r   r     s    T@ @ @  . 0 0d   i iVB;r#   r   c                  0    ] tR tRtRtRR R lltR tRtR# )	SlashCommandAutoSuggesti  zInline ghost-text suggestions for slash commands and their subcommands.

Shows the rest of a command or subcommand in dim text as you type.
Falls back to history-based suggestions for non-slash input.
Nc               $    V ^8  d   QhRRRRRR/# )rX   history_suggestzAutoSuggest | None	completerzSlashCommandCompleter | NonerY   rk   r   )r[   s   "r$   r\   $SlashCommandAutoSuggest.__annotate__  s(     $ $+$ 0$ 
	$r#   c                	    Wn         W n        R # rw   )_history
_completer)r'  r  r  s   &&&r$   r(   SlashCommandAutoSuggest.__init__  s    
 (#r#   c                	   VP                   pVP                  R 4      '       g0   V P                  '       d   V P                  P                  W4      # R# VP	                  ^R7      pV^ ,          P                  4       p\        V4      ^8X  d   VP                  R4      '       gh   VR,          P                  4       p\         FD  pVR,          pVP                  V4      '       g   K%  W8w  g   K-  \        V\        V4      R 4      u # 	  R# \        V4      ^8  d
   V^,          MRp	V	P                  4       p
V\        9   dg   \        V,          '       dT   RV	9  dM   \        V,           F;  pVP                  V
4      '       g   K  W8w  g   K$  \        V\        V	4      R 4      u # 	  V P                  '       d   V P                  P                  W4      # R# )re   Nr  r   rf  r   )r  r   r  get_suggestionr   rg   r   rG  r~   r   r   )r'  bufferr  r5  r  r  r/  r_   r   rt  ru  r   s   &&&         r$   r  &SlashCommandAutoSuggest.get_suggestion  sj   ** s##}}}}}33FEE

A
&8>>#u:?4==#5#58>>#Dr7&&t,,1A%hs4yz&:;;     #5zA~582NN$	 {"{8'<'<("&x00C~~i00S5E)#c(mn*=>> 1
 =====//AAr#   )r  r  )NN)r   r   r   r   r    r(  r  r"   r   r#   r$   r  r    s    $$r#   r  c                    V ^8  d   QhRRRR/# )rX   r   r   rY   r   )r[   s   "r$   r\   r\     s     1 13 13 1r#   c                     \         P                  P                  V 4      pTR8  d   T R2# TR	8  d   TR,          R R2# TR
8  d   TR	,          R R2# TR
,          R R2#   \         d     R# i ; i)z:Return a compact human-readable file size, or '' on error.r   i   Bz.0fKz.1fMGi   i   @)r   r   getsizerK  )r   sizes   & r$   rO  rO    s    wwt$ d{qzk+c"!$$  +&s+1--()#.a00  s   A" "A10A1)reset)fork)bg)q)zset-home)r'   )sb)
nonelowminimalmediumhighxhighshowhideonoff)r  r  ttsr6   )r   browseinspectinstall)r   r   createeditpauser:   runremove)
reload_mcp)connect
disconnectr6   )gateway)exitr  rw   )d   N)r  )F__conditional_annotations__r    
__future__r   r   recollections.abcr   r   dataclassesr   typingr   prompt_toolkit.auto_suggestr   r   prompt_toolkit.completionr	   r
   r   rV   r!   ra   rb   ri   rp   rn   r   r~   _cmdr   r   r   _aliasr   r   r   r   _catr   r   r   compiler   r   r   r   r   r   r   r   r   r   r   r   r   r   _TG_NAME_LIMITr   r   r   r   _clamp_telegram_namesr
  r  r  r  r   r  rO  )r  s   @r$   <module>r     s   # 	 	 - !  ? ; $+ + +$c&uH)!#c& w>		c& y5yc& v6	c& wBINc& v@)Lc& w=y!#c& xPR[ H6c&  zCYO!c&" zCY#%#c&& v>	J'c&( y? ,>@)c&, v99 "-c&0 |=y*61c&4 u_aj%'5c&8 wNPY59c&< x,i "=c&@ yGPAc&B y=y -9Cc&F x<i!#Gc&N x5Oc&R w7ThiSc&T zJ Uc&X x8/jJYc&\ }<o!#]c&` {A?g/ac&d yU#BDec&j vP kc&n {A?,mooc&t v>2uc&x w+_.<Z\yc&@ wNP`:TKAc&D z46FEc&H xE$EGIc&N v/1A`bOc&T |=?O&(Uc&X yMO_(E>@Yc&^ yC$0_c&f zG H6gc&j v0&9kc&l wBFKmc&n z>!#oc&r {Dfl4sc&v wDfwc&z xDf "{c&B v~vm5Cc& " cT *?)@& @9+\ . D$6t$<1TYYK!llF(,(8(8'9tyykQR%SHq\" #  35 / 4D#..t}}bA (1TYYK 9q_llF!)AfX,!7D1VH #	  %'! &D'+D,<,<'=a		{O$  

12Ddii[/C
kT^^,Aq771:++C0C   *3 33 *  "J &$  = ! JJ}- zz(+ F - l1f5D<*}I }H
3k 3l1r#   