-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (152 loc) · 6.1 KB
/
agent-docs.yml
File metadata and controls
165 lines (152 loc) · 6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Agent Builder Agent3
on:
schedule:
- cron: "*/10 * * * *"
workflow_dispatch:
inputs:
test_mode:
description: "Temporary test run: bypass in-progress lock for this run"
required: false
default: "false"
permissions:
contents: write
pull-requests: write
issues: write
concurrency:
group: agent-builder-agent3
cancel-in-progress: false
jobs:
build:
runs-on: [self-hosted, macOS, X64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Pick next eligible issue
id: pick
env:
GH_TOKEN: ${{ github.token }}
AGENT_LABEL: agent3
SKIP_IN_PROGRESS_CHECK: ${{ inputs.test_mode == 'true' && 'true' || 'false' }}
run: |
set -euo pipefail
bash ProjectBeacon/.github/scripts/pick_issue.sh
- name: Exit if no eligible issue
if: steps.pick.outputs.ISSUE_NUMBER == ''
run: |
set -euo pipefail
echo "No eligible issue found for agent3."
- name: Build prompt from issue + task profile
if: steps.pick.outputs.ISSUE_NUMBER != ''
env:
GH_TOKEN: ${{ github.token }}
ISSUE_NUMBER: ${{ steps.pick.outputs.ISSUE_NUMBER }}
run: |
set -euo pipefail
ISSUE_TITLE="$(gh issue view "$ISSUE_NUMBER" --json title --jq '.title')"
ISSUE_BODY="$(gh issue view "$ISSUE_NUMBER" --json body --jq '.body // ""')"
{
echo "You are builder agent: agent3."
echo
echo "Implement GitHub issue #${ISSUE_NUMBER}: ${ISSUE_TITLE}"
echo
echo "Issue body:"
echo "${ISSUE_BODY}"
echo
echo "Execution requirements:"
echo "- Follow AGENTS.md repository rules from ProjectBeacon/AGENTS.md."
echo "- Follow TASK-agent3.md ownership/boundaries/handoff requirements."
echo "- Produce code changes for this issue only."
echo "- Run relevant verification commands from AGENTS.md."
echo "- Create/update ProjectBeacon/PR_BODY.md with sections: Summary, Issue link, Tests run, Risk/rollback, Checklist."
echo "- Include 'Fixes #${ISSUE_NUMBER}' in the title and PR_BODY.md."
echo
echo "Repository policy:"
cat ProjectBeacon/AGENTS.md
echo
echo "Task agent profile:"
cat ProjectBeacon/TASK-agent3.md
} > ProjectBeacon/PROMPT.md
- name: Run Codex
if: steps.pick.outputs.ISSUE_NUMBER != ''
uses: openai/codex-action@v1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
prompt-file: ProjectBeacon/PROMPT.md
safety-strategy: none
sandbox: workspace-write
- name: Detect code changes
if: steps.pick.outputs.ISSUE_NUMBER != ''
id: changes
run: |
set -euo pipefail
if [[ -n "$(git status --porcelain -- ProjectBeacon ':(exclude)ProjectBeacon/PR_BODY.md' ':(exclude)ProjectBeacon/PROMPT.md')" ]]; then
echo "HAS_CHANGES=true" >> "$GITHUB_OUTPUT"
else
echo "HAS_CHANGES=false" >> "$GITHUB_OUTPUT"
fi
- name: Comment when no changes produced
if: steps.pick.outputs.ISSUE_NUMBER != '' && steps.changes.outputs.HAS_CHANGES == 'false'
env:
GH_TOKEN: ${{ github.token }}
ISSUE_NUMBER: ${{ steps.pick.outputs.ISSUE_NUMBER }}
MESSAGE: "Automation run completed but no changes were produced."
run: |
set -euo pipefail
bash ProjectBeacon/.github/scripts/comment_issue.sh
- name: Ensure PR body exists
if: steps.pick.outputs.ISSUE_NUMBER != '' && steps.changes.outputs.HAS_CHANGES == 'true'
env:
ISSUE_NUMBER: ${{ steps.pick.outputs.ISSUE_NUMBER }}
run: |
set -euo pipefail
if [[ ! -f ProjectBeacon/PR_BODY.md ]]; then
printf '%s\n' \
'Summary' \
"- Implemented automated changes for issue #${ISSUE_NUMBER}." \
'' \
'Issue link' \
"- Fixes #${ISSUE_NUMBER}" \
'' \
'Tests run' \
'- Not specified.' \
'' \
'Risk/rollback' \
'- Low to medium. Revert this PR if regressions are observed.' \
'' \
'Checklist' \
'- [x] Changes align with issue requirements.' \
'- [ ] Add or update tests if needed.' > ProjectBeacon/PR_BODY.md
fi
grep -q "Fixes #${ISSUE_NUMBER}" ProjectBeacon/PR_BODY.md || echo "\nFixes #${ISSUE_NUMBER}" >> ProjectBeacon/PR_BODY.md
- name: Commit and push branch
if: steps.pick.outputs.ISSUE_NUMBER != '' && steps.changes.outputs.HAS_CHANGES == 'true'
env:
ISSUE_NUMBER: ${{ steps.pick.outputs.ISSUE_NUMBER }}
run: |
set -euo pipefail
timestamp="$(date +%Y%m%d%H%M%S)"
branch="codex/agent3/issue-${ISSUE_NUMBER}-${timestamp}"
echo "BRANCH_NAME=${branch}" >> "$GITHUB_ENV"
git config user.name "codex-bot"
git config user.email "codex-bot@users.noreply.github.com"
git checkout -b "${branch}"
git add -A
git restore --staged ProjectBeacon/PR_BODY.md ProjectBeacon/PROMPT.md || true
git commit -m "feat(agent3): resolve issue #${ISSUE_NUMBER}"
git push -u origin "${branch}"
- name: Create PR
if: steps.pick.outputs.ISSUE_NUMBER != '' && steps.changes.outputs.HAS_CHANGES == 'true'
env:
GH_TOKEN: ${{ github.token }}
ISSUE_NUMBER: ${{ steps.pick.outputs.ISSUE_NUMBER }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
run: |
set -euo pipefail
issue_title="$(gh issue view "$ISSUE_NUMBER" --json title --jq '.title')"
pr_title="[agent3] Fixes #${ISSUE_NUMBER} - ${issue_title}"
gh pr create \
--base main \
--head "${BRANCH_NAME}" \
--title "${pr_title}" \
--body-file ProjectBeacon/PR_BODY.md \
--label "agent3"