Suggest documentation updates during review#139
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a second AI pass during gh review to detect documentation impact from the diff and (when applicable) post documentation update suggestions to the merge request.
Changes:
- Added a documentation-focused OpenAI prompt + request path, plus formatting/display helpers for documentation suggestions.
- Wired the new documentation pass into both terminal review and MR review flows.
- Added unit tests for documentation comment formatting and OpenAI request wiring; updated README to describe the new behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
ai_code_review.py |
Adds documentation-impact prompt, OpenAI call, formatting helpers, and MR/terminal integration. |
tests/test_ai_code_review.py |
Adds unit tests covering documentation suggestion formatting and request message contents. |
README.md |
Documents the new review behavior (docs-impact detection and suggestion posting). |
Comments suppressed due to low confidence (1)
ai_code_review.py:454
run_review_for_mrreturns early when diff refs can't be fetched, which prevents posting the documentation suggestions comment even though it doesn't depend on diff refs. This also means you still pay for the documentation OpenAI call but never surface the result. Consider posting the documentation comment before this early return (or moving the diff-refs check before callingsuggest_documentation_updates).
documentation_results = suggest_documentation_updates(diff_content)
# Get diff refs for inline comments
diff_refs = get_diff_refs(project_id, mr_id, gitlab_token, api_url)
if not diff_refs or not all(diff_refs.values()):
print(f"{Colors.HIGH}⚠ Could not get diff refs, posting summary only{Colors.RESET}")
comment = format_gitlab_comment(results)
post_to_merge_request(comment, project_id, mr_id, gitlab_token, api_url)
return
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def format_documentation_comment(results): | ||
| """Format documentation suggestions as a GitLab markdown comment.""" | ||
| if not results or not results.get('needed') or not results.get('suggestions'): | ||
| return None |
8033669 to
023fe8f
Compare
|
Updated to handle the missing diff-refs path from the Copilot note: documentation suggestions are now posted even when inline review comments cannot be positioned.\n\nFresh verification:\n- |
023fe8f to
4b8d965
Compare
|
Handled the latest review edge case in |
Summary
Fixes #87
Verification
python3 -m unittest discover -s tests -vpython3 -m py_compile ai_code_review.py gitHappens.pygit diff --check HEAD~1..HEAD