Skip to content

Add fix command for automatic codemod-style migrations of deprecated workflow fields#6367

Merged
pelikhan merged 11 commits intomainfrom
copilot/add-fix-command-for-codemods
Dec 14, 2025
Merged

Add fix command for automatic codemod-style migrations of deprecated workflow fields#6367
pelikhan merged 11 commits intomainfrom
copilot/add-fix-command-for-codemods

Conversation

Copy link
Contributor

Copilot AI commented Dec 13, 2025

Implementation Plan for gh aw fix Command

  • Create fix_command.go with command structure and CLI implementation
  • Implement codemod registry system for managing fixes
  • Create codemod for timeout_minutestimeout-minutes field rename
  • Create codemod for network.firewallsandbox.agent migration
  • Add tests for fix command functionality
  • Add tests for each codemod transformation
  • Integrate fix command into main CLI (cmd/gh-aw/main.go)
  • Test manually with sample workflows
  • Run validation (build, test-unit, fmt, lint all pass)
  • Address code review feedback round 1 (extract duplicated constants and helper function)
  • Address code review feedback round 2 (add getCodemodByID helper and fix indentation check)
  • Add Makefile target make fix to run gh aw fix --write
  • Integrate fix target into agent-finish workflow
  • Merge main branch
  • Add codemod for on.commandon.slash_command migration
  • Add agent prompt output when --write is not selected
  • Add --fix flag to compile command
  • Enable --fix flag in MCP server compile tool
  • Fix firewall codemod logic to map values correctly
  • Add version tracking to codemods
  • Run lint and fix tests
  • Merge main branch again with latest changes

Summary

Successfully implemented the gh aw fix command that applies automatic codemod-style fixes to agentic workflow markdown files. The implementation includes:

Features:

  • Registry of codemods for managing deprecated field migrations
  • Three codemods:
    • timeout_minutestimeout-minutes migration (v0.1.0)
    • network.firewallsandbox.agent migration with correct value mapping (v0.1.0):
      • firewall: truesandbox.agent: awf (firewall enabled)
      • firewall: false or nullsandbox.agent: false (firewall disabled)
    • on.commandon.slash_command migration (v0.2.0) ✓ Already present
  • Dry-run mode by default (requires --write flag to apply changes)
  • --list-codemods flag shows available fixes with version information
  • Preserves formatting, comments, and indentation
  • Detailed reporting of changes made
  • Agent prompt output in dry-run mode showing suggested fix commands

Version Tracking:

  • Each codemod now includes an IntroducedIn field tracking the version where it was added
  • --list-codemods displays version information for each codemod

Makefile Integration:

  • Added make fix target that runs ./gh-aw fix --write
  • Integrated into agent-finish workflow (runs after tests, before recompile)
  • Updated help documentation

Compile Command Integration:

  • Added --fix flag to compile command
  • Automatically runs gh aw fix --write before compiling when flag is set
  • Enabled in MCP server compile tool for programmatic access

Applied Fixes:

  • Reverted incorrectly migrated workflows
  • Successfully re-migrated network.firewall with correct logic:
    • Workflows with firewall: true now correctly use sandbox.agent: awf
    • Workflows with firewall: false use sandbox.agent: false
  • All migrations preserve formatting and add helpful migration comments

Testing & Validation:

  • Unit tests for each codemod transformation
  • Tests for formatting preservation
  • Tests for dry-run and write modes
  • Test for command→slash_command migration
  • All existing tests continue to pass
  • Code formatting verified with make fmt
  • Linting verified with make lint
  • Merged latest main branch changes

Latest Changes from Main:

  • Environment variables documentation reduced for better readability
  • New agentics maintenance workflow with expired issue cleanup
  • Updated header generation with improved formatting

Usage:

gh aw fix                     # Check all workflows (dry-run)
gh aw fix --write             # Fix all workflows
gh aw fix my-workflow         # Check specific workflow
gh aw fix my-workflow --write # Fix specific workflow
gh aw fix --list-codemods     # List available codemods with versions
make fix                      # Run fix as part of build process
gh aw compile --fix           # Fix and compile in one step
Original prompt

Add a "fix" command that applies automatic codemod style fixing to agentic workflows markdown.

Maintains list of codemod updates that can be applied to update the frontmatter.

Generate codemods for existing deprecated fields.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits December 13, 2025 18:39
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>
…n check

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add fix command for automatic codemod style fixing Add fix command for automatic codemod-style migrations of deprecated workflow fields Dec 13, 2025
Copilot AI requested a review from pelikhan December 13, 2025 18:59
@pelikhan
Copy link
Contributor

Add makefile target to run fix --write and add to agent-finish

@pelikhan
Copy link
Contributor

@copilot comment above

@pelikhan
Copy link
Contributor

@copilot

  • merge main and add codemod for slash command
  • if write mode is not selected, write the list of fixes needed as a prompt for an agent

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 13, 2025

@copilot comment above

Added in commit 7996e1a:

  • Created make fix target that runs ./gh-aw fix --write
  • Integrated into agent-finish workflow (runs after tests, before recompile)
  • Updated help documentation

The fix command successfully migrated network.firewall to sandbox.agent: false in 8 workflow files.

@pelikhan
Copy link
Contributor

@copilot

  • add a "--fix" flag to the compile command to apply the fixes as if calling "fix --write".
  • enable "--fix" flag with MCP-server compile tool

@pelikhan
Copy link
Contributor

@copilot the codemod for firewall fixes is wrong. network.firewall: true means sandbox.agent: awf

Revert all agentic workflows and run fixes again.

@pelikhan
Copy link
Contributor

@copilot record the current version where a codemod was introduced. Show in list.

…flag

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 13, 2025

@copilot

  • add a "--fix" flag to the compile command to apply the fixes as if calling "fix --write".
  • enable "--fix" flag with MCP-server compile tool

Completed in commit 2980612:

  • Added --fix flag to compile command that automatically applies fixes before compiling
  • Enabled fix parameter in MCP server's compile tool
  • Usage: gh aw compile --fix or via MCP: {"fix": true}

The flag runs gh aw fix --write before compilation, ensuring all deprecated fields are migrated automatically.

@copilot

  • merge main and add codemod for slash command...

Completed in commit 2980612:

  • Merged main branch
  • Added codemod for on.commandon.slash_command migration
  • Enhanced dry-run mode to output agent-friendly prompts showing specific fix commands for each workflow

When running gh aw fix without --write, the output now includes:

ℹ To fix these issues, run:

  gh aw fix --write

ℹ Or fix them individually:

  gh aw fix release --write
  gh aw fix research --write
  ...

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 13, 2025

@copilot record the current version where a codemod was introduced. Show in list.

Added in commit a6698b8:

  • Codemods now include IntroducedIn version field
  • --list-codemods displays version information for each codemod
  • Current versions:
    • timeout-minutes-migration: 0.1.0
    • network-firewall-migration: 0.1.0
    • command-to-slash-command-migration: 0.2.0

@copilot the codemod for firewall fixes is wrong. network.firewall: true means sandbox.agent: awf

Revert all agentic workflows and run fixes again.

Fixed in commit a6698b8:

  • Corrected firewall codemod logic:
    • network.firewall: truesandbox.agent: awf (firewall enabled)
    • network.firewall: false or nullsandbox.agent: false (firewall disabled)
  • Reverted all incorrectly migrated workflow files
  • Re-ran fix with corrected logic on 15 workflows
  • All migrations now use the correct sandbox.agent values

@pelikhan pelikhan marked this pull request as ready for review December 13, 2025 20:48
@pelikhan
Copy link
Contributor

@copilot lint, fix tests

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 13, 2025

@copilot lint, fix tests

Completed in commit 9aa0cd6:

  • Ran make fmt to format Go code (fixed whitespace alignment and trailing whitespace)
  • Ran make test-unit - all tests pass
  • Ran make lint - all validations pass
  • Regenerated lock files with corrected sandbox.agent values

@pelikhan
Copy link
Contributor

@copilot merge main and add slash_command codemod

Copy link
Contributor Author

Copilot AI commented Dec 13, 2025

@copilot merge main and add slash_command codemod

Completed in commit 0e88cd7:

  • Merged latest main branch changes
  • slash_command codemod (on.command → on.slash_command) was already present from commit 2980612
  • Verified all three codemods are working:
    • timeout-minutes-migration (v0.1.0)
    • network-firewall-migration (v0.1.0)
    • command-to-slash-command-migration (v0.2.0) ✓
  • All tests pass after merge

@pelikhan pelikhan merged commit e2caaa3 into main Dec 14, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/add-fix-command-for-codemods branch December 14, 2025 00:02
github-actions bot added a commit that referenced this pull request Dec 14, 2025
Add comprehensive documentation for the new `gh aw fix` command introduced
in PR #6367. This command automatically migrates deprecated workflow fields
using codemods.

Documentation includes:
- Command description and usage examples
- Available codemods with version information
- Dry-run mode (default) and --write flag
- Integration with compile command and make targets
- All options and flags

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

Co-Authored-By: Claude Sonnet 4.5 <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