Skip to content

Commit 0e827b1

Browse files
Copilotpelikhan
andcommitted
Simplify prompt and script handling
- Remove shebang from checkout_pr.sh (not needed for embedded scripts) - Simplify pr_context_prompt.md (remove redundant sections) - Include cat/EOF logic in WritePromptTextToYAML helper - Update pr.go to use simplified helper - Update tests to match simplified prompt content - Improve code clarity and maintainability Co-authored-by: pelikhan <[email protected]>
1 parent 89d975b commit 0e827b1

6 files changed

Lines changed: 5 additions & 43 deletions

File tree

‎.github/workflows/tidy.lock.yml‎

Lines changed: 0 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pkg/workflow/pr.go‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ func (c *Compiler) generatePRContextPromptStep(yaml *strings.Builder, data *Work
6060
yaml.WriteString(" env:\n")
6161
yaml.WriteString(" GITHUB_AW_PROMPT: /tmp/aw-prompts/prompt.txt\n")
6262
yaml.WriteString(" run: |\n")
63-
yaml.WriteString(" cat >> $GITHUB_AW_PROMPT << 'EOF'\n")
6463
WritePromptTextToYAML(yaml, prContextPromptText, " ")
65-
yaml.WriteString(" EOF\n")
6664
}
6765

6866
// hasCommentRelatedTriggers checks if the workflow has any comment-related event triggers

‎pkg/workflow/pr_checkout_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ Test workflow without contents read permission.
203203
if !strings.Contains(lockStr, "automatically checked out to the PR's branch") {
204204
t.Error("PR context prompt should explain the branch context")
205205
}
206-
if !strings.Contains(lockStr, "Available Actions") {
207-
t.Error("PR context prompt should include available actions section")
206+
if !strings.Contains(lockStr, "Current Branch Context") {
207+
t.Error("PR context prompt should include branch context heading")
208208
}
209209
}
210210
})

‎pkg/workflow/sh.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ func WriteShellScriptToYAML(yaml *strings.Builder, script string, indent string)
2323
}
2424
}
2525

26-
// WritePromptTextToYAML writes prompt text with proper indentation to a strings.Builder
26+
// WritePromptTextToYAML writes prompt text to a YAML heredoc with proper indentation
2727
func WritePromptTextToYAML(yaml *strings.Builder, text string, indent string) {
28+
yaml.WriteString(indent + "cat >> $GITHUB_AW_PROMPT << 'EOF'\n")
2829
textLines := strings.Split(text, "\n")
2930
for _, line := range textLines {
3031
fmt.Fprintf(yaml, "%s%s\n", indent, line)
3132
}
33+
yaml.WriteString(indent + "EOF\n")
3234
}

‎pkg/workflow/sh/checkout_pr.sh‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/bin/bash
21
set -e
32

43
# Determine PR number based on event type

‎pkg/workflow/sh/pr_context_prompt.md‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,3 @@
1111
- Any file operations you perform will be on the PR branch code
1212
- You can inspect, analyze, and work with the PR changes directly
1313
- The PR branch has been checked out using `gh pr checkout`
14-
15-
### Available Actions
16-
17-
You can:
18-
- Review the changes in the PR by examining files
19-
- Run tests or linters on the PR code
20-
- Make additional changes to the PR branch if needed
21-
- Create commits on the PR branch (they will appear in the PR)
22-
- Switch to other branches using `git checkout` if needed
23-
24-
### Current Branch Information
25-
26-
To see which branch you're currently on, you can run:
27-
```bash
28-
git branch --show-current
29-
git log -1 --oneline
30-
```
31-

0 commit comments

Comments
 (0)