From 5599422253a86ef8762f25a19025665ff01f389f Mon Sep 17 00:00:00 2001 From: cfdaily Date: Wed, 20 May 2026 20:36:09 +0800 Subject: [PATCH] auto-sync: 2026-05-20 20:36:09 --- src/api/project_routes.py | 26 ++++++++++++++++++++++++++ src/main.py | 5 +++++ 2 files changed, 31 insertions(+) diff --git a/src/api/project_routes.py b/src/api/project_routes.py index 5c1ba75..1013192 100644 --- a/src/api/project_routes.py +++ b/src/api/project_routes.py @@ -54,3 +54,29 @@ async def archive_project(project_id: str): if not reg.archive_project(project_id): raise HTTPException(404, f"Project not found: {project_id}") return {"ok": True} + + +@router.delete("/{project_id}") +async def delete_project(project_id: str): + """逻辑删除项目(status→deleted)""" + reg = _registry() + # 检查项目存在 + info = reg.get_project(project_id) + if not info: + raise HTTPException(404, f"Project not found: {project_id}") + if not reg.delete_project(project_id): + raise HTTPException(500, "Delete failed") + return {"ok": True} + + +@router.patch("/{project_id}") +async def update_project(project_id: str, body: Dict[str, Any]): + """更新项目元数据(name/description 等)""" + reg = _registry() + allowed = {"name", "description", "status"} + updates = {k: v for k, v in body.items() if k in allowed} + if not updates: + return {"ok": True} + if not reg.update_project(project_id, **updates): + raise HTTPException(404, f"Project not found: {project_id}") + return {"ok": True} diff --git a/src/main.py b/src/main.py index ff4bd27..822489a 100644 --- a/src/main.py +++ b/src/main.py @@ -113,6 +113,11 @@ async def lifespan(app: FastAPI): if discovered: logger.info("Auto-discovered projects: %s", discovered) + # v3.0: 自动发现 sanguo_projects 正式项目 + sanguo_discovered = registry.discover_sanguo_projects() + if sanguo_discovered: + logger.info("Auto-discovered sanguo projects: %s", sanguo_discovered) + daemon_config = config.get("daemon", {}) tick_interval = daemon_config.get("tick_interval", 30) max_dispatch = daemon_config.get("max_dispatch_per_tick", 3)