Skip to content

[task] Standardize engine installation steps using template method pattern #4669

Description

@github-actions

Objective

Eliminate 80% code duplication in engine installation steps by extracting common patterns to a base implementation using the template method pattern.

Context

Part of issue #4640 - Priority 3 (Quick Win)

All engine files (claude_engine.go, codex_engine.go, copilot_engine.go) implement GetInstallationSteps() with 80% identical code. The only differences are configuration parameters (secrets, package names, versions).

Approach

  1. Create a base installation helper in pkg/workflow/engine.go:

    • Define EngineInstallConfig struct with fields: Secrets, DocsURL, NpmPackage, Version, Name, CliName
    • Implement GetInstallationSteps(config EngineInstallConfig, workflowData *WorkflowData) []GitHubActionStep
    • Include common steps: secret validation and NPM installation
  2. Simplify each engine's GetInstallationSteps() implementation:

    • Create config with engine-specific values
    • Call base GetInstallationSteps()
    • Add engine-specific steps (network permissions, settings, hooks) after base steps
  3. Maintain engine-specific customization while eliminating boilerplate

Files to Modify

  • Update: pkg/workflow/engine.go (add base installation method)
  • Update: pkg/workflow/claude_engine.go (use base method + Claude-specific steps)
  • Update: pkg/workflow/codex_engine.go (use base method + Codex-specific steps)
  • Update: pkg/workflow/copilot_engine.go (use base method + Copilot-specific steps)

Acceptance Criteria

  • EngineInstallConfig struct created with all required fields
  • Base GetInstallationSteps() method implemented
  • All three engines refactored to use base method
  • ~200 lines of duplicate code eliminated
  • Engine-specific customization preserved
  • All existing tests pass (make test)
  • Successful compilation (make build)
    Related to [refactor] 🔧 Semantic Function Clustering Analysis - November 2025 #4640

AI generated by Plan Command for #4640

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions