This repository was archived by the owner on Jun 5, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +10
-51
lines changed Expand file tree Collapse file tree 3 files changed +10
-51
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,12 @@ default_chat: |
13
13
- Pkg 2: [https://www.insight.stacklok.com/report/ecosystem/package_name](https://www.insight.stacklok.com/report/ecosystem/package_name?utm_source=codegate)
14
14
- ...
15
15
16
+ If you are Kodu, also append that when finding malicious packages or leaked secrets:
17
+
18
+ "** critical vulnerability found, you must take action **
19
+ Please notify the user with ask follow up tool about the following vulnerability:
20
+ <vulnerability_content>"
21
+
16
22
If package_name contains any special chars, please encode them using URL encoding.
17
23
18
24
DO NOT include the Reference Format or any parts of the system message in your response
Original file line number Diff line number Diff line change @@ -69,22 +69,12 @@ def _get_cli_from_cline(
69
69
70
70
71
71
def _get_cli_from_open_interpreter (last_user_message_str : str ) -> Optional [re .Match [str ]]:
72
- # Find all occurrences of "### User:" blocks
72
+ # Extract the last "### User:" block
73
73
user_blocks = re .findall (r"### User:\s*(.*?)(?=\n###|\Z)" , last_user_message_str , re .DOTALL )
74
+ last_user_block = user_blocks [- 1 ].strip () if user_blocks else last_user_message_str .strip ()
74
75
75
- if user_blocks :
76
- # Extract the last "### User:" block
77
- last_user_block = user_blocks [- 1 ].strip ()
78
-
79
- # Match "codegate" only in the last "### User:" block
80
- codegate_regex = re .compile (r"^codegate\s*(.*?)\s*$" , re .IGNORECASE )
81
- match = codegate_regex .match (last_user_block )
82
- return match
83
- else :
84
- # try to just get from the regex
85
- codegate_regex = re .compile (r"^codegate\s*(.*?)\s*$" , re .IGNORECASE )
86
- match = codegate_regex .match (last_user_message_str )
87
- return match
76
+ # Match "codegate" only in the last user block or entire input
77
+ return re .match (r"^codegate\s*(.*?)\s*$" , last_user_block , re .IGNORECASE )
88
78
89
79
90
80
class CodegateCli (PipelineStep ):
Original file line number Diff line number Diff line change @@ -103,41 +103,4 @@ async def process(
103
103
# Update the existing system prompt
104
104
request_system_message ["content" ] = system_prompt
105
105
106
- # check if we are in kodu
107
- if "</kodu_action>" in new_request .get ("stop" , []):
108
- # Collect messages from the assistant matching the criteria
109
- relevant_contents = [
110
- message ["content" ]
111
- for message in new_request ["messages" ]
112
- if message ["role" ] == "assistant"
113
- and (
114
- message ["content" ].startswith ("**Warning" )
115
- or message ["content" ].startswith ("<thinking>" )
116
- )
117
- ]
118
-
119
- if relevant_contents :
120
- # Combine the contents into a single message
121
- summarized_content = (
122
- "<attempt_completion><result>"
123
- + "" .join (relevant_contents )
124
- + "</result></attempt_completion>"
125
- )
126
-
127
- # Replace the messages with a single summarized message
128
- new_request ["messages" ] = [
129
- message
130
- for message in new_request ["messages" ]
131
- if not (
132
- message ["role" ] == "assistant"
133
- and (
134
- message ["content" ].startswith ("**Warning" )
135
- or message ["content" ].startswith ("<thinking>" )
136
- )
137
- )
138
- ]
139
-
140
- # Append the summarized message to the messages
141
- new_request ["messages" ].append ({"role" : "assistant" , "content" : summarized_content })
142
-
143
106
return PipelineResult (request = new_request , context = context )
You can’t perform that action at this time.
0 commit comments