You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letprompt=`You are a helpful programming assistant. Please analyze the following code and provide a comprehensive explanation.
81
+
letprompt=`Analyze the selected code (marked with >>>) and provide a concise explanation.
82
82
83
-
**IMPORTANT**: The code marked with ">>> code <<< // [SELECTED BY USER]" is what the user specifically selected for explanation. Focus your explanation on this selected code, but use the surrounding context to provide better understanding.
84
-
85
-
**Code to analyze:**
83
+
**Code with line numbers:**
86
84
\`\`\`${context.language}
87
85
${codeSnippet}
88
86
\`\`\`
89
87
90
-
**Context:**`;
91
-
92
-
if(context.functionName){
93
-
prompt+=`\n- This code is part of the function: ${context.functionName}`;
94
-
}
95
-
96
-
if(context.className){
97
-
prompt+=`\n- This code is part of the class: ${context.className}`;
98
-
}
99
-
100
-
if(context.variables.length>0){
101
-
prompt+=`\n- Related variables: ${context.variables.join(', ')}`;
prompt+=`\n\n**Please provide a well-formatted explanation with:**
111
-
1. **Primary Focus**: A clear explanation of what the SELECTED code (marked with >>>) does
112
-
2. **How it works**: Explain the mechanics and logic of the selected code
113
-
3. **Context Integration**: How the selected code fits within the surrounding code/function/class
114
-
4. **Related Lines**: Identify OTHER lines in the provided code that are directly related to or affected by the selected code (NOT the selected lines themselves)
115
-
5. **Important concepts**: Any important patterns, algorithms, or best practices demonstrated
88
+
**Instructions:**
89
+
1. Focus ONLY on the selected code (marked with >>>)
90
+
2. Be concise - 2-3 short paragraphs maximum
91
+
3. If you identify related lines that help understand the selected code, mention their line numbers
92
+
4. Use the surrounding code as context but don't explain it unless directly relevant
116
93
117
-
**CRITICAL**: When identifying "related lines", only mention line numbers or code snippets that are NOT part of the user's selection but are relevant to understanding the selected code.
118
-
119
-
**Formatting Guidelines:**
120
-
- Use markdown formatting for better readability
121
-
- Wrap any code snippets in triple backticks with language specification
122
-
- Use **bold** for important terms
123
-
- Use bullet points or numbered lists for clarity
124
-
- If identifying related lines, format them as: "Related lines: Line X (purpose), Line Y (purpose)"
125
-
- Keep the explanation comprehensive but focused on the selected code
126
-
127
-
Example format:
128
-
## What the selected code does
129
-
Brief overview of the selected code's purpose...
94
+
**Response format:**
95
+
## Purpose
96
+
Brief explanation of what the selected code does.
130
97
131
98
## How it works
132
-
Step-by-step breakdown of the selected code...
133
-
134
-
## Context and integration
135
-
How this fits with the surrounding code...
99
+
Concise explanation of the mechanism.
136
100
137
-
## Related code elements
138
-
- Line X: [explanation of how this line relates]
139
-
- Variable Y: [explanation of how this relates]
101
+
## Related lines
102
+
If applicable: "Lines X, Y: brief explanation of relevance"
140
103
141
-
Keep the explanation suitable for a developer trying to understand the selected code.`;
0 commit comments