Skip to content

Commit 9de945e

Browse files
Copilotpelikhan
andauthored
Remove duplicate code for YAML conversion in workflow engines (#2830)
* Initial plan * Initial analysis - understanding duplication Co-authored-by: pelikhan <[email protected]> * Changes before error encountered Co-authored-by: pelikhan <[email protected]> * Complete duplicate code removal - all tests passing Co-authored-by: pelikhan <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: pelikhan <[email protected]>
1 parent f749d29 commit 9de945e

File tree

9 files changed

+10
-24
lines changed

9 files changed

+10
-24
lines changed

.github/workflows/go-logger.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/technical-doc-writer.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/tidy.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/unbloat-docs.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/workflow/agentic_engine.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ func (e *BaseEngine) GetLogFileForParsing() string {
171171
return "/tmp/gh-aw/agent-stdio.log"
172172
}
173173

174+
// convertStepToYAML converts a step map to YAML string - uses proper YAML serialization
175+
// This is a shared implementation inherited by all engines that embed BaseEngine
176+
func (e *BaseEngine) convertStepToYAML(stepMap map[string]any) (string, error) {
177+
return ConvertStepToYAML(stepMap)
178+
}
179+
174180
// EngineRegistry manages available agentic engines
175181
type EngineRegistry struct {
176182
engines map[string]CodingAgentEngine

pkg/workflow/claude_engine.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,6 @@ func (e *ClaudeEngine) GetExecutionSteps(workflowData *WorkflowData, logFile str
287287
return steps
288288
}
289289

290-
// convertStepToYAML converts a step map to YAML string - uses proper YAML serialization
291-
func (e *ClaudeEngine) convertStepToYAML(stepMap map[string]any) (string, error) {
292-
return ConvertStepToYAML(stepMap)
293-
}
294-
295290
// GetLogParserScriptId returns the JavaScript script name for parsing Claude logs
296291
func (e *ClaudeEngine) GetLogParserScriptId() string {
297292
return "parse_claude_log"

pkg/workflow/codex_engine.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,6 @@ codex %sexec%s%s%s"$INSTRUCTION" 2>&1 | tee %s`, modelParam, webSearchParam, ful
172172
return steps
173173
}
174174

175-
// convertStepToYAML converts a step map to YAML string - uses proper YAML serialization
176-
func (e *CodexEngine) convertStepToYAML(stepMap map[string]any) (string, error) {
177-
return ConvertStepToYAML(stepMap)
178-
}
179-
180175
// expandNeutralToolsToCodexTools converts neutral tools to Codex-specific tools format
181176
// This ensures that playwright tools get the same allowlist as the copilot agent
182177
func (e *CodexEngine) expandNeutralToolsToCodexTools(tools map[string]any) map[string]any {

pkg/workflow/copilot_engine.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,6 @@ COPILOT_CLI_INSTRUCTION=$(cat /tmp/gh-aw/aw-prompts/prompt.txt)
328328
return steps
329329
}
330330

331-
// convertStepToYAML converts a step map to YAML string - uses proper YAML serialization
332-
func (e *CopilotEngine) convertStepToYAML(stepMap map[string]any) (string, error) {
333-
return ConvertStepToYAML(stepMap)
334-
}
335-
336331
// GetSquidLogsSteps returns the steps for collecting and uploading Squid logs
337332
func (e *CopilotEngine) GetSquidLogsSteps(workflowData *WorkflowData) []GitHubActionStep {
338333
var steps []GitHubActionStep

pkg/workflow/custom_engine.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@ func (e *CustomEngine) GetExecutionSteps(workflowData *WorkflowData, logFile str
137137
return steps
138138
}
139139

140-
// convertStepToYAML converts a step map to YAML string - uses proper YAML serialization
141-
func (e *CustomEngine) convertStepToYAML(stepMap map[string]any) (string, error) {
142-
return ConvertStepToYAML(stepMap)
143-
}
144-
145140
// RenderMCPConfig renders MCP configuration using shared logic
146141
func (e *CustomEngine) RenderMCPConfig(yaml *strings.Builder, tools map[string]any, mcpTools []string, workflowData *WorkflowData) {
147142
// Use shared JSON MCP config renderer

0 commit comments

Comments
 (0)