Skip to content

[FIX]: 리뷰 탭 전환 및 리뷰 문장 입력 UX 개선 #301

[FIX]: 리뷰 탭 전환 및 리뷰 문장 입력 UX 개선

[FIX]: 리뷰 탭 전환 및 리뷰 문장 입력 UX 개선 #301

name: AI Targeted Fixer
on:
pull_request_review_comment:
types: [created]
jobs:
targeted-fix:
if: |
github.event.comment.user.login != 'github-actions[bot]' &&
contains(github.event.comment.body, '@fix-this')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-aider
- name: Install Tools
run: pip install aider-chat
- name: Resolve comment context
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
IN_REPLY_TO: ${{ github.event.comment.in_reply_to_id }}
run: |
# 답글(@fix-this)이면 부모 코멘트(CodeRabbit 리뷰)를 가져와야 함
if [ -n "$IN_REPLY_TO" ]; then
PARENT=$(gh api "repos/$REPO/pulls/comments/$IN_REPLY_TO")
echo "$PARENT" | jq -r '.body' > comment_body.txt
echo "$PARENT" | jq -r '.path' > file_path.txt
echo "$PARENT" | jq -r '.diff_hunk' > code_context.txt
else
echo '${{ github.event.comment.body }}' > comment_body.txt
echo '${{ github.event.comment.path }}' > file_path.txt
echo '${{ github.event.comment.diff_hunk }}' > code_context.txt
fi
- name: Run Targeted Fix
env:
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
run: |
COMMENT_BODY=$(cat comment_body.txt)
FILE_PATH=$(cat file_path.txt)
CODE_CONTEXT=$(cat code_context.txt)
if [ -z "$FILE_PATH" ] || [ "$FILE_PATH" = "null" ]; then
echo "Could not resolve file path. Exiting."
exit 1
fi
echo "Targeting file: $FILE_PATH"
# CodeRabbit의 "🤖 Prompt for AI Agents" 섹션 추출 시도
AI_PROMPT=$(echo "$COMMENT_BODY" | sed -n '/🤖 Prompt for AI Agents/,/```$/p' | sed '1d;$d' | grep -v '^```' || echo "")
# strategy.md 생성
{
echo "CRITICAL: Fix ONLY the file provided. Do NOT ask for other files or try to update imports in other files."
echo ""
if [ -n "$AI_PROMPT" ]; then
echo "## AI Agent Instructions (from CodeRabbit):"
echo "$AI_PROMPT"
echo ""
fi
echo "## Full Review Comment:"
echo "$COMMENT_BODY"
echo ""
echo "## Code Context (diff hunk):"
echo '```'
echo "$CODE_CONTEXT"
echo '```'
echo ""
echo "IMPORTANT: Apply changes to THIS file only ($FILE_PATH). Ignore suggestions about updating other files."
echo ""
echo "## Commit Message Guidelines - CRITICAL"
echo "- Use conventional commit format: type: description in Korean"
echo "- Type MUST be in English: feat, fix, refactor, docs, style, test, chore"
echo "- Description MUST be in Korean"
echo "- Examples:"
echo " - refactor: CategoryLayout을 default export로 변경"
echo " - fix: 타입 오류 수정"
echo " - style: 코드 포맷팅 개선"
} > strategy.md
aider --model deepseek/deepseek-chat --message-file strategy.md --yes-always --no-check-update --no-gitignore "$FILE_PATH"
- name: Push Changes
run: |
git push origin HEAD:${{ github.event.pull_request.head.ref }} || echo "Nothing to push"