feat: add repo hygiene proactive agent#7
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
📝 WalkthroughWalkthroughThis PR introduces the Repo Hygiene Agent, a new automated agent that runs on GitHub PR events, performs read-only code-quality analysis via AI, and reports findings to PR comments, Notion journals, workspace memory, and optional Slack channels. ChangesRepo Hygiene Agent
Sequence DiagramsequenceDiagram
participant GitHub as GitHub (PR Event)
participant Handler as Repo Hygiene Handler
participant Analysis as Diagnosis Pipeline
participant Model as AI Model
participant PR_Comment as GitHub (Comment)
participant Notion as Notion (Journal)
participant Memory as Workspace Memory
participant Slack as Slack (Optional)
GitHub->>Handler: pull_request.opened/synchronize
Handler->>Analysis: readPr() + diagnose()
Analysis->>Model: run(prompt with diff & hints & memory)
Model-->>Analysis: JSON hygiene report
Analysis-->>Handler: parsed HygieneReport
Handler->>PR_Comment: renderPrComment()
Handler->>Notion: writeNotionJournal()
Handler->>Memory: rememberRun()
Handler->>Slack: renderSlackSummary()
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@repo-hygiene/agent.ts`:
- Around line 52-55: After posting the PR comment with ctx.github.comment, make
the Notion journaling calls best-effort so failures there don't cause the
handler to throw and trigger a retry that would duplicate the comment: wrap
calls to writeNotionJournal and rememberRun in a try/catch (referencing
writeNotionJournal(ctx, pr, event, report, body) and rememberRun(ctx, pr, event,
report, notionPage.url)), catch and log the error (including the error object)
and return/continue without rethrowing; ensure any downstream code can handle a
missing notionPage.url (e.g., treat it as null) so the handler completes
successfully even if Notion fails.
- Around line 98-99: The code treats MAX_DIFF_CHARS as a minimum (Math.max(4000,
diffBudget)) instead of a true maximum, so small configured values are ignored;
change the logic around diffBudget/boundedDiff to respect a user-specified
maximum while still enforcing an upper cap (e.g., 40000). Specifically, update
how diffBudget is applied in boundedDiff (the boundedDiff variable and the
diffBudget derived from input(ctx, 'MAX_DIFF_CHARS')) so that when diffBudget is
finite you slice using Math.min(40000, Math.max(0, diffBudget)) and otherwise
default to 40000.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3b5873f4-ac40-49bf-9d3f-58424d4dd8aa
📒 Files selected for processing (5)
README.mdrepo-hygiene/README.mdrepo-hygiene/agent.tsrepo-hygiene/persona.jsonrepo-hygiene/persona.ts
There was a problem hiding this comment.
2 issues found across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Addressed the two review findings:
Validation:
|
Summary
Validation
Notes
Summary by cubic
Adds a repo-hygiene proactive agent that reviews opened/updated PRs in read-only mode to flag duplicated/dead code, divergent paths, stale docs/skills, and code smells. It posts a concise PR comment, journals the run to Notion with hardened error handling (non-blocking), optionally sends a Slack summary, and saves memory for trend tracking.
New Features
pull_request.openedandpull_request.synchronize.MAX_DIFF_CHARS).persona.ts/persona.json) and handler (agent.ts) with a read-only sandbox.Migration
NOTION_DATABASE_ID(required); optionallySLACK_CHANNEL; tuneMAX_DIFF_CHARS.repo-hygiene/README.md).Written for commit 6abf6e0. Summary will update on new commits.
Review in cubic