Objective
Improve file cohesion by relocating misplaced functions from pkg/cli/add_command.go to their appropriate domain files.
Context
The add_command.go file contains several functions that don't belong there, violating separation of concerns and making code harder to find and reuse. These functions handle setup, git operations, and PR creation - responsibilities that should live in dedicated files.
Related to #3713 - Outlier Functions Issues #1, #2, and #3.
Approach
-
Move setup functions (Lines 819-907):
ensureCopilotInstructions
ensureAgenticWorkflowPrompt
ensureAgenticWorkflowAgent
ensureSharedAgenticWorkflowAgent
ensureSetupAgenticWorkflowsAgent
- Create new file
pkg/cli/agent_setup.go or add to pkg/cli/copilot_setup.go
-
Move git operation (Line 912):
checkCleanWorkingDirectory
- Move to
pkg/cli/git.go (existing file)
-
Move PR operation (Line 934):
createPR
- Move to
pkg/cli/pr_command.go or create pkg/cli/pr_helpers.go
-
Refactor compilation logic:
compileWorkflow and compileWorkflowWithTracking
- Extract shared utilities to avoid duplication with
compile_command.go
-
Update all references to moved functions
Files to Create
pkg/cli/agent_setup.go (or decide to use existing copilot_setup.go)
- Possibly
pkg/cli/pr_helpers.go if PR operations need dedicated file
Files to Modify
pkg/cli/add_command.go - Remove misplaced functions
pkg/cli/git.go - Add checkCleanWorkingDirectory
pkg/cli/pr_command.go - Add createPR (or create pr_helpers.go)
- Any files that reference the moved functions - Update imports
Acceptance Criteria
AI generated by Plan Command for #3713
Objective
Improve file cohesion by relocating misplaced functions from
pkg/cli/add_command.goto their appropriate domain files.Context
The
add_command.gofile contains several functions that don't belong there, violating separation of concerns and making code harder to find and reuse. These functions handle setup, git operations, and PR creation - responsibilities that should live in dedicated files.Related to #3713 - Outlier Functions Issues #1, #2, and #3.
Approach
Move setup functions (Lines 819-907):
ensureCopilotInstructionsensureAgenticWorkflowPromptensureAgenticWorkflowAgentensureSharedAgenticWorkflowAgentensureSetupAgenticWorkflowsAgentpkg/cli/agent_setup.goor add topkg/cli/copilot_setup.goMove git operation (Line 912):
checkCleanWorkingDirectorypkg/cli/git.go(existing file)Move PR operation (Line 934):
createPRpkg/cli/pr_command.goor createpkg/cli/pr_helpers.goRefactor compilation logic:
compileWorkflowandcompileWorkflowWithTrackingcompile_command.goUpdate all references to moved functions
Files to Create
pkg/cli/agent_setup.go(or decide to use existing copilot_setup.go)pkg/cli/pr_helpers.goif PR operations need dedicated fileFiles to Modify
pkg/cli/add_command.go- Remove misplaced functionspkg/cli/git.go- Add checkCleanWorkingDirectorypkg/cli/pr_command.go- Add createPR (or create pr_helpers.go)Acceptance Criteria
checkCleanWorkingDirectorymoved to git.gocreatePRmoved to appropriate PR fileRelated to [refactor] 🔧 Semantic Function Clustering Analysis: Refactoring Opportunities #3713