Skip to content

refactor: split compiler_yaml.go (1262 lines) into focused modules#45494

Draft
pelikhan with Copilot wants to merge 2 commits into
mainfrom
copilot/file-diet-refactor-compiler-yaml
Draft

refactor: split compiler_yaml.go (1262 lines) into focused modules#45494
pelikhan with Copilot wants to merge 2 commits into
mainfrom
copilot/file-diet-refactor-compiler-yaml

Conversation

Copilot AI commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

pkg/workflow/compiler_yaml.go had grown to 1262 lines across 5 unrelated functional domains, exceeding the 800-line threshold and making the file hard to navigate and maintain.

Changes

Extracted into 4 new files, leaving compiler_yaml.go as a thin orchestration layer:

File Lines Responsibility
compiler_yaml.go 221 Orchestration: buildJobsAndValidate, generateYAML, generateWorkflowBody
compiler_yaml_normalize.go 167 YAML text normalization: blank-line collapsing, trailing-whitespace trimming, block-scalar detection
compiler_yaml_header.go 220 Header/metadata emission: generateWorkflowHeader, effectiveStrictMode, effectiveSafeUpdate
compiler_yaml_prompt.go 374 Prompt assembly: chunking, import resolution, expression mapping, runtime-import macros
compiler_yaml_steps.go 310 Step generation: pre/post/pre-agent steps, generateCreateAwInfo, output collection

All functions remain in the same package with identical signatures — purely a file-boundary split with no behavior changes.

Extract distinct functional domains from the 1262-line compiler_yaml.go
into 4 new focused files:

- compiler_yaml_normalize.go: YAML text normalization utilities
  (normalizeBlankLines, countLeadingSpaces, blockScalarHeaderIndentForLine)
- compiler_yaml_header.go: YAML header/metadata emission
  (generateWorkflowHeader, effectiveStrictMode, effectiveSafeUpdate)
- compiler_yaml_prompt.go: Prompt assembly and chunking
  (generatePrompt, splitContentIntoChunks, extractPromptChunksFromMarkdown,
  writePromptBashStep, resolveWorkspaceRoot)
- compiler_yaml_steps.go: Individual step generation
  (generatePreSteps, generatePostSteps, generatePreAgentSteps,
  writeStepsSection, generateCreateAwInfo, generateOutputCollectionStep)

compiler_yaml.go trimmed to top-level orchestration only:
  (buildJobsAndValidate, generateYAML, generateWorkflowBody)

All tests pass. No behavior changes.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor pkg/workflow/compiler_yaml.go into focused modules refactor: split compiler_yaml.go (1262 lines) into focused modules Jul 14, 2026
Copilot AI requested a review from pelikhan July 14, 2026 14:13
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.

[file-diet] Refactor pkg/workflow/compiler_yaml.go (1262 lines) into focused modules

2 participants