@@ -199,13 +199,11 @@ local function generate_search_replace_instructions(context_instance)
199199 ' # OUTPUT FORMAT' ,
200200 ' You MUST output ONLY in SEARCH/REPLACE blocks. No explanations, no markdown, no additional text.' ,
201201 ' ' ,
202- ' ```' ,
203202 ' <<<<<<< SEARCH' ,
204203 ' [exact lines from the original code]' ,
205204 ' =======' ,
206205 ' [modified version of those lines]' ,
207206 ' >>>>>>> REPLACE' ,
208- ' ```' ,
209207 ' ' ,
210208 ' # CRITICAL RULES' ,
211209 ' 1. **Exact matching**: Copy SEARCH content EXACTLY character-for-character from the provided code' ,
@@ -246,7 +244,6 @@ local function generate_search_replace_instructions(context_instance)
246244 ' # EXAMPLES' ,
247245 ' ' ,
248246 ' **Modify a return value:**' ,
249- ' ```' ,
250247 ' <<<<<<< SEARCH' ,
251248 ' function calculate()' ,
252249 ' local result = x + y' ,
@@ -258,10 +255,8 @@ local function generate_search_replace_instructions(context_instance)
258255 ' return result * 3 -- Changed multiplier' ,
259256 ' end' ,
260257 ' >>>>>>> REPLACE' ,
261- ' ```' ,
262258 ' ' ,
263259 ' **Insert a new line:**' ,
264- ' ```' ,
265260 ' <<<<<<< SEARCH' ,
266261 ' local config = {' ,
267262 ' timeout = 5000,' ,
@@ -272,10 +267,8 @@ local function generate_search_replace_instructions(context_instance)
272267 ' retry_count = 3,' ,
273268 ' }' ,
274269 ' >>>>>>> REPLACE' ,
275- ' ```' ,
276270 ' ' ,
277271 ' **Remove a line:**' ,
278- ' ```' ,
279272 ' <<<<<<< SEARCH' ,
280273 ' local debug_mode = true' ,
281274 ' local verbose = true' ,
@@ -284,16 +277,13 @@ local function generate_search_replace_instructions(context_instance)
284277 ' local debug_mode = true' ,
285278 ' local silent = false' ,
286279 ' >>>>>>> REPLACE' ,
287- ' ```' ,
288280 ' ' ,
289281 ' **Insert new code at cursor (empty SEARCH):**' ,
290282 ' When the cursor is on an empty line or you need to insert without replacing, use an empty SEARCH section:' ,
291- ' ```' ,
292283 ' <<<<<<< SEARCH' ,
293284 ' =======' ,
294285 ' local new_variable = "inserted at cursor"' ,
295286 ' >>>>>>> REPLACE' ,
296- ' ```' ,
297287 ' ' ,
298288 ' # FINAL REMINDER' ,
299289 ' Output ONLY the SEARCH/REPLACE blocks. The SEARCH section must match the original code exactly.' ,
@@ -332,13 +322,10 @@ local create_message = Promise.async(function(message, buf, range, context_insta
332322
333323 local result = context .format_message_plain_text (message , context_instance , format_opts ):await ()
334324
335- -- Convert instructions to text
336- local instructions_text = type (instructions ) == ' table' and table.concat (instructions , ' \n ' ) or tostring (instructions )
337-
338- -- Create a clear separator between instructions and user request
339- local full_text = instructions_text .. ' \n\n ' .. string.rep (' =' , 80 ) .. ' \n\n ' .. ' # USER REQUEST\n\n ' .. result .text
340-
341- local parts = { { type = ' text' , text = full_text } }
325+ local parts = {
326+ { type = ' text' , text = instructions_text },
327+ { type = ' text' , text = ' \n\n ' .. string.rep (' =' , 80 ) .. ' \n\n ' .. ' # USER REQUEST\n\n ' .. result .text },
328+ }
342329
343330 -- Use instructions as system prompt for models that support it
344331 local params = { parts = parts , system = instructions_text }
0 commit comments