Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 22, 2025

Moves 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 provides immediate error feedback when no changes exist, rather than discovering it later in processing jobs.

Implementation

  • MCP Server (safe_outputs_mcp_server.cjs)

    • Added generateGitPatch() with two strategies: named branch and HEAD commits
    • Handlers throw errors immediately if patch is empty or generation fails
    • Returns patch metadata (path, size, lines) on success
  • Workflow Compilation (git_patch.go, compiler_yaml.go)

    • Removed patch generation step from main job
    • Retained upload artifact step for processing job compatibility
    • Updated generateGitPatchStep()generateGitPatchUploadStep()
  • Tests

    • Added safe_outputs_mcp_server_patch.test.cjs with 217 lines of coverage
    • Updated existing tests to expect no generation step in main job

Error Flow

Before:

AI execution → (always) generate patch → upload artifact → processing job discovers empty patch

After:

AI execution → tool call → generate patch (fails fast if empty) → upload artifact → processing job

Error messages throw at tool invocation:

  • "No changes to commit - patch is empty"
  • "Failed to generate patch: [details]"

Backward Compatibility

Processing jobs continue downloading aw.patch artifact as before. Upload step runs if: 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
    • Triggering command: /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

Refactor the aw.patch patch generation to JavaScript in the safe output MCP server. Generate the patch when the tool is called. Report error when the patch is empty.

Remove dedicated step to generate patch.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits November 22, 2025 20:59
- 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
Copilot finished work on behalf of pelikhan November 22, 2025 21:14
Copilot AI requested a review from pelikhan November 22, 2025 21:14
@github-actions
Copy link
Contributor

github-actions bot commented Nov 22, 2025

✅ Agentic Changeset Generator completed successfully.

@pelikhan pelikhan marked this pull request as ready for review November 22, 2025 22:13
Copilot AI review requested due to automatic review settings November 22, 2025 22:13
Copilot finished reviewing on behalf of pelikhan November 22, 2025 22:15
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 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.

@pelikhan pelikhan merged commit 3df7a3e into main Nov 22, 2025
22 checks passed
@pelikhan pelikhan deleted the copilot/refactor-patch-generation-js branch November 22, 2025 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants