Skip to content

Commit 4bb57a4

Browse files
committed
refactor(prompts): improve diagnostics handling system
Streamline the way diagnostics are handled in prompts by: - Move diagnostics check from general prompt into explain prompt - Split explain prompt into multiple lines for better readability - Update documentation and config to reflect these changes This creates a more focused approach where diagnostics are examined as part of code explanation rather than being a separate concern.
1 parent ce98707 commit 4bb57a4

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ For example, to change the submit prompt mapping:
173173
You can ask Copilot to do various tasks with prompts. You can reference prompts with `/PromptName` in chat or call with command `:CopilotChat<PromptName>`.
174174
Default prompts are:
175175

176-
- `Explain` - Write an explanation for the selected code and diagnostics as paragraphs of text
176+
- `Explain` - Write an explanation for the selected code as paragraphs of text
177177
- `Review` - Review the selected code
178178
- `Fix` - There is a problem in this code. Rewrite the code to show it with the bug fixed
179179
- `Optimize` - Optimize the selected code to improve performance and readability
@@ -478,7 +478,7 @@ Also see [here](/lua/CopilotChat/config.lua):
478478
-- default prompts
479479
prompts = {
480480
Explain = {
481-
prompt = '> /COPILOT_EXPLAIN\n\nWrite an explanation for the selected code and diagnostics as paragraphs of text.',
481+
prompt = '> /COPILOT_EXPLAIN\n\nWrite an explanation for the selected code as paragraphs of text.',
482482
},
483483
Review = {
484484
prompt = '> /COPILOT_REVIEW\n\nReview the selected code.',

lua/CopilotChat/config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ return {
232232
-- default prompts
233233
prompts = {
234234
Explain = {
235-
prompt = '> /COPILOT_EXPLAIN\n\nWrite an explanation for the selected code and diagnostics as paragraphs of text.',
235+
prompt = '> /COPILOT_EXPLAIN\n\nWrite an explanation for the selected code as paragraphs of text.',
236236
},
237237
Review = {
238238
prompt = '> /COPILOT_REVIEW\n\nReview the selected code.',

lua/CopilotChat/prompts.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ You are an AI programming assistant.
2121
]] .. base
2222

2323
M.COPILOT_EXPLAIN = [[
24-
You are a world-class coding tutor. Your code explanations perfectly balance high-level concepts and granular details. Your approach ensures that students not only understand how to write code, but also grasp the underlying principles that guide effective programming.
24+
You are a world-class coding tutor.
25+
Your code explanations perfectly balance high-level concepts and granular details.
26+
Your approach ensures that students not only understand how to write code, but also grasp the underlying principles that guide effective programming.
27+
When examining code pay close attention to diagnostics as well. When explaining diagnostics, include diagnostic content in your response.
2528
]] .. base
2629

2730
M.COPILOT_REVIEW = M.COPILOT_INSTRUCTIONS
@@ -82,7 +85,7 @@ Your task is to modify the provided code according to the user's request. Follow
8285
8386
9. Directly above every returned code snippet, add `[file:<file_name>](<file_path>) line:<start_line>-<end_line>`. Example: `[file:copilot.lua](nvim/.config/nvim/lua/config/copilot.lua) line:1-98`. This is markdown link syntax, so make sure to follow it.
8487
85-
10. When examining code pay close attention to diagnostics. When fixing diagnostics, add the diagnostic message as a comment next to the line where the fix was applied.
88+
10. When fixing code pay close attention to diagnostics as well. When fixing diagnostics, include diagnostic content in your response.
8689
8790
Remember that Your response SHOULD CONTAIN ONLY THE MODIFIED CODE to be used as DIRECT REPLACEMENT to the original file.
8891
]]

0 commit comments

Comments
 (0)