-
Notifications
You must be signed in to change notification settings - Fork 1
124 lines (106 loc) · 4.96 KB
/
Copy pathauto-fix-issue.yml
File metadata and controls
124 lines (106 loc) · 4.96 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
name: Auto-fix Issue (mini-swe-agent)
on:
issues:
types: [labeled]
permissions:
contents: write
pull-requests: write
issues: write
concurrency:
group: autofix-${{ github.event.issue.number }}
cancel-in-progress: true
jobs:
fix:
# Triggered by adding the "fix-me" label to an issue
if: github.event.label.name == 'fix-me'
runs-on: ubuntu-latest
timeout-minutes: 30 # hard cap so a stuck agent cannot burn runner minutes
steps:
- uses: actions/checkout@v4
- name: Setup Node (project test environment)
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- name: Setup Python & mini-swe-agent
uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install mini-swe-agent
- name: Comment on issue (start)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh issue comment ${{ github.event.issue.number }} \
--body "🤖 mini-swe-agent (Kimi K3) has started working on this issue. A draft PR will be opened automatically when done."
- name: Run mini-swe-agent (Kimi K3)
env:
# Kimi K3 API (OpenAI-compatible endpoint, passed through via litellm openai/)
# Anthropic-compatible endpoint: https://api.kimi.com/coding/
KIMI_API_KEY: ${{ secrets.KIMI_API_KEY }}
OPENAI_API_KEY: ${{ secrets.KIMI_API_KEY }}
OPENAI_BASE_URL: https://api.kimi.com/coding/v1
# Skip the interactive first-run setup wizard (aborts in non-TTY CI);
# MSWEA_CONFIGURED is the actual bypass flag, MSWEA_MODEL_NAME sets the model
MSWEA_CONFIGURED: "true"
MSWEA_MODEL_NAME: openai/k3-256k
# litellm has no pricing entry for this passthrough model; don't crash on cost calc
MSWEA_COST_TRACKING: ignore_errors
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
# Git identity for commits made by the agent (runner has none by default)
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Write the issue to /tmp instead of embedding it in the shell script,
# so arbitrary issue content (quotes, EOF lines, etc.) cannot break parsing
gh issue view "$ISSUE_NUMBER" --json title,body \
-q '.title + "\n\n" + .body' > /tmp/issue.md
TASK=$(cat <<EOF
You are a maintainer of this repository. Fix GitHub issue #${ISSUE_NUMBER},
whose full text is saved at /tmp/issue.md (read it first: cat /tmp/issue.md).
Project context: an opencode plugin written in TypeScript (a /loop command
that runs prompts on a schedule).
- Build: npm run build
- Test: npm test (must pass after your changes)
Rules:
1. Read the relevant source code first, identify the root cause, and apply
a minimal fix. Do not refactor, reformat, or touch unrelated files.
2. Run npm test and make sure everything passes; iterate if it fails.
3. Commit your fix and open a draft PR:
git checkout -b fix/issue-${ISSUE_NUMBER} || git checkout fix/issue-${ISSUE_NUMBER}
git add -A && git commit -m "fix: resolve issue #${ISSUE_NUMBER}"
git push -u origin fix/issue-${ISSUE_NUMBER}
gh pr create --title "fix: resolve issue #${ISSUE_NUMBER}" \
--body "Auto-generated by mini-swe-agent (Kimi K3). Please review carefully.\n\ncloses #${ISSUE_NUMBER}" \
--draft
4. NEVER push to main, NEVER use git push --force, and NEVER modify
files under .github/workflows/.
EOF
)
mini -t "$TASK" \
--model openai/k3-256k \
--yolo \
--exit-immediately \
--cost-limit 0 \
--output "traj-${ISSUE_NUMBER}.json" || true
- name: Upload trajectory
if: always()
uses: actions/upload-artifact@v4
with:
name: traj-${{ github.event.issue.number }}
path: traj-*.json
retention-days: 30
- name: Comment on issue (result)
if: always()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
PR_URL=$(gh pr list --head "fix/issue-${ISSUE_NUMBER}" --json url -q '.[0].url')
if [ -n "$PR_URL" ]; then
gh issue comment "$ISSUE_NUMBER" --body "✅ Fix PR created: ${PR_URL} — please review before merging."
else
gh issue comment "$ISSUE_NUMBER" --body "⚠️ The agent could not complete the fix (step/cost limit reached or root cause unclear). See the trajectory artifact in this workflow run for details; feel free to add more context to the issue and retry."
fi