From d09fd4a173fa40b2cc318e3a9e9da309d64b8805 Mon Sep 17 00:00:00 2001 From: cfdaily Date: Sun, 14 Jun 2026 14:20:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[moz]=20fix(api):=20flake8=20lint=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E2=80=94=20=E7=A7=BB=E9=99=A4=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/shared.py | 4 ++-- src/api/task_routes.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/api/shared.py b/src/api/shared.py index 8bddf0c..0b4d161 100644 --- a/src/api/shared.py +++ b/src/api/shared.py @@ -1,6 +1,5 @@ """共享 helper 和常量""" -from pathlib import Path from typing import Any, Dict from fastapi import HTTPException @@ -56,7 +55,8 @@ def _init_agent_ids(): if _KNOWN_AGENT_IDS: return try: - import yaml, os + import yaml + import os cfg_path = os.path.join(os.path.dirname(__file__), "..", "..", "config", "default.yaml") with open(cfg_path) as f: cfg = yaml.safe_load(f) diff --git a/src/api/task_routes.py b/src/api/task_routes.py index a0e04af..9071619 100644 --- a/src/api/task_routes.py +++ b/src/api/task_routes.py @@ -19,7 +19,6 @@ from src.api.shared import ( _bb, _q, _task_to_dict, - _validate_project, _extract_mentions, ) From cc2e5aa64caa1741e68171bc72a6667406528c5a Mon Sep 17 00:00:00 2001 From: cfdaily Date: Sun, 14 Jun 2026 14:22:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[moz]=20fix(api):=20Review=20M1=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20=E2=80=94=20expand=3Dall=20=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E6=97=A7=E6=A0=BC=E5=BC=8F=20+=20=5Ftoolchain=20=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=20=5FVIRTUAL=5FPROJECTS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - M1: expand=all 保持旧 list 格式(向后兼容 TaskModal .map()/.length) - 细粒度 expand=comments,events 用新 {items,total_count,limit} 格式 - S1(PR#73): _toolchain 加入 _VIRTUAL_PROJECTS - S1(PR#72): 移除 _validate_project 未使用 import --- src/api/shared.py | 2 +- src/api/task_routes.py | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/api/shared.py b/src/api/shared.py index 0b4d161..77d2d5b 100644 --- a/src/api/shared.py +++ b/src/api/shared.py @@ -10,7 +10,7 @@ from src.blackboard.registry import ProjectRegistry from src.utils import get_data_root # 虚拟项目白名单 -_VIRTUAL_PROJECTS = frozenset({"_general", "_mail"}) +_VIRTUAL_PROJECTS = frozenset({"_general", "_mail", "_toolchain"}) def _validate_project(project_id: str) -> str: diff --git a/src/api/task_routes.py b/src/api/task_routes.py index 9071619..d3a71e5 100644 --- a/src/api/task_routes.py +++ b/src/api/task_routes.py @@ -55,10 +55,27 @@ async def get_task(project_id: str, task_id: str, if not expand: return result - expand_list = expand.split(",") if expand != "all" else [ - "comments", "outputs", "reviews", "events", "decisions" - ] + # expand=all: 保持旧格式(list + 聚合字段),向后兼容前端 TaskModal + if expand == "all": + q = _q(project_id) + detail = q.task_detail(task_id) + if detail: + result["comments_count"] = detail.get("comments_count", 0) + result["outputs_count"] = detail.get("outputs_count", 0) + result["review_status"] = detail.get("review_status") + result["latest_event_detail"] = detail.get("latest_event_detail") + result["comments"] = [dict(c.__dict__) + for c in bb.get_comments(task_id)] + result["outputs"] = [dict(o.__dict__) for o in bb.get_outputs(task_id)] + result["reviews"] = [dict(r.__dict__) for r in bb.get_reviews(task_id)] + result["decisions"] = [dict(d.__dict__) + for d in bb.get_decisions(task_id)] + result["events"] = q.task_events(task_id) + result["experiences"] = q.task_experiences(task_id) + return result + # 细粒度 expand: 新格式(comments/events 带 limit + total_count) + expand_list = expand.split(",") q = _q(project_id) if "comments" in expand_list: