Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

Overview

This PR extracts 22 YAML generation functions from the oversized pkg/workflow/compiler.go (3,472 lines) into a new dedicated file pkg/workflow/yaml_generation.go to improve code organization and maintainability.

Changes

Files Created

  • pkg/workflow/yaml_generation.go (910 lines) - New file containing all YAML generation logic

Files Modified

  • pkg/workflow/compiler.go - Reduced from 3,472 to 2,594 lines (878 lines removed, 25.3% reduction)

Functions Extracted

All 22 functions were successfully moved as receiver methods on the *Compiler type:

Core Generation Functions:

  • generateJobName - Converts workflow names to valid YAML job identifiers
  • generateYAML - Generates complete GitHub Actions YAML content
  • generateMainJobSteps - Generates steps section for the main job

Upload and Logging Functions:

  • generateUploadAgentLogs - Uploads agent stdio logs
  • generateUploadAssets - Uploads safe outputs assets
  • generateUploadAwInfo - Uploads agentic run info
  • generateUploadPrompt - Uploads prompt file
  • generateUploadAccessLogs - Uploads network access logs
  • generateUploadMCPLogs - Uploads MCP server logs

Log Processing Functions:

  • generateLogParsing - Parses agent logs for step summary
  • generateErrorValidation - Validates agent logs for errors
  • generateExtractAccessLogs - Extracts network access logs

Pattern Conversion Functions:

  • convertGoPatternToJavaScript - Converts Go regex patterns to JavaScript format
  • convertErrorPatternsToJavaScript - Converts error pattern slices

Prompt Generation Functions:

  • generatePrompt - Generates the main prompt step
  • generateCacheMemoryPromptStep - Generates cache memory prompt section
  • generateSafeOutputsPromptStep - Generates safe outputs prompt section

Engine Execution Functions:

  • generateEngineExecutionSteps - Generates engine execution steps
  • generateAgentVersionCapture - Captures agent version information
  • generateCreateAwInfo - Creates aw_info.json with metadata
  • generateOutputCollectionStep - Reads output file and sets GitHub Actions output

Post-Processing Functions:

  • generatePostSteps - Generates post-steps that run after AI execution

Testing

  • ✅ All unit tests pass: make test-unit
  • ✅ Build successful: make build
  • ✅ No import errors or broken references
  • ✅ All receiver methods properly maintained on *Compiler type

Related Issues

Part of #2273 - Refactor oversized compiler.go file

This extraction improves code organization by separating YAML generation concerns from the main compilation logic, making the codebase more maintainable and easier to navigate.

Original prompt

This section details on the original issue you should resolve

<issue_title>[task] Extract generation functions from compiler.go to yaml_generation.go</issue_title>
<issue_description>## Objective
Extract 20 YAML generation functions from the oversized pkg/workflow/compiler.go (3,472 lines) into a new dedicated file pkg/workflow/yaml_generation.go.

Context

Part of issue #2273. The compiler.go file is too large and mixes multiple responsibilities. This task focuses on extracting generation functions to improve code organization and maintainability.

Functions to Extract

Move these 20 generation functions from compiler.go to new yaml_generation.go:

  • generateJobName
  • generateYAML
  • generateMainJobSteps
  • generateUploadAgentLogs
  • generateUploadAssets
  • generateLogParsing
  • generateErrorValidation
  • generateUploadAwInfo
  • generateUploadPrompt
  • generateExtractAccessLogs
  • generateUploadAccessLogs
  • generateUploadMCPLogs
  • generatePrompt
  • generateCacheMemoryPromptStep
  • generateSafeOutputsPromptStep
  • generatePostSteps
  • generateEngineExecutionSteps
  • generateAgentVersionCapture
  • generateCreateAwInfo
  • generateOutputCollectionStep
  • convertGoPatternToJavaScript
  • convertErrorPatternsToJavaScript

Approach

  1. Create new file pkg/workflow/yaml_generation.go
  2. Move all 20 generation functions from compiler.go to yaml_generation.go
  3. Ensure all receiver methods remain on *Compiler type
  4. Update imports as needed
  5. Verify no broken references

Files to Modify

  • Create: pkg/workflow/yaml_generation.go
  • Update: pkg/workflow/compiler.go (remove moved functions)

Acceptance Criteria

AI generated by Plan Command for #2273</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #2275


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Oct 24, 2025
Copilot AI and others added 2 commits October 24, 2025 11:56
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ion.go

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review October 24, 2025 12:07
@github-actions
Copy link
Contributor

Agentic Changeset Generator triggered by this pull request.

Copilot AI and others added 2 commits October 24, 2025 12:07
Copilot AI changed the title [WIP] Extract generation functions to yaml_generation.go Extract 22 YAML generation functions from compiler.go to yaml_generation.go Oct 24, 2025
Copilot AI requested a review from pelikhan October 24, 2025 12:10
Copilot finished work on behalf of pelikhan October 24, 2025 12:10
@pelikhan pelikhan closed this Oct 24, 2025
@pelikhan pelikhan deleted the copilot/extract-yaml-generation-functions branch October 24, 2025 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[task] Extract generation functions from compiler.go to yaml_generation.go

2 participants