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
-
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
-
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
-
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
AI generated by Plan Command for #4640
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) implementGetInstallationSteps()with 80% identical code. The only differences are configuration parameters (secrets, package names, versions).Approach
Create a base installation helper in
pkg/workflow/engine.go:EngineInstallConfigstruct with fields:Secrets,DocsURL,NpmPackage,Version,Name,CliNameGetInstallationSteps(config EngineInstallConfig, workflowData *WorkflowData) []GitHubActionStepSimplify each engine's
GetInstallationSteps()implementation:GetInstallationSteps()Maintain engine-specific customization while eliminating boilerplate
Files to Modify
pkg/workflow/engine.go(add base installation method)pkg/workflow/claude_engine.go(use base method + Claude-specific steps)pkg/workflow/codex_engine.go(use base method + Codex-specific steps)pkg/workflow/copilot_engine.go(use base method + Copilot-specific steps)Acceptance Criteria
EngineInstallConfigstruct created with all required fieldsGetInstallationSteps()method implementedmake test)make build)Related to [refactor] 🔧 Semantic Function Clustering Analysis - November 2025 #4640