Conversation
Co-authored-by: blackboxprogramming <118287761+blackboxprogramming@users.noreply.github.com>
Co-authored-by: blackboxprogramming <118287761+blackboxprogramming@users.noreply.github.com>
Co-authored-by: blackboxprogramming <118287761+blackboxprogramming@users.noreply.github.com>
Co-authored-by: blackboxprogramming <118287761+blackboxprogramming@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an automated PR triage/management workflow plus supporting CLI tooling and documentation to standardize how PRs in this repo are labeled, reviewed, and tracked.
Changes:
- Introduces a new GitHub Actions workflow to analyze PRs and apply labels/comments/reviewer requests.
- Adds a
scripts/pr_manager.pyCLI (demo-data based) andscripts/README.mdusage docs. - Adds PR management documentation (
PR_MANAGEMENT.md,PR_HANDLER_SUMMARY.md) and updatesTODO.md.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/pr-handler.yml |
New PR handler workflow for analysis, labeling, commenting, reviewer requests, and merge-readiness checks. |
scripts/pr_manager.py |
New CLI script skeleton for listing/inspecting/labeling/reviewing/merging PRs (currently demo-oriented). |
scripts/README.md |
Documents the PR manager script usage and intended feature set. |
PR_MANAGEMENT.md |
Describes PR lifecycle, labels, and operational process for maintainers. |
PR_HANDLER_SUMMARY.md |
High-level summary of the PR handler system and its intended capabilities. |
TODO.md |
Marks PR handler workflow + CLI as completed DevOps items. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Usage: | ||
| ./pr_manager.py list # List all open PRs | ||
| ./pr_manager.py show <number> # Show PR details | ||
| ./pr_manager.py label <number> <label> # Add label to PR | ||
| ./pr_manager.py review <number> # Request review | ||
| ./pr_manager.py merge <number> # Merge PR (if ready) | ||
| ./pr_manager.py status # Show PR statistics |
There was a problem hiding this comment.
The usage examples in the module docstring reference ./pr_manager.py ..., but the script is located under scripts/pr_manager.py. Update the examples to use the correct path (or clarify that users should cd scripts first) to avoid broken copy/paste commands.
| Usage: | |
| ./pr_manager.py list # List all open PRs | |
| ./pr_manager.py show <number> # Show PR details | |
| ./pr_manager.py label <number> <label> # Add label to PR | |
| ./pr_manager.py review <number> # Request review | |
| ./pr_manager.py merge <number> # Merge PR (if ready) | |
| ./pr_manager.py status # Show PR statistics | |
| Usage (from the repository root): | |
| python scripts/pr_manager.py list # List all open PRs | |
| python scripts/pr_manager.py show <number> # Show PR details | |
| python scripts/pr_manager.py label <number> <label> # Add label to PR | |
| python scripts/pr_manager.py review <number> # Request review | |
| python scripts/pr_manager.py merge <number> # Merge PR (if ready) | |
| python scripts/pr_manager.py status # Show PR statistics |
| // Apply labels | ||
| if (labels.length > 0) { | ||
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, |
There was a problem hiding this comment.
The workflow_dispatch path will fail because this job uses context.issue.number, which is undefined for workflow_dispatch events. Consider setting an explicit PR number output in analyze-pr (e.g., pr_number) and using that for issue_number/pull_number across label/comment/reviewer steps when github.event_name == 'workflow_dispatch'.
| // Apply labels | |
| if (labels.length > 0) { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| // Determine PR number (supports both pull_request and workflow_dispatch) | |
| const prNumber = context.eventName === 'workflow_dispatch' | |
| ? Number(context.payload && context.payload.inputs && context.payload.inputs.pr_number) | |
| : (context.issue && context.issue.number); | |
| // Apply labels | |
| if (labels.length > 0 && prNumber) { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, |
| const orgsFound = orgPatterns.filter(org => | ||
| title.includes(org) || body.includes(org) | ||
| ); |
There was a problem hiding this comment.
Org scope detection won’t match because title is lowercased but orgPatterns contain mixed-case strings, and body.includes(org) is case-sensitive. Normalize both title/body and patterns to the same case before matching so org_scope labels are applied correctly.
| const orgsFound = orgPatterns.filter(org => | |
| title.includes(org) || body.includes(org) | |
| ); | |
| const bodyLower = body.toLowerCase(); | |
| const orgPatternsLower = orgPatterns.map(org => org.toLowerCase()); | |
| const orgsFound = orgPatterns.filter((org, index) => { | |
| const orgLower = orgPatternsLower[index]; | |
| return title.includes(orgLower) || bodyLower.includes(orgLower); | |
| }); |
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| labels: labels | ||
| }); |
There was a problem hiding this comment.
Applying labels will fail the step if any label doesn’t already exist in the repo (GitHub API returns 422). Since org labels are dynamically generated (e.g., org:foundation, org:enterprises), consider either creating missing labels first or wrapping addLabels in try/catch and only applying labels that exist.
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| labels: labels | |
| }); | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| // Fetch all existing labels in the repo to avoid 422 on non-existent labels | |
| const existingLabels = await github.paginate( | |
| github.rest.issues.listLabelsForRepo, | |
| { owner, repo } | |
| ); | |
| const existingLabelNames = new Set(existingLabels.map(l => l.name)); | |
| const validLabels = labels.filter(label => existingLabelNames.has(label)); | |
| if (validLabels.length > 0) { | |
| await github.rest.issues.addLabels({ | |
| owner, | |
| repo, | |
| issue_number: context.issue.number, | |
| labels: validLabels | |
| }); | |
| } |
| const pr = context.payload.pull_request; | ||
|
|
||
| // Check CI status | ||
| const checks = await github.rest.checks.listForRef({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| ref: pr.head.sha | ||
| }); | ||
|
|
||
| const allPassed = checks.data.check_runs.every(check => | ||
| check.conclusion === 'success' || check.conclusion === 'skipped' | ||
| ); | ||
|
|
||
| if (allPassed && pr.mergeable) { | ||
| await github.rest.issues.createComment({ |
There was a problem hiding this comment.
This job assumes context.payload.pull_request exists, but it will be undefined for workflow_dispatch runs even if can_auto_merge is true, causing a runtime error. Also, check_runs.every(...) returns true when there are zero checks, which could incorrectly report “ready to merge”; ensure at least one relevant check run exists (or query required checks) before declaring success.
| // Check if WIP | ||
| const isWIP = pr.title.includes('[WIP]') || pr.title.includes('WIP:') || pr.draft; | ||
| core.setOutput('is_wip', isWIP); | ||
|
|
||
| // Determine PR type based on title and files | ||
| let prType = 'other'; | ||
| const title = pr.title.toLowerCase(); |
There was a problem hiding this comment.
WIP detection is case-sensitive (e.g., '[WIP]' and 'WIP:' only). If titles use '[wip]' or 'wip:' they’ll be treated as ready-for-review. Consider using a case-insensitive match (lowercasing the title first) to make this robust.
| // Check if WIP | |
| const isWIP = pr.title.includes('[WIP]') || pr.title.includes('WIP:') || pr.draft; | |
| core.setOutput('is_wip', isWIP); | |
| // Determine PR type based on title and files | |
| let prType = 'other'; | |
| const title = pr.title.toLowerCase(); | |
| // Check if WIP (case-insensitive) | |
| const lowerTitle = pr.title.toLowerCase(); | |
| const isWIP = lowerTitle.includes('[wip]') || lowerTitle.includes('wip:') || pr.draft; | |
| core.setOutput('is_wip', isWIP); | |
| // Determine PR type based on title and files | |
| let prType = 'other'; | |
| const title = lowerTitle; |
| import json | ||
| import os | ||
| import sys | ||
| from datetime import datetime | ||
| from typing import Dict, List, Optional |
There was a problem hiding this comment.
There are several unused imports here (json, os, sys, datetime, List, Optional). Since this file is user-facing CLI tooling, keeping imports minimal reduces lint noise and avoids implying functionality that isn’t implemented yet.
| import json | |
| import os | |
| import sys | |
| from datetime import datetime | |
| from typing import Dict, List, Optional | |
| from typing import Dict |
| ### Auto-Merge Eligible | ||
| PRs from `copilot/**` branches can auto-merge when: | ||
| - Not marked as draft or WIP | ||
| - All CI checks pass | ||
| - No merge conflicts | ||
| - At least one approval (if required) | ||
|
|
There was a problem hiding this comment.
This section describes “Auto-Merge Eligible” behavior, but the workflow as implemented only comments on merge readiness and never actually enables/executes auto-merge. Either update the docs to reflect the current behavior, or implement the auto-merge action/enablement that this section promises.
| - Show detailed PR information | ||
| - Add labels to PRs | ||
| - Request reviews | ||
| - Merge PRs with safety checks |
There was a problem hiding this comment.
This README claims the PR manager can “Merge PRs with safety checks”, but the script currently only prints a gh pr merge ... command and a reminder; it doesn’t perform or verify checks. Either adjust the README wording to match current behavior, or implement actual pre-merge validation (e.g., check status/mergeability via gh/API) before offering the merge command.
| - Merge PRs with safety checks | |
| - Assist with merging PRs by generating merge commands and safety-check reminders |
| ## Current Open PRs | ||
|
|
||
| ### High Priority | ||
|
|
||
| #### PR #7: Update MEMORY.md | ||
| - **Status**: Ready for review (not draft) | ||
| - **Type**: Documentation update | ||
| - **Summary**: Marks completed roadmap items through dispatcher | ||
| - **Changes**: 1101 additions, 5 deletions, 6 files | ||
| - **Action Needed**: Final review and merge | ||
|
|
||
| #### PR #12: Add CLAUDE.md | ||
| - **Status**: Draft | ||
| - **Type**: Documentation | ||
| - **Summary**: AI assistant guide for BlackRoad Bridge | ||
| - **Changes**: 340 additions, 1 file | ||
| - **Action Needed**: Finalize and mark ready for review | ||
|
|
||
| ### Infrastructure & Testing | ||
|
|
||
| #### PR #2: Infrastructure Setup | ||
| - **Status**: Ready for review (not draft) | ||
| - **Type**: Infrastructure | ||
| - **Summary**: Testing, CI/CD, auto-merge, Claude Code API integration | ||
| - **Changes**: 7267 additions, 21 deletions, 38 files | ||
| - **Scope**: Comprehensive testing framework (97 tests, 73% coverage) | ||
| - **Action Needed**: Review and merge - foundational infrastructure | ||
|
|
||
| ### Feature Development | ||
|
|
||
| #### PR #3: Wiki Documentation | ||
| - **Status**: Draft | ||
| - **Type**: Documentation | ||
| - **Summary**: Comprehensive Wiki documentation structure (27 pages, 3,522 lines) | ||
| - **Changes**: 3853 additions, 30 files | ||
| - **Action Needed**: Review wiki structure and publishing plan | ||
|
|
||
| #### PR #4: AI Agent Codespace | ||
| - **Status**: Ready for review (not draft) | ||
| - **Type**: AI Feature | ||
| - **Summary**: Collaborative AI agent codespace with open source models | ||
| - **Changes**: 3771 additions, 1 deletion, 23 files | ||
| - **Action Needed**: Test agent collaboration features | ||
|
|
||
| #### PR #5: Org Sync System | ||
| - **Status**: Ready for review (not draft) [WIP in title] | ||
| - **Type**: Infrastructure | ||
| - **Summary**: Updates pushing to other orgs and repos | ||
| - **Changes**: 1216 additions, 2 deletions, 8 files | ||
| - **Action Needed**: Complete security scan | ||
|
|
||
| #### PR #6: Collaboration & Memory | ||
| - **Status**: Ready for review (not draft) [WIP in title] | ||
| - **Type**: Core Feature | ||
| - **Summary**: Collaboration and memory functions for sessions | ||
| - **Changes**: 3665 additions, 15 files | ||
| - **Action Needed**: Update main Bridge documentation | ||
|
|
||
| ### Current PR (This One) | ||
|
|
||
| #### PR #18: Handle Incoming PRs | ||
| - **Status**: Work in Progress | ||
| - **Type**: Workflow/Automation | ||
| - **Summary**: PR handling workflow and management system | ||
| - **Action Needed**: Complete implementation | ||
|
|
There was a problem hiding this comment.
The “Current Open PRs” section is a static snapshot of PR numbers, diffs, and statuses that will become stale quickly and can mislead readers. Consider moving this to a generated report (e.g., produced by the script/workflow and updated automatically) or removing the snapshot and documenting the process instead.
| ## Current Open PRs | |
| ### High Priority | |
| #### PR #7: Update MEMORY.md | |
| - **Status**: Ready for review (not draft) | |
| - **Type**: Documentation update | |
| - **Summary**: Marks completed roadmap items through dispatcher | |
| - **Changes**: 1101 additions, 5 deletions, 6 files | |
| - **Action Needed**: Final review and merge | |
| #### PR #12: Add CLAUDE.md | |
| - **Status**: Draft | |
| - **Type**: Documentation | |
| - **Summary**: AI assistant guide for BlackRoad Bridge | |
| - **Changes**: 340 additions, 1 file | |
| - **Action Needed**: Finalize and mark ready for review | |
| ### Infrastructure & Testing | |
| #### PR #2: Infrastructure Setup | |
| - **Status**: Ready for review (not draft) | |
| - **Type**: Infrastructure | |
| - **Summary**: Testing, CI/CD, auto-merge, Claude Code API integration | |
| - **Changes**: 7267 additions, 21 deletions, 38 files | |
| - **Scope**: Comprehensive testing framework (97 tests, 73% coverage) | |
| - **Action Needed**: Review and merge - foundational infrastructure | |
| ### Feature Development | |
| #### PR #3: Wiki Documentation | |
| - **Status**: Draft | |
| - **Type**: Documentation | |
| - **Summary**: Comprehensive Wiki documentation structure (27 pages, 3,522 lines) | |
| - **Changes**: 3853 additions, 30 files | |
| - **Action Needed**: Review wiki structure and publishing plan | |
| #### PR #4: AI Agent Codespace | |
| - **Status**: Ready for review (not draft) | |
| - **Type**: AI Feature | |
| - **Summary**: Collaborative AI agent codespace with open source models | |
| - **Changes**: 3771 additions, 1 deletion, 23 files | |
| - **Action Needed**: Test agent collaboration features | |
| #### PR #5: Org Sync System | |
| - **Status**: Ready for review (not draft) [WIP in title] | |
| - **Type**: Infrastructure | |
| - **Summary**: Updates pushing to other orgs and repos | |
| - **Changes**: 1216 additions, 2 deletions, 8 files | |
| - **Action Needed**: Complete security scan | |
| #### PR #6: Collaboration & Memory | |
| - **Status**: Ready for review (not draft) [WIP in title] | |
| - **Type**: Core Feature | |
| - **Summary**: Collaboration and memory functions for sessions | |
| - **Changes**: 3665 additions, 15 files | |
| - **Action Needed**: Update main Bridge documentation | |
| ### Current PR (This One) | |
| #### PR #18: Handle Incoming PRs | |
| - **Status**: Work in Progress | |
| - **Type**: Workflow/Automation | |
| - **Summary**: PR handling workflow and management system | |
| - **Action Needed**: Complete implementation | |
| ## Viewing Current Open PRs | |
| The PR Handler is designed to keep labels and statuses on pull requests up to date. | |
| Instead of maintaining a static list of “current” PRs in this document (which | |
| would quickly become stale), use GitHub’s live views or generated reports. | |
| ### In GitHub UI | |
| To see the current state of open PRs in this repository: | |
| 1. Go to the **Pull requests** tab. | |
| 2. Use filters such as: | |
| - `is:open is:pr` | |
| - `is:open is:pr label:"ready-for-review"` | |
| - `is:open is:pr label:"work-in-progress"` | |
| - `is:open is:pr label:"type:workflow"` (or other type labels) | |
| 3. Save commonly used filter queries as **custom views** in the GitHub UI. | |
| ### Example Saved Searches | |
| - **High-priority review queue** | |
| `is:open is:pr label:"ready-for-review" sort:updated-desc` | |
| - **Infrastructure and testing PRs** | |
| `is:open is:pr label:"type:infrastructure" sort:created-desc` | |
| `is:open is:pr label:"type:testing" sort:created-desc` | |
| - **Feature development PRs** | |
| `is:open is:pr label:"type:core-feature" sort:updated-desc` | |
| `is:open is:pr label:"type:ai-feature" sort:updated-desc` | |
| ### Generated Reports (Optional) | |
| If you configure a workflow to generate a PR status report (for example, as | |
| a Markdown file or dashboard artifact), reference that report from here | |
| instead of listing specific PR numbers. For instance: | |
| - Link to a regularly updated `PR_STATUS.md` generated by CI. | |
| - Link to a dashboard that aggregates open PRs and their labels. | |
| This keeps the documentation accurate over time while avoiding hardcoded, | |
| quickly outdated snapshots of open pull requests. |
The repository lacked systematic PR handling infrastructure. With 8 open PRs spanning workflows, features, and documentation, manual triage was inefficient and inconsistent.
Implementation
Automated Workflow (
.github/workflows/pr-handler.yml)CLI Tool (
scripts/pr_manager.py)Documentation (
PR_MANAGEMENT.md,PR_HANDLER_SUMMARY.md)Label System
Type:
workflows|documentation|testing|infrastructure|ai-enhancement|enhancementStatus:
work-in-progress|ready-for-review|needs-changes|approvedOrg:
org:os|org:ai|org:cloud|multi-org|all-orgsNotes
CLI tool uses demo data; production integration requires GitHub API (PyGithub or gh CLI). Structure and commands are production-ready.
Workflow complements existing
pr-review.yml(code quality) andintelligent-auto-pr.yml(automated PRs) without overlap.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.