diff --git a/src/commands.ts b/src/commands.ts index 1b22c05..fc0d8b8 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -27,7 +27,7 @@ export async function handleCommand( /context - 현재 컨텍스트 확인 /profile - 내 프로필 보기 /stats - 대화 통계 -/reset - 대화 초기화`; +/reset - 대화 초기화 (확인 필요)`; case '/help': return `📖 도움말 @@ -37,7 +37,7 @@ export async function handleCommand( /context - 현재 컨텍스트 상태 /profile - 내 프로필 보기 /stats - 대화 통계 -/reset - 모든 대화 기록 삭제 +/reset - 대화 초기화 (확인 단계 있음) 사용자 프로필 시스템: • 메시지 ${config.threshold}개마다 프로필 업데이트 @@ -93,11 +93,43 @@ ${summary.summary} } case '/reset': { - await env.DB.batch([ + const ctx = await getConversationContext(env.DB, userId, chatId); + const msgCount = ctx.totalMessages; + const profileGen = ctx.previousSummary?.generation || 0; + + if (msgCount === 0 && profileGen === 0) { + return '📭 삭제할 데이터가 없습니다.'; + } + + return `⚠️ 정말 초기화할까요? + +삭제될 데이터: +• 메시지 버퍼: ${ctx.recentMessages.length}개 +• 프로필: v${profileGen} +• 총 메시지 기록: ${msgCount}개 + +이 작업은 되돌릴 수 없습니다! + +확인하려면 /reset-confirm 을 입력하세요. +취소하려면 아무 메시지나 보내세요.`; + } + + case '/reset-confirm': { + const result = await env.DB.batch([ env.DB.prepare('DELETE FROM message_buffer WHERE user_id = ?').bind(userId), env.DB.prepare('DELETE FROM summaries WHERE user_id = ?').bind(userId), ]); - return '🗑️ 모든 대화 기록과 요약이 초기화되었습니다.'; + + const deletedMessages = result[0].meta.changes || 0; + const deletedSummaries = result[1].meta.changes || 0; + + return `🗑️ 초기화 완료! + +삭제됨: +• 메시지: ${deletedMessages}개 +• 프로필: ${deletedSummaries}개 + +새로운 대화를 시작하세요!`; } case '/debug': {