feat: /reset 명령어에 확인 단계 추가

- /reset: 삭제될 데이터 미리보기 및 확인 요청
- /reset-confirm: 실제 삭제 실행
- 실수로 데이터 삭제 방지

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-01-14 13:36:55 +09:00
parent 3d70bf0c1a
commit 6fd4a4028d

View File

@@ -27,7 +27,7 @@ export async function handleCommand(
/context - 현재 컨텍스트 확인
/profile - 내 프로필 보기
/stats - 대화 통계
/reset - 대화 초기화`;
/reset - 대화 초기화 (확인 필요)`;
case '/help':
return `📖 <b>도움말</b>
@@ -37,7 +37,7 @@ export async function handleCommand(
/context - 현재 컨텍스트 상태
/profile - 내 프로필 보기
/stats - 대화 통계
/reset - 모든 대화 기록 삭제
/reset - 대화 초기화 (확인 단계 있음)
<b>사용자 프로필 시스템:</b>
• 메시지 ${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 `⚠️ <b>정말 초기화할까요?</b>
삭제될 데이터:
• 메시지 버퍼: ${ctx.recentMessages.length}
• 프로필: v${profileGen}
• 총 메시지 기록: ${msgCount}
<b>이 작업은 되돌릴 수 없습니다!</b>
확인하려면 /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': {