Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use copilot and cursor instructions as a extra_instructions #1424

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion pr_agent/tools/pr_code_suggestions.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(self, pr_url: str, cli_mode=False, args: list = None,
"diff": "", # empty diff for initial calculation
"diff_no_line_numbers": "", # empty diff for initial calculation
"num_code_suggestions": num_code_suggestions,
"extra_instructions": get_settings().pr_code_suggestions.extra_instructions,
"extra_instructions": self._load_extra_instructions(),
"commit_messages_str": self.git_provider.get_commit_messages(),
"relevant_best_practices": "",
"is_ai_metadata": get_settings().get("config.enable_ai_metadata", False),
Expand All @@ -93,6 +93,23 @@ def __init__(self, pr_url: str, cli_mode=False, args: list = None,
self.progress += f"""\nWork in progress ...<br>\n<img src="https://codium.ai/images/pr_agent/dual_ball_loading-crop.gif" width=48>"""
self.progress_response = None

def _load_extra_instructions(self):
extra_instructions = get_settings().pr_code_suggestions.extra_instructions
if extra_instructions:
return extra_instructions

file_paths = ['.github/copilot-instructions.md', '.cursorrules']
for file_path in file_paths:
try:
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read().strip()
if content:
return content
except FileNotFoundError:
continue

return ""

async def run(self):
try:
if not self.git_provider.get_files():
Expand Down