Team Ai
Apppublic

Yash030/claude-code-proxy

sourceHugging Faceupdated 5mo agoView on Hugging Face
2likes
command_utils.cpython-314.pyc52 linesDownload Raw Back to __pycache__
1+
2�Ej���n�Rt^RIt^RIt]P!R4tRRltRRltRRltR	R3ltR#)z0Command parsing utilities for API optimizations.Nz^[A-Za-z_][A-Za-z0-9_]*=.*$c�0�V^8�dQhR\R\/#)��part�return)�str�bool)�formats"�9C:\Users\yashw\.claude\temp-hf-clone\api\command_utils.py�__annotate__r4	s��0�0�S�0�T�0�c�>�\\PV44#)z9Return True when a token is a shell-style env assignment.)r�_ENV_ASSIGNMENT_RE�match)rs&r	�_is_env_assignmentr	s���"�(�(��.�/�/rc�\�V^8�dQhR\\,R\\,/#)r�partsr)�listr)rs"r	r5r6s"����$�s�)���S�	�rc�n�^p\V4F!wr#\V4'dV^,pK!M	WR#)z?Return command parts after leading shell-style env assignments.N)�	enumerater)r�	cmd_start�irs&   r	�_strip_env_assignmentsrs<���I��U�#����d�#�#��A��I��	$�7���rc�0�V^8�dQhR\R\/#)r�commandr�r)rs"r	r8r9s��;5�;5�C�;5�C�;5rc��RV9gRV9dR#\P!VRR7pV'gR#.p^p\V4F2wrE\V4'dVP	V4V^,pK2M	V\V48�dR#WRpV'gR#V^,p0R10mpWx9d:\V4^8�d*V^,p	V	P
R4'gVR	V	2#V#V'gV#R	PV4R	,V,# \d?TP4pT'gR#\T4pT'dT^,u#Ru#i;i)aCExtract the command prefix for fast prefix detection.11 12Parses a shell command safely, handling environment variables and13command injection attempts. Returns the command prefix suitable14for quick identification.15 16Returns:17    Command prefix (e.g., "git", "git commit", "npm install")18    or "none" if no valid command found19�`z$(�command_injection_detectedF��posix�noneN�-� >�go�git�npm�pip�yarn�cargo�docker�kubectl)20�shlex�splitrr�append�len�21startswith�join�22ValueErrorr)23rr�24env_prefixrrr�	cmd_parts�25first_word�two_word_commands�second_words26&         r	�extract_command_prefixr7s@���g�~����+�-5����G�5�1�����27��	� ��'�G�A�!�$�'�'��!�!�$�'���E�	��(���E�28�"���*�%�	����q�\�29�	30���*�s�9�~��/A�#�A�,�K��)�)�#�.�.�$��Q�{�m�4�4���!+�z�X����*�1E��1K�j�1X�X���5��
�
�����*�5�1�	�(�y��|�4�f�4�5�sN�D�AD�D�AD�D�#D�%D�-D�/D�"E�4E�E�Ec�<�V^8�dQhR\R\R\/#)rr�outputrr)rs"r	r31r32Ws&��M+�M+�C�M+��M+��M+rc�>�0R
mp0Rmp\P!VRR7pV'gR#\V4pV'gR#V^,PR4R,PR4R,P4pWb9dR#Wc9d^.pVR,F-pVP	R4'dKVPV4K/	V'dRP
V4p	R	V	R332#R#VR8Xd�0Rmp34Rp.pRp
VR,FJpV
'dRp
KVP	R4'dW�9dVR9dRpRp
K9VPV4KL	V'dTMVR,pV'dRP
V4p	R	V	R352#R#R# \dR#i;i)aTExtract file paths from a command locally without API call.36 37Determines if the command reads file contents and extracts paths accordingly.38Commands like ls/dir/find just list files, so return empty.39Commands like cat/head/tail actually read contents, so extract the file path.40 41Returns:42    Filepath extraction result in <filepaths> format43Frz<filepaths>44</filepaths>�/�\:�NNr!�45z<filepaths>46z
47</filepaths>�grepT>	�cd�ls�rm�dir�pwd�find�tree�mkdir�rmdir>�bat�cat�head�less�more�tail�type�����>�-A�-B�-C�-e�-f�-m>rTrU)r+r,r�lowerr/r-r0r1)rr9�listing_commands�reading_commandsrr3�base_cmd�	filepathsr�	paths_str�flags_with_args�pattern_provided_via_flag�48positional�	skip_nexts&&            r	�extract_filepaths_from_commandraWs���49��N��5+����G�5�1���.�*�5�1�	��.��Q�<�%�%�c�*�2�.�4�4�T�:�2�>�D�D�F���'�.��'��I�!�"�
�
���?�?�3�'�'��� � ��&�&�50� �I�I�i�0�	�&�y�k��@�@�.��v��B�O�(-�%��J��I�!�"�
�
��� %�I���?�?�3�'�'��.��<�/�8<�5�$(�	���!�!�$�'�&�'@�51�Z�PR�^�I�� �I�I�i�0�	�&�y�k��@�@�.�*���+�*�+�sB�F
�F
�A	F
�A	F
�F
�/?F
�//F
�F
�2F
�
F�F)	�__doc__�rer+�compiler
rrr7ra�rr	�<module>rfs4��6�	���Z�Z� >�?��0�52�;5�|M+r