@@ -1161,12 +1161,18 @@ def _first_value(scope: ScopeResult) -> str:
11611161
11621162 The text the action piped in when it has it, then the whole message the
11631163 ``message`` rule reports, then whichever rule names a value first. A PR
1164- description has no such line: its first line does not identify it.
1164+ description has no such line: its first line does not identify it. An
1165+ AI rule's value is the tool or the author it found, never the text, so
1166+ it never stands in for a commit's subject.
11651167 """
11661168 if scope .label == "PR description" :
11671169 return ""
11681170 values = [scope .text , _message_value (scope )]
1169- values .extend (str (check .get ("value" ) or "" ) for check in scope .checks )
1171+ values .extend (
1172+ str (check .get ("value" ) or "" )
1173+ for check in scope .checks
1174+ if check .get ("rule_id" ) not in AI_RULE_IDS
1175+ )
11701176 for value in values :
11711177 if value .strip ():
11721178 return value .strip ().splitlines ()[0 ].strip ()
@@ -1697,23 +1703,31 @@ def _hunk(scope: ScopeResult, status: str) -> list[str]:
16971703 """
16981704 is_commit = bool (scope .sha ) and scope .label .startswith ("Commit" )
16991705 lines = [f"@@ { scope .sha [:7 ] if is_commit else scope .label } @@" ]
1706+ value = _first_value (scope )
17001707 removed : list [str ] = []
17011708 added : list [str ] = []
17021709 advice : list [str ] = []
1710+ # Whether a piece of advice is about the value itself: a subject or a
1711+ # branch name that has to change. Advice about something else, such as
1712+ # an AI tool as the commit's author, leaves the subject as context.
1713+ about_value = False
17031714 for check in _findings (scope , status ):
17041715 minus , plus = _line_edits (scope , check )
17051716 removed .extend (minus )
17061717 added .extend (plus )
17071718 if not (minus or plus ):
17081719 advice .append (_advice (check ))
1720+ checked = str (check .get ("value" ) or "" ).strip ()
1721+ about_value |= not checked or checked .splitlines ()[0 ].strip () == value
17091722 if scope .raw_text and not scope .checks :
17101723 advice .append ("the output could not be parsed, see the step log" )
1724+ about_value = True
17111725 removed , added , advice = (list (dict .fromkeys (x )) for x in (removed , added , advice ))
1712- value = _first_value (scope )
17131726 if value and value not in removed :
1714- # Advice is about the value itself, so it is what was found; a fix
1715- # that only touches other lines leaves it as context.
1716- lines .append (f"{ '-' if advice else ' ' } { value } " )
1727+ # Advice about the value means it is what was found; a fix that only
1728+ # touches other lines, or advice about something else, leaves it as
1729+ # context.
1730+ lines .append (f"{ '-' if about_value else ' ' } { value } " )
17171731 lines .extend (f"- { line } " for line in removed )
17181732 lines .extend (f"+ { line } " for line in added )
17191733 lines .extend (f"# { line } " for line in advice )
0 commit comments