-
Notifications
You must be signed in to change notification settings - Fork 0
519 lines (464 loc) · 23.1 KB
/
Copy pathagent.yml
File metadata and controls
519 lines (464 loc) · 23.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
name: GoudEngine Agent
on:
issues:
types: [labeled]
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
jobs:
# Job 1: Plan-only agent for default flow (no skip-plan label)
plan-agent:
name: Plan Agent
if: >-
vars.AGENT_ENABLED == 'true' &&
github.event_name == 'issues' &&
github.event.label.name == 'agent-ready' &&
!contains(toJSON(github.event.issue.labels.*.name), 'skip-plan')
runs-on: ubuntu-latest
timeout-minutes: 30
concurrency:
group: agent-${{ github.event.issue.number }}
cancel-in-progress: false
permissions:
contents: read
pull-requests: read
issues: write
actions: read
id-token: write
steps:
- name: Swap label to agent-planning
env:
GH_TOKEN: ${{ github.token }}
run: |
gh issue edit ${{ github.event.issue.number }} \
--remove-label "agent-ready" \
--add-label "agent-planning" \
--repo ${{ github.repository }}
- uses: actions/checkout@v7
with:
fetch-depth: 1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxxf86vm-dev libasound2-dev
- name: Run Claude Code (planning)
id: claude
uses: anthropics/claude-code-action@v1
continue-on-error: true
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
allowed_bots: "goudengine-agent"
show_full_output: "true"
prompt: |
You are in PLANNING MODE for the following issue.
Title: ${{ github.event.issue.title }}
Number: #${{ github.event.issue.number }}
Body:
${{ github.event.issue.body }}
Your task:
1. Read AGENTS.md for project conventions and architecture
2. Explore the relevant codebase areas thoroughly
3. Understand the full scope of changes needed
4. Produce a structured implementation plan
Rules:
- Do NOT create branches, modify files, or open PRs
- Do NOT write implementation code
- Focus entirely on analysis and planning
When your plan is ready, post it as a comment on the issue using:
gh issue comment ${{ github.event.issue.number }} --repo ${{ github.repository }} --body "<plan>"
The plan MUST use this structure:
<!-- agent-plan -->
## Implementation Plan for #${{ github.event.issue.number }}
### Summary
<brief description of what this plan covers>
### Analysis
- **Issue type**: feature | fix | refactor | docs | ci
- **Layers touched**: Core | FFI | SDK | Examples
- **Complexity**: low | medium | high
- **Agent teams**: engine-lead | integration-lead | quality-lead
### Approach
<numbered steps for implementation>
### Files to Modify
<list of existing files that need changes>
### Files to Create
<list of new files, or "None">
### Testing Strategy
<how to verify the changes work>
### Open Questions
<any uncertainties or decisions needed, or "None">
<!-- end-agent-plan -->
claude_args: |
--model claude-opus-4-6
--max-budget-usd 15
--allowedTools "Read,Glob,Grep,Agent,Skill,TaskCreate,TaskUpdate,TaskList,TaskGet,Bash(cargo check:*),Bash(cargo test --no-run:*),Bash(gh:*),Bash(git log:*),Bash(git diff:*),Bash(git status:*),Bash(ls:*),Bash(find:*),Bash(wc:*),Bash(tree:*),Bash(rg:*)"
--append-system-prompt "You are working on GoudEngine, a Rust game engine with C# and Python SDK bindings. You are in PLANNING MODE — do NOT modify any files, create branches, or open PRs. Read the root AGENTS.md for full project context, architecture, and conventions. Your sole output is an implementation plan posted as an issue comment."
- name: Handle success — move to plan review
if: steps.claude.outcome == 'success'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh issue edit ${{ github.event.issue.number }} \
--remove-label "agent-planning" \
--add-label "agent-plan-review" \
--repo ${{ github.repository }}
- name: Handle failure
if: steps.claude.outcome == 'failure'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh issue edit ${{ github.event.issue.number }} \
--remove-label "agent-planning" \
--add-label "agent-blocked" \
--repo ${{ github.repository }}
gh issue comment ${{ github.event.issue.number }} \
--body "The planning agent failed to produce a plan. Manual intervention required. Check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details." \
--repo ${{ github.repository }}
- name: Fail job if Claude failed
if: steps.claude.outcome == 'failure'
run: exit 1
# Job 2: Single-shot agent for trivial issues with skip-plan label
skip-plan-agent:
name: Skip-Plan Agent
if: >-
vars.AGENT_ENABLED == 'true' &&
github.event_name == 'issues' &&
github.event.label.name == 'agent-ready' &&
contains(toJSON(github.event.issue.labels.*.name), 'skip-plan')
runs-on: ubuntu-latest
timeout-minutes: 120
concurrency:
group: agent-${{ github.event.issue.number }}
cancel-in-progress: false
permissions:
contents: write
pull-requests: write
issues: write
actions: read
id-token: write
steps:
- name: Swap label to agent-working
env:
GH_TOKEN: ${{ github.token }}
run: |
gh issue edit ${{ github.event.issue.number }} \
--remove-label "agent-ready" \
--add-label "agent-working" \
--repo ${{ github.repository }}
- uses: actions/checkout@v7
with:
fetch-depth: 1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxxf86vm-dev libasound2-dev
- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1
continue-on-error: true
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
allowed_bots: "goudengine-agent"
show_full_output: "true"
prompt: |
Implement the following GitHub issue.
Title: ${{ github.event.issue.title }}
Number: #${{ github.event.issue.number }}
Body:
${{ github.event.issue.body }}
Requirements:
- Create a branch named: agent/issue-${{ github.event.issue.number }}-<short-slug>
- Use conventional commits (feat:, fix:, etc.)
- Read AGENTS.md for project conventions
- Run cargo check, cargo fmt --check, cargo clippy -- -D warnings
- When opening the PR, read .github/pull_request_template.md and use it to structure the PR body
- Include "Closes #${{ github.event.issue.number }}" in the Related Issues field
claude_args: |
--model claude-opus-4-6
--max-budget-usd 50
--allowedTools "Bash(*),Read,Write,Edit,MultiEdit,Glob,Grep,Agent,Skill,TaskCreate,TaskUpdate,TaskList,TaskGet"
--disallowedTools "Bash(cargo publish:*),Bash(git push --force:*),Bash(git push -f:*),Bash(rm -rf /:*),Bash(rm -rf ~:*),Bash(chmod -R 777:*),Bash(gh issue delete:*),Bash(gh repo delete:*),Bash(gh repo archive:*)"
--append-system-prompt "You are working on GoudEngine, a Rust game engine with C# and Python SDK bindings. Read the root AGENTS.md for full project context, architecture, and conventions. Key principles: Rust-first (all logic in Rust, SDKs are thin FFI wrappers), layer hierarchy (libs -> engine -> ffi -> sdks -> examples), FFI exports need #[no_mangle] extern C and #[repr(C)], SDK parity (every FFI function must have both C# and Python wrappers). Run cargo check, cargo fmt --check, and cargo clippy after changes."
- name: Check if PR was created
id: check-pr
if: steps.claude.outcome == 'failure'
env:
GH_TOKEN: ${{ github.token }}
run: |
PR_URL=$(gh pr list --head "agent/issue-${{ github.event.issue.number }}" --json url --jq '.[0].url' --repo ${{ github.repository }})
if [ -n "$PR_URL" ]; then
echo "pr_created=true" >> "$GITHUB_OUTPUT"
echo "Agent created PR despite reporting failure: $PR_URL"
else
echo "pr_created=false" >> "$GITHUB_OUTPUT"
fi
- name: Handle success
if: steps.claude.outcome == 'success' || steps.check-pr.outputs.pr_created == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh issue edit ${{ github.event.issue.number }} \
--remove-label "agent-working" \
--repo ${{ github.repository }}
- name: Handle failure
if: steps.claude.outcome == 'failure' && steps.check-pr.outputs.pr_created != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh issue edit ${{ github.event.issue.number }} \
--remove-label "agent-working" \
--add-label "agent-blocked" \
--repo ${{ github.repository }}
gh issue comment ${{ github.event.issue.number }} \
--body "The autonomous agent failed to complete this issue. Manual intervention required. Check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details." \
--repo ${{ github.repository }}
- name: Fail job if Claude truly failed
if: steps.claude.outcome == 'failure' && steps.check-pr.outputs.pr_created != 'true'
run: exit 1
# Job 3: Revise plan based on human feedback via @goudengine-plan
revise-plan-agent:
name: Revise Plan Agent
if: >-
vars.AGENT_ENABLED == 'true' &&
github.event_name == 'issue_comment' &&
contains(github.event.comment.body, '@goudengine-plan')
runs-on: ubuntu-latest
timeout-minutes: 30
concurrency:
group: agent-${{ github.event.issue.number }}
cancel-in-progress: false
permissions:
contents: read
pull-requests: read
issues: write
actions: read
id-token: write
steps:
- name: Check label gate
id: gate
env:
GH_TOKEN: ${{ github.token }}
run: |
labels=$(gh issue view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json labels --jq '.labels[].name')
if ! echo "$labels" | grep -q "^agent-plan-review$"; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "Issue does not have agent-plan-review label, skipping."
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Check revision cap
id: cap
if: steps.gate.outputs.skip != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
revision_count=$(gh issue view ${{ github.event.issue.number }} --repo ${{ github.repository }} --comments --json comments --jq '[.comments[].body | select(contains("<!-- agent-plan-revision:"))] | length')
if [ "$revision_count" -ge 3 ]; then
echo "capped=true" >> "$GITHUB_OUTPUT"
gh issue comment ${{ github.event.issue.number }} \
--body "Plan revision cap reached (3 revisions). Please apply \`agent-plan-approved\` to proceed with the current plan, or manually revise the plan in a comment." \
--repo ${{ github.repository }}
else
echo "capped=false" >> "$GITHUB_OUTPUT"
echo "revision_number=$((revision_count + 1))" >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@v7
if: steps.gate.outputs.skip != 'true' && steps.cap.outputs.capped != 'true'
with:
fetch-depth: 1
- name: Install Rust toolchain
if: steps.gate.outputs.skip != 'true' && steps.cap.outputs.capped != 'true'
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install system dependencies
if: steps.gate.outputs.skip != 'true' && steps.cap.outputs.capped != 'true'
run: |
sudo apt-get update
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxxf86vm-dev libasound2-dev
- name: Run Claude Code (revision)
if: steps.gate.outputs.skip != 'true' && steps.cap.outputs.capped != 'true'
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
allowed_bots: "goudengine-agent"
trigger_phrase: "@goudengine-plan"
show_full_output: "true"
prompt: |
You are revising an implementation plan for issue #${{ github.event.issue.number }}.
Title: ${{ github.event.issue.title }}
Read the full comment thread:
gh issue view ${{ github.event.issue.number }} --repo ${{ github.repository }} --comments --json comments
Find the most recent comment containing "<!-- agent-plan -->" (the current plan).
The human's feedback is in their comment (which triggered this run).
Post a REVISED plan as a new comment incorporating the feedback.
Use the same <!-- agent-plan --> / <!-- end-agent-plan --> structure.
Add a "### Changes from Previous Plan" section at the top of the plan body.
Include this marker: <!-- agent-plan-revision: ${{ steps.cap.outputs.revision_number }} -->
claude_args: |
--model claude-opus-4-6
--max-budget-usd 10
--allowedTools "Read,Glob,Grep,Agent,Skill,TaskCreate,TaskUpdate,TaskList,TaskGet,Bash(cargo check:*),Bash(cargo test --no-run:*),Bash(gh:*),Bash(git log:*),Bash(git diff:*),Bash(git status:*),Bash(ls:*),Bash(find:*),Bash(wc:*),Bash(tree:*),Bash(rg:*)"
--append-system-prompt "You are working on GoudEngine, a Rust game engine with C# and Python SDK bindings. You are in PLAN REVISION MODE — do NOT modify any files, create branches, or open PRs. Read the root AGENTS.md for full project context. Your sole output is a revised implementation plan posted as an issue comment."
# Job 4: Execute the approved plan
execute-plan-agent:
name: Execute Plan Agent
if: >-
vars.AGENT_ENABLED == 'true' &&
github.event_name == 'issues' &&
github.event.label.name == 'agent-plan-approved'
runs-on: ubuntu-latest
timeout-minutes: 120
concurrency:
group: agent-${{ github.event.issue.number }}
cancel-in-progress: false
permissions:
contents: write
pull-requests: write
issues: write
actions: read
id-token: write
steps:
- name: Swap labels to agent-working
env:
GH_TOKEN: ${{ github.token }}
run: |
gh issue edit ${{ github.event.issue.number }} \
--remove-label "agent-plan-approved" \
--remove-label "agent-plan-review" \
--add-label "agent-working" \
--repo ${{ github.repository }}
- uses: actions/checkout@v7
with:
fetch-depth: 1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxxf86vm-dev libasound2-dev
- name: Run Claude Code (execution)
id: claude
uses: anthropics/claude-code-action@v1
continue-on-error: true
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
allowed_bots: "goudengine-agent"
show_full_output: "true"
prompt: |
Implement the following GitHub issue according to the approved plan.
Title: ${{ github.event.issue.title }}
Number: #${{ github.event.issue.number }}
Body:
${{ github.event.issue.body }}
IMPORTANT: An implementation plan has been approved for this issue.
Read the approved plan by running:
gh issue view ${{ github.event.issue.number }} --repo ${{ github.repository }} --comments --json comments --jq '.comments[].body'
Find the most recent comment containing "<!-- agent-plan -->" and follow that plan.
The plan is your blueprint. Follow it closely, but apply judgment if the
codebase has changed. Document any deviations.
Requirements:
- Create a branch named: agent/issue-${{ github.event.issue.number }}-<short-slug>
- Use conventional commits (feat:, fix:, etc.)
- Read AGENTS.md for project conventions
- Run cargo check, cargo fmt --check, cargo clippy -- -D warnings
- When opening the PR, read .github/pull_request_template.md and use it to structure the PR body
- Include "Closes #${{ github.event.issue.number }}" in the Related Issues field
claude_args: |
--model claude-opus-4-6
--max-budget-usd 50
--allowedTools "Bash(*),Read,Write,Edit,MultiEdit,Glob,Grep,Agent,Skill,TaskCreate,TaskUpdate,TaskList,TaskGet"
--disallowedTools "Bash(cargo publish:*),Bash(git push --force:*),Bash(git push -f:*),Bash(rm -rf /:*),Bash(rm -rf ~:*),Bash(chmod -R 777:*),Bash(gh issue delete:*),Bash(gh repo delete:*),Bash(gh repo archive:*)"
--append-system-prompt "You are working on GoudEngine, a Rust game engine with C# and Python SDK bindings. Read the root AGENTS.md for full project context, architecture, and conventions. Key principles: Rust-first (all logic in Rust, SDKs are thin FFI wrappers), layer hierarchy (libs -> engine -> ffi -> sdks -> examples), FFI exports need #[no_mangle] extern C and #[repr(C)], SDK parity (every FFI function must have both C# and Python wrappers). Run cargo check, cargo fmt --check, and cargo clippy after changes. IMPORTANT: An approved plan exists in the issue comments — read it first and follow it."
- name: Check if PR was created
id: check-pr
if: steps.claude.outcome == 'failure'
env:
GH_TOKEN: ${{ github.token }}
run: |
PR_URL=$(gh pr list --head "agent/issue-${{ github.event.issue.number }}" --json url --jq '.[0].url' --repo ${{ github.repository }})
if [ -n "$PR_URL" ]; then
echo "pr_created=true" >> "$GITHUB_OUTPUT"
echo "Agent created PR despite reporting failure: $PR_URL"
else
echo "pr_created=false" >> "$GITHUB_OUTPUT"
fi
- name: Handle success
if: steps.claude.outcome == 'success' || steps.check-pr.outputs.pr_created == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh issue edit ${{ github.event.issue.number }} \
--remove-label "agent-working" \
--repo ${{ github.repository }}
- name: Handle failure
if: steps.claude.outcome == 'failure' && steps.check-pr.outputs.pr_created != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh issue edit ${{ github.event.issue.number }} \
--remove-label "agent-working" \
--add-label "agent-blocked" \
--repo ${{ github.repository }}
gh issue comment ${{ github.event.issue.number }} \
--body "The execution agent failed to implement this issue. Manual intervention required. Check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details." \
--repo ${{ github.repository }}
- name: Fail job if Claude truly failed
if: steps.claude.outcome == 'failure' && steps.check-pr.outputs.pr_created != 'true'
run: exit 1
# Job 5: Interactive agent triggered by @goudengine-agent mentions
interactive-agent:
name: Interactive Agent
if: >-
vars.AGENT_ENABLED == 'true' &&
((github.event_name == 'issue_comment' &&
contains(github.event.comment.body, '@goudengine-agent') &&
!contains(github.event.comment.body, '@goudengine-plan')) ||
(github.event_name == 'pull_request_review_comment' &&
contains(github.event.comment.body, '@goudengine-agent')))
runs-on: ubuntu-latest
timeout-minutes: 120
concurrency:
group: agent-interactive-${{ github.event.issue.number || github.event.pull_request.number }}
cancel-in-progress: false
permissions:
contents: write
pull-requests: write
issues: write
actions: read
id-token: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxxf86vm-dev libasound2-dev
- name: Run Claude Code
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
allowed_bots: "goudengine-agent"
trigger_phrase: "@goudengine-agent"
show_full_output: "true"
claude_args: |
--model claude-opus-4-6
--max-budget-usd 50
--allowedTools "Bash(*),Read,Write,Edit,MultiEdit,Glob,Grep,Agent,Skill,TaskCreate,TaskUpdate,TaskList,TaskGet"
--disallowedTools "Bash(cargo publish:*),Bash(git push --force:*),Bash(git push -f:*),Bash(rm -rf /:*),Bash(rm -rf ~:*),Bash(chmod -R 777:*),Bash(gh issue delete:*),Bash(gh repo delete:*),Bash(gh repo archive:*)"
--append-system-prompt "You are working on GoudEngine, a Rust game engine with C# and Python SDK bindings. Read the root AGENTS.md for full project context, architecture, and conventions. Key principles: Rust-first (all logic in Rust, SDKs are thin FFI wrappers), layer hierarchy (libs -> engine -> ffi -> sdks -> examples), FFI exports need #[no_mangle] extern C and #[repr(C)], SDK parity (every FFI function must have both C# and Python wrappers). Run cargo check, cargo fmt --check, and cargo clippy after changes."