diff --git a/console.py b/console.py index 46ee668..0d89251 100644 --- a/console.py +++ b/console.py @@ -17,7 +17,7 @@ os.environ["NO_PROXY"] = "openrouter.ai,platform.brojs.ru,git.brojs.ru," + os.en from dotenv import load_dotenv load_dotenv() -from solve_task import fetch_todo_tasks, solve, run_all +from solve_task import fetch_todo_tasks, fetch_all_tasks, solve, run_all HELP = """ Команды: @@ -53,9 +53,15 @@ async def main(): print(HELP) elif cmd == "tasks": - tasks = await fetch_todo_tasks() + tasks = await fetch_all_tasks() if not tasks: - print(" Нет активных заданий.") + print(" Заданий не найдено.") + else: + print(f"\n {'ID':10} {'Статус':20} Название") + print(f" {'-'*10} {'-'*20} {'-'*40}") + for t in tasks: + print(f" {t['id'][:8]}... {t['status']:20} {t['title']}") + print() elif cmd.startswith("solve "): task_id = cmd.split(" ", 1)[1].strip() diff --git a/solve_task.py b/solve_task.py index 63794c8..062848d 100644 --- a/solve_task.py +++ b/solve_task.py @@ -389,6 +389,29 @@ async def fetch_todo_tasks(course_id: str = COURSE_ID) -> list[tuple[str, str]]: return tasks +async def fetch_all_tasks(course_id: str = COURSE_ID) -> list[dict]: + """Возвращает все задания курса с их статусами (для мониторинга).""" + raw = await mcp_call("tasks_list", {"courseId": course_id}) + try: + data = json.loads(raw) + except (json.JSONDecodeError, TypeError): + return [] + items = data.get("tasks", data) if isinstance(data, dict) else data + if not isinstance(items, list): + return [] + result = [] + for item in items: + t = item.get("task", item) if isinstance(item, dict) else {} + tid = t.get("id", "") + if tid: + result.append({ + "id": tid, + "title": t.get("title", t.get("name", "")), + "status": item.get("status", ""), + }) + return result + + # --------------------------------------------------------------------------- # Полный автоматический прогон # ---------------------------------------------------------------------------