From fcd3ebfd41674c975c9436da4ff22ab32aa3a4aa Mon Sep 17 00:00:00 2001 From: CD Date: Fri, 6 Mar 2026 23:42:06 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20docs=5Fmanager=20=EC=84=B8=EC=85=98=20?= =?UTF-8?q?=EA=B8=B0=EB=A1=9D=20=ED=81=AC=EB=9E=98=EC=8B=9C=20=EB=B0=A9?= =?UTF-8?q?=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - record_session을 try/except로 감싸서 실패해도 봇 지속 - mkdir 안전장치 추가 (에이전트가 docs/ 삭제할 수 있음) - em-dash → ASCII dash 변경 --- core/docs_manager.py | 79 +++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/core/docs_manager.py b/core/docs_manager.py index 5821621..124c260 100644 --- a/core/docs_manager.py +++ b/core/docs_manager.py @@ -68,49 +68,54 @@ class DocsManager: def record_session(self, request: str, summary: dict, plan: dict = None) -> str: """작업 세션을 기록.""" - now = datetime.now() - filename = f"{now.strftime('%Y-%m-%d_%H%M%S')}.md" - filepath = self.sessions_path / filename + try: + self.sessions_path.mkdir(parents=True, exist_ok=True) + now = datetime.now() + filename = f"{now.strftime('%Y-%m-%d_%H%M%S')}.md" + filepath = self.sessions_path / filename - lines = [ - f"# 작업 기록 — {now.strftime('%Y-%m-%d %H:%M')}", - "", - f"## 요청", - f"{request}", - "", - ] - - if plan: - lines.extend([ - f"## 계획", - f"{plan.get('summary', str(plan)[:300])}", + lines = [ + f"# 작업 기록 - {now.strftime('%Y-%m-%d %H:%M')}", "", - ]) - - if isinstance(summary, dict): - lines.extend([ - f"## 결과", - f"{summary.get('summary', str(summary)[:300])}", + f"## 요청", + f"{request}", "", - ]) + ] - changes = summary.get("changes", []) - if changes: - lines.append("## 변경 파일") - for c in changes: - lines.append(f"- `{c.get('file', '?')}` — {c.get('description', '')}") - lines.append("") + if plan: + lines.extend([ + f"## 계획", + f"{plan.get('summary', str(plan)[:300])}", + "", + ]) - warnings = summary.get("warnings", []) - if warnings: - lines.append("## 주의사항") - for w in warnings: - lines.append(f"- {w}") - lines.append("") + if isinstance(summary, dict): + lines.extend([ + f"## 결과", + f"{summary.get('summary', str(summary)[:300])}", + "", + ]) - filepath.write_text("\n".join(lines), encoding="utf-8") - logger.info(f"세션 기록: {filepath}") - return str(filepath) + changes = summary.get("changes", []) + if changes: + lines.append("## 변경 파일") + for c in changes: + lines.append(f"- `{c.get('file', '?')}` - {c.get('description', '')}") + lines.append("") + + warnings = summary.get("warnings", []) + if warnings: + lines.append("## 주의사항") + for w in warnings: + lines.append(f"- {w}") + lines.append("") + + filepath.write_text("\n".join(lines), encoding="utf-8") + logger.info(f"세션 기록: {filepath}") + return str(filepath) + except Exception as e: + logger.warning(f"세션 기록 실패 (무시): {e}") + return "" def append_changelog(self, entry: str): """Changelog에 항목 추가."""