Refactor patch generation from workflow step to MCP server#4570
Merged
Refactor patch generation from workflow step to MCP server#4570
Conversation
- Move git patch generation from dedicated workflow step to MCP server - Generate patch when create_pull_request or push_to_pull_request_branch tools are called - Report error immediately when patch is empty (no changes) - Keep upload artifact step for backward compatibility with processing jobs - Update tests to reflect new behavior Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add comprehensive test suite for patch generation logic - Test empty patch detection and error handling - Test successful patch generation response structure - Test git command patterns and error messages - All tests pass successfully Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Run make fmt to format code - Run make agent-finish for full validation - All 87 workflows recompiled successfully - All tests pass, no lint errors Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor patch generation to JavaScript in MCP server
Refactor patch generation from workflow step to MCP server
Nov 22, 2025
Contributor
|
✅ Agentic Changeset Generator completed successfully. |
pelikhan
approved these changes
Nov 22, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors git patch generation from a dedicated workflow step to the safe-outputs MCP server, where it executes when create_pull_request or push_to_pull_request_branch tools are called. This architectural change enables immediate error feedback when no changes exist, rather than discovering it later in processing jobs.
Key changes:
- Adds
generateGitPatch()function to the MCP server with two strategies (named branch and HEAD commits) - Handlers throw errors immediately if patch is empty or generation fails
- Removes the "Generate git patch" workflow step from main job
- Retains upload artifact step for backward compatibility with processing jobs
Reviewed changes
Copilot reviewed 85 out of 85 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/js/safe_outputs_mcp_server.cjs |
Added generateGitPatch() function with two fallback strategies and integration into create/push handlers |
pkg/workflow/js/safe_outputs_mcp_server_patch.test.cjs |
New test file with 217 lines covering patch generation logic, error handling, and git command patterns |
pkg/workflow/git_patch.go |
Renamed function from generateGitPatchStep() to generateGitPatchUploadStep() and removed patch generation logic |
pkg/workflow/compiler_yaml.go |
Updated function call and added explanatory comments about the architectural change |
pkg/workflow/git_patch_test.go |
Updated test expectations to verify patch generation step is NOT in main job |
pkg/workflow/patch_generation_test.go |
Updated test expectations and comments to reflect MCP server architecture |
.github/workflows/*.lock.yml |
Multiple compiled workflows now include the generateGitPatch() function and no longer have the "Generate git patch" step |
.changeset/patch-refactor-patch-generation-to-mcp-server.md |
Changeset documenting the refactoring |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves git patch generation from a dedicated workflow step to the safe-outputs MCP server, where it executes when
create_pull_requestorpush_to_pull_request_branchtools are called. This provides immediate error feedback when no changes exist, rather than discovering it later in processing jobs.Implementation
MCP Server (
safe_outputs_mcp_server.cjs)generateGitPatch()with two strategies: named branch and HEAD commitsWorkflow Compilation (
git_patch.go,compiler_yaml.go)generateGitPatchStep()→generateGitPatchUploadStep()Tests
safe_outputs_mcp_server_patch.test.cjswith 217 lines of coverageError Flow
Before:
After:
Error messages throw at tool invocation:
Backward Compatibility
Processing jobs continue downloading
aw.patchartifact as before. Upload step runsif: always()regardless of patch existence.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/usr/bin/gh gh api user --jq .login(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.