Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
22
lua/avante/templates/editing.avanterules
Normal file
22
lua/avante/templates/editing.avanterules
Normal file
@@ -0,0 +1,22 @@
|
||||
{% extends "planning.avanterules" %}
|
||||
{% block user_prompt %}
|
||||
Your task is to modify the provided code according to the user's request. Follow these instructions precisely:
|
||||
|
||||
1. Return ONLY the complete modified code.
|
||||
|
||||
2. Do not include any explanations, comments, or line numbers in your response.
|
||||
|
||||
3. Ensure the returned code is complete and can be directly used as a replacement for the original code.
|
||||
|
||||
4. Preserve the original structure, indentation, and formatting of the code as much as possible.
|
||||
|
||||
5. Do not omit any parts of the code, even if they are unchanged.
|
||||
|
||||
6. Maintain the SAME indentation in the returned code as in the source code
|
||||
|
||||
7. DO NOT include three backticks: {%raw%}```{%endraw%} in your suggestion. Treat the suggested code AS IS.
|
||||
|
||||
8. Only return the new code snippets to be updated, DO NOT return the entire file content.
|
||||
|
||||
Remember that Your response SHOULD CONTAIN ONLY THE MODIFIED CODE to be used as DIRECT REPLACEMENT to the original file.
|
||||
{% endblock %}
|
||||
125
lua/avante/templates/planning.avanterules
Normal file
125
lua/avante/templates/planning.avanterules
Normal file
@@ -0,0 +1,125 @@
|
||||
{# Uses https://mitsuhiko.github.io/minijinja-playground/ for testing:
|
||||
{
|
||||
"ask": true,
|
||||
"use_xml_format": true,
|
||||
"question": "Refactor to include tab flow",
|
||||
"code_lang": "lua",
|
||||
"file_content": "local Config = require('avante.config')"
|
||||
}
|
||||
#}
|
||||
{%- if use_xml_format -%}
|
||||
{%- if selected_code -%}
|
||||
<context>
|
||||
```{{code_lang}}
|
||||
{{file_content}}
|
||||
```
|
||||
</context>
|
||||
|
||||
<code>
|
||||
```{{code_lang}}
|
||||
{{selected_code}}
|
||||
```
|
||||
</code>
|
||||
{%- else -%}
|
||||
<code>
|
||||
```{{code_lang}}
|
||||
{{file_content}}
|
||||
```
|
||||
</code>
|
||||
{%- endif %}{%- if project_context -%}
|
||||
<project_context>
|
||||
{{project_context}}
|
||||
</project_context>
|
||||
{%- endif %}{%- if memory_context -%}
|
||||
<memory_context>
|
||||
{{memory_context}}
|
||||
</memory_context>
|
||||
{%- endif %}
|
||||
{% else %}
|
||||
{%- if selected_code -%}
|
||||
CONTEXT:
|
||||
```{{code_lang}}
|
||||
{{file_content}}
|
||||
```
|
||||
|
||||
CODE:
|
||||
```{{code_lang}}
|
||||
{{selected_code}}
|
||||
```
|
||||
{%- else -%}
|
||||
CODE:
|
||||
```{{code_lang}}
|
||||
{{file_content}}
|
||||
```
|
||||
{%- endif %}{%- if project_context -%}
|
||||
PROJECT CONTEXT:
|
||||
{{project_context}}
|
||||
{%- endif %}{%- if memory_context -%}
|
||||
MEMORY CONTEXT:
|
||||
{{memory_context}}
|
||||
{%- endif %}{%- endif %}{%- if ask %}
|
||||
{%- if not use_xml_format %}
|
||||
|
||||
INSTRUCTION: {% else %}
|
||||
<instruction>{% endif -%}
|
||||
{% block user_prompt %}
|
||||
Your primary task is to suggest code modifications with precise line number ranges. Follow these instructions meticulously:
|
||||
|
||||
1. Carefully analyze the original code, paying close attention to its structure and line numbers. Line numbers start from 1 and include ALL lines, even empty ones.
|
||||
|
||||
2. When suggesting modifications:
|
||||
a. Use the language in the question to reply. If there are non-English parts in the question, use the language of those parts.
|
||||
b. Explain why the change is necessary or beneficial.
|
||||
c. If an image is provided, make sure to use the image in conjunction with the code snippet.
|
||||
d. Provide the exact code snippet to be replaced using this format:
|
||||
{% raw %}
|
||||
Replace lines: {{start_line}}-{{end_line}}
|
||||
```{{language}}
|
||||
{{suggested_code}}
|
||||
```
|
||||
{% endraw %}
|
||||
3. Crucial guidelines for suggested code snippets:
|
||||
- The content regarding line numbers MUST strictly follow the format "Replace lines: {{start_line}}-{{end_line}}". Do not be lazy!
|
||||
- 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).
|
||||
- Please keep your suggested code changes minimal, and do not include irrelevant lines in the code snippet.
|
||||
- Maintain the SAME indentation in the returned code as in the source code
|
||||
|
||||
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 and comments lines, comments. Do not be lazy!
|
||||
- Use the same number for start and end lines for single-line changes.
|
||||
- For multi-line changes, ensure the range covers ALL affected lines, from first to last.
|
||||
- Double-check that your line numbers 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.
|
||||
- Confirm that no unrelated code is accidentally modified or deleted.
|
||||
- Verify that the start_line and end_line correctly include all intended lines for replacement.
|
||||
- Perform a final alignment check to ensure your line numbers haven't shifted, especially the start_line.
|
||||
- Double-check that your line numbers align perfectly with the original code structure.
|
||||
- DO NOT return the complete modified code with applied changes!
|
||||
|
||||
Remember that ACCURATE line numbers are CRITICAL. The range {%raw%}{{start_line}}{%endraw%} to {%raw%}{{end_line}}{%endraw%} must include ALL LINES to be replaced. Double-check ALL RANGES before finalizing your response, and MAKE SURE THAT {%raw%}{{start_line}}{%endraw%} hasn't been shifted down. ENSURE line numbers MATCH the original code structure and indentation ARE PRESERVED.
|
||||
{% endblock %}
|
||||
{%- if use_xml_format -%}
|
||||
</instruction>
|
||||
|
||||
<question>{{question}}</question>
|
||||
{%- else %}
|
||||
QUESTION:
|
||||
{{question}}
|
||||
{%- endif %}
|
||||
{% else %}
|
||||
{% if use_xml_format -%}
|
||||
<question>{{question}}</question>
|
||||
{% else %}
|
||||
QUESTION:
|
||||
{{question}}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
32
lua/avante/templates/suggesting.avanterules
Normal file
32
lua/avante/templates/suggesting.avanterules
Normal file
@@ -0,0 +1,32 @@
|
||||
{% extends "planning.avanterules" %}
|
||||
{% block user_prompt %}
|
||||
Your task is to suggest code modifications at the cursor position. Follow these instructions meticulously:
|
||||
|
||||
1. Carefully analyze the original code, paying close attention to its structure and the cursor position.
|
||||
|
||||
2. You must follow this json format when suggesting modifications:
|
||||
|
||||
{% raw %}
|
||||
[
|
||||
{
|
||||
"row": ${row},
|
||||
"col": ${column},
|
||||
"content": "Your suggested code here"
|
||||
}
|
||||
]
|
||||
{% endraw %}
|
||||
|
||||
3. When suggesting suggested code:
|
||||
- Each element in the returned list is a COMPLETE and INDEPENDENT code snippet.
|
||||
- MUST be a valid json format. Don't be lazy!
|
||||
- Only return the new code to be inserted.
|
||||
- Your returned code should not overlap with the original code in any way. Don't be lazy!
|
||||
- Please strictly check the code around the position and ensure that the complete code after insertion is correct. Don't be lazy!
|
||||
- Do not return the entire file content or any surrounding code.
|
||||
- Do not include any explanations, comments, or line numbers in your response.
|
||||
- Ensure the suggested code fits seamlessly with the existing code structure and indentation.
|
||||
- If there are no recommended modifications, return an empty list.
|
||||
|
||||
Remember to ONLY RETURN the suggested code snippet, without any additional formatting or explanation.
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user