refactor: 전체 구조 점검 - 데드코드 제거, 에이전트 모드 통일, 취소 기능
1. 데드 코드 제거: execute() 146줄, _read_project_files() 31줄 2. 전 역할 agent 모드: summarize도 call_agent로 변경 3. 작업 취소: 취소/stop/cancel 입력으로 실행 중 작업 중단 4. 중복 방지: 채널당 1작업만 허용
This commit is contained in:
@@ -55,6 +55,9 @@ bot = commands.Bot(
|
||||
# 워크스페이스 매니저 (전역)
|
||||
ws_manager = WorkspaceManager()
|
||||
|
||||
# 실행 중인 작업 추적 (채널ID → asyncio.Task)
|
||||
_running_tasks: dict[int, asyncio.Task] = {}
|
||||
|
||||
|
||||
# ──────────────────────────────────────────────
|
||||
# 대화 기억
|
||||
@@ -222,6 +225,24 @@ async def on_message(message: discord.Message):
|
||||
if not user_text:
|
||||
return
|
||||
|
||||
# 취소 명령어 확인
|
||||
cancel_keywords = {"취소", "stop", "cancel", "중지", "멈춰"}
|
||||
if user_text.lower() in cancel_keywords:
|
||||
channel_id = message.channel.id
|
||||
if channel_id in _running_tasks and not _running_tasks[channel_id].done():
|
||||
_running_tasks[channel_id].cancel()
|
||||
del _running_tasks[channel_id]
|
||||
await message.reply(
|
||||
embed=discord.Embed(
|
||||
title="🛑 작업 취소됨",
|
||||
description="실행 중인 작업을 취소했습니다.",
|
||||
color=0xE74C3C,
|
||||
)
|
||||
)
|
||||
else:
|
||||
await message.reply("실행 중인 작업이 없습니다.")
|
||||
return
|
||||
|
||||
# 통합 프롬프트 호출
|
||||
async with message.channel.typing():
|
||||
try:
|
||||
@@ -246,7 +267,29 @@ async def on_message(message: discord.Message):
|
||||
await message.channel.send(
|
||||
f"ℹ️ {note} 미설정 상태입니다. 로컬 작업만 진행됩니다."
|
||||
)
|
||||
await _handle_task(message, user_text, ws)
|
||||
|
||||
# 작업을 추적 가능한 Task로 실행
|
||||
channel_id = message.channel.id
|
||||
if channel_id in _running_tasks and not _running_tasks[channel_id].done():
|
||||
await message.reply("⚠️ 이미 작업이 실행 중입니다. `취소` 후 다시 요청하세요.")
|
||||
return
|
||||
|
||||
async def _tracked_task():
|
||||
try:
|
||||
await _handle_task(message, user_text, ws)
|
||||
except asyncio.CancelledError:
|
||||
await message.channel.send(
|
||||
embed=discord.Embed(
|
||||
title="🛑 작업 취소됨",
|
||||
description="작업이 사용자에 의해 취소되었습니다.",
|
||||
color=0xE74C3C,
|
||||
)
|
||||
)
|
||||
finally:
|
||||
_running_tasks.pop(channel_id, None)
|
||||
|
||||
task = asyncio.create_task(_tracked_task())
|
||||
_running_tasks[channel_id] = task
|
||||
elif mode == "clarify":
|
||||
question = result.get("question", "더 구체적으로 말씀해 주시겠어요?")
|
||||
embed = discord.Embed(
|
||||
|
||||
Reference in New Issue
Block a user