From fac9a33ad5cf2d8363f09197c4215aed5de6a30d Mon Sep 17 00:00:00 2001 From: "Benjamin D. Smith" Date: Tue, 26 May 2026 01:52:47 +1000 Subject: [PATCH] feat(pr-prep): read upstream CONTRIBUTING.md + surface pre-push gates per commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 1.4: fetch `CONTRIBUTING.md` (case-insensitive) via gh api from the upstream repo, cache to /tmp, extract pre-push commands + test layout conventions + branch naming rules + banned patterns. The agent uses these inline when writing PR bodies. Step 4.5: annotate each CLEAN/OVERLAP/SIBLING commit row with the required pre-push gate (e.g. `bun run verify`), whether changed files trigger special test paths (eval-replay for retrieval), and whether the commit added tests. Soft warning on missing-tests when not-required is unclear — don't block, let the human decide. Co-Authored-By: Claude Opus 4.8 (1M context) --- pr-prep/SKILL.md | 48 ++++++++++++++++++++++++++++++++++++++++++- pr-prep/SKILL.md.tmpl | 48 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 94 insertions(+), 2 deletions(-) diff --git a/pr-prep/SKILL.md b/pr-prep/SKILL.md index b96173df7..4c68433de 100644 --- a/pr-prep/SKILL.md +++ b/pr-prep/SKILL.md @@ -875,7 +875,34 @@ branch name wherever the instructions say "the base branch" or ``. 3. Resolve the upstream repo via `gh repo view --json nameWithOwner -q .nameWithOwner`. Default uses `origin`; override via `--repo owner/name`. -4. Sanity-check: at least 1 commit in `$BASE_BRANCH..HEAD`. If zero, +4. **Read the upstream `CONTRIBUTING.md` (if present)** and surface its + pre-push gates + test requirements so the agent knows what must + pass BEFORE filing. Cache to `/tmp/pr-prep-contributing.md` for + the rest of the run. + + ```bash + gh api "repos/$REPO/contents/CONTRIBUTING.md" --jq .content 2>/dev/null \ + | base64 -d > /tmp/pr-prep-contributing.md || \ + gh api "repos/$REPO/contents/contributing.md" --jq .content 2>/dev/null \ + | base64 -d > /tmp/pr-prep-contributing.md || \ + echo "" > /tmp/pr-prep-contributing.md + ``` + + Extract + echo at this step (no need to dump the whole file in the + final report — the agent uses it inline when writing PR bodies): + - Required pre-push commands (e.g. `bun run verify`, `npm test`, + `cargo test`). Look for "before pushing", "pre-push", "verify", + "must pass", "required" headings. + - Test layout conventions (where do unit / e2e / regression tests + belong). Look for "Writing tests", "test structure" sections. + - Branch naming / commit message conventions. Look for "branch + name", "commit format", "conventional commits". + - Welcomed PR areas (if listed). Skips contributions that conflict + with the repo's roadmap. + - Banned patterns (e.g. "never add to allowlist", "no new mocks", + "no breaking changes"). Treat as hard gates. + +5. Sanity-check: at least 1 commit in `$BASE_BRANCH..HEAD`. If zero, abort with "no commits to audit; you're already on $BASE_BRANCH". ```bash @@ -947,6 +974,25 @@ Final severity bucket per commit: | **SIBLING** | OPEN issues but no PR; or merged-recently with overlap | | **CLEAN** | No hits, or only old closed issues | +## Step 4.5: Surface CONTRIBUTING.md pre-push gates per commit + +For each commit that survives audit (CLEAN / OVERLAP / SIBLING — not +EXACT_DUP), check whether the changed files trigger any +CONTRIBUTING.md-stated test path. Example: a commit touching +`src/core/search/*` should run the eval-replay loop per the gbrain +CONTRIBUTING.md "Trigger paths" section. + +Annotate each CLEAN/OVERLAP/SIBLING row with: + +``` + Pre-push gate: bun run verify (from CONTRIBUTING.md) + Trigger paths matched: none (no retrieval / no special test required) + Tests added in commit: yes / no / not required +``` + +If `Tests added: no` AND `not required` is unclear, surface as a +soft warning in the report but don't block — let the human decide. + ## Step 5: Render report Markdown table per commit: diff --git a/pr-prep/SKILL.md.tmpl b/pr-prep/SKILL.md.tmpl index fe86b6399..588cc6efe 100644 --- a/pr-prep/SKILL.md.tmpl +++ b/pr-prep/SKILL.md.tmpl @@ -63,7 +63,34 @@ recommended action. 3. Resolve the upstream repo via `gh repo view --json nameWithOwner -q .nameWithOwner`. Default uses `origin`; override via `--repo owner/name`. -4. Sanity-check: at least 1 commit in `$BASE_BRANCH..HEAD`. If zero, +4. **Read the upstream `CONTRIBUTING.md` (if present)** and surface its + pre-push gates + test requirements so the agent knows what must + pass BEFORE filing. Cache to `/tmp/pr-prep-contributing.md` for + the rest of the run. + + ```bash + gh api "repos/$REPO/contents/CONTRIBUTING.md" --jq .content 2>/dev/null \ + | base64 -d > /tmp/pr-prep-contributing.md || \ + gh api "repos/$REPO/contents/contributing.md" --jq .content 2>/dev/null \ + | base64 -d > /tmp/pr-prep-contributing.md || \ + echo "" > /tmp/pr-prep-contributing.md + ``` + + Extract + echo at this step (no need to dump the whole file in the + final report — the agent uses it inline when writing PR bodies): + - Required pre-push commands (e.g. `bun run verify`, `npm test`, + `cargo test`). Look for "before pushing", "pre-push", "verify", + "must pass", "required" headings. + - Test layout conventions (where do unit / e2e / regression tests + belong). Look for "Writing tests", "test structure" sections. + - Branch naming / commit message conventions. Look for "branch + name", "commit format", "conventional commits". + - Welcomed PR areas (if listed). Skips contributions that conflict + with the repo's roadmap. + - Banned patterns (e.g. "never add to allowlist", "no new mocks", + "no breaking changes"). Treat as hard gates. + +5. Sanity-check: at least 1 commit in `$BASE_BRANCH..HEAD`. If zero, abort with "no commits to audit; you're already on $BASE_BRANCH". ```bash @@ -135,6 +162,25 @@ Final severity bucket per commit: | **SIBLING** | OPEN issues but no PR; or merged-recently with overlap | | **CLEAN** | No hits, or only old closed issues | +## Step 4.5: Surface CONTRIBUTING.md pre-push gates per commit + +For each commit that survives audit (CLEAN / OVERLAP / SIBLING — not +EXACT_DUP), check whether the changed files trigger any +CONTRIBUTING.md-stated test path. Example: a commit touching +`src/core/search/*` should run the eval-replay loop per the gbrain +CONTRIBUTING.md "Trigger paths" section. + +Annotate each CLEAN/OVERLAP/SIBLING row with: + +``` + Pre-push gate: bun run verify (from CONTRIBUTING.md) + Trigger paths matched: none (no retrieval / no special test required) + Tests added in commit: yes / no / not required +``` + +If `Tests added: no` AND `not required` is unclear, surface as a +soft warning in the report but don't block — let the human decide. + ## Step 5: Render report Markdown table per commit: