Skip to content

feat: support org-level issue/PR templates from .github repo#441

Merged
jwm4 merged 2 commits into
ambient-code:mainfrom
jwm4:feat/org-level-templates
May 18, 2026
Merged

feat: support org-level issue/PR templates from .github repo#441
jwm4 merged 2 commits into
ambient-code:mainfrom
jwm4:feat/org-level-templates

Conversation

@jwm4
Copy link
Copy Markdown
Contributor

@jwm4 jwm4 commented May 18, 2026

Summary

  • When a repository lacks local .github/ISSUE_TEMPLATE/ or PULL_REQUEST_TEMPLATE.md, the issue_pr_templates assessor now falls back to checking the GitHub organization's .github repository via the REST API
  • Uses GITHUB_TOKEN if available (for private org .github repos), works unauthenticated for public repos
  • Fails gracefully: any API error (404, timeout, no token) preserves current behavior with no regression

Closes #430

Test plan

  • 6 unit tests for _parse_github_owner (HTTPS, SSH, non-GitHub, None, empty)
  • 2 unit tests for local-only detection (no API call made when local templates exist, or when URL is missing)
  • 4 unit tests for org-level fallback (issue templates, PR template, both, partial score with 1 template)
  • 3 unit tests for graceful failure (API 404, timeout, non-GitHub URL)
  • All 20 structure assessor tests pass
  • All 953 passing unit tests still pass (14 pre-existing failures in unrelated modules)
  • Ruff lint passes
  • Manual test against kagenti/kagenti (the example from the issue)

This PR was created by Bill Murdock with assistance from Claude Code.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Template assessments now check organization-level templates when local templates are missing.
    • Enhanced issue template scoring: 2+ templates earn 50 points, 1 template earns 25 points.
    • Improved template status measurement and reporting.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@jwm4 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 56 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 50e1a9e2-6d32-415f-9e59-0a44ec071ba2

📥 Commits

Reviewing files that changed from the base of the PR and between 67ec7ec and bb08caa.

📒 Files selected for processing (2)
  • src/agentready/assessors/structure.py
  • tests/unit/test_assessors_structure.py
📝 Walkthrough

Walkthrough

The assessor now falls back to GitHub organization-level templates when a repository lacks its own .github/ISSUE_TEMPLATE/ directory. It parses the GitHub owner from the repository URL and queries the organization's .github repository via REST API to detect PR and issue templates, updating the scoring and measured value accordingly. Tests cover URL parsing, local detection without API calls, org-level fallback scenarios, and error cases.

Changes

Org-Level Template Fallback

Layer / File(s) Summary
Imports and GitHub API helper methods
src/agentready/assessors/structure.py
Import requests and add _parse_github_owner() to extract org name from repository URLs, and _check_org_templates() to query GitHub API ({owner}/.github) for org-level templates with optional token auth.
Assess method org-level fallback and remediation guidance
src/agentready/assessors/structure.py
Track issue_templates_found, score templates (≥2→50, 1→25, 0→no score), and implement fallback: fetch org-level templates when local PR or issue templates are missing. Update measured_value to unconditionally report PR:{pr_template_found}, Issues:{template_count}. Add remediation note that <org>/.github templates are recognized.
Test infrastructure, fixtures, and URL parsing tests
tests/unit/test_assessors_structure.py
Add test utilities (pytest, MagicMock, patch), TestIssuePRTemplatesAssessor class with assessor() fixture and _make_repo() helper. Test _parse_github_owner() for HTTPS (with/without .git), SSH, non-GitHub, and None/empty inputs.
Local and org-level template detection tests
tests/unit/test_assessors_structure.py
Test local template detection without API calls when .github/ exists. Test org-level fallback: issue templates found, PR templates found, both types found, and partial success (one issue template). Verify status, score, and evidence updates.
Error handling and edge case tests
tests/unit/test_assessors_structure.py
Test graceful handling of API 404 (no score change), request timeout (fail with score 0), and non-GitHub URLs (skip org checks, no HTTP call).
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title follows Conventional Commits format (feat: ...) and accurately describes the main feature: adding org-level template fallback support.
Linked Issues check ✅ Passed Code changes fully implement all requirements from #430: local template checks first [#430], org detection and .github API fallback [#430], graceful error handling [#430], and scoring logic [#430].
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing org-level template discovery: assessor logic, helper methods, and comprehensive test coverage for the feature.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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 and usage tips.

@jwm4
Copy link
Copy Markdown
Contributor Author

jwm4 commented May 18, 2026

Tested this against kagenti/kagenti (the example from issue #430). Without any GITHUB_TOKEN set, the org-level fallback works correctly for this public org .github repo: finds the PR template and 4 issue templates, scoring 100.

Evidence from the assessment:

  • "PR template found (org-level)"
  • "Issue templates found (org-level): 4 templates"

Error handling also looks solid: each API call is wrapped in try/except (requests.RequestException, ValueError) so transient failures degrade gracefully without crashing the assessment.

One minor note: config.yml (GitHub's template chooser configuration) gets counted as an issue template since the filter matches all .yml/.yaml files. In this case it doesn't affect the outcome (4 templates found either way), but it could inflate the count in edge cases.

This comment is from Bill Murdock with assistance from Claude Code.

When a repository lacks local issue or PR templates, fall back to
checking the GitHub organization's .github repository via the REST API.
This matches GitHub's own template inheritance behavior. Closes ambient-code#430.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jwm4 jwm4 force-pushed the feat/org-level-templates branch from 70188c0 to 67ec7ec Compare May 18, 2026 18:32
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

📈 Test Coverage Report

Branch Coverage
This PR 73.6%
Main 73.3%
Diff ✅ +0.3%

Coverage calculated from unit tests only

@jwm4 jwm4 merged commit 0117161 into ambient-code:main May 18, 2026
6 checks passed
@jwm4 jwm4 deleted the feat/org-level-templates branch May 18, 2026 18:46
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.38.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support org-level issue templates from .github repo

1 participant