-
Notifications
You must be signed in to change notification settings - Fork 46
Closed
Description
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):
ensureCopilotInstructionsensureAgenticWorkflowPromptensureAgenticWorkflowAgentensureSharedAgenticWorkflowAgentensureSetupAgenticWorkflowsAgent- Create new file
pkg/cli/agent_setup.goor add topkg/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.goor createpkg/cli/pr_helpers.go
-
Refactor compilation logic:
compileWorkflowandcompileWorkflowWithTracking- 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.goif PR operations need dedicated file
Files 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)- Any files that reference the moved functions - Update imports
Acceptance Criteria
- All 5 setup functions moved to appropriate setup file
-
checkCleanWorkingDirectorymoved to git.go -
createPRmoved to appropriate PR file - Compilation logic refactored to use shared utilities
- All function references updated with correct imports
- All tests pass without modification
- File cohesion improved - each file has single, clear purpose
- No functionality changed - only code organization improved
Related to [refactor] 🔧 Semantic Function Clustering Analysis: Refactoring Opportunities #3713
AI generated by Plan Command for #3713
Reactions are currently unavailable