NewUpgradeCommand creates the upgrade command
()
| 32 | |
| 33 | // NewUpgradeCommand creates the upgrade command |
| 34 | func NewUpgradeCommand() *cobra.Command { |
| 35 | cmd := &cobra.Command{ |
| 36 | Use: "upgrade", |
| 37 | Short: "Upgrade repository with latest agent files and apply codemods to all workflows", |
| 38 | Long: `Upgrade the repository to the latest version of agentic workflows. |
| 39 | |
| 40 | This command: |
| 41 | 1. Updates the dispatcher agent file to the latest template (like 'init' command) |
| 42 | 2. Applies automatic codemods to fix deprecated fields in all workflows (like 'fix --write') |
| 43 | 3. Updates GitHub Actions versions in .github/aw/actions-lock.json (unless --no-actions is set) |
| 44 | 4. Compiles all workflows to generate lock files (like 'compile' command) |
| 45 | |
| 46 | Flag behavior: |
| 47 | - --no-fix skips codemods, action version updates, and workflow compilation |
| 48 | - --no-actions and --no-compile are only applied when --no-fix is not set |
| 49 | |
| 50 | DEPENDENCY HEALTH AUDIT: |
| 51 | Use --audit to check dependency health without performing upgrades. This includes: |
| 52 | - Outdated Go dependencies with available updates |
| 53 | - Security advisories from GitHub Security Advisory API |
| 54 | - Dependency maturity analysis (v0.x vs stable versions) |
| 55 | - Comprehensive dependency health report |
| 56 | |
| 57 | The --audit flag skips the normal upgrade process. |
| 58 | |
| 59 | This command always upgrades all Markdown files in .github/workflows.`, |
| 60 | Example: ` ` + string(constants.CLIExtensionPrefix) + ` upgrade # Upgrade all workflows |
| 61 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --no-fix # Update agent files only (skip codemods, actions, and compilation) |
| 62 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --no-actions # Skip updating GitHub Actions versions |
| 63 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --no-compile # Skip recompiling workflows (do not modify lock files) |
| 64 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --create-pull-request # Upgrade and open a pull request |
| 65 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --dir custom/workflows # Upgrade workflows in custom directory |
| 66 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --org my-org # Preview upgrade pull requests across an organization |
| 67 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --org my-org --repos '*-service' # Limit org mode to matching repositories |
| 68 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --org my-org --create-pull-request # Open upgrade pull requests in org repositories |
| 69 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --org my-org --create-pull-request --yes # Auto-accept per-repo confirmations for PR creation (required in CI) |
| 70 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --org my-org --create-issue # Open issues in org repos with agentic workflows |
| 71 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --org my-org --create-issue --yes # Auto-accept per-repo confirmations (required in CI) |
| 72 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --audit # Check dependency health without upgrading |
| 73 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --audit --json # Output audit results in JSON format |
| 74 | ` + string(constants.CLIExtensionPrefix) + ` upgrade --pre-releases # Include prerelease versions when self-upgrading the extension (stable releases are the default)`, |
| 75 | Args: cobra.NoArgs, |
| 76 | RunE: func(cmd *cobra.Command, args []string) error { |
| 77 | verbose, _ := cmd.Flags().GetBool("verbose") |
| 78 | dir, _ := cmd.Flags().GetString("dir") |
| 79 | noFix, _ := cmd.Flags().GetBool("no-fix") |
| 80 | createPRFlag, _ := cmd.Flags().GetBool("create-pull-request") |
| 81 | prFlagAlias, _ := cmd.Flags().GetBool("pr") |
| 82 | createPR := createPRFlag || prFlagAlias |
| 83 | createIssue, _ := cmd.Flags().GetBool("create-issue") |
| 84 | yes, _ := cmd.Flags().GetBool("yes") |
| 85 | noActions, _ := cmd.Flags().GetBool("no-actions") |
| 86 | noCompile, _ := cmd.Flags().GetBool("no-compile") |
| 87 | auditFlag, _ := cmd.Flags().GetBool("audit") |
| 88 | jsonOutput, _ := cmd.Flags().GetBool("json") |
| 89 | disabledCodemods, _ := cmd.Flags().GetStringSlice("disable-codemod") |
| 90 | skipExtensionUpgrade, _ := cmd.Flags().GetBool("skip-extension-upgrade") |
| 91 | approveUpgrade, _ := cmd.Flags().GetBool("approve") |