Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 22, 2025

Adds add-reviewer safe output type enabling AI agents to programmatically add reviewers to pull requests with filtering and targeting controls.

Changes

Schema & Types

  • Added AddReviewerOutput schema with reviewers array and optional pull_request_number
  • Created TypeScript interfaces: AddReviewerItem and AddReviewerConfig
  • Added add_reviewer tool signature to MCP server tools

JavaScript Implementation (pkg/workflow/js/add_reviewer.cjs)

  • Processes validated JSONL output to add reviewers via GitHub API
  • Filters by optional allowed reviewers list
  • Enforces configurable max count (default: 3)
  • Supports target modes: "triggering" (default), "*" (any PR), or explicit PR number
  • Special handling for "copilot" reviewer → copilot-pull-request-reviewer[bot]
  • Staged mode preview for testing
  • Validates usernames to 39 characters (GitHub limit)

Go Implementation

  • Job builder in pkg/workflow/add_reviewer.go using shared buildSafeOutputJob() pattern
  • Configuration parsing in safe_outputs.go with schema integration
  • Wired into compiler job creation pipeline
  • Added to MCP tools filter for conditional exposure

Configuration Example

safe-outputs:
  add-reviewer:
    reviewers: ["octocat", "mona"]  # Optional allowlist
    max: 5                          # Optional, default: 3
    target: "triggering"            # triggering | * | PR number
    target-repo: "org/other-repo"   # Optional cross-repo

Testing

  • 10 JavaScript unit tests covering filtering, limits, staging, error handling
  • Updated Go unit tests for tools registration
  • Test workflow: pkg/cli/workflows/test-copilot-add-reviewer.md

Implementation Notes

Reuses reviewer addition patterns from create-pull-request job builder. Follows established safe output architecture with validation pipeline: JSON Schema → TypeScript types → JSONL collection → Go job generation.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login t.go go integration_test.go test.go on_test.go _test.go always_declared_test.go (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Add a "add-reviewer" safe output that adds a reviewer to a pull request.

  • reuse code from create-pull-request to add reviewer
  • infer pull request from context or through fields
  • support filters to limit pull requests like other safe outputs

Custom agent used: add-safe-output-type
Adding a New Safe Output Type to GitHub Agentic Workflows


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 22, 2025
Copilot AI and others added 9 commits November 22, 2025 16:57
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…implementation for add-reviewer safe output

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…d-reviewer safe output

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ix nil checks, optimize reviewer processing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add add-reviewer safe output to add reviewers Add add-reviewer safe output for automated PR reviewer management Nov 22, 2025
Copilot AI requested a review from pelikhan November 22, 2025 17:41
Copilot finished work on behalf of pelikhan November 22, 2025 17:41
@pelikhan pelikhan marked this pull request as ready for review November 22, 2025 18:55
Copilot AI review requested due to automatic review settings November 22, 2025 18:55
Copilot finished reviewing on behalf of pelikhan November 22, 2025 18:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new add-reviewer safe output type to GitHub Agentic Workflows, enabling AI agents to programmatically add reviewers to pull requests with filtering and targeting controls.

Key Changes

  • Implemented complete add-reviewer safe output with schema validation, JavaScript execution, and Go integration
  • Added support for reviewer filtering via allowlist, configurable max count (default: 3), and target modes (triggering/any PR/explicit number)
  • Special handling for "copilot" reviewer which maps to copilot-pull-request-reviewer[bot]

Reviewed changes

Copilot reviewed 93 out of 95 changed files in this pull request and generated no comments.

Show a summary per file
File Description
schemas/agent-output.json Added AddReviewerOutput schema definition with reviewers array and optional pull_request_number
pkg/workflow/js/add_reviewer.cjs Main JavaScript implementation with filtering, deduplication, and GitHub API integration
pkg/workflow/js/add_reviewer.test.cjs Comprehensive unit tests covering filtering, limits, staging, and error scenarios
pkg/workflow/add_reviewer.go Go job builder and configuration parser following established safe output patterns
pkg/workflow/safe_outputs.go Integration of add-reviewer into safe outputs configuration and MCP tools
pkg/workflow/compiler_jobs.go Wiring of add-reviewer job into compilation pipeline
pkg/workflow/js/collect_ndjson_output.cjs Validation logic for add_reviewer output with username length enforcement
pkg/workflow/js/safe_outputs_tools.json MCP tool signature for add_reviewer
pkg/parser/schemas/main_workflow_schema.json Frontmatter schema for add-reviewer configuration
docs/src/content/docs/reference/frontmatter-full.md Documentation for add-reviewer configuration options
.github/workflows/*.lock.yml Updated compiled workflows with new validation constant
pkg/workflow/scripts.go Script bundling setup for add_reviewer.cjs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pelikhan pelikhan merged commit ab3d651 into main Nov 22, 2025
104 checks passed
@pelikhan pelikhan deleted the copilot/add-reviewer-safe-output branch November 22, 2025 19:11
github-actions bot added a commit that referenced this pull request Nov 23, 2025
Add documentation for three new safe output types merged in the last 24 hours:

- close-issue: Close GitHub issues with comment and state reason filtering
- add-reviewer: Add reviewers to pull requests with allowlist support
- close-pull-request: Close PRs without merging with label/title filtering

Changes made:
- Added entries to safe outputs table in reference documentation
- Added detailed configuration sections for each new safe output type
- Included examples with all configuration options
- Documented target modes, filtering options, and cross-repo support

Features documented from:
- PR #4568: close-pull-request safe output
- PR #4564: add-reviewer safe output
- PR #4554: close-issue safe output

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

2 participants