Skip to content

Add Discord codebase digest workflow#1920

Merged
merill merged 9 commits into
mainfrom
agent/discord-codebase-digest
Jul 9, 2026
Merged

Add Discord codebase digest workflow#1920
merill merged 9 commits into
mainfrom
agent/discord-codebase-digest

Conversation

@merill

@merill merill commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a daily Discord codebase digest for the Maester repo.

  • posts a daily 9am Australia/Melbourne digest through a Discord webhook
  • uses GITHUB_TOKEN with read-only contents/pull-request permissions
  • excludes bot/dependency update noise
  • formats clickable commit and PR links as Discord Markdown
  • splits long digests into multiple safe-size Discord posts

Discord setup

The #codebase-updates Discord channel and Maester bot webhook have been created, and DISCORD_CODEBASE_WEBHOOK_URL has been saved as a GitHub Actions secret for maester365/maester.

Validation

  • node --check .github/scripts/discord-codebase-digest.mjs
  • local dry run with DIGEST_DRY_RUN=true DIGEST_SINCE_HOURS=72
  • local no-op check with a near-empty window
  • scheduled-time guard check outside 9am Melbourne
  • forced live post to #codebase-updates verified the webhook posts as Maester bot with no user or role mentions

Summary by CodeRabbit

  • New Features
    • Added an automated Discord “codebase digest” summarizing recent main-branch activity.
    • Runs daily on a schedule and supports manual runs with dry-run, force post, and configurable lookback; also includes a monthly historical backfill mode.
    • Organizes updates into Discord-ready sections for merged pull requests and direct commits, with safe truncation and chunked delivery.
  • Reliability
    • Improved posting robustness by retrying on Discord rate limits and handling empty-update cases gracefully.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2b3f3c5e-1bce-4abf-af65-789b812bc156

📥 Commits

Reviewing files that changed from the base of the PR and between 75359f4 and 4ceb0a7.

📒 Files selected for processing (2)
  • .github/scripts/discord-codebase-digest.mjs
  • .github/workflows/discord-codebase-digest.yml
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/discord-codebase-digest.yml
  • .github/scripts/discord-codebase-digest.mjs

📝 Walkthrough

Walkthrough

Adds a scheduled GitHub Actions workflow and a standalone Node.js script that gather recent GitHub activity, assemble merged-PR and direct-commit digests, and post them to a Discord webhook in daily and monthly-backfill modes.

Changes

Discord Codebase Digest

Layer / File(s) Summary
Configuration and CLI entry
.github/scripts/discord-codebase-digest.mjs
Defines environment-driven configuration, validates required inputs, parses repository and mode settings, and dispatches execution to daily or monthly-backfill flows.
Daily digest flow
.github/scripts/discord-codebase-digest.mjs
Implements the daily run path that checks Melbourne local time, computes the commit window, fetches recent activity, builds the digest, and outputs chunks.
Monthly historical backfill flow
.github/scripts/discord-codebase-digest.mjs
Implements month enumeration, dry-run preview handling, backfill confirmation checks, monthly digest generation, and sequential chunk posting with delays.
Digest content and chunking
.github/scripts/discord-codebase-digest.mjs
Implements commit classification, PR merging and filtering, contributor and title formatting, section assembly, chunk splitting, and page header formatting for Discord output.
GitHub and Discord HTTP helpers
.github/scripts/discord-codebase-digest.mjs
Implements GitHub commit and PR retrieval, authenticated JSON requests, Discord webhook validation and posting, and retry handling for rate limits.
Backfill date and time utilities
.github/scripts/discord-codebase-digest.mjs
Implements month-key parsing and enumeration, Melbourne-based UTC boundary conversion, current month helpers, date formatting, sleep, and process termination.
Workflow wiring
.github/workflows/discord-codebase-digest.yml
Adds the GitHub Actions workflow with manual inputs, cron schedules, read-only permissions, concurrency settings, and the job that runs the digest script.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding a Discord codebase digest workflow.
Description check ✅ Passed The description covers the summary, setup, and validation, though it omits the issue reference and checklist template items.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/discord-codebase-digest

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

codacy-production Bot commented Jul 9, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 116 complexity

Metric Results
Complexity 116

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 9, 2026

Copy link
Copy Markdown

Deploying maester with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4ceb0a7
Status:⚡️  Build in progress...

View logs

@merill

merill commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Updated the workflow to use the Discord webhook's configured avatar instead of passing a website avatar URL in each payload. The existing Maester bot webhook in #codebase-updates has been updated from ~/Downloads/maester-bot.png, and a forced validation post succeeded after the change.

@merill

merill commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Updated the webhook payload to set Discord's SUPPRESS_EMBEDS message flag (1 << 2) so commit/PR links remain clickable without rendering GitHub preview cards. Forced validation post in #codebase-updates came back with flags: 4, suppress_embeds: true, and embeds: 0.

@merill

merill commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Updated the digest lines to include contributor attribution. Merged PR entries now use the PR author, and direct commit entries use the GitHub commit author when available, falling back to the raw commit author name. Example dry-run output: Manifesto by [merill](https://github.com/merill) ([#1918](...)). Also revalidated syntax, dry-run chunking, and a forced Discord post with embeds still suppressed.

@merill

merill commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Added contributor attribution and simplified the date header. Digest lines now include by [contributor](profile), using PR author for merged PRs and commit author for direct commits. The header now shows a single local digest date, e.g. _9 July 2026_, instead of a date/time range. Validated with node --check and a 72-hour dry run.

@merill merill marked this pull request as ready for review July 9, 2026 02:58
@merill merill requested a review from a team as a code owner July 9, 2026 02:58

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (1)
.github/workflows/discord-codebase-digest.yml (1)

34-36: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add a job timeout for the network-heavy digest run.

Without timeout-minutes, a stalled GitHub/Discord request can burn the default Actions timeout window.

Proposed workflow guardrail
   post-digest:
     name: Post daily Discord digest
     runs-on: ubuntu-latest
+    timeout-minutes: 10
🤖 Prompt for 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.

In @.github/workflows/discord-codebase-digest.yml around lines 34 - 36, Add an
explicit timeout to the post-digest job so a stalled GitHub or Discord request
does not consume the default runner window. Update the workflow job named
post-digest in the discord-codebase-digest workflow by setting a reasonable
timeout-minutes value alongside runs-on, and keep the rest of the job logic
unchanged.
🤖 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 @.github/scripts/discord-codebase-digest.mjs:
- Line 3: The API_ROOT value is taken directly from GITHUB_API_URL before
githubJson adds the Authorization header, so validate that origin first. Update
discord-codebase-digest.mjs around API_ROOT and githubJson to allow only
GitHub/GHES hosts (or otherwise fail closed) before sending the token, and
ensure any requests to untrusted origins are blocked rather than authenticated.
- Around line 222-228: The PR lookup in fetchPullRequest currently swallows all
githubJson errors and returns null, which can misclassify PR-backed commits as
direct commits. Update fetchPullRequest to only return null for the known “not
found” case, using the existing fetchPullRequest/githubJson error handling path
to detect it, and rethrow or let all other errors fail the digest so merge
commits and bot/dependency updates are not silently treated as direct commits.
- Around line 202-217: The commit collection loop in discord-codebase-digest.mjs
is capped at 10 pages, which can silently drop commits after 1,000 results.
Update the pagination in the commit-fetching logic to keep requesting pages
until githubJson returns fewer than 100 items, or add a fail-closed guard that
throws when the 10-page limit is hit with a full page. Keep the fix localized to
the loop that uses page, pageItems, and all.
- Around line 94-96: The monthly backfill window is being computed with UTC
boundaries, which can shift commits near month edges into the wrong digest
month. Update monthStart and nextMonthStart in discord-codebase-digest.mjs to
use Australia/Melbourne-local midnight boundaries, and make sure the backfill
flow that builds the since/until range uses those Melbourne-aligned values
consistently.

In @.github/workflows/discord-codebase-digest.yml:
- Around line 39-40: The checkout step in the workflow currently leaves Git
credentials persisted, which is unnecessary for this read-only job. Update the
`Checkout repository` step that uses `actions/checkout` to explicitly disable
persisted credentials by setting `persist-credentials: false`, while leaving the
rest of the workflow unchanged since the Node script already uses `GITHUB_TOKEN`
directly.

---

Nitpick comments:
In @.github/workflows/discord-codebase-digest.yml:
- Around line 34-36: Add an explicit timeout to the post-digest job so a stalled
GitHub or Discord request does not consume the default runner window. Update the
workflow job named post-digest in the discord-codebase-digest workflow by
setting a reasonable timeout-minutes value alongside runs-on, and keep the rest
of the job logic unchanged.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a4c3addc-bf93-4605-b870-8b21016c1598

📥 Commits

Reviewing files that changed from the base of the PR and between 8e9cb46 and 425a1a8.

📒 Files selected for processing (2)
  • .github/scripts/discord-codebase-digest.mjs
  • .github/workflows/discord-codebase-digest.yml

Comment thread .github/scripts/discord-codebase-digest.mjs Outdated
Comment thread .github/scripts/discord-codebase-digest.mjs
Comment thread .github/scripts/discord-codebase-digest.mjs Outdated
Comment thread .github/scripts/discord-codebase-digest.mjs
Comment thread .github/workflows/discord-codebase-digest.yml
@merill merill merged commit d6cf8a0 into main Jul 9, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant