INNER CODE UNIT · Python
_get_cli_from_copilot
stacklok/codegate · src/codegate/pipeline/cli/cli.py:97
def _get_cli_from_copilot(last_user_message_str: str) -> Optional[re.Match[str]]:
"""
Process Copilot-specific CLI command format.
Copilot sends messages in the format:
<attachment>file contents</attachment>codegate command
Args:
last_user_message_str (str): The message string from Copilot
Returns:
Optional[re.Match[str]]: A regex match object if command is found, None otherwise
"""
cleaned_text = re.sub(
r"<attachment>.*</attachment>", "", last_user_message_str, flags=re.DOTALL
)
return codegate_regex.match(cleaned_text.strip())