Skip to content

interact_spatial_scatter notworking #47

interact_spatial_scatter notworking

interact_spatial_scatter notworking #47

name: "Auto Fix Issue (mini-swe-agent)"
on:
issues:
types: [labeled]
permissions:
issues: write
contents: write
pull-requests: write
jobs:
swe-agent-fix:
if: github.event.label.name == 'auto-fix'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install mini-swe-agent
run: |
pip install mini-swe-agent
mini --help || echo "mini-swe-agent installed"
- name: Fetch issue body via GitHub API
id: issue
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_PAT }}
script: |
const issue = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ github.event.issue.number }},
});
const fs = require('fs');
const content = `# Issue #${ issue.data.number }: ${ issue.data.title }\n\n${ issue.data.body || '(no body)' }`;
fs.writeFileSync('issue_body.md', content);
return content;
- name: Comment analysis started
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_PAT }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ github.event.issue.number }},
body: '## 🤖 mini-swe-agent 正在分析并修复此 issue...\n\n预计 5-15 分钟完成。\n\n[查看进度](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})'
});
- name: Skip first-time setup wizard
run: |
mkdir -p ~/.config/mini-swe-agent
echo 'MSWEA_CONFIGURED=true' > ~/.config/mini-swe-agent/.env
- name: Run mini-swe-agent
id: sweagent
env:
OPENAI_API_KEY: ${{ secrets.ZHIPUAI_API_KEY }}
MSWEA_COST_TRACKING: "ignore_errors"
MSWEA_CONFIGURED: "true"
run: |
echo "Running mini-swe-agent on issue #${{ github.event.issue.number }}"
TASK_CONTENT=$(cat issue_body.md)
mini \
--config config/glm5_stereopy.yaml \
--task "$TASK_CONTENT" \
--yolo \
--exit-immediately \
2>&1 | tee swe_agent_output.log || true
if git diff --quiet; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
echo "mini-swe-agent did not produce any changes"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
echo "mini-swe-agent produced changes:"
git diff --stat
fi
- name: Create branch and push fix
if: steps.sweagent.outputs.has_changes == 'true'
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
BRANCH="auto-fix/issue-${ISSUE_NUMBER}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH"
git add -A
git commit -m "fix #${ISSUE_NUMBER}: auto-generated fix by mini-swe-agent + GLM-5"
git push origin "$BRANCH"
- name: Comment with results (success)
if: steps.sweagent.outputs.has_changes == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_PAT }}
script: |
const issueNum = ${{ github.event.issue.number }};
const branch = `auto-fix/issue-${issueNum}`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNum,
body: [
'## 🤖 mini-swe-agent 修复完成',
'',
`代码已推送到分支 \`${branch}\`。`,
'',
'CI 将自动运行 lint + test 并创建 PR。',
'',
`[查看 Actions 日志](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})`,
].join('\n')
});
- name: Comment with results (no changes)
if: steps.sweagent.outputs.has_changes != 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_PAT }}
script: |
const fs = require('fs');
let logTail = '';
try {
const log = fs.readFileSync('swe_agent_output.log', 'utf8');
const lines = log.split('\n');
logTail = lines.slice(-30).join('\n');
} catch {}
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ github.event.issue.number }},
body: [
'## 🤖 mini-swe-agent 未能生成修复',
'',
'Agent 分析了此 issue 但未产生代码修改。可能原因:',
'- Issue 描述不够详细,缺少可复现的信息',
'- 问题过于复杂,需要人工介入',
'- 模型输出不符合预期格式',
'',
'<details><summary>Agent 日志(最后 30 行)</summary>',
'',
'```',
logTail.substring(0, 3000),
'```',
'</details>',
'',
`[查看完整日志](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})`,
].join('\n')
});