Skip to content

Group consecutive shell redirects to eliminate SC2129 warnings#15065

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/update-workflow-compiler-redirection
Closed

Group consecutive shell redirects to eliminate SC2129 warnings#15065
Copilot wants to merge 3 commits intomainfrom
copilot/update-workflow-compiler-redirection

Conversation

Copy link
Contributor

Copilot AI commented Feb 12, 2026

Shellcheck reports 164 SC2129 style warnings across all compiled workflows for using consecutive individual redirects instead of grouped redirects. This generates unnecessarily verbose shell scripts and triggers linter warnings.

Changes

Modified pkg/workflow/unified_prompt_step.go:

  • Added writeGroupedPromptSections() and writeGroupedUserPromptChunks() to group consecutive unconditional sections
  • Modified generateUnifiedPromptCreationStep() to use grouping helpers
  • Conditionals and single sections remain ungrouped (no benefit)
  • First redirect uses > (create), grouped redirects use >> (append)

Updated test assertions:

  • TestGenerateUnifiedPromptCreationStep_FirstContentUsesCreate - check redirect operators instead of exact cat command strings
  • TestPlaywrightPromptIncludedWhenEnabled, TestTempFolderPromptIncluded - match cat commands without requiring individual redirects

Example

Before:

cat "/opt/gh-aw/prompts/temp_folder_prompt.md" >> "$GH_AW_PROMPT"
cat "/opt/gh-aw/prompts/markdown.md" >> "$GH_AW_PROMPT"
cat << 'GH_AW_PROMPT_EOF' >> "$GH_AW_PROMPT"
<safe-outputs>
...
</safe-outputs>
GH_AW_PROMPT_EOF

After:

{
  cat "/opt/gh-aw/prompts/temp_folder_prompt.md"
  cat "/opt/gh-aw/prompts/markdown.md"
  cat << 'GH_AW_PROMPT_EOF'
  <safe-outputs>
  ...
  </safe-outputs>
  GH_AW_PROMPT_EOF
} >> "$GH_AW_PROMPT"

Impact

  • Eliminates all 164 SC2129 warnings (verified with actionlint across 148 workflows)
  • Reduces shell script verbosity
  • Minor performance improvement (fewer redirect operations)
  • No behavior changes - identical output file contents
Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Update workflow compiler to generate grouped shell redirects (SC2129)</issue_title>
<issue_description>## Objective

Modify the gh-aw workflow compiler to generate grouped shell redirects instead of individual redirects, eliminating 164 shellcheck SC2129 style warnings across all compiled workflows.

Context

From discussion #15009 - Actionlint/shellcheck reports 164 occurrences of SC2129 across all 149 workflows (49% of all findings). This is a style issue in compiler-generated code.

Current Pattern (Generated):

echo "line 1" >> "$GH_AW_PROMPT"
echo "line 2" >> "$GH_AW_PROMPT"
echo "line 3" >> "$GH_AW_PROMPT"

Desired Pattern:

{
  echo "line 1"
  echo "line 2"
  echo "line 3"
} >> "$GH_AW_PROMPT"

Approach

  1. Locate the compiler code that generates shell scripts with redirects (likely in prompt construction or YAML generation phase)

    • Check pkg/workflow/compiler.go or pkg/workflow/compiler_yaml.go
    • Look for code generating multiple consecutive redirects to the same file/variable
  2. Implement grouping logic:

    • Detect sequences of commands redirecting to the same file
    • Group them using brace syntax { ... }
    • Apply single redirect at the end
  3. Handle edge cases:

    • Single redirects (don't group)
    • Mixed redirect types (> vs >>)
    • Redirects to different files
    • Preserve error handling behavior
  4. Test the changes:

    • Recompile several workflows with make recompile
    • Verify generated .lock.yml files use grouped redirects
    • Run gh aw compile --actionlint to confirm SC2129 warnings eliminated
    • Run make test-unit to ensure tests pass
    • Test workflow execution to ensure behavior unchanged

Files to Modify

  • pkg/workflow/compiler.go or pkg/workflow/compiler_yaml.go (compiler logic)
  • Potentially add helper functions for grouping redirects
  • Update tests if needed

Acceptance Criteria

  • Compiler generates grouped redirects for consecutive commands targeting same file
  • All 164 SC2129 warnings eliminated (verify with actionlint)
  • Edge cases handled correctly (single redirects, mixed types)
  • Unit tests pass (make test-unit)
  • Sample workflows recompile and execute correctly
  • Generated code is cleaner and more performant

AI generated by Plan Command for discussion #15009

  • expires on Feb 14, 2026, 1:28 AM UTC

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 12, 2026 02:15
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update workflow compiler to generate grouped shell redirects Group consecutive shell redirects to eliminate SC2129 warnings Feb 12, 2026
Copilot AI requested a review from pelikhan February 12, 2026 02:24
@pelikhan pelikhan closed this Feb 12, 2026
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.

[plan] Update workflow compiler to generate grouped shell redirects (SC2129)

2 participants

Comments