|
34 | 34 | extract_content_from_diff, |
35 | 35 | process_diff_file, |
36 | 36 | prepare_nodes_iter, |
| 37 | + apply_custom_guidance, |
37 | 38 | ) |
38 | 39 |
|
39 | 40 |
|
@@ -69,7 +70,14 @@ def __init__( |
69 | 70 | setattr(self, k, kwargs[k]) |
70 | 71 |
|
71 | 72 | self.llm_provider = llm_provider |
| 73 | + # Optional user-provided guidance to be appended to system prompts |
| 74 | + self.custom_prompt_text = kwargs.get("custom_prompt_text") |
72 | 75 | self.plugin_config = load_plugin_config() |
| 76 | + |
| 77 | + # Load precedence note from general prompts |
| 78 | + self.custom_guidance_precedence = self.plugin_config.get( |
| 79 | + "general_prompts", {} |
| 80 | + ).get("custom_guidance_precedence", "") |
73 | 81 | self.plugins = load_plugins(self.plugin_config) |
74 | 82 |
|
75 | 83 | # Cache splitters and extension/plugin lookups |
@@ -355,6 +363,11 @@ def review_patch(self, patch_file, validate=False): |
355 | 363 | issue.get("issue", "") for issue in review_dict.get("reviews", []) |
356 | 364 | ) |
357 | 365 | summary_prompt = language_prompts["snippet_security_summary"] |
| 366 | + summary_prompt = apply_custom_guidance( |
| 367 | + summary_prompt, |
| 368 | + self.custom_prompt_text, |
| 369 | + self.custom_guidance_precedence, |
| 370 | + ) |
358 | 371 | changes_summary = summarize_changes( |
359 | 372 | self.llm_provider, file_diff.path, issues, summary_prompt |
360 | 373 | ) |
@@ -471,6 +484,9 @@ def _process_file_reviews( |
471 | 484 |
|
472 | 485 | for chunk in chunks: |
473 | 486 | system_prompt = f"{language_prompts[default_prompt_key]} \n {language_prompts['security_review_checks']} \n {report_prompt}" |
| 487 | + system_prompt = apply_custom_guidance( |
| 488 | + system_prompt, self.custom_prompt_text, self.custom_guidance_precedence |
| 489 | + ) |
474 | 490 | review = perform_security_review( |
475 | 491 | self.llm_provider, file_path, chunk, combined_context, system_prompt |
476 | 492 | ) |
|
0 commit comments