auto-sync: 2026-05-30 18:32:22 (catch-all)
This commit is contained in:
@@ -249,6 +249,31 @@ async def update_status(project_id: str, task_id: str, body: Dict[str, Any]):
|
||||
return {"ok": True, "old_status": current, "new_status": new_status}
|
||||
|
||||
|
||||
# --- @mention 自动提取(#04) ---
|
||||
_KNOWN_AGENT_IDS: list = []
|
||||
|
||||
def _init_agent_ids():
|
||||
"""从配置文件加载 Agent ID 列表"""
|
||||
global _KNOWN_AGENT_IDS
|
||||
if _KNOWN_AGENT_IDS:
|
||||
return
|
||||
try:
|
||||
import yaml
|
||||
cfg_path = os.path.join(os.path.dirname(__file__), "..", "..", "config", "default.yaml")
|
||||
with open(cfg_path) as f:
|
||||
cfg = yaml.safe_load(f)
|
||||
_KNOWN_AGENT_IDS = list(cfg.get("daemon", {}).get("agent_profiles", {}).keys())
|
||||
except Exception:
|
||||
_KNOWN_AGENT_IDS = []
|
||||
|
||||
def _extract_mentions(text: str) -> list:
|
||||
"""从文本中自动提取 @agent-id 格式的 mention"""
|
||||
import re
|
||||
_init_agent_ids()
|
||||
candidates = set(re.findall(r'@([a-z][a-z0-9]*(?:-[a-z][a-z0-9]*)+)', text))
|
||||
return [a for a in candidates if a in _KNOWN_AGENT_IDS]
|
||||
|
||||
|
||||
# --- Comments ---
|
||||
|
||||
@router.get("/tasks/{task_id}/comments")
|
||||
|
||||
Reference in New Issue
Block a user