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:
"""작업 세션을 기록."""
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에 항목 추가."""