From ee5fa4f8684a8acd167702099a422cc8a7310022 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 Jan 2026 22:03:16 +0000 Subject: [PATCH 1/3] Initial plan From 3ae1a81dacf387d8206564eea1ee0c77a271f12c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 Jan 2026 22:10:25 +0000 Subject: [PATCH 2/3] Add codemod to delete dangling upgrade-agentic-workflow.md file Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/copilot-agents.go | 20 +++++++ pkg/cli/copilot_agents_test.go | 104 +++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) diff --git a/pkg/cli/copilot-agents.go b/pkg/cli/copilot-agents.go index 6c875d79b3c..9fb5f66a856 100644 --- a/pkg/cli/copilot-agents.go +++ b/pkg/cli/copilot-agents.go @@ -307,6 +307,11 @@ func deleteOldAgentFiles(verbose bool) error { "create-shared-agentic-workflow.agent.md", } + // Also delete the dangling singular form file from .github/aw/ + awFiles := []string{ + "upgrade-agentic-workflow.md", // singular form (typo/duplicate) + } + for _, agentFile := range agentFiles { agentPath := filepath.Join(gitRoot, ".github", "agents", agentFile) @@ -321,5 +326,20 @@ func deleteOldAgentFiles(verbose bool) error { } } + // Delete dangling files from .github/aw/ + for _, awFile := range awFiles { + awPath := filepath.Join(gitRoot, ".github", "aw", awFile) + + // Check if the file exists and remove it + if _, err := os.Stat(awPath); err == nil { + if err := os.Remove(awPath); err != nil { + return fmt.Errorf("failed to remove old aw file %s: %w", awFile, err) + } + if verbose { + fmt.Fprintf(os.Stderr, "Removed old aw file: %s\n", awPath) + } + } + } + return nil } diff --git a/pkg/cli/copilot_agents_test.go b/pkg/cli/copilot_agents_test.go index 62e0a07406f..4d668008971 100644 --- a/pkg/cli/copilot_agents_test.go +++ b/pkg/cli/copilot_agents_test.go @@ -208,3 +208,107 @@ func TestEnsureFileMatchesTemplate_VerboseOutput(t *testing.T) { }) } } + +// TestDeleteOldAgentFiles tests deletion of old agent files +func TestDeleteOldAgentFiles(t *testing.T) { + tests := []struct { + name string + filesToCreate []string // Paths relative to git root + expectedDeleted []string // Files that should be deleted + }{ + { + name: "deletes old agent files from .github/agents", + filesToCreate: []string{ + ".github/agents/create-agentic-workflow.agent.md", + ".github/agents/debug-agentic-workflow.agent.md", + ".github/agents/create-shared-agentic-workflow.agent.md", + }, + expectedDeleted: []string{ + ".github/agents/create-agentic-workflow.agent.md", + ".github/agents/debug-agentic-workflow.agent.md", + ".github/agents/create-shared-agentic-workflow.agent.md", + }, + }, + { + name: "deletes singular upgrade-agentic-workflow.md from .github/aw", + filesToCreate: []string{ + ".github/aw/upgrade-agentic-workflow.md", + }, + expectedDeleted: []string{ + ".github/aw/upgrade-agentic-workflow.md", + }, + }, + { + name: "deletes both agent and aw files", + filesToCreate: []string{ + ".github/agents/create-agentic-workflow.agent.md", + ".github/aw/upgrade-agentic-workflow.md", + }, + expectedDeleted: []string{ + ".github/agents/create-agentic-workflow.agent.md", + ".github/aw/upgrade-agentic-workflow.md", + }, + }, + { + name: "handles no files to delete", + filesToCreate: []string{}, + expectedDeleted: []string{}, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + // Create a temporary directory for testing + tempDir := testutil.TempDir(t, "test-*") + + // Change to temp directory and initialize git repo + oldWd, _ := os.Getwd() + defer func() { + _ = os.Chdir(oldWd) + }() + err := os.Chdir(tempDir) + if err != nil { + t.Fatalf("Failed to change directory: %v", err) + } + + // Initialize git repo + if err := exec.Command("git", "init").Run(); err != nil { + t.Fatalf("Failed to init git repo: %v", err) + } + + // Create test files + for _, filePath := range tt.filesToCreate { + fullPath := filepath.Join(tempDir, filePath) + dir := filepath.Dir(fullPath) + if err := os.MkdirAll(dir, 0755); err != nil { + t.Fatalf("Failed to create directory %s: %v", dir, err) + } + if err := os.WriteFile(fullPath, []byte("test content"), 0644); err != nil { + t.Fatalf("Failed to create file %s: %v", fullPath, err) + } + } + + // Call deleteOldAgentFiles + err = deleteOldAgentFiles(false) + if err != nil { + t.Fatalf("deleteOldAgentFiles() returned error: %v", err) + } + + // Verify expected files were deleted + for _, filePath := range tt.expectedDeleted { + fullPath := filepath.Join(tempDir, filePath) + if _, err := os.Stat(fullPath); !os.IsNotExist(err) { + t.Errorf("Expected file %s to be deleted, but it still exists", filePath) + } + } + + // Verify other files weren't affected (if any exist) + // For example, the plural form should not be deleted + pluralPath := filepath.Join(tempDir, ".github/aw/upgrade-agentic-workflows.md") + if _, err := os.Stat(pluralPath); err == nil { + // If it existed, it should still exist + t.Logf("Correctly preserved .github/aw/upgrade-agentic-workflows.md (plural)") + } + }) + } +} From 6bb1f46b8fb81f404cbe5ed183c3ed2fd09066a8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 Jan 2026 22:15:48 +0000 Subject: [PATCH 3/3] Verify code formatting and linting pass Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/copilot_agents_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/cli/copilot_agents_test.go b/pkg/cli/copilot_agents_test.go index 4d668008971..adf9e0f4354 100644 --- a/pkg/cli/copilot_agents_test.go +++ b/pkg/cli/copilot_agents_test.go @@ -212,8 +212,8 @@ func TestEnsureFileMatchesTemplate_VerboseOutput(t *testing.T) { // TestDeleteOldAgentFiles tests deletion of old agent files func TestDeleteOldAgentFiles(t *testing.T) { tests := []struct { - name string - filesToCreate []string // Paths relative to git root + name string + filesToCreate []string // Paths relative to git root expectedDeleted []string // Files that should be deleted }{ { @@ -250,8 +250,8 @@ func TestDeleteOldAgentFiles(t *testing.T) { }, }, { - name: "handles no files to delete", - filesToCreate: []string{}, + name: "handles no files to delete", + filesToCreate: []string{}, expectedDeleted: []string{}, }, }