Skip to content

[task] Move misplaced functions from add_command.go to appropriate files #3744

@github-actions

Description

@github-actions

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

  1. 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
  2. Move git operation (Line 912):

    • checkCleanWorkingDirectory
    • Move to pkg/cli/git.go (existing file)
  3. Move PR operation (Line 934):

    • createPR
    • Move to pkg/cli/pr_command.go or create pkg/cli/pr_helpers.go
  4. Refactor compilation logic:

    • compileWorkflow and compileWorkflowWithTracking
    • Extract shared utilities to avoid duplication with compile_command.go
  5. 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

  • All 5 setup functions moved to appropriate setup file
  • checkCleanWorkingDirectory moved to git.go
  • createPR moved 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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions