Skip to content
This repository was archived by the owner on Jul 3, 2026. It is now read-only.

Commit 9245d90

Browse files
Merge pull request #4 from alexanderlhicks/update_workflow
small changes
2 parents 6d8f0e0 + 002fe4b commit 9245d90

5 files changed

Lines changed: 14 additions & 25 deletions

File tree

.codex

Whitespace-only changes.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
__pycache__/
2+
.codex

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ For pull requests with multiple file changes, the action employs a hierarchical
3434
6. **Style Check (optional):** If a style guide is available and the diff is within the style-analysis size budget, a Style Checker Agent reviews the changes concurrently with file summarization.
3535
7. **Synthesis:** The Synthesis Agent generates a structured overview from per-file summaries, PR title, and body. For very large PRs (40+ summaries), uses two-stage synthesis: per-directory groups first, then global.
3636
8. **Refinement:** A Refiner Agent reviews the draft for accuracy, brevity, and professional tone.
37-
9. **Post Comment:** The final summary (including sorry delta, statistics, declaration changes, quality signals, coverage notes, style report, and per-file summaries) is posted as a PR comment. Previous summary comments are found and updated (supports both current and legacy comment identifiers).
37+
9. **Post Comment:** The final summary (including sorry delta, statistics, declaration changes, quality signals, coverage notes, style report, and per-file summaries) is posted as a PR comment. Previous summary comments are found and updated.
3838

3939
## Usage
4040

summary.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
LARGE_PR_FILE_THRESHOLD = 50 # Files to summarize above which tiered mode activates
2626
LARGE_PR_SYNTHESIS_THRESHOLD = 40 # Per-file summaries above which two-stage synthesis activates
2727
COMMENT_IDENTIFIER = "<!-- lean-pr-summary-{{timestamp}} -->"
28-
LEGACY_COMMENT_IDENTIFIER = "<!-- gemini-pr-summary-{{timestamp}} -->"
2928
CACHE_IDENTIFIER = "<!-- lean-summary-cache: "
30-
LEGACY_CACHE_IDENTIFIER = "<!-- gemini-cache: "
3129

3230
# --- Global Provider and Token Tracker ---
3331
_provider: LLMProvider = None # Initialized in main()
@@ -622,19 +620,18 @@ def __init__(self, pr: PullRequest, config_fingerprint: str):
622620
def _load_from_comment(self, pr: PullRequest):
623621
comment = find_existing_comment(pr)
624622
if comment:
625-
for marker in (CACHE_IDENTIFIER, LEGACY_CACHE_IDENTIFIER):
626-
if marker not in comment.body:
627-
continue
628-
try:
629-
cache_str = comment.body.split(marker, 1)[1].split("-->", 1)[0]
630-
data = json.loads(cache_str)
631-
# Invalidate entire cache if config fingerprint changed
632-
if data.get("_config") != self._config_fingerprint:
633-
print("Cache invalidated: model or prompt template changed.")
634-
return {}
635-
return data
636-
except (IndexError, json.JSONDecodeError):
623+
if CACHE_IDENTIFIER not in comment.body:
624+
return {}
625+
try:
626+
cache_str = comment.body.split(CACHE_IDENTIFIER, 1)[1].split("-->", 1)[0]
627+
data = json.loads(cache_str)
628+
# Invalidate entire cache if config fingerprint changed
629+
if data.get("_config") != self._config_fingerprint:
630+
print("Cache invalidated: model or prompt template changed.")
637631
return {}
632+
return data
633+
except (IndexError, json.JSONDecodeError):
634+
return {}
638635
return {}
639636

640637
def get(self, file_path, file_diff_hash):
@@ -837,11 +834,7 @@ def get_github_objects(token, repo_name, pr_number):
837834

838835
def find_existing_comment(pr: PullRequest):
839836
"""Finds a comment previously posted by this action."""
840-
patterns = [
841-
COMMENT_IDENTIFIER.replace("{{timestamp}}", ".*?"),
842-
LEGACY_COMMENT_IDENTIFIER.replace("{{timestamp}}", ".*?"),
843-
]
844-
comment_regex = re.compile("|".join(f"(?:{p})" for p in patterns))
837+
comment_regex = re.compile(COMMENT_IDENTIFIER.replace("{{timestamp}}", ".*?"))
845838
return next((c for c in pr.get_issue_comments() if comment_regex.search(c.body)), None)
846839

847840
def post_github_comment(pr: PullRequest, summary: str):

tests/test_summary.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ def fake_load(path, revision=None):
9494
self.assertEqual(affected, [])
9595
self.assertIn("bodyOnly", added[0])
9696

97-
def test_find_existing_comment_matches_legacy_identifier(self):
98-
pr = FakePR([FakeComment("text\n<!-- gemini-pr-summary-2026-01-01-00-00-00 -->\n")])
99-
found = summary.find_existing_comment(pr)
100-
self.assertIsNotNone(found)
101-
10297

10398
if __name__ == "__main__":
10499
unittest.main()

0 commit comments

Comments
 (0)