@@ -85,6 +85,8 @@ def analyze_and_implement(issue_title, issue_body, project_context, structure):
8585- 파일 경로는 프로젝트 루트 기준 상대 경로
8686- content에는 파일의 전체 내용을 포함하세요
8787- JSON 형식만 출력하고 다른 설명은 포함하지 마세요
88+ - **중요**: JSON 문자열 내의 백슬래시는 반드시 이중 백슬래시(\\ \\ )로 이스케이프하세요
89+ - **중요**: 코드 내의 특수문자(따옴표, 백슬래시 등)를 JSON에 포함할 때는 올바르게 이스케이프하세요
8890"""
8991
9092 try :
@@ -98,10 +100,30 @@ def analyze_and_implement(issue_title, issue_body, project_context, structure):
98100 if response_text .startswith ('```' ):
99101 # ```json ... ``` 형식 처리
100102 lines = response_text .split ('\n ' )
101- response_text = '\n ' .join (lines [1 :- 1 ])
103+ # 첫 줄(```json)과 마지막 줄(```) 제거
104+ if lines [0 ].startswith ('```' ):
105+ lines = lines [1 :]
106+ if lines and lines [- 1 ].strip () == '```' :
107+ lines = lines [:- 1 ]
108+ response_text = '\n ' .join (lines )
109+
110+ # 응답 저장 (디버깅용)
111+ print (f"\n 📝 Gemini 응답 (처음 500자):" )
112+ print (response_text [:500 ])
113+ print ("..." )
102114
103115 result = json .loads (response_text )
104116 return result
117+ except json .JSONDecodeError as e :
118+ print (f"❌ JSON 파싱 오류: { e } " )
119+ print (f"\n 전체 응답 내용:" )
120+ print (response_text )
121+
122+ # 파일로 저장
123+ with open ('/tmp/gemini_response.txt' , 'w' , encoding = 'utf-8' ) as f :
124+ f .write (response_text )
125+ print ("\n 응답이 /tmp/gemini_response.txt에 저장되었습니다." )
126+ raise
105127 except Exception as e :
106128 print (f"Error in Gemini API call: { e } " )
107129 print (f"Response: { response .text if 'response' in locals () else 'No response' } " )
0 commit comments