@@ -71,7 +71,12 @@ AI_PROMPT_INJECT_PLACEHOLDER = f"""
71
71
- Your goal is to detect the single best place for this "{ AI_PLACEHOLDER } "
72
72
marker injection and inject it there. At the place where a human-readable
73
73
summary would be expected.
74
- - You are not allowed to remove a single character in the PR template!
74
+ - You are NOT ALLOWED to remove a single character in the PR template!
75
+ - You are NOT ALLOWED to add any new lines to the PR template EXCEPT that
76
+ "{ AI_PLACEHOLDER } " marker! I.e. you must always add exactly one new line
77
+ with that marker, not more.
78
+ - Never wrap anything with markdown blocks or something like that. Follow
79
+ the rules above!
75
80
- Never change sub-headers, surrounding text etc. there.
76
81
- Do not delete any sections, even if those sections appear empty.
77
82
- Only include the response text in that part. Don't add any comments or
@@ -747,6 +752,7 @@ class Main:
747
752
748
753
assert commit .url is not None
749
754
pr = self .gh_get_pr (url = commit .url )
755
+ body = pr .body
750
756
751
757
self .settings_load ()
752
758
if self .settings :
@@ -758,7 +764,7 @@ class Main:
758
764
rules_hash = ai_hash_extract (injected_text .text )
759
765
if rules_hash != self .ai_get_rules_hash ():
760
766
commit .title = pr .title
761
- pr . body = self .process_build_pr_body_with_ai (
767
+ body = self .process_build_pr_body_with_ai (
762
768
commit = commit ,
763
769
pr_template = injected_text .template_with_placeholder ,
764
770
)
@@ -769,6 +775,7 @@ class Main:
769
775
head_commit_hash = commit .hash ,
770
776
pr_numbers = pr_numbers ,
771
777
pr_number_current = pr_number_current ,
778
+ body = body ,
772
779
)
773
780
774
781
#
@@ -784,10 +791,13 @@ class Main:
784
791
return pr_template or ""
785
792
786
793
self .print_ai_generating ()
794
+ pr_template = pr_template or AI_DEFAULT_PR_TEMPLATE
787
795
788
796
injected_text = self .ai_generate_injected_text (
789
- prompt_inject_placeholder = self .ai_build_prompt_inject_placeholder (
790
- pr_template = pr_template or AI_DEFAULT_PR_TEMPLATE ,
797
+ prompt_inject_placeholder = (
798
+ pr_template
799
+ if AI_PLACEHOLDER in pr_template
800
+ else self .ai_build_prompt_inject_placeholder (pr_template = pr_template )
791
801
),
792
802
prompt_generate_summary = self .ai_build_prompt_generate_summary (
793
803
title = commit .title ,
@@ -929,12 +939,13 @@ class Main:
929
939
head_commit_hash : str ,
930
940
pr_numbers : list [int ],
931
941
pr_number_current : int | None ,
942
+ body : str ,
932
943
) -> tuple [Pr , PrUpsertResult ]:
933
944
if base_branch is None :
934
945
base_branch = self .remote_base_branch
935
946
936
- new_body = body_suffix_upsert (
937
- body = pr . body ,
947
+ body = body_suffix_upsert (
948
+ body = body ,
938
949
pr_numbers = pr_numbers ,
939
950
pr_number_current = pr_number_current ,
940
951
)
@@ -945,7 +956,7 @@ class Main:
945
956
946
957
if (
947
958
pr .base_branch == base_branch
948
- and pr .body == new_body
959
+ and pr .body == body
949
960
and pr .state == "OPEN"
950
961
and (MIDDLE_PR_LABEL in pr .labels ) == is_middle_pr
951
962
):
@@ -1027,11 +1038,11 @@ class Main:
1027
1038
"--body-file" ,
1028
1039
"-" ,
1029
1040
],
1030
- input = new_body ,
1041
+ input = body ,
1031
1042
)
1032
1043
1033
1044
pr .base_branch = base_branch
1034
- pr .body = new_body
1045
+ pr .body = body
1035
1046
return pr , upsert_result
1036
1047
1037
1048
#
@@ -1490,12 +1501,13 @@ class Main:
1490
1501
def ai_generate_injected_text (
1491
1502
self ,
1492
1503
* ,
1493
- prompt_inject_placeholder : AiPrompt ,
1504
+ prompt_inject_placeholder : AiPrompt | str ,
1494
1505
prompt_generate_summary : AiPrompt ,
1495
1506
) -> AiInjectedText :
1496
- task_inject_placeholder = Task (
1497
- self .ai_send_request ,
1498
- prompt = prompt_inject_placeholder ,
1507
+ task_inject_placeholder = (
1508
+ Task (lambda : prompt_inject_placeholder )
1509
+ if isinstance (prompt_inject_placeholder , str )
1510
+ else Task (self .ai_send_request , prompt = prompt_inject_placeholder )
1499
1511
)
1500
1512
task_generate_summary = Task (
1501
1513
self .ai_send_request ,
0 commit comments