From 095c65689d97833810a570a17a354580bef9b9e9 Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 18 Aug 2024 02:46:19 +0800 Subject: [PATCH] feat: refine prompts (#52) --- lua/avante/ai_bot.lua | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lua/avante/ai_bot.lua b/lua/avante/ai_bot.lua index 87f0b43..b8f35b1 100644 --- a/lua/avante/ai_bot.lua +++ b/lua/avante/ai_bot.lua @@ -28,24 +28,22 @@ Replace lines: {{start_line}}-{{end_line}} {{suggested_code}} ``` -3. Crucial guidelines for line numbers: +3. Crucial guidelines for suggested code snippets: + - Only apply the change(s) suggested by the most recent assistant message (before your generation). + - Do not make any unrelated changes to the code. + - Produce a valid full rewrite of the entire original file without skipping any lines. Do not be lazy! + - Do not arbitrarily delete pre-existing comments/empty Lines. + - Do not omit large parts of the original file for no reason. + - Do not omit any needed changes from the requisite messages/code blocks. + - If there is a clicked code block, bias towards just applying that (and applying other changes implied). + +4. Crucial guidelines for line numbers: - The range {{start_line}}-{{end_line}} is INCLUSIVE. Both start_line and end_line are included in the replacement. - Count EVERY line, including empty lines, comments, and the LAST line of the file. - For single-line changes, use the same number for start and end lines. - For multi-line changes, ensure the range covers ALL affected lines, from the very first to the very last. - - Include the entire block (e.g., complete function) when modifying structured code. - - Pay special attention to the start_line, ensuring it's not omitted or incorrectly set. - - Double-check that your start_line is correct, especially for changes at the beginning of the file. - - Also, be careful with the end_line, especially when it's the last line of the file. - Double-check that your line numbers align perfectly with the original code structure. -4. Context and verification: - - Show 1-2 unchanged lines before and after each modification as context. - - These context lines are NOT included in the replacement range. - - After each suggestion, recount the lines to verify the accuracy of your line numbers. - - Double-check that both the start_line and end_line are correct for each modification. - - Verify that your suggested changes align perfectly with the original code structure. - 5. Final check: - Review all suggestions, ensuring each line number is correct, especially the start_line and end_line. - Pay extra attention to the start_line of each modification, ensuring it hasn't shifted down.