Skip to content

Standardize prompt generation pattern - move scattered functions to dedicated files#3564

Merged
pelikhan merged 3 commits intomainfrom
copilot/standardize-prompt-generation
Nov 10, 2025
Merged

Standardize prompt generation pattern - move scattered functions to dedicated files#3564
pelikhan merged 3 commits intomainfrom
copilot/standardize-prompt-generation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 10, 2025

Three generate*PromptStep functions were scattered in compiler_yaml.go and pr.go while five others already had dedicated files. This PR completes the standardization by moving all prompt generation functions to the {feature}_prompt.go pattern.

Changes

Moved Functions to Dedicated Files:

  • generateCacheMemoryPromptStepcache_memory_prompt.go
  • generateSafeOutputsPromptStepsafe_outputs_prompt.go
  • generatePRContextPromptStep + helper → pr_prompt.go

Pattern:

// pkg/workflow/{feature}_prompt.go
func (c *Compiler) generate{Feature}PromptStep(yaml *strings.Builder, ...) {
    if !shouldInclude { return }
    
    appendPromptStepWithHeredoc(yaml, "Description",
        func(y *strings.Builder) {
            generate{Feature}PromptSection(y, config)
        })
}

All 8 prompt generation functions now follow consistent file organization. Helper functions like generateCacheMemoryPromptSection remain in their domain files (cache.go, safe_outputs.go).

Test Coverage: Added 10 test cases covering enabled/disabled states and edge cases for each moved function.

Original prompt

This section details on the original issue you should resolve

<issue_title>[task] Standardize prompt generation pattern - organize generatePromptStep functions</issue_title>
<issue_description>## Objective
Standardize the organization of generate*PromptStep functions by moving scattered prompt generators into dedicated files following the existing pattern.

Context

Multiple generate*PromptStep functions are inconsistently organized. Some have dedicated files, while others are scattered in larger files like compiler_yaml.go and pr.go.

Current distribution:

  • generateEditToolPromptStep - has edit_tool_prompt.go
  • generateGitHubContextPromptStep - has github_context.go
  • generatePlaywrightPromptStep - has playwright_prompt.go
  • generateTempFolderPromptStep - has temp_folder.go
  • generateXPIAPromptStep - has xpia.go
  • generateCacheMemoryPromptStep - in compiler_yaml.go
  • generateSafeOutputsPromptStep - in compiler_yaml.go
  • generatePRContextPromptStep - in pr.go

Part of issue #3435.

Approach

1. Analyze existing prompt generation patterns

Review the well-organized prompt files to understand the pattern:

  • File naming convention: {feature}_prompt.go
  • Function structure and dependencies
  • Testing approach

2. Create dedicated prompt files

Create:

  • pkg/workflow/cache_memory_prompt.go - Move generateCacheMemoryPromptStep
  • pkg/workflow/safe_outputs_prompt.go - Move generateSafeOutputsPromptStep
  • pkg/workflow/pr_prompt.go - Move generatePRContextPromptStep

3. Move prompt generation functions

Move each function to its dedicated file with:

  • Function implementation
  • Any related helper functions
  • Appropriate documentation

4. Update imports

  • Update compiler_yaml.go to remove moved functions
  • Update pr.go to remove moved functions
  • Update any files that reference these functions
  • Ensure no circular dependencies

Files to Modify

Create:

  • pkg/workflow/cache_memory_prompt.go
  • pkg/workflow/safe_outputs_prompt.go
  • pkg/workflow/pr_prompt.go

Update:

  • pkg/workflow/compiler_yaml.go (remove moved functions)
  • pkg/workflow/pr.go (remove moved function)
  • Update imports in files that use these functions
  • Create/update test files as needed

Acceptance Criteria

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

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


✨ 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 and others added 2 commits November 10, 2025 14:05
…iles

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] Standardize organization of generatePromptStep functions Standardize prompt generation pattern - move scattered functions to dedicated files Nov 10, 2025
Copilot AI requested a review from pelikhan November 10, 2025 14:12
@pelikhan pelikhan marked this pull request as ready for review November 10, 2025 14:14
Copilot AI review requested due to automatic review settings November 10, 2025 14:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the prompt generation code by extracting three function groups from compiler_yaml.go into dedicated files, following the project's code organization guidelines of keeping files focused and under 800 lines. The refactoring improves maintainability by organizing prompt-related functions by their specific domain.

Key changes:

  • Extracted safe outputs prompt generation to safe_outputs_prompt.go
  • Extracted cache memory prompt generation to cache_memory_prompt.go
  • Extracted PR context prompt generation to pr_prompt.go
  • Added comprehensive test coverage for all three prompt generation features
  • Enhanced documentation for runs-on and concurrency fields

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/workflow/safe_outputs_prompt.go New file containing generateSafeOutputsPromptStep function (moved from compiler_yaml.go)
pkg/workflow/safe_outputs_prompt_test.go New test file with 3 test cases covering safe outputs prompt generation scenarios
pkg/workflow/cache_memory_prompt.go New file containing generateCacheMemoryPromptStep function (moved from compiler_yaml.go)
pkg/workflow/cache_memory_prompt_test.go New test file with 3 test cases covering cache memory prompt generation scenarios
pkg/workflow/pr_prompt.go New file containing generatePRContextPromptStep and hasCommentRelatedTriggers functions (moved from pr.go)
pkg/workflow/pr_prompt_test.go New test file with 4 test cases covering PR context prompt generation scenarios
pkg/workflow/pr.go Removed two functions that were moved to pr_prompt.go
pkg/workflow/compiler_yaml.go Removed two functions that were moved to their respective domain files
docs/src/content/docs/reference/frontmatter-full.md Enhanced documentation with clearer descriptions and context for runs-on and concurrency fields

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pelikhan pelikhan merged commit 45c30b2 into main Nov 10, 2025
80 of 84 checks passed
@pelikhan pelikhan deleted the copilot/standardize-prompt-generation branch November 10, 2025 15:03
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] Standardize prompt generation pattern - organize generatePromptStep functions

3 participants