From 6fd4a4028d92130a55fcb2dd66af7ead265917cd Mon Sep 17 00:00:00 2001 From: kappa Date: Wed, 14 Jan 2026 13:36:55 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20/reset=20=EB=AA=85=EB=A0=B9=EC=96=B4?= =?UTF-8?q?=EC=97=90=20=ED=99=95=EC=9D=B8=20=EB=8B=A8=EA=B3=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /reset: 삭제될 데이터 미리보기 및 확인 요청 - /reset-confirm: 실제 삭제 실행 - 실수로 데이터 삭제 방지 Co-Authored-By: Claude Opus 4.5 --- src/commands.ts | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) 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': {