fix: docs_manager 세션 기록 크래시 방지

- record_session을 try/except로 감싸서 실패해도 봇 지속
- mkdir 안전장치 추가 (에이전트가 docs/ 삭제할 수 있음)
- em-dash → ASCII dash 변경
This commit is contained in:
2026-03-06 23:42:06 +09:00
parent a408bb32fe
commit fcd3ebfd41

View File

@@ -68,49 +68,54 @@ class DocsManager:
def record_session(self, request: str, summary: dict, plan: dict = None) -> str: def record_session(self, request: str, summary: dict, plan: dict = None) -> str:
"""작업 세션을 기록.""" """작업 세션을 기록."""
now = datetime.now() try:
filename = f"{now.strftime('%Y-%m-%d_%H%M%S')}.md" self.sessions_path.mkdir(parents=True, exist_ok=True)
filepath = self.sessions_path / filename now = datetime.now()
filename = f"{now.strftime('%Y-%m-%d_%H%M%S')}.md"
filepath = self.sessions_path / filename
lines = [ lines = [
f"# 작업 기록 {now.strftime('%Y-%m-%d %H:%M')}", f"# 작업 기록 - {now.strftime('%Y-%m-%d %H:%M')}",
"",
f"## 요청",
f"{request}",
"",
]
if plan:
lines.extend([
f"## 계획",
f"{plan.get('summary', str(plan)[:300])}",
"", "",
]) f"## 요청",
f"{request}",
if isinstance(summary, dict):
lines.extend([
f"## 결과",
f"{summary.get('summary', str(summary)[:300])}",
"", "",
]) ]
changes = summary.get("changes", []) if plan:
if changes: lines.extend([
lines.append("## 변경 파일") f"## 계획",
for c in changes: f"{plan.get('summary', str(plan)[:300])}",
lines.append(f"- `{c.get('file', '?')}` — {c.get('description', '')}") "",
lines.append("") ])
warnings = summary.get("warnings", []) if isinstance(summary, dict):
if warnings: lines.extend([
lines.append("## 주의사항") f"## 결과",
for w in warnings: f"{summary.get('summary', str(summary)[:300])}",
lines.append(f"- {w}") "",
lines.append("") ])
filepath.write_text("\n".join(lines), encoding="utf-8") changes = summary.get("changes", [])
logger.info(f"세션 기록: {filepath}") if changes:
return str(filepath) 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): def append_changelog(self, entry: str):
"""Changelog에 항목 추가.""" """Changelog에 항목 추가."""