Skip to content

feat: Implement IssuePRTemplatesAssessor #84

@jeremyeder

Description

@jeremyeder

feat: Implement IssuePRTemplatesAssessor

Attribute Definition

Attribute ID: issue_pr_templates (Attribute #23 - Tier 3)

Definition: Standardized templates for issues and PRs in .github/ directory.

Why It Matters: Templates provide structure for AI when creating issues or PRs. Ensures all necessary context is provided consistently.

Impact on Agent Behavior:

  • Automatically fills templates when creating PRs
  • Ensures checklist completion
  • Consistent issue reporting format
  • Better context for understanding existing issues/PRs

Measurable Criteria:

  • PULL_REQUEST_TEMPLATE.md in .github/ or root
  • Issue templates in .github/ISSUE_TEMPLATE/
  • PR template includes:
  • Issue templates for:
    • Bug reports (with reproduction steps)
    • Feature requests (with use case)
    • Questions/discussions

Implementation Requirements

File Location: src/agentready/assessors/structure.py

Class Name: IssuePRTemplatesAssessor

Tier: 3 (Important)

Default Weight: 0.015 (1.5% of total score)

Assessment Logic

Scoring Approach: Check for template files in .github/ directory

Evidence to Check (score components):

  1. PR template exists (50%)

    • Check for: .github/PULL_REQUEST_TEMPLATE.md, PULL_REQUEST_TEMPLATE.md, .github/pull_request_template.md
  2. Issue templates exist (50%)

    • Check for: .github/ISSUE_TEMPLATE/ directory
    • Count issue templates (bug_report.md, feature_request.md, etc.)
    • Minimum: 2 templates (bug + feature)

Scoring Logic:

pr_template_score = 50 if pr_template_exists else 0

if issue_template_dir_exists:
    template_count = len(issue_templates)
    if template_count >= 2:
        issue_template_score = 50
    elif template_count == 1:
        issue_template_score = 25
    else:
        issue_template_score = 0
else:
    issue_template_score = 0

total_score = pr_template_score + issue_template_score

status = "pass" if total_score >= 75 else "fail"

Code Pattern to Follow

Reference: PreCommitHooksAssessor for file existence check

Pattern:

  1. Check for .github/ directory
  2. Look for PR template in multiple locations
  3. Check for ISSUE_TEMPLATE/ directory
  4. Count issue template files
  5. Calculate binary/proportional score
  6. Provide remediation with examples

Example Finding Responses

Pass (Score: 100)

Finding(
    attribute=self.attribute,
    status="pass",
    score=100.0,
    measured_value="PR + 3 issue templates",
    threshold="PR template + 2 issue templates",
    evidence=[
        "PR template found: .github/PULL_REQUEST_TEMPLATE.md",
        "Issue template directory: .github/ISSUE_TEMPLATE/",
        "3 issue templates: bug_report.md, feature_request.md, question.md",
    ],
    remediation=None,
    error_message=None,
)

Fail (Score: 50)

Finding(
    attribute=self.attribute,
    status="fail",
    score=50.0,
    measured_value="PR template only",
    threshold="PR template + 2 issue templates",
    evidence=[
        "PR template found: .github/PULL_REQUEST_TEMPLATE.md",
        "No issue template directory found",
    ],
    remediation=self._create_remediation(),
    error_message=None,
)

Fail (Score: 0)

Finding(
    attribute=self.attribute,
    status="fail",
    score=0.0,
    measured_value="no templates",
    threshold="PR template + issue templates",
    evidence=[
        "No PR template found",
        "No issue template directory found",
    ],
    remediation=self._create_remediation(),
    error_message=None,
)

Registration

Add to src/agentready/services/scanner.py in create_all_assessors():

from ..assessors.structure import (
    StandardLayoutAssessor,
    GitignoreCompletenessAssessor,
    IssuePRTemplatesAssessor,  # Add this import
)

def create_all_assessors() -> List[BaseAssessor]:
    return [
        # ... existing assessors ...
        IssuePRTemplatesAssessor(),  # Add this line
    ]

Testing Guidance

Test File: tests/unit/test_assessors_structure.py

Test Cases to Add:

  1. test_templates_pass_both_present: PR + multiple issue templates
  2. test_templates_fail_pr_only: PR template but no issue templates
  3. test_templates_fail_issue_only: Issue templates but no PR template
  4. test_templates_fail_none: No templates at all
  5. test_templates_partial_one_issue: PR + only 1 issue template

Note: AgentReady has GITHUB_ISSUES.md but no formal templates yet (opportunity for improvement).

Dependencies

External Tools: None (file system check only)

Python Standard Library:

  • pathlib.Path for file/directory checks

Remediation Steps

def _create_remediation(self) -> Remediation:
    return Remediation(
        summary="Create issue and PR templates for consistent contributions",
        steps=[
            "Create .github/ directory",
            "Add PULL_REQUEST_TEMPLATE.md with checklist",
            "Create .github/ISSUE_TEMPLATE/ directory",
            "Add bug_report.md template",
            "Add feature_request.md template",
            "Optionally add question.md or config.yml",
        ],
        tools=[],
        commands=[
            "# Create directory structure",
            "mkdir -p .github/ISSUE_TEMPLATE",
            "",
            "# Create PR template",
            "touch .github/PULL_REQUEST_TEMPLATE.md",
            "",
            "# Create issue templates",
            "touch .github/ISSUE_TEMPLATE/bug_report.md",
            "touch .github/ISSUE_TEMPLATE/feature_request.md",
        ],
        examples=[
            """# .github/PULL_REQUEST_TEMPLATE.md

## Summary
<!-- Brief description of changes -->

## Related Issues
<!-- Fixes #123, Closes #456 -->

## Changes Made
-
-
-

## Testing Performed
- [ ] Unit tests added/updated
- [ ] Integration tests pass
- [ ] Manual testing completed

## Checklist
- [ ] Code follows project style guidelines
- [ ] Tests added for new functionality
- [ ] Documentation updated
- [ ] No breaking changes (or documented if necessary)
- [ ] All CI checks passing
""",
            """# .github/ISSUE_TEMPLATE/bug_report.md

---
name: Bug Report
about: Create a report to help us improve
title: '[BUG] '
labels: bug
assignees: ''
---

## Describe the Bug
A clear and concise description of what the bug is.

## To Reproduce
Steps to reproduce the behavior:
1.
2.
3.

## Expected Behavior
What you expected to happen.

## Actual Behavior
What actually happened.

## Environment
- OS: [e.g., macOS, Ubuntu]
- Version: [e.g., 1.2.3]
- Python/Node version: [e.g., 3.11]

## Additional Context
Add any other context about the problem here.
""",
            """# .github/ISSUE_TEMPLATE/feature_request.md

---
name: Feature Request
about: Suggest an idea for this project
title: '[FEATURE] '
labels: enhancement
assignees: ''
---

## Feature Description
Clear description of the feature you'd like to see.

## Use Case
Explain the problem this feature would solve.

## Proposed Solution
How you envision this feature working.

## Alternatives Considered
Other approaches you've thought about.

## Additional Context
Any other context, mockups, or examples.
""",
        ],
        citations=[
            Citation(
                source="GitHub Docs",
                title="About issue and pull request templates",
                url="https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/about-issue-and-pull-request-templates",
                relevance="Official GitHub documentation on templates",
            ),
        ],
    )

Implementation Notes

  1. PR Template Locations: Check multiple paths in priority order:
    • .github/PULL_REQUEST_TEMPLATE.md
    • PULL_REQUEST_TEMPLATE.md
    • .github/pull_request_template.md
  2. Issue Template Detection: Check for .github/ISSUE_TEMPLATE/ directory
  3. Template Counting: Use .glob("*.md") to count issue templates
  4. Scoring: 50% for PR template, 50% for issue templates (≥2)
  5. Edge Cases: Return partial score for 1 issue template (25%)
  6. Not Applicable: Never (all repos benefit from templates)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions